:root {
  --bg: #0d0e11;
  --panel: #15171c;
  --panel-2: #1c1f26;
  --line: #2a2e38;
  --text: #e9eaee;
  --muted: #8a909d;
  --accent: #ff5a36;

  --reel: #ff5a36;
  --podcast: #8f6dff;
  --film: #26b5d6;

  --st-idea: #6b7280;
  --st-draft: #e3b341;
  --st-ready: #3fb950;
  --st-recorded: #58a6ff;
  --st-published: #b083f0;

  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 20px; flex: none;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 800; letter-spacing: .08em; font-size: 15px; }
.brand span { color: var(--accent); margin-left: 4px; }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.save-state { color: var(--muted); font-size: 12px; margin-right: 6px; }
.save-state.error { color: #ff7b72; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #3a3f4b; background: #232731; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: #ff7b72; color: #ff7b72; }
.btn.sm { padding: 4px 10px; font-size: 12px; }

main { flex: 1; min-height: 0; }
.empty { color: var(--muted); font-size: 13px; }

/* ---------- Chips / format / status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px;
  font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.fmt-reel { --c: var(--reel); }
.fmt-podcast { --c: var(--podcast); }
.fmt-film { --c: var(--film); }
.st-idea { --s: var(--st-idea); }
.st-draft { --s: var(--st-draft); }
.st-ready { --s: var(--st-ready); }
.st-recorded { --s: var(--st-recorded); }
.st-published { --s: var(--st-published); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--s); }

/* ---------- Planogram ---------- */
.plan { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
.side {
  border-right: 1px solid var(--line); padding: 16px; overflow: auto;
  display: flex; flex-direction: column; gap: 10px; background: var(--panel);
}
.side h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.side h3 small { color: var(--text); margin-left: 4px; }
.side .hint { margin: 0; font-size: 12px; color: var(--muted); }
.side-list { display: flex; flex-direction: column; gap: 6px; min-height: 60px; }
.side.over { background: #1a1d24; outline: 2px dashed var(--accent); outline-offset: -6px; }
.legend { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); display: grid; gap: 6px; justify-items: start; }
.legend h4 { margin: 0 0 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.cal { display: flex; flex-direction: column; min-width: 0; padding: 14px 18px 18px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-nav h2 { margin: 0 8px; font-size: 20px; min-width: 190px; text-align: center; }
.cal-nav .arrow { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 18px; }
.cal-stats { display: flex; gap: 6px; flex-wrap: wrap; }
.dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.dow div { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-left: 6px; }
.grid { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cell {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px; min-height: 0; display: flex; flex-direction: column; gap: 4px; overflow: hidden;
}
.cell.weekend { background: #131519; }
.cell.out { opacity: .45; }
.cell.today { border-color: var(--accent); }
.cell.today .cell-head span { background: var(--accent); color: #fff; }
.cell.over { outline: 2px dashed var(--accent); outline-offset: -3px; background: #1a1d24; }
.cell-head { display: flex; align-items: center; justify-content: space-between; }
.cell-head span { font-size: 12px; font-weight: 600; padding: 1px 6px; border-radius: 6px; }
.cell-add {
  opacity: 0; border: 0; background: var(--panel-2); width: 22px; height: 22px; border-radius: 6px; cursor: pointer; color: var(--muted);
}
.cell:hover .cell-add { opacity: 1; }
.cell-add:hover { color: var(--text); background: var(--accent); }
.cell-cards { display: flex; flex-direction: column; gap: 4px; overflow: auto; min-height: 0; }

.card {
  display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none;
  padding: 5px 8px; border-radius: 7px; background: var(--panel-2);
  border-left: 3px solid var(--c); font-size: 12px; line-height: 1.3;
}
.card:hover { background: #252933; }
.card.dragging { opacity: .4; }
.card .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--s); flex: none; }
.card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.untitled .card-title { color: var(--muted); font-style: italic; }
.side .card { font-size: 13px; padding: 8px 10px; }

/* ---------- Archive ---------- */
.archive { height: 100%; overflow: auto; padding: 22px 28px 40px; }
.arch-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.arch-head h2 { margin: 0; font-size: 20px; }
.arch-head h2 small { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select, .field input, .field select, .field textarea {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none;
}
.filters input:focus, .filters select:focus, .field :is(input, select, textarea):focus { border-color: var(--accent); }
.filters input[type=search] { width: 280px; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--panel); }
.table .t-title { font-weight: 600; }
.table .t-title.untitled { color: var(--muted); font-style: italic; font-weight: 400; }
.table td.t-main { width: 100%; max-width: 0; }
.table .snippet { color: var(--muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table mark { background: #ff5a3644; color: var(--text); border-radius: 3px; padding: 0 2px; }
.table .num { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions .btn { margin-left: 4px; }

/* ---------- Editor ---------- */
.editor { height: 100%; display: flex; flex-direction: column; }
.ed-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.ed-title {
  flex: 1; min-width: 220px; font-size: 20px; font-weight: 700; background: transparent; border: 0; outline: none; padding: 4px 0;
}
.ed-title::placeholder { color: #4b505c; }
.ed-actions { display: flex; gap: 8px; }
.ed-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 300px; }
.ed-text {
  width: 100%; height: 100%; resize: none; border: 0; outline: none; background: var(--bg);
  padding: 28px max(28px, calc((100% - 760px) / 2)); font-size: 18px; line-height: 1.7;
}
.ed-text::placeholder { color: #4b505c; }
.ed-meta { border-left: 1px solid var(--line); background: var(--panel); padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.field textarea { resize: vertical; min-height: 90px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel-2); border-radius: 8px; padding: 10px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }
.syntax { font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.syntax h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.syntax code { color: var(--text); background: #2a2e38; padding: 1px 5px; border-radius: 4px; }
.syntax div { margin: 3px 0; }
.meta-foot { margin-top: auto; font-size: 11px; color: var(--muted); }

/* ---------- Prompter ---------- */
.prompter { position: fixed; inset: 0; z-index: 100; background: #000; color: #fff; display: flex; flex-direction: column; }
.prompter[hidden] { display: none; }
.p-stage { position: relative; flex: 1; overflow: hidden; cursor: pointer; }
.p-scroll { position: absolute; inset: 0; }
.p-scroll.mirror { transform: scaleX(-1); }
.p-text {
  margin: 0 auto; will-change: transform;
  padding-top: calc(var(--guide, 40vh) - .675em); padding-bottom: 80vh;
  line-height: 1.35; font-weight: 600; letter-spacing: .005em;
}
.p-content { position: relative; }
.p-content p { margin: 0 0 .9em; }
.p-content .w { transition: color .25s; }
.p-content .w.b { color: #ffd23f; }
.prompter.voice-mode .p-content .w.read { color: #4a4d55; }
.p-content p.spk { border-left: .12em solid var(--spk); padding-left: .45em; margin-left: -.57em; }
.p-content .spk-name { display: block; font-size: .38em; letter-spacing: .14em; color: var(--spk); font-weight: 700; margin-bottom: .15em; }
.p-content h2 {
  margin: 1.2em 0 .5em; font-size: .5em; text-transform: uppercase; letter-spacing: .15em; color: var(--accent);
  border-top: 2px solid #ff5a3655; padding-top: .6em;
}
.p-content .cue { font-size: .45em; color: #8a909d; font-weight: 500; font-style: italic; margin: .4em 0 1em; }
.p-content .cue-inline { color: #8a909d; font-weight: 500; font-style: italic; font-size: .7em; }
.p-content strong { color: #ffd23f; }
.p-content hr { border: 0; height: 1.2em; margin: 0; }
.p-content .empty { color: #666; font-size: .5em; }

.p-guide {
  position: absolute; left: 0; right: 0; top: var(--guide, 40vh); height: 0; pointer-events: none;
  border-top: 2px solid #ff5a3699;
}
.p-guide::before, .p-guide::after {
  content: ""; position: absolute; top: -9px; border: 8px solid transparent;
}
.p-guide::before { left: 0; border-left: 14px solid var(--accent); }
.p-guide::after { right: 0; border-right: 14px solid var(--accent); }
.p-guide.off { display: none; }
.p-fade { position: absolute; left: 0; right: 0; pointer-events: none; }
.p-fade.top { top: 0; height: calc(var(--guide, 40vh) * .55); background: linear-gradient(#000, #0000); }
.p-fade.bottom { bottom: 0; height: 30vh; background: linear-gradient(#0000, #000); }
.p-countdown {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 30vh; font-weight: 800;
  color: var(--accent); background: #000c; pointer-events: none;
}
.p-countdown[hidden] { display: none; }

.p-progress { height: 3px; background: #1a1a1a; flex: none; }
.p-progress div { height: 100%; width: 0; background: var(--accent); }

.p-bar {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #0d0e11; border-top: 1px solid #222; transition: opacity .3s; flex-wrap: wrap;
}
.p-bar button {
  background: #1c1f26; border: 1px solid #2a2e38; color: #fff; border-radius: 8px; padding: 6px 11px; cursor: pointer; min-width: 34px;
}
.p-bar button:hover { background: #262a33; }
.p-bar button.on { border-color: var(--accent); color: var(--accent); }
.p-bar .p-play { background: var(--accent); border-color: var(--accent); min-width: 54px; font-size: 16px; }
.p-group { display: flex; align-items: center; gap: 4px; padding: 0 6px; }
.p-group span { font-size: 11px; color: #8a909d; text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
.p-group b { min-width: 74px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.p-meta { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: #8a909d; min-width: 0; }
.p-title { color: #fff; font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-time { font-variant-numeric: tabular-nums; }

.prompter.playing:not(.show-ui) .p-bar { opacity: 0; }
.prompter.playing:not(.show-ui) .p-stage { cursor: none; }

/* ---------- Pilot (modal) ---------- */
.remote-btn.connected { border-color: #3fb950; color: #3fb950; }
.modal { position: fixed; inset: 0; z-index: 200; background: #000a; display: grid; place-items: center; padding: 20px; }
.modal-box {
  position: relative; width: min(440px, 100%); max-height: 100%; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px;
}
.modal-box h3 { margin: 0 0 14px; font-size: 18px; }
.modal-x { position: absolute; top: 14px; right: 14px; border: 0; background: var(--panel-2); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: 240px; height: 240px; margin: 0 auto 14px; display: grid; place-items: center; }
.qr svg { width: 100%; height: 100%; }
.qr .empty { color: #555; text-align: center; padding: 10px; }
.modal-box ol { padding-left: 20px; margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.modal-box ol b { color: var(--text); }
.modal-box li { margin: 4px 0; }
.remote-url { display: grid; gap: 4px; }
.remote-url code { font-size: 11px; background: var(--panel-2); padding: 6px 8px; border-radius: 6px; word-break: break-all; user-select: all; }
.remote-status { margin: 12px 0 4px; font-weight: 600; }
.modal-box .hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.p-mic {
  position: absolute; top: 14px; right: 16px; display: none; font-size: 13px; font-weight: 600;
  padding: 5px 10px; border-radius: 99px; background: #ff5a3633; color: #ff8c70;
}
.prompter.listening .p-mic { display: block; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.p-sections {
  background: #1c1f26; border: 1px solid #2a2e38; color: #fff; border-radius: 8px; padding: 6px 8px; max-width: 170px;
}
.p-bar button:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- Edytor: docelowa długość, publikacja ---------- */
.ed-wrap { position: relative; min-height: 0; background: var(--bg); }
.ed-wrap .ed-text, .ed-backdrop {
  position: absolute; inset: 0; margin: 0; font-size: 18px; line-height: 1.7;
  padding: 28px max(28px, calc((100% - 760px) / 2)); white-space: pre-wrap; overflow-wrap: break-word; overflow-y: scroll;
  font-family: inherit; letter-spacing: normal;
}
.ed-wrap .ed-text { background: transparent; z-index: 1; }
.ed-backdrop { color: transparent; pointer-events: none; }
.ed-backdrop mark { color: transparent; background: #ff4d4d38; border-radius: 3px; box-shadow: 0 0 0 1px #ff4d4d55; }
.stat.over { background: #3a1d1d; }
.stat.over b { color: #ff7b72; }
.target-bar { height: 5px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-top: -6px; }
.target-bar div { height: 100%; background: #3fb950; transition: width .2s; }
.target-bar.over div { background: #ff7b72; }
.target-msg { font-size: 12px; color: var(--muted); margin-top: -8px; }
.target-msg.over { color: #ff7b72; }
.target-msg:empty { display: none; }
.meta-h { margin: 6px 0 -4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.field > span em { font-style: normal; text-transform: none; letter-spacing: 0; float: right; font-weight: 400; }
.field textarea#ed-caption { min-height: 80px; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 13px; }
.checks label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.checks input { accent-color: var(--accent); width: 15px; height: 15px; }
.url-row { display: flex; gap: 6px; }
.url-row input { flex: 1; min-width: 0; }

/* ---------- Planogram: tydzień, godziny ---------- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-left: 8px; }
.seg button { background: transparent; border: 0; padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel-2); color: var(--text); }
.card-time { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.dow.week { display: none; }
.grid.week .cell { padding: 8px; }
.grid.week .cell-head span { font-size: 13px; }
.wcard { flex-direction: column; align-items: stretch; gap: 5px; padding: 9px 10px; }
.wcard .card-title { white-space: normal; font-weight: 600; font-size: 13px; }
.wc-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.wc-time { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.wcard.untitled .wc-time { font-style: normal; }
.wc-meta { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--muted); }
.wc-meta .over, .table td.over { color: #ff7b72; }

/* ---------- Toast, modal, historia ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300;
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px;
  background: #23262e; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px #0008;
}
.modal-box.wide { width: min(980px, 100%); }
.modal-box h3 small { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 6px; }
.hist { display: grid; grid-template-columns: 260px 1fr; gap: 14px; height: min(70vh, 640px); }
.hist-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.hist-item { text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: pointer; }
.hist-item b { display: block; font-size: 13px; }
.hist-item span { font-size: 12px; color: var(--muted); }
.hist-item.on { border-color: var(--accent); }
.hist-view { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.hist-view pre {
  flex: 1; margin: 0; overflow: auto; white-space: pre-wrap; font: 15px/1.6 inherit; font-family: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
}
.hist-view .btn { align-self: flex-end; }
.table tr.trashed { cursor: default; opacity: .8; }
.table td small { color: var(--muted); }

@media (max-width: 1100px) {
  .plan { grid-template-columns: 200px 1fr; }
  .ed-body { grid-template-columns: 1fr 270px; }
}

/* ---------- Przestrzenie, offline ---------- */
.ws-select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  font-weight: 600; max-width: 220px; margin-left: -8px; cursor: pointer;
}
.save-state.offline { color: #e3b341; }
.ws-list { display: grid; gap: 8px; margin: 12px 0; }
.ws-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.ws-row input, .ws-add input {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; min-width: 0;
}
.ws-row input:focus, .ws-add input:focus { border-color: var(--accent); }
.ws-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.modal-box .hint { font-size: 12px; color: var(--muted); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.user-box { display: flex; align-items: center; gap: 8px; margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--line); font-size: 13px; color: var(--muted); }
