/* Dragon Tennis app. Colours from the channel banner: clay court, slate teal wordmark, pale court lines.
   Layout: one column on phones; on wide screens the editor becomes viewer + inspector over a timeline. */
:root {
  --paper: #f3f6f5;
  --panel: #ffffff;
  --ink: #13262a;
  --teal: #24444a;
  --teal-deep: #142b2e;
  --muted: #5b7075;
  --rule: #d9e3e2;
  --clay: #c4673f;
  --clay-deep: #a4512d;
  --line: #9cc9d9;
  --check: #d99a1e;
  --keep: #2f8a5a;
  --drop: #b8c4c4;
  --bad: #b23a2c;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --text: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  font-variation-settings: "wdth" 100;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--line); outline-offset: 2px; }
.mono, time, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- top bar */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--teal); color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.mark { display: flex; flex-direction: column; text-decoration: none; color: inherit; line-height: 1.05; }
.mark b { font: 800 19px var(--display); font-variation-settings: "wdth" 125; letter-spacing: .14em; }
.mark span { font: 600 10px var(--display); font-variation-settings: "wdth" 125; letter-spacing: .32em; color: var(--line); }
.bar nav { display: flex; gap: 6px; }
.bar nav button { background: transparent; border: 1px solid rgba(255,255,255,.28); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; }

main {
  max-width: 1280px; margin: 0 auto;
  padding-block: 18px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* ---------- the one-line instruction on every screen */
.say {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: start;
  border-left: 4px solid var(--clay); background: var(--panel);
  padding: 14px 14px 14px 16px; margin-bottom: 18px; border-radius: 0 10px 10px 0;
}
.say-now { margin: 0; font-weight: 700; font-size: 18px; text-wrap: balance; }
.say-next { margin: 0; grid-column: 1; color: var(--muted); font-size: 15px; }
.tip-btn {
  grid-row: 1 / span 2; grid-column: 2; width: 34px; height: 34px; border-radius: 50%;
  border: 1.5px solid var(--teal); background: transparent; font-weight: 800; color: var(--teal);
}
.tip { grid-column: 1 / -1; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--rule); color: var(--ink); font-size: 15px; }

