:root {
  color-scheme: light;
  --bg: 48 30% 96%;
  --fg: 30 8% 10%;
  --card: 45 25% 93%;
  --muted: 45 22% 90%;
  --muted-fg: 40 6% 39%;
  --accent: 217 84% 46%;
  --accent-fg: 0 0% 98%;
  --destructive: 4 70% 47%;
  --border: 45 18% 85%;
  --wave: 30 8% 22%;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --display: "Space Grotesk", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: 30 8% 8%;
    --fg: 45 25% 90%;
    --card: 30 7% 11%;
    --muted: 30 6% 15%;
    --muted-fg: 40 6% 60%;
    --accent: 217 90% 62%;
    --accent-fg: 30 8% 8%;
    --destructive: 4 75% 58%;
    --border: 30 6% 20%;
    --wave: 45 20% 78%;
  }
}
*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; }
body {
  background: hsl(var(--bg));
  color: hsl(var(--fg));
  font: 13px/1.5 var(--mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: hsl(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.top { display: flex; align-items: baseline; gap: 16px; padding: 14px 24px; border-bottom: 1px solid hsl(var(--border)); flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 700; font-size: 18px; color: hsl(var(--fg)); }
.brand:hover { text-decoration: none; }
.mark { color: hsl(var(--accent)); font-weight: 400; }
.tag { color: hsl(var(--muted-fg)); }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px; }

.drop { border: 1px dashed hsl(var(--border)); background: hsl(var(--card)); padding: 64px 32px; text-align: center; margin-top: 4vh; }
.drop h1 { font-family: var(--display); font-weight: 700; font-size: clamp(26px, 4vw, 40px); line-height: 1.1; margin: 0 0 12px; letter-spacing: -0.01em; }
.caret::after { content: "▋"; color: hsl(var(--accent)); animation: blink 1s step-end infinite; margin-left: 4px; font-family: var(--mono); font-weight: 400; }
@keyframes blink { 50% { opacity: 0; } }
.sub { color: hsl(var(--muted-fg)); max-width: 560px; margin: 0 auto 24px; }
.hint { color: hsl(var(--muted-fg)); font-size: 12px; margin-top: 20px; }

.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row.tight { justify-content: flex-start; }

.btn {
  font: inherit; color: hsl(var(--fg)); background: hsl(var(--bg));
  border: 1px solid hsl(var(--border)); padding: 6px 12px; cursor: pointer;
  transition: border-color .12s, background-color .12s, color .12s; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover:not(:disabled) { border-color: hsl(var(--accent)); color: hsl(var(--accent)); }
.btn:focus-visible, input:focus-visible { outline: 1px solid hsl(var(--accent)); outline-offset: 1px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: hsl(var(--accent)); border-color: hsl(var(--accent)); color: hsl(var(--accent-fg)); }
.btn.primary:hover:not(:disabled) { color: hsl(var(--accent-fg)); filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.live { border-color: hsl(var(--destructive)); color: hsl(var(--destructive)); }

.filebar { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.fname { font-family: var(--display); font-weight: 700; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.fname::before { content: "■ "; color: hsl(var(--accent)); font-weight: 400; }
.meta { color: hsl(var(--muted-fg)); flex: 1; }

.wave-wrap { position: relative; height: 240px; border: 1px solid hsl(var(--border)); background: hsl(var(--card)); cursor: crosshair; touch-action: none; user-select: none; }
.wave-wrap canvas { position: absolute; inset: 0; width: 100%; height: calc(100% - 20px); display: block; }
.ruler { position: absolute; left: 0; right: 0; bottom: 0; height: 20px; border-top: 1px solid hsl(var(--border)); font-size: 10px; color: hsl(var(--muted-fg)); overflow: hidden; }
.ruler span { position: absolute; top: 2px; padding-left: 3px; border-left: 1px solid hsl(var(--border)); height: 16px; }
.scroll { width: 100%; margin: 6px 0 0; accent-color: hsl(var(--accent)); }

.transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 20px; }
.time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 92px; margin-left: 8px; }
.sel { color: hsl(var(--muted-fg)); font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: hsl(var(--muted-fg)); cursor: pointer; }
.chk input { accent-color: hsl(var(--accent)); }

.grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .fname { max-width: 100%; } }
.panel { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 16px; }
.panel h2 { font-family: var(--display); font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.panel h2::before { content: "■ "; color: hsl(var(--accent)); font-weight: 400; }
.panel h2:not(:first-child) { margin-top: 20px; }
.note { color: hsl(var(--muted-fg)); font-size: 12px; }
#scope { margin: -4px 0 10px; }
.ops { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.param { display: flex; align-items: center; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.param > .btn { min-width: 128px; }
.param label { color: hsl(var(--muted-fg)); display: inline-flex; align-items: center; gap: 6px; }
input[type=number] { font: inherit; width: 72px; padding: 5px 6px; background: hsl(var(--bg)); color: hsl(var(--fg)); border: 1px solid hsl(var(--border)); }

.hist { position: relative; list-style: none; margin: 10px 0 0; padding: 0; max-height: 180px; overflow: auto; border: 1px solid hsl(var(--border)); background: hsl(var(--bg)); }
.hist li { padding: 4px 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; color: hsl(var(--muted-fg)); }
.hist li:hover { color: hsl(var(--fg)); }
.hist li.on { color: hsl(var(--fg)); }
.hist li.on span::before { content: "▸ "; color: hsl(var(--accent)); }
.hist li.future { opacity: .45; }
.hist li small { color: hsl(var(--muted-fg)); }

.stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-variant-numeric: tabular-nums; }
.stats dt { color: hsl(var(--muted-fg)); }
.stats dd { margin: 0; }
.stats .hot { color: hsl(var(--destructive)); }

.keys { list-style: none; padding: 0; margin: 0; color: hsl(var(--muted-fg)); font-size: 12px; display: grid; gap: 4px; }
kbd { font: inherit; color: hsl(var(--fg)); border: 1px solid hsl(var(--border)); background: hsl(var(--bg)); padding: 0 4px; }

.bar { height: 4px; background: hsl(var(--muted)); margin-top: 10px; }
.bar i { display: block; height: 100%; width: 0; background: hsl(var(--accent)); }

.dropveil { position: fixed; inset: 12px; border: 1px dashed hsl(var(--accent)); background: hsl(var(--bg) / .9); display: none; align-items: center; justify-content: center; font-family: var(--display); font-size: 28px; font-weight: 700; z-index: 20; pointer-events: none; }
body.dragging .dropveil { display: flex; }
.recveil { position: fixed; inset: 0; background: hsl(var(--bg) / .88); display: flex; align-items: center; justify-content: center; z-index: 30; }
.recbox { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 28px 32px; display: grid; justify-items: center; gap: 14px; }
.recdot { width: 12px; height: 12px; background: hsl(var(--destructive)); animation: blink 1s step-end infinite; }
.rectime { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: hsl(var(--fg)); color: hsl(var(--bg)); padding: 8px 14px; opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 40; max-width: 90vw; }
.toast.show { opacity: 1; }

.foot { color: hsl(var(--muted-fg)); padding: 16px 24px; border-top: 1px solid hsl(var(--border)); font-size: 12px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 600px) {
  main { padding: 14px; }
  .drop { padding: 40px 18px; }
  .wave-wrap { height: 180px; }
  .ops { grid-template-columns: 1fr; }
}
