:root {
  color-scheme: dark;
  --zinc-950: #09090b; --zinc-900: #18181b; --zinc-700: #3f3f46;
  --zinc-400: #a1a1aa; --zinc-100: #f4f4f5; --cyan-300: #67e8f9;
  --surface: var(--zinc-950); --panel: var(--zinc-900);
  --text: var(--zinc-100); --muted: var(--zinc-400); --border: var(--zinc-700);
  --button-bg: var(--panel); --focus: var(--cyan-300);
  font: 14px 'Segoe UI', sans-serif;
  background: var(--surface); color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header { display: flex; align-items: center; gap: 8px; padding: 16px; }
header > div { flex: 1; min-width: 0; }
h1 { font-size: 20px; margin: 0; }
p { margin: 4px 0 0; }
#filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
button, select { font: inherit; color: inherit; border: 1px solid var(--border); background: var(--button-bg); border-radius: 8px; min-height: 44px; padding: 8px 12px; }
button { cursor: pointer; min-width: 44px; }
button:hover:not(:disabled), button[aria-pressed="true"] { border-color: var(--focus); }
button[aria-pressed="true"] { color: var(--focus); }
:is(button, input, select):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
:disabled { opacity: .45; cursor: default; }
nav, .tool-group, .playback { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#secondary-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
nav { padding: 0 16px 12px; }
.tool-group { padding-right: 8px; border-right: 1px solid var(--border); }
main { flex: 1; min-height: 100px; position: relative; overflow: hidden; background: var(--surface); }
video { position: absolute; width: 100%; height: 100%; object-fit: contain; }
canvas { position: absolute; pointer-events: none; touch-action: none; }
canvas.drawing { pointer-events: auto; cursor: crosshair; }
#empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.8; color: var(--muted); pointer-events: none; }
[hidden] { display: none !important; }
footer { padding: 12px 16px; border-top: 1px solid var(--border); }
#seek { flex: 1; min-width: 100px; min-height: 44px; accent-color: var(--focus); }
#time { font-variant-numeric: tabular-nums; min-width: 112px; }
#status { margin-top: 8px; }
.hint { color: var(--muted); font-size: 12px; }
.local-help { color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 8px; }
#exit-fullscreen { display: none; }
html:fullscreen header { display: none; }
html:fullscreen nav { position: absolute; inset: 0 0 auto; z-index: 3; padding: 4px 8px; background: rgb(24 24 27 / .9); }
html:fullscreen footer { position: absolute; inset: auto 0 0; z-index: 3; background: rgb(24 24 27 / .9); padding: 4px 8px; }
html:fullscreen #status, html:fullscreen .hint, html:fullscreen .local-help { display: none; }
html:fullscreen #exit-fullscreen { display: inline-block; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
dialog::backdrop { background: rgb(0 0 0 / .72); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
dialog label { display: block; margin: 16px 0 8px; }
dialog input { width: 100%; min-height: 48px; font: inherit; padding: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
#drive-error { color: #fda4af; margin-top: 12px; }
#drive-help { line-height: 1.5; color: var(--muted); }
@media (max-width: 800px) { header, footer { padding: 8px 12px; } nav { padding: 0 12px 8px; } button { padding-inline: 8px; } }
@media (max-width: 600px) {
  header { flex-wrap: wrap; gap: 4px; }
  header > div { flex-basis: 100%; }
  h1 { font-size: 18px; }
  nav { padding-inline: 8px; }
  nav, .tool-group, #secondary-tools, .playback { gap: 4px; }
  .tool-group { padding-right: 0; border-right: 0; }
  #secondary-tools { flex-basis: 100%; }
  #seek { order: 3; flex-basis: calc(100% - 128px); }
  #time { order: 4; min-width: 112px; }
  label[for="seek"] { display: none; }
  #status, .hint { font-size: 11px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  header, footer { padding: 4px 8px; }
  header h1, #status, .hint, .local-help { display: none; }
  header > div { flex-basis: auto; }
  nav { padding: 0 8px 4px; gap: 4px; }
  nav, .tool-group, #secondary-tools, .playback { gap: 4px; }
  button, select { padding: 4px 8px; }
  #secondary-tools { position: absolute; z-index: 5; top: 96px; left: 8px; right: 8px; padding: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
