/* Annotate. Colours follow Kora Island's Glass theme with the Rose accent
   (the same tokens as Kora Harvest). A dark-only tool: footage reads best on black. */

:root {
  --bg: #0a0b10;
  --surface: rgb(52 58 71 / .65);
  --surface-2: rgb(74 81 97 / .75);
  --line: rgb(255 255 255 / .14);
  --line-strong: rgb(255 255 255 / .35);
  --text: #f6f4ef;
  --muted: #c4c8d2;
  --dim: #9ba1ad;
  --on-accent: #111815;
  --mint: #b1e7c7;
  --amber: #f4cc89;
  --rose: #ffb4c6;
  --accent: var(--rose);
  --danger: #ff9b9b;
  --rec: #ff453a;
  --glass-edge:
    inset 0 1px 0 rgb(255 255 255 / .35),
    inset 0 -1px 0 rgb(255 255 255 / .08),
    inset 0 0 0 1px rgb(255 255 255 / .14),
    0 .8em 2em -.6em rgb(0 0 0 / .45);
  --sans: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", monospace;
  --radius: 22px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 16px; z-index: 100; }
.skip:focus { left: 16px; }
.boot { padding: 48px 16px; text-align: center; color: var(--muted); }
.meta { color: var(--dim); font-size: 14px; margin: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--glass-edge);
  cursor: pointer; text-decoration: none; color: var(--text); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.rec { background: var(--rec); color: #fff; border-color: transparent; }
.icon-btn { width: 44px; padding: 0; border-radius: 12px; flex: none; }
.icon-btn[aria-pressed="true"], .speeds .btn[aria-pressed="true"] { background: var(--text); color: var(--bg); }
svg.icon { width: 22px; height: 22px; flex: none; }

/* Pages (library, review, about) */
.page { max-width: 960px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 24px 0 16px; }
.brand { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -.02em; }
.brand small { display: block; font-size: 14px; font-weight: 400; color: var(--dim); letter-spacing: 0; }
.drop { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 24px 16px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); background: rgb(255 180 198 / .08); }
.steps { margin: 12px 0 0; padding-left: 20px; text-align: left; display: inline-block; }
.cards { list-style: none; padding: 0; margin: 24px 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--glass-edge); overflow: hidden; display: flex; flex-direction: column; }
.card img, .card .thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; }
.card-body { padding: 12px 16px 16px; display: grid; gap: 8px; }
.card h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.foot { margin-top: 32px; display: grid; gap: 4px; color: var(--dim); font-size: 14px; }
.prose { max-width: 680px; }
.prose h2 { margin-top: 32px; }

/* Studio */
.studio {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "bar bar" "tools stage" "tools transport";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.bar { grid-area: bar; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.bar .title { flex: 1; min-width: 0; margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rec-controls { display: flex; align-items: center; gap: 8px; }
.rec-time { font: 500 15px var(--mono); font-variant-numeric: tabular-nums; min-width: 5ch; text-align: right; }
.rec-time.live::before { content: "●"; color: var(--rec); margin-right: 6px; animation: blink 1s steps(2) infinite; }
.rec-time.warn { color: var(--amber); }
.meter { width: 40px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--mint); transform-origin: left; transform: scaleX(var(--level, 0)); }
.tools { grid-area: tools; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-right: 1px solid var(--line); overflow-y: auto; }
.tools hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.swatch { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 2px solid transparent; background: none; display: grid; place-items: center; cursor: pointer; padding: 0; }
.swatch span { width: 24px; height: 24px; border-radius: 50%; background: var(--swatch); }
.swatch[aria-pressed="true"] { border-color: var(--text); }
.stage { grid-area: stage; position: relative; background: #000; overflow: hidden; }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage video { object-fit: contain; }
.stage canvas { touch-action: none; cursor: crosshair; }
.transport { grid-area: transport; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.transport input[type="range"] { flex: 1; min-width: 80px; height: 44px; accent-color: var(--accent); }
.time { font: 13px var(--mono); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.speeds { display: flex; gap: 4px; }
.speeds .btn { min-height: 36px; padding: 0 10px; font-size: 14px; }

@media (max-width: 720px) {
  .studio {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "bar" "stage" "transport" "tools";
  }
  .tools { flex-direction: row; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
  .tools hr { width: auto; margin: 0 4px; border-top: 0; border-left: 1px solid var(--line); }
  .transport { flex-wrap: wrap; }
  .transport input[type="range"] { order: -1; flex-basis: 100%; }
  .time { margin-left: auto; }
  .back-label { display: none; }
  .bar { gap: 8px; }
  .studio .bar { flex-wrap: wrap; }
  .studio .rec-controls { flex: 1 0 100%; justify-content: flex-end; flex-wrap: wrap; }
  .studio .rec-controls .meter { flex: none; }
}

/* Review */
.review { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; display: grid; gap: 16px; }
.review .bar { padding: max(8px, env(safe-area-inset-top)) 0 8px; }
.player { display: grid; gap: 12px; }
.player video { width: 100%; max-height: 60dvh; background: #000; border-radius: 16px; }
.render-status { display: grid; gap: 8px; padding: 16px; background: var(--surface); border-radius: 16px; box-shadow: var(--glass-edge); }
.render-status p { margin: 0; }
progress { width: 100%; accent-color: var(--accent); }
.editor { display: grid; gap: 12px; }
.editor h2 { margin: 0; font-size: 18px; }
.wave { display: block; width: 100%; height: 72px; border-radius: 12px; background: rgb(255 255 255 / .04); touch-action: none; cursor: pointer; }
.cut-buttons, .export { display: flex; flex-wrap: wrap; gap: 8px; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: 999px; background: rgb(255 69 58 / .18); font: 13px var(--mono); }
.chip .icon-btn { width: 32px; min-height: 32px; border-radius: 50%; }

/* Dialogs and toasts */
dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: #16181f; color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .6); }
dialog form { display: grid; gap: 16px; }
dialog h2 { margin: 0; font-size: 19px; }
dialog p { margin: 0; color: var(--muted); }
.field { display: grid; gap: 6px; }
.field input { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(480px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 14px; background: #1d2029; box-shadow: var(--glass-edge); }
.toast.error { color: var(--danger); }

@keyframes blink { 50% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
