:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1d2027;
  --line: #343a46;
  --muted: #aab3c4;
  --accent: #8b7cff;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: #f4f6fa;
}
button, input, select { font: inherit; }
button, select, input { border: 1px solid var(--line); border-radius: 8px; background: #161920; color: inherit; }
button { padding: 9px 13px; cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #101018; font-weight: 700; }
.danger { color: #ff9b9b; border-color: #754548; }
.bar {
  flex: 0 0 auto;
  min-height: 55px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.brand { margin-right: auto; font-size: 18px; white-space: nowrap; }
.brand span { font-size: 14px; font-weight: 500; color: var(--muted); }
#progress { color: var(--muted); white-space: nowrap; }
main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  overflow: hidden;
}
.viewer { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; background: #08090c; }
.video-head { flex: 0 0 auto; padding: 8px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.video-head-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.video-head h1 { margin: 0; font-size: 17px; white-space: nowrap; }
.video-head small { color: var(--accent); font-weight: 700; }
.source-hints { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: 12px; }
.source-hints span { padding: 2px 7px; border: 1px solid var(--line); border-radius: 7px; white-space: nowrap; }
.source-hints strong { color: #f4f6fa; }
#clip-status { color: var(--muted); white-space: nowrap; }
.player-shell { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #000; }
.player-shell video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.player-shell.zoomed { cursor: grab; }
.player-shell.dragging { cursor: grabbing; }
#player-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #060607; color: var(--muted); }
.player-controls { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; padding: 9px 12px; border-top: 1px solid var(--line); background: #17191f; }
.control-button { flex: 0 0 auto; min-width: 34px; height: 34px; padding: 0 7px; }
.speed { flex: 0 0 auto; min-width: 48px; height: 34px; padding: 0 8px; }
.zoom-value { min-width: 38px; color: var(--muted); font-size: 12px; text-align: center; }
.timeline { position: relative; flex: 1 1 auto; min-width: 100px; height: 34px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #12151a; cursor: pointer; }
.timeline-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: #343a46; pointer-events: none; }
.timeline-head { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #eee; pointer-events: none; }
.timeline-range { position: absolute; top: 0; bottom: 0; display: none; background: rgba(30, 181, 0, .26); border-left: 2px solid #1eb500; border-right: 2px solid #ff5a5a; pointer-events: none; }
.timeline-mark { position: absolute; top: 0; bottom: 0; display: none; width: 2px; pointer-events: none; }
.timeline-mark.start { background: #1eb500; }
.timeline-mark.end { background: #ff5a5a; }
.time-label { position: relative; z-index: 1; padding: 0 9px; line-height: 32px; font-size: 11px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; pointer-events: none; }
.transport { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 14px; border-top: 1px solid var(--line); }
aside { min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); padding: 18px; background: var(--panel); }
#review-panel { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
aside h2 { font-size: 18px; margin: 0 0 12px; }
aside p { color: var(--muted); }
#annotation-panel h2 { margin-top: 0; }
.annotation-state { margin: -4px 0 10px; padding: 8px 10px; border: 1px solid #735b43; border-radius: 8px; color: #f3cda4; font-size: 12px; }
.annot-panel { display: flex; flex-direction: column; gap: 8px; }
.ap-row, .ap-block { border: 1px solid var(--line); border-radius: 10px; background: #161920; padding: 9px 10px; }
.ap-row { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.ap-row.start { border-left: 3px solid #1eb500; }
.ap-row.end { border-left: 3px solid #ff5a5a; }
.ap-main { flex: 1 1 auto; min-width: 0; }
.ap-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.ap-value { margin-top: 2px; font-size: 14px; font-variant-numeric: tabular-nums; }
.ap-value.empty, .quiet { color: #798291; }
.ap-block { display: flex; flex-direction: column; gap: 8px; }
.ap-block label { margin: 0; }
.ap-block select { width: 100%; padding: 8px; }
.routine-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.routine-choice { min-width: 0; padding: 0 5px; font-size: 12px; font-weight: 600; }
kbd { display: inline-block; min-width: 15px; padding: 1px 4px; border-radius: 3px; background: #323741; color: #bac3d3; font: 10px ui-monospace, Consolas, monospace; text-align: center; text-transform: none; }
.mark-set, .mark-jump, .counter-button { background: #292e38; }
.mark-set { min-width: 46px; }
.mark-jump { width: 34px; padding: 9px 0; }
.counter-controls, .button-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.counter-button { width: 32px; height: 32px; padding: 0; font-size: 18px; font-weight: 700; }
#moves-value { min-width: 29px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.choice { min-width: 33px; height: 32px; padding: 0 7px; font-size: 13px; font-weight: 700; }
.choice.active { color: var(--accent); border-color: var(--accent); background: rgba(139, 124, 255, .15); }
.save-error { min-height: 16px; margin: 2px 0 0; color: #ffaeae; font-size: 12px; }
.clip-list-head { margin: 18px 0 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.clip-list { display: grid; gap: 5px; }
.clip-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 10px; text-align: left; font-size: 12px; }
.clip-item.active { border-color: var(--accent); background: rgba(139, 124, 255, .12); }
.clip-item.saved { color: #8cdaa9; }
.clip-item.removed { color: #e59c9c; }
.clip-item span + span { color: var(--muted); font-size: 11px; }
label { display: block; margin: 13px 0; color: #dce1eb; font-weight: 600; }
label input:not([type=checkbox]), label select { display: block; width: 100%; padding: 9px; margin-top: 6px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.two button { margin-bottom: 13px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 20px; }
.wide { width: 100%; margin-top: 18px; }
.annot-panel .wide { margin-top: 0; }
.required { color: #f2a4a4; font-size: 11px; }
#message { min-height: 22px; color: #ffaeae; white-space: pre-wrap; }
#results-content { line-height: 2; }
.pill { display: inline-block; padding: 2px 7px; border: 1px solid var(--line); border-radius: 10px; }
[hidden] { display: none !important; }
dialog { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 20px; background: var(--panel); color: #f4f6fa; }
dialog::backdrop { background: rgba(0, 0, 0, .72); }
dialog h2 { margin: 0 0 15px; }
#close-shortcuts { float: right; }
.shortcut-list { display: grid; grid-template-columns: minmax(115px, 1fr) 2fr; gap: 7px 12px; }
.shortcut-list span:nth-child(odd) { color: var(--accent); font-family: ui-monospace, Consolas, monospace; }

@media (max-width: 900px) { .player-controls { flex-wrap: wrap; } .timeline { order: 1; flex-basis: 100%; } }
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; }
  .brand { width: 100%; }
  main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(210px, 42%); }
  aside { border-left: 0; border-top: 1px solid var(--line); }
}
