:root {
  --bg: #121317;
  --panel: #1b1d23;
  --panel2: #23262e;
  --line: #2f333d;
  --text: #e9eaee;
  --muted: #9298a6;
  --accent: #e3262b;
  --accent2: #ff5a5f;
  --body: #3d7bfd;
  --hook: #f2a516;
  --ok: #2fb86b;
  --warn: #f2a516;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 Inter, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #4a505e; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent2); }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: #5b6273; }
select { width: auto; padding: 6px 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { display: grid; place-items: center; min-height: 60vh; text-align: center; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.body { color: #9dbbff; border-color: #2c4a8a; }
.chip.hook { color: #ffd27a; border-color: #7a5a14; }
.chip.ok { color: #7be0a6; border-color: #1f6a43; }
.chip.warn { color: #ffd27a; border-color: #7a5a14; }
.chip.bad { color: #ff9a9d; border-color: #7a2326; }

header#top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 52px;
  background: rgba(18, 19, 23, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; text-decoration: none; letter-spacing: -.02em; font-size: 16px; }
.logo { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--accent);
  color: #fff; font-size: 11px; margin-right: 4px; }
#crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); min-width: 0; overflow: hidden; }
#crumbs a { text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
#crumbs a:hover { color: var(--text); }
#me { color: var(--muted); }
#admin-link { text-decoration: none; color: var(--muted); }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 90vw; }

/* auth */
.auth { max-width: 380px; margin: 9vh auto; padding: 28px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; }
.auth h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.auth p { margin: 0 0 18px; }
.auth label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 12px; }
.auth button.primary { width: 100%; margin-top: 18px; padding: 10px; }
.auth .alt { margin-top: 14px; text-align: center; }
.auth .err { color: #ff8a8d; margin-top: 12px; min-height: 1em; }
.qr { background: #fff; border-radius: 10px; padding: 10px; width: 200px; margin: 6px auto 10px; display: block; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; text-align: center; }
.code { letter-spacing: .4em; text-align: center; font-size: 20px; font-family: ui-monospace, Menlo, monospace; }

/* lists */
.page { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.page h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 4px 0 18px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  text-decoration: none; display: flex; flex-direction: column; }
.card:hover { border-color: #4a505e; }
.card .thumb { aspect-ratio: 9 / 12; background: #000; display: grid; place-items: center; overflow: hidden; }
.card .thumb video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.card .meta { padding: 10px 12px 12px; display: grid; gap: 4px; }
.card .title { font-weight: 600; }
.plist { display: grid; gap: 8px; }
.prow { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.prow:hover { border-color: #4a505e; }
.prow .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tablewrap { overflow-x: auto; }
table.admin { width: 100%; border-collapse: collapse; }
table.perms td:not(:first-child), table.perms th:not(:first-child) { text-align: center; }
table.perms input { width: 18px; height: 18px; accent-color: var(--accent); }
button.danger { background: #b3262a; border-color: #b3262a; color: #fff; font-weight: 600; }
.row.end { justify-content: flex-end; margin-top: 16px; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .6); display: grid; place-items: center; padding: 16px; }
.modal .box { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0 0 6px; white-space: pre-wrap; word-break: break-word; }
.modal label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 12px; }
.modal .err { color: #ff8a8d; min-height: 1em; margin-top: 8px; }
table.admin td, table.admin th { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }

/* player: fits the window like frame.io (video never taller than the screen) */
.player { display: grid; grid-template-columns: minmax(0, 1fr) 380px; height: calc(100dvh - 52px); }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.stage-top { display: flex; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; }
.videos { flex: 1 1 0; min-height: 0; display: flex; gap: 14px; justify-content: center; align-items: center;
  padding: 14px; background: #0b0c0f; }
.vwrap { position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100%; min-height: 0; cursor: pointer;
  background: #000; border-radius: 6px; overflow: hidden; }
.vwrap video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.vwrap .tag { position: absolute; top: 8px; left: 8px; font-size: 12px; background: rgba(0, 0, 0, .6); padding: 2px 8px;
  border-radius: 99px; color: #fff; pointer-events: none; }
.bigplay { position: absolute; left: 50%; top: 50%; width: 74px; height: 74px; margin: -37px 0 0 -37px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); display: grid; place-items: center; pointer-events: none; transition: opacity .15s; }
.bigplay::after { content: ""; margin-left: 6px; border-style: solid; border-width: 15px 0 15px 25px;
  border-color: transparent transparent transparent #fff; }
.vwrap.playing .bigplay { opacity: 0; }
.controls { padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--panel); }
.seglegend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.seglegend .lg { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; font-size: 13px; font-weight: 600; border-radius: 99px; }
.seglegend .lg i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.seglegend .lg.hook i { background: var(--hook); }
.seglegend .lg.body i { background: var(--body); }
.seglegend .lg small { font-weight: 400; color: var(--muted); }
.seglegend .lg.now { border-color: #fff; }
.timeline { position: relative; height: 52px; cursor: pointer; margin: 2px 0 10px; user-select: none; touch-action: none; }
.timeline .segs { position: absolute; left: 0; right: 0; top: 0; height: 24px; display: flex; border-radius: 5px; overflow: hidden; }
.timeline .seg { height: 100%; font-size: 12px; line-height: 24px; padding: 0 8px; overflow: hidden; white-space: nowrap;
  text-overflow: ellipsis; color: #111; font-weight: 700; border-right: 2px solid var(--panel); }
.timeline .seg small { font-weight: 500; opacity: .75; margin-left: 6px; }
.timeline .seg.hook { background: var(--hook); }
.timeline .seg.body { background: var(--body); color: #fff; }
.timeline .seg.now { box-shadow: inset 0 0 0 2px #fff; }
.timeline .track { position: absolute; left: 0; right: 0; top: 31px; height: 8px; background: var(--panel2); border-radius: 4px; }
.timeline .fill { position: absolute; left: 0; top: 31px; height: 8px; background: var(--accent); border-radius: 4px; }
.timeline .range { position: absolute; top: 28px; height: 14px; background: rgba(255, 255, 255, .25); border-radius: 3px; }
.timeline .mark { position: absolute; top: 42px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%;
  background: #fff; border: 2px solid var(--panel); }
.timeline .mark.body { background: #9dbbff; }
.timeline .mark.hook { background: #ffd27a; }
.timeline .mark.done { opacity: .35; }
.timeline .mark.span { border-radius: 3px; margin-left: 0; height: 6px; top: 43px; border: 0; }
.timeline .head { position: absolute; top: -2px; width: 2px; height: 46px; margin-left: -1px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
.timeline .head::after { content: ""; position: absolute; left: -5px; top: 30px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; }
.timeline .hover { position: absolute; top: -26px; transform: translateX(-50%); font: 12px ui-monospace, Menlo, monospace;
  background: #000; border: 1px solid var(--line); padding: 2px 6px; border-radius: 4px; pointer-events: none; white-space: nowrap; }
.ctl { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.ctl .grp { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ctl .grp.r { justify-content: flex-end; }
.ctl button { padding: 6px 11px; min-width: 38px; }
.ctl #play { min-width: 48px; font-size: 16px; }
.tcbox { display: flex; gap: 10px; align-items: center; justify-content: center; }
.tc { font: 700 22px/1 ui-monospace, Menlo, monospace; letter-spacing: .02em; background: #000; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; min-width: 190px; text-align: center; }
.tc small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 4px; letter-spacing: 0; }
.segnow { font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.segnow.hook { background: var(--hook); color: #111; }
.segnow.body { background: var(--body); color: #fff; }
.keys { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.keys b { color: var(--text); font-weight: 600; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px;
  padding: 0 5px; }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; padding: 12px; color: var(--muted); }
.tabs button.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.pane { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.composer { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 8px; }
.composer textarea { min-height: 64px; resize: vertical; }
.modes { display: flex; gap: 6px; }
.modes button { padding: 4px 9px; font-size: 12px; }
.modes button.on { border-color: var(--accent); color: #fff; }
.filters { display: flex; gap: 6px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
.filters button { padding: 3px 9px; font-size: 12px; }
.filters button.on { border-color: #5b6273; color: #fff; }
.c { padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: var(--panel2); }
.c.done { opacity: .55; }
.c.cur { border-color: var(--accent); }
.c .h { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.c .who { font-weight: 600; }
.c .t { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: #ffb3b5; cursor: pointer; }
.c .txt { white-space: pre-wrap; word-break: break-word; }
.c .acts { display: flex; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.c .acts a { cursor: pointer; text-decoration: none; }
.c .acts a:hover { color: var(--text); }
.c .replies { margin: 8px 0 0 12px; border-left: 2px solid var(--line); padding-left: 10px; }
.c .replies .r { margin-bottom: 6px; }
.words { line-height: 2; }
.words span { cursor: pointer; padding: 1px 2px; border-radius: 3px; }
.words span:hover { background: var(--panel2); }
.words span.now { background: var(--accent); color: #fff; }
.words span.extra { text-decoration: underline wavy var(--warn); }
.words .miss { color: #ff9a9d; text-decoration: line-through; font-size: 12px; margin: 0 3px; cursor: pointer; }
.check { padding: 10px; border-radius: 8px; background: var(--panel2); border: 1px solid var(--line); margin-bottom: 12px; }
.check li { margin: 3px 0; }

@media (max-height: 820px) {
  .keys { display: none; }
  .videos { padding: 8px; }
  .controls { padding: 6px 14px 8px; }
  .seglegend { margin-bottom: 4px; }
  .seglegend .lg { padding: 2px 9px; font-size: 12px; }
  .timeline { margin: 0 0 6px; }
  .tc { font-size: 18px; padding: 6px 12px; min-width: 160px; }
  .tc small { display: none; }
}
@media (max-width: 700px) {
  header#top { gap: 10px; padding: 0 12px; }
  #crumbs, #me { display: none; }
  .page { padding: 16px 12px 40px; }
}
@media (max-width: 900px) {
  .player { grid-template-columns: 1fr; height: auto; }
  .videos { flex: none; height: 64vh; }
  .stage { border-right: 0; }
  .side { min-height: 60vh; }
  .ctl { grid-template-columns: 1fr; }
  .ctl .grp, .ctl .grp.r { justify-content: center; }
  .keys { display: none; }
}
