:root {
  --bg: #f6f5f3; --card: #fff; --fg: #1c1917; --muted: #78716c; --soft: #f0eeeb;
  --accent: oklch(0.63 0.19 38); --accent-fg: #fff; --ok: #15803d;
  --ring: rgba(0,0,0,.07); --outline: rgba(0,0,0,.1);
  --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0,0,0,.04), 0 6px 16px -4px rgba(0,0,0,.06);
  --ease: cubic-bezier(0.2, 0, 0, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09; --card: #171412; --fg: #fafaf9; --muted: #a8a29e; --soft: #221f1c;
    --accent: oklch(0.7 0.17 40); --accent-fg: #1c0f08; --ok: #4ade80;
    --ring: rgba(255,255,255,.08); --outline: rgba(255,255,255,.1);
    --shadow: 0 0 0 1px var(--ring), 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); }
.tn, output { font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 13px; margin: 0; text-wrap: pretty; }
.center { text-align: center; }

.shell { max-width: 1280px; margin: 0 auto; padding: 16px; }
.top { display: flex; align-items: center; gap: 10px; height: 48px; margin-bottom: 8px; }
.top h1 { font-size: 18px; letter-spacing: -0.02em; }
.tag { color: var(--muted); font-size: 13px; }
.logo { display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.logo i { width: 3px; border-radius: 2px; background: var(--accent); }
.logo i:nth-child(1) { height: 8px; } .logo i:nth-child(2) { height: 16px; } .logo i:nth-child(3) { height: 11px; } .logo i:nth-child(4) { height: 18px; }

/* ---------- start (first visit) ---------- */
.start { max-width: 720px; margin: 8vh auto 0; text-align: center; display: grid; gap: 12px; }
.start h2 { font-size: 34px; line-height: 1.1; letter-spacing: -0.03em; }
.lede { margin: 0 auto 12px; color: var(--muted); max-width: 44ch; font-size: 16px; text-wrap: pretty; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.slot {
  position: relative; display: grid; gap: 4px; align-content: start; padding: 20px; min-height: 200px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); cursor: pointer; outline: 1.5px dashed transparent; outline-offset: -8px;
  transition-property: outline-color, box-shadow, background-color; transition-duration: .15s; transition-timing-function: var(--ease);
}
.slot:hover, .slot.over { outline-color: var(--accent); }
.slot.over { background: color-mix(in oklab, var(--accent) 7%, var(--card)); }
.slot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.slot b { font-size: 18px; letter-spacing: -0.01em; }
.slot b em { font-style: normal; font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 6px; }
.slot-hint { color: var(--muted); }
.slot .btn { margin-top: auto; justify-self: start; display: inline-grid; place-items: center; }
.step { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; background: var(--soft); font-weight: 700; font-size: 13px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.slot.done .step { background: var(--ok); color: #fff; }
.slot.next { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.slot-thumb { position: absolute; right: 16px; top: 16px; width: 64px; height: 64px; border-radius: 12px; object-fit: cover; box-shadow: inset 0 0 0 1px var(--outline); outline: 1px solid var(--outline); outline-offset: -1px; }
.warn { color: var(--accent); margin: 0; }

/* ---------- editor ---------- */
.app { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stage { display: grid; gap: 12px; min-width: 0; }
.screen { position: relative; background: #000; border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; display: grid; place-items: center; max-height: 68vh; }
.screen canvas { display: block; max-width: 100%; max-height: 68vh; width: auto; height: auto; }
.play { position: absolute; left: 12px; bottom: 12px; width: 48px; height: 48px; border: 0; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; backdrop-filter: blur(8px); cursor: pointer; display: grid; place-items: center;
  transition-property: scale, background-color; transition-duration: .15s; transition-timing-function: var(--ease); }
.play:hover { background: rgba(0,0,0,.7); }
.play:active { scale: 0.96; }
.play::before { content: ""; position: absolute; inset: -4px; }
.play svg { grid-area: 1 / 1; transition-property: opacity, scale, filter; transition-duration: .2s; transition-timing-function: var(--ease); }
.play .i-pause { opacity: 0; scale: .25; filter: blur(4px); }
.screen.playing .i-play { opacity: 0; scale: .25; filter: blur(4px); }
.screen.playing .i-pause { opacity: 1; scale: 1; filter: blur(0); }
.busy { position: absolute; top: 12px; left: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; }
.transport { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

.songs-head { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 8px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); cursor: pointer;
  transition-property: box-shadow; transition-duration: .15s; transition-timing-function: var(--ease); }
.row.sel { box-shadow: var(--shadow), 0 0 0 2px var(--accent); }
.row.enter { animation: rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } }
.thumb { position: relative; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 4px; overflow: hidden; background: var(--soft); cursor: pointer; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  transition-property: scale; transition-duration: .15s; transition-timing-function: var(--ease); }
.thumb:active { scale: 0.96; }
.thumb::before { content: ""; position: absolute; inset: -4px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--outline); pointer-events: none; }
.meta { min-width: 0; display: grid; }
.name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 2px; background: var(--soft); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); transition-property: transform; transition-duration: .2s; transition-timing-function: linear; }
.end { display: flex; align-items: center; gap: 4px; min-width: 40px; justify-content: flex-end; }
.dl { display: inline-grid; place-items: center; min-height: 40px; padding: 0 14px; border-radius: 8px; background: var(--ok); color: #fff; font-weight: 600; text-decoration: none; transition-property: scale; transition-duration: .15s; transition-timing-function: var(--ease); }
.dl:active { scale: 0.96; }
.x { width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; transition-property: background-color, color, scale; transition-duration: .15s; transition-timing-function: var(--ease); }
.x:hover { background: var(--soft); color: var(--fg); }
.x:active { scale: 0.96; }

/* ---------- inspector ---------- */
.panel { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.panel-scroll { overflow: auto; padding: 16px 12px 4px; display: grid; gap: 20px; align-content: start; scrollbar-width: thin; }
.panel section { display: grid; gap: 10px; }
.panel h3 { padding: 0 4px; }
.h-row { display: flex; align-items: center; justify-content: space-between; }
.panel-foot { padding: 12px; box-shadow: 0 -1px 0 var(--ring); }

.btn { position: relative; min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; transition-property: scale, background-color, opacity; transition-duration: .15s; transition-timing-function: var(--ease); }
.btn.small { padding: 0 12px; font-size: 13px; }
.btn:active:not(:disabled) { scale: 0.96; }
.btn:focus-visible, .seg input:focus-visible + span, .chip input:focus-visible + span, .switch input:focus-visible + i, .text:focus-visible, .color input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.ghost { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }
.btn.ghost:hover { background: var(--soft); }
.btn.primary { width: 100%; min-height: 48px; border-radius: 12px; background: var(--accent); color: var(--accent-fg); font-size: 15px; }
.btn.primary:hover:not(:disabled) { background: color-mix(in oklab, var(--accent) 90%, black); }
.btn:disabled { opacity: .5; cursor: default; }
.surprise { display: inline-flex; align-items: center; gap: 6px; }
.surprise svg { transition-property: rotate; transition-duration: .35s; transition-timing-function: var(--ease); }
.surprise:active svg { rotate: 90deg; }

.cover { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; }
.cover-thumb { width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--soft); position: relative; }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--outline); }
.cover-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.seg { display: flex; padding: 3px; gap: 2px; background: var(--soft); border-radius: 8px; }
.seg label { flex: 1; position: relative; min-width: 0; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: grid; place-items: center; min-height: 40px; padding: 0 6px; border-radius: 5px; font-weight: 500; font-size: 13px; color: var(--muted); text-align: center; transition-property: background-color, color, box-shadow; transition-duration: .15s; transition-timing-function: var(--ease); }
.seg input:checked + span { background: var(--card); color: var(--fg); box-shadow: var(--shadow); }

.presets { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.presets button { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--soft); color: var(--fg); font: inherit; font-weight: 500; font-size: 13px; cursor: pointer; transition-property: scale, background-color; transition-duration: .15s; transition-timing-function: var(--ease); }
.presets button:hover { background: color-mix(in oklab, var(--accent) 14%, var(--soft)); }
.presets button:active { scale: 0.96; }
.chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: grid; place-items: center; min-height: 44px; border-radius: 8px; background: var(--soft); font-weight: 500; font-size: 13px; color: var(--muted); transition-property: background-color, color, box-shadow; transition-duration: .15s; transition-timing-function: var(--ease); }
.chip input:checked + span { background: var(--card); color: var(--fg); box-shadow: var(--shadow), 0 0 0 1.5px var(--accent); }

