/* Prompter — ciemny interfejs (praca na planie zdjęciowym), akcent bursztynowy = linia czytania. */
:root {
  --bg: #0b0b0d;
  --s1: #141417;
  --s2: #1c1c20;
  --s3: #27272c;
  --bd: #2e2e34;
  --tx: #f4f4f6;
  --mut: #a0a0aa;
  --acc: #ffc533;
  --acc-ink: #1d1600;
  --ok: #3fd68a;
  --live: #ff5a4f;
  --danger: #ff6b61;
  --r: 14px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--tx); font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: .35; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
:where(input:not([type=range], [type=file]), textarea, select) {
  width: 100%; background: var(--s1); border: 1px solid var(--bd); border-radius: 12px; padding: 12px 14px; font-size: 16px;
}
:where(input, textarea, select):focus { outline: none; border-color: var(--acc); }
::placeholder { color: #6c6c75; }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--mut); }
.small { font-size: 13px; }
.pad-s { padding: 12px 4px; margin: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
[hidden] { display: none !important; }

/* ---------- przyciski ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 12px; background: var(--acc); color: var(--acc-ink); font-weight: 650; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.small .i { width: 18px; height: 18px; }
.btn.ghost { background: var(--s2); color: var(--tx); border: 1px solid var(--bd); }
.btn.wide { width: 100%; }
.ibtn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--tx); flex: none; }
.ibtn:hover { background: var(--s2); }
.ibtn.small { width: 34px; height: 34px; border-radius: 9px; }
.ibtn.small .i { width: 18px; height: 18px; }
.ibtn.danger { color: var(--danger); }
.link { display: flex; align-items: center; gap: 12px; padding: 11px 6px; width: 100%; text-align: left; border-radius: 10px; }
.link:hover { background: var(--s2); }
.link .i { color: var(--mut); }

/* ---------- logowanie i wybór trybu ---------- */
.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px 24px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.brand h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--s3); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 6px; right: 6px; top: 14px; height: 4px; border-radius: 2px; background: var(--acc); }
.login { width: min(360px, 100%); display: grid; gap: 12px; }
.err { color: var(--danger); min-height: 1.4em; margin: 0; }
.start { width: min(760px, 100%); }
.start > .muted { margin: 0; }
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 22px; }
.mode-card { display: grid; gap: 4px; padding: 20px; border-radius: 18px; background: var(--s1); border: 1px solid var(--bd); }
.mode-card:hover { background: var(--s2); border-color: #45454d; }
.mode-card .i { width: 28px; height: 28px; color: var(--acc); margin-bottom: 12px; }
.mode-title { font-size: 19px; font-weight: 650; }
.mode-desc { color: var(--mut); font-size: 14px; }

/* ---------- scena promptera (ekran i podgląd) ---------- */
.stage { position: relative; overflow: hidden; background: #000; color: #fff; contain: strict; --font: 64px; --margin: 10; }
.stage.measure { position: absolute; left: -100000px; top: 0; visibility: hidden; pointer-events: none; }
.flip { position: absolute; inset: 0; }
.stage.mirror .flip { transform: scaleX(-1); }
.scroller { position: absolute; left: 0; right: 0; top: 0; will-change: transform; }
.text {
  position: relative; /* offsetTop kwestii liczony od początku tekstu */
  display: flow-root; padding: 0 calc(var(--margin) * 1%);
  font-family: var(--sans); font-size: var(--font); line-height: var(--lh, 1.3); font-weight: 600; letter-spacing: .004em;
  white-space: pre-line; overflow-wrap: break-word;
}
.stage.caps .text { text-transform: uppercase; letter-spacing: .02em; }
.text .kw { margin: 0 0 .8em; }
.text .kw:last-child { margin-bottom: 0; }
.text .cue { color: var(--acc); opacity: .6; font-weight: 500; font-style: italic; }
/* strefa czytania: tekst nad linią i daleko pod nią przygaszony */
.shade, .shade-b { position: absolute; left: 0; right: 0; pointer-events: none; display: none; }
.shade { top: 0; background: linear-gradient(to bottom, rgba(0, 0, 0, .85), rgba(0, 0, 0, .4)); }
.shade-b { bottom: 0; background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .6) 35%, rgba(0, 0, 0, .78)); }
.stage.focus .shade, .stage.focus .shade-b { display: block; }
.stage { --mark: #ffc533; }
.stage[data-mark=red] { --mark: #ff5a4f; }
.stage[data-mark=green] { --mark: #3fd68a; }
.stage[data-mark=blue] { --mark: #4da3ff; }
.stage[data-mark=white] { --mark: #ffffff; }
.reading { position: absolute; left: 0; right: 0; height: 0; pointer-events: none; --tri: calc(var(--font) * .2); }
.reading::before, .reading::after { content: ""; position: absolute; top: calc(var(--tri) * -1); border: var(--tri) solid transparent; }
.reading::before { left: 0; border-left: calc(var(--tri) * 1.4) solid var(--mark); border-right-width: 0; }
.reading::after { right: 0; border-right: calc(var(--tri) * 1.4) solid var(--mark); border-left-width: 0; }
/* odliczanie przed startem (wewnątrz .flip, więc w trybie lustra też się odbija) */
.count { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .62); color: var(--mark); font-family: var(--sans); font-size: calc(var(--font) * 3.2); font-weight: 800; font-variant-numeric: tabular-nums; pointer-events: none; }
.count:empty { display: none; }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 10%; text-align: center; color: #85858f; font-family: var(--sans); font-size: calc(var(--font) * .6); font-weight: 500; pointer-events: none; }
.stage-msg:empty { display: none; }

/* ---------- tryb EKRAN ---------- */
body.mode-display { position: fixed; inset: 0; overflow: hidden; background: #000; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mode-display #app { position: fixed; inset: 0; }
.mode-display #app > .stage { position: absolute; left: 0; top: 0; touch-action: none; cursor: pointer; }
body.mode-display.playing { cursor: none; }
.d-ui { position: fixed; inset: 0; pointer-events: none; transition: opacity .25s ease; }
.playing .d-ui { opacity: 0; }
.playing .d-ui .d-btn { pointer-events: none; }
.offline.playing .d-ui { opacity: 1; }
.d-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.d-info { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 15px; color: #d2d2d9; background: rgba(22, 22, 26, .85); padding: 8px 16px; border-radius: 999px; }
.d-state { color: var(--acc); font-weight: 650; }
.d-state:empty { display: none; }
.d-conn { display: none; color: var(--live); font-weight: 650; }
.offline .d-conn { display: inline; }
.d-btns { display: flex; gap: 8px; }
.d-btn { pointer-events: auto; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: rgba(28, 28, 32, .88); color: #fff; }
.d-btn .i { width: 24px; height: 24px; }
.d-hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom)); max-width: calc(100% - 32px); text-align: center; color: #a6a6ae; font-size: 14px; background: rgba(22, 22, 26, .88); padding: 8px 16px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- tryb PILOT ---------- */
body.mode-remote { overscroll-behavior-y: none; }
.remote { max-width: 1180px; margin: 0 auto; padding: 0 16px max(28px, env(safe-area-inset-bottom)); }
.r-head { display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 0 12px; }
.r-titles { flex: 1; min-width: 0; }
.r-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-sub { font-size: 13px; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mut); background: var(--s1); border: 1px solid var(--bd); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #5a5a62; }
.pill.ok .dot { background: var(--ok); }
.banner { display: none; margin: 0 0 12px; padding: 9px 14px; border-radius: 12px; background: #2f2400; color: var(--acc); font-size: 14px; text-align: center; }
.banner.show { display: block; }
.r-main { display: grid; gap: 16px; }
.r-side { display: grid; gap: 14px; min-width: 0; align-content: start; }
.preview-wrap { min-width: 0; }
.preview { position: relative; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #000; box-shadow: 0 0 0 1px var(--bd); touch-action: none; cursor: grab; }
.p-scale { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.p-info { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; pointer-events: none; }
.p-chip { font-size: 11px; font-weight: 650; color: #e2e2e8; background: rgba(30, 30, 34, .88); padding: 3px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.p-chip:empty { display: none; }
.p-hint { text-align: center; color: #75757e; font-size: 12px; margin: 8px 0 0; }
.transport { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.t-btn { display: grid; justify-items: center; gap: 4px; padding: 8px 2px; min-width: 54px; border-radius: 12px; }
.t-btn .i { width: 24px; height: 24px; }
.t-btn:active { background: var(--s2); }
.t-label { font-size: 11px; color: var(--mut); }
.play { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; background: var(--acc); color: var(--acc-ink); flex: none; transition: background .15s; }
.play .i { width: 32px; height: 32px; fill: currentColor; }
.play.on { background: var(--live); color: #fff; }
.steppers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stepper { background: var(--s1); border: 1px solid var(--bd); border-radius: var(--r); padding: 10px 10px 8px; display: grid; gap: 6px; }
.step-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mut); }
.step-label .i { width: 14px; height: 14px; }
.step-ctl { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.step-btn { width: 46px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--s2); user-select: none; -webkit-user-select: none; }
.step-btn:active { background: var(--s3); }
.step-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.5ch; text-align: center; }

@media (min-width: 900px), (orientation: landscape) and (max-height: 560px) {
  .r-main { grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr); align-items: start; }
  .preview-wrap { position: sticky; top: 12px; }
}

/* ---------- osoby i kwestie ---------- */
.people { display: grid; gap: 8px; }
.rec-pick { width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px; text-align: left; background: var(--s1); border: 1px solid var(--bd); border-radius: var(--r); padding: 9px 14px; }
.rec-pick-label { font-size: 11px; color: var(--mut); text-transform: uppercase; letter-spacing: .06em; grid-column: 1; }
.rec-pick-name { font-weight: 650; grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-pick .i { grid-column: 2; grid-row: 1 / 3; color: var(--mut); }
.plist, .kwlist { list-style: none; margin: 0; padding: 0; }
.plist { display: grid; gap: 6px; }
.person { background: var(--s1); border: 1px solid var(--bd); border-radius: var(--r); overflow: hidden; }
.person.active { border-color: var(--acc); background: #1a1810; }
.pbtn { width: 100%; display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 14px; text-align: left; min-height: 56px; }
.pnum { width: 28px; height: 28px; border-radius: 8px; background: var(--s3); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--mut); }
.person.active .pnum { background: var(--acc); color: var(--acc-ink); }
.pname { font-weight: 650; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pmeta { font-size: 12px; color: var(--mut); white-space: nowrap; }
.kwlist { border-top: 1px solid #2d2a1d; padding: 4px; max-height: 300px; overflow: auto; }
.kwbtn { width: 100%; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; text-align: left; padding: 8px 10px; border-radius: 10px; font-size: 14px; color: #cfcfd6; }
.kwn { color: var(--mut); font-variant-numeric: tabular-nums; }
.kwt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kwbtn.cur { background: rgba(255, 197, 51, .14); color: #fff; }
.kwbtn.cur .kwn { color: var(--acc); }
.people.compact .pmeta { display: none; }

/* ---------- arkusz (sheet) ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(560px, 100%); max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column; background: var(--s1); border: 1px solid var(--bd); border-bottom: 0; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); color: var(--tx); cursor: auto; user-select: text; -webkit-user-select: text; }
@media (min-width: 700px) {
  .sheet-back { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--bd); }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 2px 20px; }
.sheet-head h2 { font-size: 18px; margin: 0; }
.sheet-body { overflow: auto; padding: 8px 20px 20px; overscroll-behavior: contain; }
.settings { display: grid; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; flex-wrap: wrap; }
.row.col { display: grid; gap: 4px; justify-content: stretch; }
.row-top { display: flex; justify-content: space-between; gap: 12px; }
.row-label { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
.row-label .i { color: var(--mut); }
.row-val { color: var(--mut); font-variant-numeric: tabular-nums; }
.switch { width: 52px; height: 32px; border-radius: 999px; background: var(--s3); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--acc); }
.switch.on::after { transform: translateX(20px); }
input[type=range] { width: 100%; accent-color: var(--acc); height: 32px; margin: 0; }
.links { border-top: 1px solid var(--bd); margin-top: 4px; padding-top: 6px; }
.set-h { margin: 6px 0 -2px; font-size: 12px; font-weight: 650; color: var(--mut); text-transform: uppercase; letter-spacing: .07em; }
.set-h:first-child { margin-top: 0; }
.chips { display: flex; gap: 8px; }
.chip { width: 28px; height: 28px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.chip[data-c=amber] { --c: #ffc533; }
.chip[data-c=red] { --c: #ff5a4f; }
.chip[data-c=green] { --c: #3fd68a; }
.chip[data-c=blue] { --c: #4da3ff; }
.chip[data-c=white] { --c: #ffffff; }
.chip[aria-pressed=true] { box-shadow: 0 0 0 2px var(--s1), 0 0 0 4px var(--tx); }
.pw-form { display: grid; gap: 10px; }
.pw-form p { margin: 0; }
.reclist { display: grid; gap: 6px; }
.recrow { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 12px; background: var(--s2); border: 1px solid transparent; }
.recrow.active { border-color: var(--acc); }
.recrow-name { font-weight: 650; }
.recrow-meta { font-size: 13px; color: var(--mut); }

/* ---------- tryb TEKSTY ---------- */
.editor { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: 100vh; }
.e-side { border-right: 1px solid var(--bd); padding: max(16px, env(safe-area-inset-top)) 12px 16px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.e-side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.e-side-head h1 { font-size: 20px; margin: 0; }
.e-recs { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; flex: 1; align-content: start; }
.e-rec { width: 100%; text-align: left; display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; }
.e-rec:hover { background: var(--s1); }
.e-rec.sel { background: var(--s2); box-shadow: inset 3px 0 0 var(--acc); }
.e-rec-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.e-rec-meta { font-size: 12px; color: var(--mut); }
.e-nav { border-top: 1px solid var(--bd); padding-top: 6px; }
.e-doc { padding: 8px 28px 80px; max-width: 940px; width: 100%; }
.e-doc-head { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 3; background: var(--bg); padding: max(10px, env(safe-area-inset-top)) 0 10px; }
.e-back { display: none; }
.e-name { font-size: 22px; font-weight: 700; background: transparent; border-color: transparent; padding: 8px 10px; min-width: 0; }
.e-name:hover { border-color: var(--bd); }
.e-name:focus { background: var(--s1); }
.e-status { font-size: 13px; color: var(--mut); white-space: nowrap; }
.e-status.ok { color: var(--ok); }
.e-status.err { color: var(--danger); }
.e-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.e-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.ep { background: var(--s1); border: 1px solid var(--bd); border-radius: 16px; padding: 12px; display: grid; gap: 10px; }
.ep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ep-num { width: 28px; height: 28px; border-radius: 8px; background: var(--s3); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--mut); flex: none; }
.ep-name { flex: 1 1 160px; width: auto; font-weight: 650; font-size: 17px; padding: 8px 10px; background: var(--s2); }
.ep-meta { font-size: 12px; color: var(--mut); white-space: nowrap; }
.ep-actions { display: flex; gap: 2px; margin-left: auto; }
.ep-text { resize: vertical; min-height: 120px; line-height: 1.55; background: var(--bg); }
.e-add { margin-top: 14px; width: 100%; }
.e-empty { padding: 48px 0; display: grid; gap: 10px; justify-items: start; }
.e-empty h2 { margin: 0; font-size: 22px; }
.e-empty p { margin: 0 0 8px; }
.imp { display: grid; gap: 12px; }
.imp-text { min-height: 240px; resize: vertical; font-size: 15px; line-height: 1.5; }
.imp-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.imp-mode { width: auto; flex: 1; min-width: 200px; }
.imp-preview { margin: 0; font-size: 14px; }

@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; }
  .e-side { position: static; height: auto; min-height: 100vh; border-right: 0; }
  .editor.has-sel .e-side { display: none; }
  .editor:not(.has-sel) .e-doc { display: none; }
  .e-back { display: inline-grid; }
  .e-doc { padding: 0 12px 60px; }
  .e-name { font-size: 19px; }
  .ep-name { flex-basis: calc(100% - 38px); }
  .ep-meta { padding-left: 38px; }
}
