/* Textík — tmavý motiv, vždy. */
:root {
  --bg: #0f1319;
  --panel: #1a2029;
  --text: #e8eaed;
  --muted: #9aa4b2;
  --border: #2b333f;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
  --focus: #1e40af;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* atribut hidden musí přebít .center/.view display */
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); }

.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}
.card h1 { margin: 0 0 .25rem; font-size: 1.5rem; }
.card .sub { color: var(--muted); margin: 0 0 1.5rem; }

label { display: block; font-weight: 600; margin: 1rem 0 .35rem; }
input[type=text], input[type=password], select, textarea {
  width: 100%;
  padding: .7rem .8rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--accent);
}

button, .btn {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: .7rem 1.1rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.danger { background: #cc2222; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
button:disabled { opacity: .5; cursor: not-allowed; }

.full { width: 100%; margin-top: 1.25rem; }
.msg { margin-top: 1rem; min-height: 1.2em; font-weight: 600; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

/* ── stavový pruh připojení ── */
#conn {
  position: fixed; top: 0; left: 0; right: 0;
  padding: .4rem 1rem; text-align: center; font-weight: 700;
  font-size: .95rem; z-index: 50; transition: transform .2s;
  color: #fff;
}
#conn.ok { background: var(--ok); }
#conn.bad { background: var(--err); }
#conn.hidden { transform: translateY(-100%); }

/* ── split button (sdílení odkazu) ── */
.split-btn { display: inline-flex; border-radius: 10px; position: relative; }
.split-btn__main {
  cursor: pointer; border: none; border-radius: 10px 0 0 10px;
  padding: .7rem 1rem; font: 500 1rem/1 inherit;
  background: var(--accent); color: #fff; transition: background .15s;
}
.split-btn__main:hover { background: var(--accent-hover); }
.split-btn__divider { width: 1px; background: rgba(255,255,255,.3); align-self: stretch; flex-shrink: 0; }
.split-btn__arrow {
  cursor: pointer; border: none; border-radius: 0 10px 10px 0;
  padding: .7rem .65rem; background: var(--accent); color: #fff;
  display: flex; align-items: center; transition: background .15s;
}
.split-btn__arrow:hover { background: var(--accent-hover); }
.split-btn__arrow svg { width: 14px; height: 14px; display: block; transition: transform .15s; }
.split-btn--open .split-btn__arrow svg { transform: rotate(180deg); }
.split-btn__dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: .5rem;
  min-width: 150px; box-shadow: 0 4px 16px rgba(0,0,0,.12); z-index: 100; overflow: hidden;
}
.split-btn--open .split-btn__dropdown { display: block; }
.split-btn__dropdown button {
  display: block; width: 100%; border: none; background: transparent;
  padding: .6rem 1rem; text-align: left; cursor: pointer;
  font: 500 .9rem/1.4 inherit; color: var(--text); transition: background .1s;
}
.split-btn__dropdown button:hover { background: rgba(37,99,235,.08); color: var(--accent); }
.split-btn__dropdown button + button { border-top: 1px solid var(--border); }
.split-btn.btn--copied .split-btn__main,
.split-btn.btn--copied .split-btn__main:hover,
.split-btn.btn--copied .split-btn__arrow,
.split-btn.btn--copied .split-btn__arrow:hover { background: #16a34a; }

/* ── střídání přepisovatelů — flash banner ── */
#handover-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 999;
  display: flex; justify-content: center;
  pointer-events: none;
  opacity: 0; transition: opacity .25s;
  padding-top: 4.5rem;
}
#handover-banner.show { opacity: .9; }
#handover-banner-inner {
  background: var(--ok); color: #fff;
  font-size: 3.25rem; font-weight: 400; text-align: center;
  padding: 1.5rem 4rem; border-radius: 18px;
  box-shadow: 0 8px 48px rgba(0,0,0,.5);
}

/* ── admin toast notifikace ── */
#admin-toast {
  position: fixed; top: 1.2rem; right: 1.2rem;
  padding: .65rem 1.1rem; border-radius: .5rem;
  font-weight: 600; font-size: .9rem; color: #fff;
  z-index: 200; pointer-events: none; max-width: 360px;
  opacity: 0; transform: translateY(-.4rem);
  transition: opacity .18s, transform .18s;
}
#admin-toast.show { opacity: 1; transform: translateY(0); }
#admin-toast.ok { background: var(--ok); }
#admin-toast.err { background: var(--err); }