h1 { font: 800 28px/1.1 var(--display); font-variation-settings: "wdth" 112; letter-spacing: .01em; margin: 0 0 14px; text-wrap: balance; }
h2 { font: 800 18px var(--display); font-variation-settings: "wdth" 112; margin: 0 0 10px; }
.muted { color: var(--muted); }
.err { color: var(--bad); font-weight: 600; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--clay); color: #fff; font-weight: 800; letter-spacing: .02em; text-decoration: none;
}
.btn:hover { background: var(--clay-deep); }
.btn.big { min-height: 58px; font-size: 19px; width: 100%; }
.btn.ghost { background: transparent; color: var(--teal); border: 1.5px solid var(--teal); }
.btn.ghost:hover { background: rgba(36,68,74,.06); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- matches */
.matches { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); margin-top: 14px; }
.match {
  display: grid; grid-template-columns: 112px 1fr; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 10px;
  text-align: left; width: 100%;
}
.match:hover { border-color: var(--teal); }
.thumb {
  width: 112px; aspect-ratio: 16 / 9; border-radius: 8px; background-color: var(--teal);
  background-repeat: no-repeat; position: relative; overflow: hidden;
}
.thumb.court::after {
  content: ""; position: absolute; inset: 18% 12%; border: 1.5px solid var(--line); border-radius: 2px;
  background: linear-gradient(90deg, transparent calc(50% - .75px), var(--line) calc(50% - .75px), var(--line) calc(50% + .75px), transparent calc(50% + .75px));
}
.match-title { font-weight: 800; font-size: 17px; margin: 0; min-width: 0; overflow-wrap: anywhere; }
.match-meta { font-size: 14px; color: var(--muted); margin: 2px 0 6px; }
.chip { display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; background: #e7eeed; color: var(--teal); }
.chip.live { background: var(--line); color: var(--teal-deep); }
.chip.ready { background: var(--clay); color: #fff; }
.chip.done { background: var(--keep); color: #fff; }
.chip.bad { background: var(--bad); color: #fff; }
.empty { background: var(--panel); border: 1.5px dashed var(--rule); border-radius: 12px; padding: 28px 18px; text-align: center; color: var(--muted); }

/* ---------- upload */
.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 18px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 700; }
.field input { min-height: 48px; border: 1.5px solid var(--rule); border-radius: 10px; padding: 0 12px; background: #fff; }
.meter { height: 14px; border-radius: 999px; background: #e3eae9; overflow: hidden; margin: 16px 0 10px; }
.meter i { display: block; height: 100%; width: 0; background: var(--clay); border-radius: inherit; transition: width .3s; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--mono); font-size: 14px; color: var(--muted); }
.big-num { font: 800 44px/1 var(--display); font-variation-settings: "wdth" 112; font-variant-numeric: tabular-nums; }

/* ---------- step rail */
.rail { display: flex; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; flex-wrap: wrap; }
.rail li { font-size: 13px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: #e7eeed; color: var(--muted); }
.rail li.on { background: var(--teal); color: #fff; }
.rail li.ok { background: #dcebe3; color: var(--keep); }

/* ---------- listening */
.listen { display: grid; gap: 16px; }
@media (min-width: 900px) { .listen { grid-template-columns: 1.4fr 1fr; } }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.counter { background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; padding: 12px; }
.counter span { display: block; font-size: 13px; color: var(--muted); font-weight: 700; }
.counter b { font: 800 30px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.wave { width: 100%; height: 120px; display: block; background: var(--teal-deep); border-radius: 12px; }
.court { width: 100%; max-width: 420px; display: block; margin: 0 auto; }

/* ---------- editor */
.editor { display: grid; gap: 12px; }
.viewer { background: #000; border-radius: 12px; overflow: hidden; position: relative; }
.viewer video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.viewer .tc { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.6); color: #fff; font: 600 13px var(--mono); padding: 3px 8px; border-radius: 6px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tool { min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--panel); font-weight: 700; font-size: 14px; }
.tool:hover { border-color: var(--teal); }
.tool kbd { font: 600 11px var(--mono); color: var(--muted); margin-left: 4px; }
.tool.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.inspector h2 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 12px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--mono); }
.nudge { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.pill { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; background: #e7eeed; color: var(--teal); white-space: nowrap; }
.pill.check { background: #f6e3b8; color: #7a5208; }
.pill.single { background: #e4e7e7; color: #586466; }
.pill.added { background: var(--line); color: var(--teal-deep); }

.timeline { background: var(--teal-deep); color: #dfe9e8; border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.lane-label { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--line); display: flex; justify-content: space-between; gap: 8px; }
.source { position: relative; height: 34px; background: #21403f; border-radius: 6px; cursor: pointer; touch-action: none; }
.source .r { position: absolute; top: 6px; bottom: 6px; background: var(--clay); border-radius: 2px; min-width: 2px; }
.source .r.drop { background: #4f6766; }
.source .r.check { background: var(--check); }
.source .r.single { top: 12px; bottom: 12px; background: #8aa0a0; }
.source .r.drop.check, .source .r.drop.single { background: #4f6766; }
.source .r.sel { outline: 2px solid #fff; z-index: 2; }
.source .ph, .strip .ph { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #ff5a36; pointer-events: none; z-index: 3; }
.source .mk { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--line); z-index: 3; }
.result { display: flex; gap: 2px; height: 40px; overflow: hidden; border-radius: 6px; }
.result button { border: 0; padding: 0; background: var(--clay); color: #fff; font: 700 11px var(--mono); min-width: 3px; overflow: hidden; white-space: nowrap; }
.result button.check { background: var(--check); color: var(--teal-deep); }
.result button.star { box-shadow: inset 0 3px 0 #ffd84d; }
.result button.sel { background: #fff; color: var(--teal-deep); }
.strip { position: relative; height: 96px; background: #1c3837; border-radius: 6px; touch-action: none; }
.strip canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.strip .h { position: absolute; top: 0; bottom: 0; width: 22px; margin-left: -11px; cursor: ew-resize; z-index: 4; display: flex; justify-content: center; }
.strip .h::before { content: ""; width: 4px; border-radius: 2px; background: #fff; }
.strip .h::after { content: ""; position: absolute; top: 50%; width: 14px; height: 26px; margin-top: -13px; border-radius: 4px; background: #fff; }

.list { display: grid; gap: 6px; }
.item {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 10px; align-items: center;
  background: var(--panel); border: 1.5px solid var(--rule); border-radius: 12px; padding: 8px;
}
.item.sel { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(36,68,74,.15); }
.item.drop { opacity: .55; }
.item .thumb { width: 72px; }
.item-main { min-width: 0; text-align: left; background: none; border: 0; padding: 0; }
.item-main b { display: block; }
.item-main small { color: var(--muted); font-family: var(--mono); }
.item-acts { display: flex; gap: 4px; }
.ic { width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--panel); font-size: 18px; line-height: 1; }
.ic.on-star { background: #fff4c7; border-color: #e3c24e; }
.ic.on-drop { background: #f3dcd8; border-color: #d99a8f; }
.item-trim { grid-column: 1 / -1; display: grid; gap: 6px; padding-top: 6px; border-top: 1px dashed var(--rule); }

.makebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: var(--panel); border-top: 1px solid var(--rule);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.makebar .sum { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.saved { font-size: 13px; color: var(--muted); }

.desk { display: none; }
@media (min-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); }
  .editor .viewer { grid-column: 1; }
  .editor .inspector { grid-column: 2; grid-row: 1 / span 2; }
  .editor .tools { grid-column: 1; }
  .editor .timeline { grid-column: 1 / -1; }
  .editor .list { display: none; }
  .desk { display: block; }
}
@media (max-width: 899px) { .editor .timeline .strip-wrap, .editor .inspector { display: none; } }

.done-video video { width: 100%; border-radius: 12px; background: #000; display: block; }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--teal-deep); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 700; z-index: 40; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Final Cut style additions: zoomable timeline, keys panel, two finished videos */
.res-scroll { overflow-x: auto; border-radius: 6px; }
.res-scroll .result { min-width: 100%; }
.keys-dlg { position: fixed; z-index: 50; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: 80vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.keys-dlg dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 14px; }
.keys-dlg dt { font: 600 13px var(--mono); color: var(--teal); white-space: nowrap; }
.keys-dlg dd { margin: 0; font-size: 15px; }
.done-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); margin-bottom: 14px; }
.done-video h2 { margin-bottom: 8px; }