.colors { display: flex; gap: 8px; }
.color { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 10px 4px 4px; border-radius: 8px; background: var(--soft); cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.color input { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 4px; background: none; cursor: pointer; }
.color input::-webkit-color-swatch-wrapper { padding: 0; }
.color input::-webkit-color-swatch { border: 0; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--outline); }
.color input::-moz-color-swatch { border: 0; border-radius: 4px; }

.sliders { display: grid; gap: 4px; }
.slider { display: grid; gap: 0; padding: 2px 4px; }
.slider span { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 500; }
.slider output { color: var(--fg); }
input[type=range] { width: 100%; height: 28px; margin: 0; background: transparent; accent-color: var(--accent); cursor: pointer; }

.text { width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--soft); color: var(--fg); font: inherit; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; padding: 0 4px; cursor: pointer; }
.switch span { display: grid; }
.switch b { font-weight: 600; font-size: 14px; }
.switch small { color: var(--muted); font-size: 12px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--ring); position: relative; transition-property: background-color; transition-duration: .2s; transition-timing-function: var(--ease); }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 999px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition-property: translate; transition-duration: .2s; transition-timing-function: var(--ease); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { translate: 18px 0; }

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  .panel-scroll { overflow: visible; }
  .panel-foot { position: sticky; bottom: 0; background: var(--card); }
  .slots { grid-template-columns: 1fr; }
  .slot { min-height: 150px; }
  .start { margin-top: 2vh; }
  .start h2 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .row.enter { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