/* ── hlavička akce ── */
header.bar {
  display: flex; align-items: center; gap: 1rem;
  padding: .8rem 1.2rem; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  flex-wrap: wrap;
}
header.bar h1 { font-size: 1.2rem; margin: 0; flex: 1; }
.pill { font-size: .8rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; }
.pill.live { background: rgba(22,163,74,.15); color: var(--ok); }
.pill.prepared { background: rgba(107,114,128,.15); color: var(--muted); }
.pill.ended { background: rgba(217,119,6,.15); color: var(--warn); }

/* odznak s počtem připojených diváků (v hlavičce přepisu) */
.viewer-badge {
  font-size: .8rem; font-weight: 700; padding: .2rem .55rem;
  border-radius: 999px; white-space: nowrap; letter-spacing: .01em;
}
.viewer-badge.empty { background: rgba(107,114,128,.15); color: var(--muted); }
.viewer-badge.active { background: rgba(22,163,74,.15); color: var(--ok); }

/* ── viewer/transcriber: klikací odznak s rozbalovacím seznamem přezdívek ── */
.people { position: relative; display: inline-flex; }
.people__list {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--panel); border: 1px solid var(--border); border-radius: .5rem;
  min-width: 140px; max-width: 240px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 100; overflow: hidden;
}
.people__name {
  padding: .5rem .9rem; font-size: .9rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.people__name + .people__name { border-top: 1px solid var(--border); }

/* Plovoucí verze pro diváka — fixní roh, nenápadná, rozbalení překryje obsah */
.people--float {
  position: fixed; top: 1rem; right: 1rem; z-index: 90;
}
.people--float .viewer-badge {
  opacity: .65; transition: opacity .15s;
}
.people--float .viewer-badge:hover,
.people--float .viewer-badge:focus { opacity: 1; }
.people--float .people__list {
  top: calc(100% + 6px); bottom: auto;
}
.viewer-text {
  max-width: 1300px; margin: 0 auto; padding: 2rem 1.5rem 6rem;
  font-size: clamp(1.4rem, 2.6vw, 2.1rem); line-height: 1.5;
}
.viewer-text p { margin: 0 0 1.1rem; white-space: pre-wrap; }
.viewer-empty { color: var(--muted); font-style: italic; }

/* ── editor přepisovatele: souvislý dokument (jedna textarea) ── */
.bar-hint { color: var(--muted); font-size: .8rem; }
.doc-edit {
  display: block;
  max-width: 950px; width: 100%;
  min-height: 60vh; margin: 0 auto;
  padding: 1.5rem 1.25rem 45vh; /* prostor dole, ať poslední řádek nesedí u kraje */
  box-sizing: border-box;
  border: none; background: transparent; color: var(--text);
  font-family: inherit; font-size: 2.0rem; line-height: 1.6;
  resize: none; overflow: hidden;
  white-space: pre-wrap; word-break: break-word;
}
.doc-edit:focus { outline: none; }
.doc-edit::placeholder { color: currentColor; opacity: .38; }

/* ── admin ── */
.admin-wrap { max-width: 1360px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.admin-wrap h1 { margin-top: 0; }
.session-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.2rem; margin-bottom: 1rem;
}
.session-card h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; }
.row > input, .row > select { flex: 1; min-width: 140px; }
/* Formulář „Přidat akci" — vše na jednom řádku: název 40 %, koncovka 10 %, heslo 40 %. */
.add-row > input { flex: 0 1 auto; min-width: 0; }
.add-row { flex-wrap: nowrap; }
.add-row > button { flex: 0 0 auto; white-space: nowrap; }
#add-name { flex-basis: 57.75%; }
#add-slug { flex-basis: 25%; }
#add-pw   { flex-basis: 37%; }
.grow { flex: 1; }
.state-btns button { padding: .5rem .8rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Vyhledávání a tabulka existujících akcí */
.search-row { margin-bottom: .8rem; }
.search-row > input { flex: 1; }
.table-wrap { overflow-x: auto; margin-bottom: 1rem; }
.sessions-table { width: 100%; border-collapse: collapse; }
.sessions-table th {
  text-align: left; font-size: 1.1rem; color: var(--muted);
  font-weight: 600; padding: .3rem .4rem; white-space: nowrap;
}
/* nadpisy posunuté o 1 znak doprava (kromě „Koncovka odkazu") */
.sessions-table th:nth-child(2),
.sessions-table th:nth-child(4),
.sessions-table th:nth-child(5) { padding-left: 1ch; }
.sessions-table td { padding: .25rem .4rem; vertical-align: middle; }
.sessions-table tr { border-top: 1px solid var(--border); }
.sessions-table thead tr { border-top: none; }
.sessions-table input { width: 100%; padding: .5rem .6rem; min-width: 0; }
.sessions-table button { padding: .5rem .7rem; white-space: nowrap; width: 100%; }
/* Neuložené změny — zvýraznění tlačítka */
.sessions-table tr.dirty [data-save-all] { font-weight: 700; background: #d4520b; }
.sessions-table tr.dirty [data-save-all]:hover { background: #c2410c; }
.sessions-table .link-cell a { color: var(--accent); font-size: .85rem; word-break: break-all; }
/* úchyt pro přetahování */
.sessions-table .drag-cell {
  cursor: grab; user-select: none; text-align: center;
  color: var(--muted); font-size: 1.2rem; line-height: 1;
}
.sessions-table .drag-cell:active { cursor: grabbing; }
.sessions-table tr.dragging { opacity: .5; background: var(--panel); }
/* šířky sloupců: úchyt, název, koncovka, odkaz (pružný), heslo, S účtem, 2× tlačítko */
.sessions-table th:nth-child(1) { width: 1%; }
.sessions-table th:nth-child(2) { width: 30%; }
.sessions-table th:nth-child(3) { width: 12%; }
.sessions-table th:nth-child(4) { width: auto; }
.sessions-table th:nth-child(5) { width: 12%; }
.sessions-table th:nth-child(6) { width: 1%; white-space: nowrap; }
.sessions-table th:nth-child(7),
.sessions-table th:nth-child(8) { width: 1%; }
.check-cell { text-align: center; }
.check-label {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .7rem .8rem; font-size: 1rem; font-weight: 500; color: var(--text);
  line-height: normal; margin: 0;
  cursor: pointer; white-space: nowrap; user-select: none;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.check-label:focus-within {
  outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--accent);
}
.check-label input[type=checkbox] { margin: 0; }
/* odkaz na nápovědu dole v admin konzoli */
.help-link { text-align: right; margin: 1.5rem 0 0; font-size: .85rem; color: var(--muted); }
.help-link a { color: var(--muted); }
.help-link a:hover { color: var(--accent); }

/* buňka odkazu: odkaz + tlačítko QR vedle sebe */
.sessions-table .link-cell { display: flex; align-items: center; gap: .5rem; }
.sessions-table .link-cell a { flex: 1; }
.sessions-table .qr-btn {
  flex: 0 0 auto; width: auto; padding: .4rem .7rem;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  font-weight: 700; letter-spacing: .03em;
}
.sessions-table .qr-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ── modal (QR kód) ── */
.modal {
  position: fixed; inset: 0; z-index: 100; padding: 1rem;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-box {
  position: relative; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 1.5rem 1.5rem 1.25rem; max-width: 90vw; text-align: center;
}
.modal-box h3 { margin: 0 0 1rem; font-size: 1.1rem; }
.modal-close {
  position: absolute; top: .4rem; right: .5rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.7rem; line-height: 1; cursor: pointer; width: auto; padding: .1rem .45rem;
}
.modal-close:hover { color: var(--text); }
.qr-canvas-wrap { display: inline-block; background: #fff; padding: 12px; border-radius: 8px; }
.qr-canvas-wrap canvas { display: block; }
.qr-url { margin: 1rem 0; font-size: .85rem; word-break: break-all; }
.qr-url a { color: var(--accent); }
.qr-actions { display: flex; gap: .6rem; justify-content: center; }
.qr-actions button { width: auto; }

/* ── výběr barvy písma ── */
.color-picker { position: relative; }
.color-btn {
  padding: .35rem .5rem; background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px;
  display: inline-flex; align-items: center; cursor: pointer; line-height: 0;
}
.color-btn:hover { background: transparent; border-color: var(--muted); }
.color-btn .swatch { display: inline-block; width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; }
.color-palette {
  position: absolute; top: calc(100% + 6px); right: 0;
  display: flex; gap: 4px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15);
  z-index: 200;
}
.color-swatch {
  width: 22px; height: 22px; border-radius: 3px; cursor: pointer;
  border: 2px solid rgba(0,0,0,.12); padding: 0; flex-shrink: 0; transition: transform .1s;
}
.color-swatch:hover, .color-swatch.selected {
  transform: scale(1.2); outline: 2px solid var(--text); outline-offset: 1px;
}
.color-hide-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.1rem; font-weight: 700; cursor: pointer; padding: 0 3px;
  line-height: 1; flex-shrink: 0; align-self: center; margin-left: 8px;
}
.color-hide-btn:hover { color: var(--err); background: transparent; }
/* Plovoucí skupina vpravo nahoře (viewer stránka) */
.top-right-group {
  position: fixed; top: 0.4rem; right: 1rem; z-index: 90;
  display: flex; gap: .4rem; align-items: center;
}

/* ── chat ── */
/* Ikona v liště (Varianta 1: outline bublina + text) s odznakem nepřečtených. */
.chat-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: .35rem; cursor: pointer;
  padding: .35rem .6rem; background: transparent; color: var(--text);
  border: 1px solid var(--muted); border-radius: 10px;
  font: inherit; font-size: .9rem; line-height: 1;
}
.chat-btn:hover { border-color: var(--muted); color: var(--text); background: transparent; }
.chat-btn:focus, .chat-btn:focus-visible { background: transparent; outline: none; }
.chat-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.chat-unread {
  position: absolute; top: -7px; right: -7px;
  min-width: 18px; height: 18px; padding: 0 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--err); color: #fff; font-size: .68rem; font-weight: 700;
  border-radius: 999px; box-shadow: 0 0 0 2px var(--panel);
}

/* Panely jsou pevné boční lišty (ne plovoucí okna). */
.chat-col {
  position: fixed; top: var(--bar-h, 4rem); bottom: 0; width: 320px; max-width: 92vw;
  z-index: 80; display: flex;
}
/* Tažitelný handle na vnitřním okraji panelu (pravý okraj levého, levý okraj pravého) */
.chat-resize-handle {
  position: absolute; top: 0; bottom: 0; width: 8px; z-index: 10;
  cursor: col-resize;
}
.chat-resize-handle:hover, .chat-resize-handle.dragging {
  background: linear-gradient(to bottom, transparent, var(--accent) 50%, transparent);
  opacity: .35;
}
.chat-col--left  .chat-resize-handle { right: 0; }
.chat-col--right .chat-resize-handle { left: 0; }
.chat-col--left { left: 0; }
.chat-col--right { right: 0; }

.chat-panel {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  margin: .5rem; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,.16);
}
.chat-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem .8rem; border-bottom: 1px solid var(--border);
}
.chat-panel__title { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: .45rem; min-width: 0; }
/* Ikony u nadpisů chatů: „T ↔ T" (přepisovatelé) / skupinka (diváci). */
.chat-panel__titleicons { display: inline-flex; align-items: center; gap: .28rem; color: var(--muted); flex-shrink: 0; }
.chat-panel__titleicons svg { display: block; }
.chat-panel__titleicons .chat-tico { border-radius: 4px; }
.chat-panel__hide {
  background: transparent; border: none; color: var(--muted);
  font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.chat-panel__hide:hover { color: var(--err); }
.chat-panel__namerow {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .8rem; border-bottom: 1px solid var(--border);
}
.chat-panel__namelbl { font-size: .8rem; color: var(--muted); flex-shrink: 0; }
.chat-panel__name {
  flex: 1; min-width: 0; padding: .3rem .5rem; font: inherit; font-size: .9rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text);
}
.chat-panel__msgs {
  flex: 1; min-height: 0; overflow-y: auto; padding: .6rem .8rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.chat-msg { display: flex; flex-direction: column; gap: .1rem; align-items: flex-start; }
.chat-msg--own { align-items: flex-end; }
.chat-msg__name { font-size: .72rem; font-weight: 400; color: var(--muted); }
.chat-msg--transcriber .chat-msg__name { font-weight: 700; }
.chat-msg__text {
  font-size: .95rem; line-height: 1.35; white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border-radius: 8px; padding: .35rem .55rem; max-width: 100%;
}
.chat-msg--own .chat-msg__text { background: var(--accent); color: #fff; }
/* Ikona (favicon Textíku) před jménem přepisovatele v chatu s diváky */
.chat-msg--transcriber .chat-msg__name::before {
  content: '';
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%232563eb'/%3E%3Cpath d='M16 20h32M32 20v26' stroke='%23fff' stroke-width='7' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/contain;
  margin-right: 4px; vertical-align: middle; flex-shrink: 0;
}
.chat-divider {
  display: flex; align-items: center; gap: .5rem;
  color: var(--muted); font-size: .75rem; font-style: italic;
  margin: .35rem 0; flex-shrink: 0;
}
.chat-divider::before, .chat-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.chat-panel__form {
  display: flex; gap: .4rem; padding: .6rem .8rem; border-top: 1px solid var(--border);
}
.chat-panel__input {
  flex: 1; min-width: 0; padding: .45rem .6rem; font: inherit;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.chat-panel__send {
  padding: .45rem .8rem; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.chat-panel__send:hover { background: var(--accent-hover); }

/* Mobil: lišty přes celou šířku. Dva panely (přepisovatel) nad sebou. */
@media (max-width: 760px) {
  .chat-col { top: 3.5rem; left: 0; right: 0; width: 100%; max-width: 100%; }
  .chat-col--left:not(:only-child) { bottom: 50%; }
  .chat-col--left:not(:only-child) + .chat-col--right { top: 50%; }
}

