:root {
  color-scheme: light dark;
  --bg: #f4f4f1;
  --panel: #ffffff;
  --fg: #171717;
  --muted: #6a6a66;
  --line: #d6d6d0;
  --stage: #e4e4df;
  --accent: #2563eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121213;
    --panel: #1c1c1e;
    --fg: #f1f1ef;
    --muted: #9b9b96;
    --line: #36363b;
    --stage: #09090a;
    --accent: #3b82f6;
  }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }

body {
  margin: 0;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

body.dragging .empty { border-color: var(--accent); }

.wrap { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
h1 { margin: 0; font-size: 20px; }
.muted, .hint, .note, .status { color: var(--muted); margin: 0; font-size: 13px; }

.bar, .actions, .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.bar { justify-content: space-between; }

button, select {
  font: inherit;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: transparent; color: #fff; }

.range { display: flex; align-items: center; gap: 8px; color: var(--muted); }
input[type="range"] { width: 160px; max-width: 45vw; accent-color: var(--accent); }

.empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 56px 16px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
}

.strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px; }
.thumb { position: relative; flex: none; min-height: 0; padding: 3px; border-radius: 8px; }
.thumb canvas { display: block; border-radius: 4px; }
.thumb[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}

.stage {
  min-width: 0;
  touch-action: none; /* we handle pinch and pan ourselves */
  height: min(68vh, 760px);
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--stage);
  border-radius: 12px;
}

canvas {
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: crosshair;
}
