:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #1a1b1f;
  --muted: #5b5f68;
  --line: #dddcd6;
  --soft: #f0efea;
  --accent: #b23a12;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e1;
  --warn: #8a5600;
  --warn-bg: #fff3d6;
  --bad: #a3232b;
  --bad-bg: #fde7e8;
  --good: #146a3b;
  --good-bg: #e3f3e9;
  --buf: #f3f1ea;
  --focus: #1a5fd0;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --panel: #1b1d21;
    --ink: #ecedef;
    --muted: #a7acb5;
    --line: #33363d;
    --soft: #24262c;
    --accent: #ff8f5e;
    --accent-ink: #1d0d05;
    --accent-soft: #3a2117;
    --warn: #f2c46b;
    --warn-bg: #3a2d12;
    --bad: #ff9ba1;
    --bad-bg: #3e1c20;
    --good: #82d9a8;
    --good-bg: #173226;
    --buf: #202227;
    --focus: #8ab4ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 2.2rem 0 .7rem; }
p { margin: .5rem 0; }
code { background: var(--soft); padding: 0 .3em; border-radius: 4px; font-size: .92em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--panel); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
header.top { padding: 28px 16px 8px; }
.lede { color: var(--muted); max-width: 72ch; }
.privacy { font-size: .92rem; color: var(--muted); }
.privacy strong { color: var(--ink); }
.hint { color: var(--muted); font-weight: 400; }
.small { font-size: .86rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.tpl, .opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: .92rem; }
.saved { color: var(--muted); font-size: .85rem; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; width: 100%; min-width: 0;
}
select { width: auto; }
textarea { resize: vertical; line-height: 1.35; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input.invalid { border-color: var(--bad); background: var(--bad-bg); }
.f { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.f > label, .f .lbl { font-size: .8rem; color: var(--muted); font-weight: 600; }
.chk { display: inline-flex; align-items: center; gap: 6px; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

.ev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.ev-name, .ev-venue, .ev-contacts { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .ev-grid { grid-template-columns: 2fr 1fr 1.5fr repeat(4, 1fr); }
  .ev-name { grid-column: auto; }
  .ev-venue { grid-column: auto; }
  .ev-contacts { grid-column: 1 / -1; }
}

.btn {
  font: inherit; font-size: .93rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 13px; border-radius: 8px; min-height: 40px;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.link { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 4px; }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; position: sticky; top: 0; z-index: 20;
  background: var(--bg); padding: 10px 0; border-bottom: 1px solid var(--line);
}

.status { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; font-variant-numeric: tabular-nums;
  background: var(--soft); border-radius: 8px; padding: 9px 12px; font-size: .93rem; }
.status b { color: var(--muted); font-weight: 600; margin-right: 3px; }
.pill { padding: 2px 9px; border-radius: 99px; font-weight: 700; font-size: .85rem; }
.pill.ok { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

/* rows */
.list-wrap { position: relative; }
.rows { list-style: none; margin: 8px 0 0; padding: 0; }
.row { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 8px; background: var(--panel); position: relative; }
.row.dragging { z-index: 5; box-shadow: 0 8px 24px rgba(0,0,0,.18); opacity: .95; }
.row.over { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.row.anch { box-shadow: inset 4px 0 0 var(--accent); }
.row.over.anch { box-shadow: inset 4px 0 0 var(--bad); }
.row.buf { background: var(--buf); background-image: repeating-linear-gradient(135deg, transparent 0 10px, rgba(127,127,127,.06) 10px 20px); }
.dropline { position: absolute; left: 0; right: 0; height: 4px; background: var(--accent); border-radius: 2px; pointer-events: none; z-index: 6; }

.r-main { display: grid; gap: 8px; grid-template-columns: 34px 1fr 1fr; grid-template-areas:
  "h time time" "title title title" "dur dur fixed" "who who who" "loc loc owner" "act act act"; align-items: end; }
.handle { grid-area: h; }
.r-num { display: none; }
.r-time { grid-area: time; align-self: center; font-variant-numeric: tabular-nums; }
.f-title { grid-area: title; }
.f-dur { grid-area: dur; }
.f-fixed { grid-area: fixed; }
.f-who { grid-area: who; }
.f-loc { grid-area: loc; }
.f-owner { grid-area: owner; }
.r-actions { grid-area: act; display: flex; gap: 4px; justify-content: flex-end; }
.row.buf .r-main { grid-template-areas: "h time time" "title title title" "dur dur fixed" "act act act"; }

.handle { width: 34px; height: 40px; border: 1px solid transparent; border-radius: 7px; background: none; color: var(--muted);
  cursor: grab; touch-action: none; display: grid; place-items: center; padding: 0; }
.handle:hover { background: var(--soft); }
.handle svg { width: 16px; height: 16px; fill: currentColor; }
.t-start { font-weight: 700; font-size: 1.05rem; }
.t-end { color: var(--muted); margin-left: 2px; }
.t-flag { display: block; font-size: .8rem; font-weight: 600; }
.t-flag.gap { color: var(--warn); }
.t-flag.bad { color: var(--bad); }
.ib { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--muted);
  cursor: pointer; display: grid; place-items: center; padding: 0; }
.ib:hover { color: var(--ink); border-color: var(--muted); }
.ib.del:hover { color: var(--bad); border-color: var(--bad); }
.ib svg { width: 15px; height: 15px; }
.f-title input { font-weight: 600; }

.r-cues { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.f-notes { grid-column: 1 / -1; }
.compact .r-cues { display: none; }

.cols { display: none; }
.add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.empty { color: var(--muted); padding: 12px 0; }

@media (min-width: 1200px) {
  .cols, .r-main { grid-template-columns: 34px 26px 108px minmax(160px, 2.2fr) 66px 116px minmax(110px, 1.2fr) minmax(100px, 1fr) minmax(90px, .9fr) 170px; }
  .cols { display: grid; gap: 8px; padding: 6px 11px 0; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
  .r-main { grid-template-areas: none; align-items: center; }
  .r-main > * { grid-area: auto; }
  .row.buf .r-main { grid-template-areas: none; }
  .row.buf .r-actions { grid-column: 10; }
  .r-num { display: block; color: var(--muted); font-size: .85rem; text-align: right; font-variant-numeric: tabular-nums; }
  .r-main .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .r-time { font-size: .92rem; }
  .t-start { font-size: .98rem; }
  .r-cues { grid-template-columns: repeat(5, 1fr) 1.6fr; margin-left: 76px; }
  .f-notes { grid-column: auto; }
  .row.buf .r-cues { grid-template-columns: 1fr; }
  .row { padding: 8px 10px; }
}

/* sheet */
.sheet { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--panel); }
.sh-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; margin-bottom: 10px; }
.sh-kicker { margin: 0; text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; font-weight: 700; color: var(--accent); }
.sh-title { font-size: 1.25rem; margin: 2px 0; }
.sh-meta { margin: 2px 0; font-size: .9rem; font-variant-numeric: tabular-nums; }
.sh-meta b { color: var(--muted); font-weight: 600; }
.sh-contacts { font-size: .85rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }
.sh-foot { font-size: .78rem; color: var(--muted); margin-top: 8px; }
.sheet-t { width: 100%; border-collapse: collapse; font-size: .86rem; min-width: 640px; }
.sheet-t th, .sheet-t td { text-align: left; vertical-align: top; padding: 6px 7px; border-bottom: 1px solid var(--line); }
.sheet-t th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 2px solid var(--ink); }
.sheet-t .c-n { width: 2em; color: var(--muted); }
.sheet-t .c-time { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.sheet-t .c-dur { width: 3.5em; font-variant-numeric: tabular-nums; }
.sheet-t .c-title { font-weight: 600; min-width: 12em; }
.s-buf td { background: var(--buf); font-style: italic; color: var(--muted); }
.s-over td { color: var(--bad); }
.s-pin { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; margin-left: 2px; }
.s-none { color: var(--muted); text-align: center; padding: 18px; }

/* content */
.content { max-width: 860px; padding-bottom: 32px; }
.steps li { margin-bottom: .45rem; }
.table-wrap { overflow-x: auto; }
.ref { border-collapse: collapse; width: 100%; font-size: .93rem; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.ref th, .ref td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ref thead th { background: var(--soft); font-size: .85rem; }
.ref tbody th { font-weight: 600; white-space: nowrap; }
.faq details { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 0 14px; }
.faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.faq details p { margin: 0 0 12px; }
.updated { color: var(--muted); font-size: .9rem; margin-top: 1.4rem; }

.foot { border-top: 1px solid var(--line); padding: 20px 0 36px; font-size: .92rem; color: var(--muted); }
.foot ul { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot .more { margin-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 100; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 9px; display: flex; gap: 12px; align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); font-size: .93rem; }
.toast[hidden] { display: none; }

/* live mode */
.live-open { overflow: hidden; }
.live { position: fixed; inset: 0; z-index: 200; background: #0b0b0d; color: #f4f4f5; display: flex; flex-direction: column;
  padding: 14px 16px; gap: 12px; overflow-y: auto; }
.live[hidden] { display: none; }
.live :focus-visible { outline-color: #8ab4ff; }
.lv-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.lv-event { font-weight: 600; color: #b9bcc3; }
.lv-clock { font-size: clamp(1.3rem, 3.5vw, 2rem); font-weight: 700; }
.lv-drift { font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.lv-drift.ok { background: #143823; color: #8ee0ae; }
.lv-drift.warn { background: #3d2f0f; color: #ffd27a; }
.lv-drift.over { background: #4a1418; color: #ffa3a8; }
.lv-now { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; text-align: center; min-height: 0; }
.lv-state { text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: #ff9a6a; margin: 0; }
.lv-title { font-size: clamp(1.6rem, min(6vw, 7vh), 4rem); font-weight: 800; line-height: 1.1; margin: 6px 0; }
.lv-who { font-size: clamp(1rem, 2.6vw, 1.5rem); color: #c9ccd2; margin: 0; }
.lv-count { font-size: clamp(4rem, min(20vw, 24vh), 13rem); font-weight: 800; line-height: 1; margin: 12px 0 8px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.lv-count.warn { color: #ffcc5c; }
.lv-count.over { color: #ff6b73; animation: blink 1s steps(2) infinite; }
.lv-count.idle { color: #7d818a; }
@keyframes blink { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .lv-count.over { animation: none; } }
.lv-track { height: 10px; background: #26272c; border-radius: 99px; overflow: hidden; max-width: 900px; width: 100%; margin: 0 auto; }
.lv-bar { height: 100%; width: 0; background: #4fd18b; transition: width .25s linear; }
.lv-bar.warn { background: #ffcc5c; }
.lv-bar.over { background: #ff6b73; }
.lv-plan { color: #9a9ea6; font-variant-numeric: tabular-nums; margin: 8px 0 0; }
.lv-cues { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.chip { background: #1e2026; border: 1px solid #34363e; border-radius: 6px; padding: 3px 8px; font-size: .9rem; }
.chip b { color: #ff9a6a; font-weight: 700; margin-right: 3px; }
.lv-notes { color: #d6d8dc; max-width: 70ch; margin: 10px auto 0; }
.lv-next { background: #17181c; border: 1px solid #2c2e35; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.lv-next .lv-cues { justify-content: flex-start; margin-top: 4px; }
.lv-k { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: #9a9ea6; }
.lv-nt { font-size: clamp(1.15rem, 3vw, 1.7rem); font-weight: 700; }
.lv-nm { color: #b9bcc3; }
.lv-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.lbtn { font: inherit; font-weight: 700; min-height: 48px; padding: 10px 16px; border-radius: 10px; border: 1px solid #3a3c44; background: #1c1d22; color: #f4f4f5; cursor: pointer; }
.lbtn:disabled { opacity: .4; cursor: default; }
.lbtn.go { background: #1f8a4c; border-color: #1f8a4c; color: #fff; font-size: 1.2rem; min-width: 190px; min-height: 60px; }
.lbtn.go:disabled { background: #2a2c31; border-color: #2a2c31; }
.lbtn[hidden] { display: none; }
.lv-mode-l { color: #9a9ea6; font-size: .9rem; }
#lvMode { background: #1c1d22; color: #f4f4f5; border-color: #3a3c44; min-height: 48px; }
.lv-keys { text-align: center; color: #7d818a; font-size: .8rem; margin: 0; }
@media (max-width: 560px) { .lv-keys { display: none; } .lbtn.go { flex: 1 1 100%; } }

/* print: landscape cue sheet only */
@media print {
  @page { size: landscape; margin: 10mm; }
  :root { --ink: #000; --muted: #444; --line: #bbb; --panel: #fff; --bg: #fff; --buf: #f1f1f1; --accent: #000; --bad: #000; }
  body { background: #fff; color: #000; font-size: 10pt; }
  header.top, .toolbar, .panel:not(.sheet-panel), .content, .foot, .toast, .live, .skip, .sheet-panel .panel-head, .screen-only { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; margin: 0; }
  .sheet { border: 0; padding: 0; overflow: visible; }
  .sheet-t { min-width: 0; font-size: 9pt; }
  .sheet-t td.c-notes { width: 17%; }
  .sheet-t thead { display: table-header-group; }
  .sheet-t tr { break-inside: avoid; }
  .sheet-t th { color: #000; }
  .s-over td { font-weight: 700; }
  .s-buf td { background: #f1f1f1 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
