/* Operator console. Layout: header transport bar; three columns — line-up | preview + editor | settings rack. */
:root {
  /* DOP-Care brand: black, red (#FE0000), leaf green (#6EBE43), dark green (#099044) on white */
  color-scheme: light;
  --bg: #f3f5f1; --panel: #ffffff; --panel-2: #f0f3ee; --line: #dbe2d7; --fg: #111411; --muted: #5b675a;
  --tally: #e00000; --green: #099044; --green-ink: #ffffff; --leaf: #6ebe43; --eye: #d4c21a;
  --sel: #e7f4df; --sel-line: #099044; --warn-bg: #fff4d6; --warn-fg: #6b4e00;
  --ui: 'Segoe UI', system-ui, -apple-system, Roboto, 'Nirmala UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, Menlo, monospace;
  --shadow: rgba(17, 20, 17, .15);
}
/* Studio mode: dark screen while recording, same brand colours */
:root[data-mode="studio"] {
  color-scheme: dark;
  --bg: #0d100e; --panel: #151a16; --panel-2: #1d231e; --line: #2b342c; --fg: #e8ece7; --muted: #8f9b8e;
  --tally: #ff3b30; --green: #2fa85f; --green-ink: #ffffff; --leaf: #6ebe43;
  --sel: #1b3322; --sel-line: #4cb874; --warn-bg: #3a2f12; --warn-fg: #f3d27a; --shadow: rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--ui); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sel-line); outline-offset: 2px; }
h2 { margin: 0; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.app { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }

/* Header */
.bar { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); box-shadow: inset 0 -3px 0 var(--leaf); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 38px; width: auto; display: block; }
.logo-night { display: none !important; }
:root[data-mode="studio"] .logo-night { display: block !important; }
:root[data-mode="studio"] .logo-day { display: none !important; }
.brand span { font-weight: 700; font-size: 15px; letter-spacing: .02em; padding-left: 12px; border-left: 2px solid var(--tally); line-height: 1.1; }
.talent { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.on { color: var(--green); border-color: var(--sel-line); background: var(--sel); }
.btn.fs { background: var(--eye); border-color: var(--eye); color: #000; font-weight: 600; }
.btn.fs:hover:not(:disabled) { border-color: #000; }
.pill.attn { color: #000; border-color: var(--eye); background: var(--eye); }
.transport { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.speed { display: flex; align-items: center; gap: 4px; }
.speedVal { display: grid; text-align: center; min-width: 54px; line-height: 1.1; }
.speedVal small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.speedVal b { font: 600 18px var(--mono); font-variant-numeric: tabular-nums; }

.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.icon { width: 38px; padding: 8px 0; text-align: center; }
.sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 4px; }
.btn.mode[aria-pressed="true"] { background: var(--sel); border-color: var(--sel-line); color: var(--fg); }
.btn.small { padding: 2px 9px; }
.btn.play { background: var(--tally); border-color: var(--tally); color: #fff; font-weight: 700; min-width: 120px; padding: 10px 18px; font-size: 15px; }
.btn.play.live { background: var(--panel); border-color: var(--tally); color: var(--tally); }
.btn.primary { background: var(--green); border-color: var(--green); color: var(--green-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { border-color: #066b32; background: #087c3a; }

/* Columns */
.work { display: grid; grid-template-columns: 250px minmax(0, 1fr) 330px; min-height: 0; }
.col { min-height: 0; min-width: 0; }
.lineup { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.settings { border-left: 1px solid var(--line); overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.centre { display: flex; flex-direction: column; padding: 12px 16px; gap: 10px; }

/* Line-up */
.colhead { padding: 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.row { display: flex; gap: 6px; }
.scripts { list-style: none; margin: 0; padding: 6px; overflow: auto; flex: 1; counter-reset: s; }
.scripts li { counter-increment: s; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 6px; align-items: center;
  padding: 7px 6px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; }
.scripts li::before { content: counter(s); font: 12px var(--mono); color: var(--muted); text-align: right; }
.scripts li:hover { background: var(--panel-2); }
.scripts li.cur { background: var(--sel); border-color: var(--sel-line); }
.scripts .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scripts .rename { width: 100%; font: inherit; padding: 2px 6px; border: 1px solid var(--sel-line); border-radius: 4px; background: var(--panel); color: var(--fg); }
.scripts .meta { display: block; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scripts .meta .w { color: var(--warn-fg); }
.scripts .ops { display: flex; gap: 2px; opacity: 0; }
.scripts li:hover .ops, .scripts li.cur .ops, .scripts li:focus-within .ops { opacity: 1; }
.scripts .ops button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 5px; border-radius: 4px; font-size: 13px; }
.scripts .ops button:hover { color: var(--fg); background: var(--panel-2); }
.drop-hint { margin: 8px 12px 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* Preview */
.previewWrap { position: relative; flex: 0 0 auto; height: 40%; min-height: 160px; display: grid; place-items: center; background: #07090c; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.previewBox { position: relative; overflow: hidden; }
#preview { position: absolute; left: 0; top: 0; transform-origin: 0 0; cursor: pointer; }
.previewOff { position: absolute; inset: 0; display: grid; align-content: center; gap: 4px; padding: 16px 24px; text-align: center; color: #a3ada2; background: #07090c; }
.previewOff p { margin: 0; max-width: 46ch; justify-self: center; }
.previewOff b { color: #ffffff; }

.stats { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats b { color: var(--fg); font-family: var(--mono); font-weight: 600; }
.state { font: 600 11px var(--mono); letter-spacing: .1em; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.state.live { background: var(--tally); border-color: var(--tally); color: #fff; }
.state.cd { background: var(--eye); border-color: var(--eye); color: #000; }
.prog { flex: 1; min-width: 100px; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; }
.prog i { display: block; height: 100%; width: 0; background: var(--tally); }

/* Editor */
.editorHead { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.editorHead h2 { cursor: text; margin-right: 8px; max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editNote { margin-left: auto; font-size: 12px; color: var(--muted); }
.editNote.typing { color: var(--eye); }
.warn { background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; padding: 8px 12px; font-size: 13px; }
.editorWrap { position: relative; flex: 1; min-height: 140px; display: flex; }
.editor { flex: 1; min-height: 140px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 18px 14px 44px; font: 17px/1.6 Arial, 'Nirmala UI', 'Noto Sans', sans-serif; outline: none; }
.editor:focus { border-color: var(--sel-line); }
.editor p, .editor div { margin: 0 0 .7em; border-radius: 4px; transition: background .2s; }
.editor .reading { background: var(--sel); box-shadow: -10px 0 0 var(--sel), 10px 0 0 var(--sel), -14px 0 0 var(--green); }
.jump { position: absolute; left: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--sel-line); background: var(--panel); color: var(--green); cursor: pointer; font-size: 11px; padding: 0; }
.jump:hover { background: var(--green); color: var(--green-ink); }
@media (prefers-reduced-motion: reduce) { .editor p, .editor div { transition: none; } }
.editor:empty::before { content: 'Drag a client file onto this window, or type or paste the script here.'; color: var(--muted); }

/* Settings */
.sec { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(17,20,17,.04); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { display: flex; gap: 7px; align-items: center; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--green); }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg3 { grid-template-columns: repeat(3, 1fr); }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 6px 4px; font-size: 12.5px; color: var(--muted); }
.seg input:checked + span { background: var(--sel); color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--green); }
.seg input:focus-visible + span { outline: 2px solid var(--sel-line); outline-offset: -2px; }
.rng { display: grid; grid-template-columns: 84px 26px minmax(0, 1fr) 26px 46px; gap: 6px; align-items: center; }
.step { width: 26px; height: 26px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 5px; cursor: pointer; line-height: 1; font-size: 15px; padding: 0; }
.step:hover { border-color: var(--muted); }
.rng output { font: 12px var(--mono); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--green); }
.keysDlg { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--fg); padding: 16px 18px; width: min(440px, calc(100% - 32px)); box-shadow: 0 20px 60px var(--shadow); }
.keysDlg::backdrop { background: rgba(0, 0, 0, .35); }
.dlgHead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.keysDlg dl { margin: 0 0 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 12.5px; }
.keysDlg dt { font-family: var(--mono); color: var(--fg); }
.keysDlg dd { margin: 0; color: var(--muted); }
.note { margin: 0; font-size: 12px; color: var(--muted); }

/* Overlays */
.dropOverlay { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 93%, transparent); display: grid; place-items: center; pointer-events: none; }
.dropOverlay div { border: 2px dashed var(--sel-line); border-radius: 14px; padding: 40px 56px; font-size: 20px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100% - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--sel-line); border-radius: 6px; padding: 10px 12px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 24px var(--shadow); }
.toast.err { border-left-color: var(--tally); }
.toast.warn { border-left-color: var(--eye); }
.toast span { flex: 1; }

@media (max-width: 1100px) {
  .work { grid-template-columns: 220px minmax(0, 1fr); }
  .settings { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .app { height: auto; min-height: 100%; }
  .work { min-height: 0; }
  .centre { min-height: 640px; }
}
@media (max-width: 700px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .lineup { border-right: 0; border-bottom: 1px solid var(--line); max-height: 300px; }
}
