:root {
  color-scheme: light dark;
  --background: 48 30% 96%;
  --foreground: 30 8% 10%;
  --card: 45 25% 93%;
  --secondary: 45 22% 90%;
  --muted-foreground: 40 6% 39%;
  --accent: 217 84% 46%;
  --accent-foreground: 0 0% 98%;
  --destructive: 4 70% 47%;
  --border: 45 18% 85%;
  --rec: 4 78% 52%;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: 30 8% 8%;
    --foreground: 45 25% 90%;
    --card: 30 7% 11%;
    --secondary: 30 6% 15%;
    --muted-foreground: 40 8% 62%;
    --accent: 217 90% 62%;
    --accent-foreground: 30 8% 8%;
    --destructive: 4 75% 60%;
    --border: 30 6% 20%;
  }
}
*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font: 400 15.5px/1.55 var(--mono);
  -webkit-font-smoothing: antialiased;
}
a { color: hsl(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; gap: 16px;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid hsl(var(--border));
}
.brand { font-weight: 700; color: hsl(var(--foreground)); font-size: 16px; }
.brand .sq { color: hsl(var(--accent)); }
.tag { color: hsl(var(--muted-foreground)); font-size: 12.5px; flex: 1; }
main { padding: clamp(16px, 4vw, 40px); max-width: 1320px; margin: 0 auto; }
.page-transition { animation: page-enter 420ms cubic-bezier(0.22, 1, 0.36, 1) backwards; }
@keyframes page-enter { from { opacity: 0; transform: translateY(10px); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }

.hero { font: 700 clamp(1.9rem, 3.6vw, 2.7rem)/1.04 var(--display); letter-spacing: -0.02em; margin: 0 0 10px; }
.hero::after { content: "▋"; color: hsl(var(--accent)); animation: blink 1s step-end infinite; margin-left: 4px; font-weight: 400; }
@keyframes blink { 50% { opacity: 0; } }
.lede { color: hsl(var(--muted-foreground)); font-size: 13.5px; margin: 0 0 18px; }
.section-heading { font: 700 clamp(1.35rem, 2.2vw, 1.7rem)/1.2 var(--display); letter-spacing: -0.01em; margin: 0 0 14px; }
.section-heading::before { content: "■ "; color: hsl(var(--accent)); font-weight: 400; }
.caption { color: hsl(var(--muted-foreground)); font-size: 12.5px; margin: 8px 0 0; }
.notice { border: 1px solid hsl(var(--destructive)); color: hsl(var(--destructive)); padding: 12px 14px; font-size: 13.5px; margin-bottom: 20px; }

.studio { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
@media (max-width: 900px) { .studio { grid-template-columns: 1fr; } }
.stage {
  position: relative; border: 1px solid hsl(var(--border)); background: hsl(var(--card));
  aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden;
}
.stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; touch-action: none; }
.stage canvas.grab { cursor: grab; }
.stage canvas.grabbing { cursor: grabbing; }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 clamp(5rem, 16vw, 11rem)/1 var(--display); color: hsl(var(--accent));
  background: hsl(var(--background) / 0.72);
}
.countdown span { animation: pop 1s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pop { from { opacity: 0; transform: scale(1.3); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
.recbar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: hsl(var(--background)); border: 1px solid hsl(var(--border)); font-size: 13px;
}
.dot { width: 10px; height: 10px; background: hsl(var(--rec)); animation: blink 1s step-end infinite; }
.dot.paused { background: hsl(var(--muted-foreground)); animation: none; }
.elapsed { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.5ch; }

.panel { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.group { border: 1px solid hsl(var(--border)); padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.group legend { padding: 0 6px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.group:disabled { opacity: 0.45; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; }
.toggle span { flex: 1; }
input[type=checkbox] { appearance: none; width: 16px; height: 16px; border: 1px solid hsl(var(--muted-foreground)); margin: 0; display: grid; place-items: center; cursor: pointer; background: hsl(var(--background)); }
input[type=checkbox]:checked { background: hsl(var(--accent)); border-color: hsl(var(--accent)); }
input[type=checkbox]:checked::after { content: "✓"; color: hsl(var(--accent-foreground)); font-size: 11px; line-height: 1; }
input[type=checkbox]:disabled { opacity: 0.4; cursor: not-allowed; }
.range { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.range input { flex: 1; accent-color: hsl(var(--accent)); }
select, input[type=text] {
  font: inherit; font-size: 13px; color: inherit; background: hsl(var(--background));
  border: 1px solid hsl(var(--border)); padding: 7px 8px; width: 100%;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 1px solid hsl(var(--accent)); outline-offset: 2px; }
.seg { display: flex; }
.seg button { flex: 1; border-right-width: 0; }
.seg button:last-child { border-right-width: 1px; }
.seg button.on { background: hsl(var(--foreground)); color: hsl(var(--background)); border-color: hsl(var(--foreground)); }
.meter { display: grid; grid-template-columns: 56px 1fr 52px; align-items: center; gap: 8px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.meter .hint { font-size: 11px; line-height: 1.1; }
.bar { height: 8px; background: hsl(var(--secondary)); border: 1px solid hsl(var(--border)); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: hsl(var(--accent)); transition: width 80ms linear; }

button {
  font: 500 13px/1.2 var(--mono); color: hsl(var(--foreground)); background: hsl(var(--background));
  border: 1px solid hsl(var(--border)); padding: 9px 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color 150ms, border-color 150ms;
}
button:hover:not(:disabled) { border-color: hsl(var(--foreground)); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); border-color: hsl(var(--accent)); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); border-color: hsl(var(--accent)); }
button.ghost { background: transparent; }
button.danger { color: hsl(var(--destructive)); }
button.small { padding: 5px 9px; font-size: 12px; }
button.big { padding: 14px; font-size: 14.5px; font-weight: 600; }
kbd { font: 500 11px var(--mono); border: 1px solid currentColor; padding: 0 4px; opacity: 0.7; }

.review { margin-top: 40px; }
.review-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .review-grid { grid-template-columns: 1fr; } }
#player { width: 100%; background: #000; border: 1px solid hsl(var(--border)); display: block; max-height: 70vh; }
.review-side { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: hsl(var(--muted-foreground)); }
.meta { font-size: 12.5px; color: hsl(var(--muted-foreground)); margin: 0; }
.trim { margin-top: 14px; }
.trim-track { position: relative; height: 28px; background: hsl(var(--secondary)); border: 1px solid hsl(var(--border)); }
.trim-sel { position: absolute; top: 0; bottom: 0; background: hsl(var(--accent) / 0.22); border-left: 2px solid hsl(var(--accent)); border-right: 2px solid hsl(var(--accent)); }
.trim-track input { position: absolute; inset: 0; width: 100%; margin: 0; appearance: none; background: none; pointer-events: none; height: 100%; }
.trim-track input::-webkit-slider-thumb { appearance: none; pointer-events: auto; width: 10px; height: 28px; background: hsl(var(--accent)); cursor: ew-resize; }
.trim-track input::-moz-range-thumb { pointer-events: auto; width: 10px; height: 28px; background: hsl(var(--accent)); border: 0; cursor: ew-resize; }
.trim-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 12.5px; flex-wrap: wrap; }
.trim-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.trim-row span:last-child { margin-left: auto; }
.progress { height: 4px; background: hsl(var(--secondary)); margin-top: 10px; }
.progress i { display: block; height: 100%; width: 0; background: hsl(var(--accent)); }

.library { margin-top: 48px; }
.list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.item { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); display: flex; flex-direction: column; transition: background-color 300ms; }
.item:hover { background: hsl(var(--secondary)); }
.item .thumb { aspect-ratio: 16 / 9; background: hsl(var(--secondary)) center / cover no-repeat; border: 0; border-bottom: 1px solid hsl(var(--border)); padding: 0; width: 100%; position: relative; }
.item .thumb .dur { position: absolute; right: 6px; bottom: 6px; background: hsl(var(--background)); color: hsl(var(--foreground)); font-size: 11px; padding: 1px 5px; }
.item .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.item .name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 11.5px; color: hsl(var(--muted-foreground)); }
.item .acts { display: flex; gap: 6px; margin-top: 6px; }
.item .acts button { flex: 1; }
.empty { color: hsl(var(--muted-foreground)); font-size: 13.5px; }

dialog { border: 1px solid hsl(var(--border)); background: hsl(var(--card)); color: hsl(var(--foreground)); padding: 24px; max-width: 420px; width: calc(100% - 32px); }
dialog::backdrop { background: hsl(var(--background) / 0.7); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 13.5px; margin: 0 0 12px; }
.keys dd { margin: 0; color: hsl(var(--muted-foreground)); }
.foot { padding: 28px clamp(16px, 4vw, 40px); color: hsl(var(--muted-foreground)); font-size: 12.5px; border-top: 1px solid hsl(var(--border)); margin-top: 48px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: hsl(var(--foreground)); color: hsl(var(--background)); padding: 9px 14px; font-size: 13px; z-index: 10; }
@media (max-width: 600px) { .tag { display: none; } .top { justify-content: space-between; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
