/* Twiddle Studio — styled after twiddle-ai.com.cn. The interface stays neutral
   so the pedal's finish is the colour on screen; blue is the only accent.
   The site itself uses the system monospace stack, which the CSP allows. */

@property --v { syntax: "<number>"; inherits: true; initial-value: 50; }

:root {
  color-scheme: light;
  /* Tokens follow twiddle-ai.com.cn: monospace type, #111/#555/#888899 text, one blue. */
  --bg: #f5f5f5;
  --bg-2: #eeeeef;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --surface-3: #efeff1;
  --field: #ffffff;
  --line: rgba(17, 17, 17, .08);
  --line-2: rgba(17, 17, 17, .12);
  --line-3: rgba(17, 17, 17, .26);
  --ink: #111111;
  --ink-2: #555555;
  --muted: #888899;
  --faint: #b4b4c0;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --accent-soft: rgba(59, 130, 246, .1);
  --signal: var(--accent);
  --ok: #16a34a;
  --warn: #9a7410;
  --bad: #dc2626;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 14px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 10px 30px -18px rgba(17, 17, 17, .18);
  --shadow-lift: 0 2px 4px rgba(17, 17, 17, .05), 0 24px 60px -26px rgba(17, 17, 17, .28);
  --backdrop: radial-gradient(ellipse 58% 48% at 50% 40%, rgba(59, 130, 246, .11), transparent 70%), #ffffff;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --bar-h: 64px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  /* React islands (workbench.jsx) read these. */
  --wb-surface: var(--surface);
  --wb-line: var(--line-2);
  --wb-line-strong: var(--line-3);
  --wb-text: var(--ink);
  --wb-muted: var(--muted);
  --wb-accent: var(--accent);
  --wb-raised: var(--field);
  --wb-hover: var(--surface-2);
  font-family: var(--mono), "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: radial-gradient(1400px 700px at 50% -18%, #ffffff 0%, transparent 62%), var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(17, 17, 17, .14); }
[hidden] { display: none !important; }

h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.02em; text-wrap: balance; }
h2 { margin: 0; font-size: 16px; font-weight: 620; letter-spacing: -.01em; }
h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink-2); }
p { margin: 0; line-height: 1.65; }
hr { width: 100%; height: 1px; margin: 4px 0; border: 0; background: var(--line); }
code { padding: 10px 14px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--field); color: var(--ink); font: 13px/1.5 var(--mono); }
.muted { color: var(--muted); font-size: 13px; }
.lead { font-size: 15.5px; line-height: 1.7; color: var(--ink); }
.center { text-align: center; }
.link { color: var(--ink); text-decoration: underline; }
.error-text { color: var(--bad) !important; }
.hint { padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(224, 179, 65, .09); color: var(--warn); font-size: 13px; }
.icon { flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.section-kicker, .kicker {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--accent); font: 700 11px var(--mono); letter-spacing: .15em; text-transform: uppercase;
}
/* A live state carries a small red LED, like the hardware. */
.working .section-kicker::before, .pop .section-kicker::before, .kicker.live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--signal);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .14); animation: led 1.6s ease-in-out infinite;
}
@keyframes led { 50% { opacity: .35; } }

/* ---------- controls ---------- */
button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px;
  border: 1px solid var(--line-3); border-radius: var(--radius-sm);
  background: var(--field); color: var(--ink);
  font-size: 13.5px; font-weight: 700; line-height: 1.2; cursor: pointer;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
button:hover:not(:disabled), a.button:hover { border-color: var(--ink); background: rgba(17, 17, 17, .04); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, a.button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.primary:hover:not(:disabled), a.button.primary:hover { background: var(--accent); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(59, 130, 246, .3); }
button.primary:disabled { opacity: 1; background: var(--surface-3); color: var(--faint); box-shadow: none; }
button.big { min-height: 48px; padding: 0 30px; font-size: 14.5px; }
button.small { min-height: 30px; padding: 0 10px; font-size: 12px; }
/* Quiet actions read as links: the site's nav underline grows in blue. */
button.ghost, .link-button { position: relative; background: transparent; border-color: transparent; color: var(--ink-2); padding: 0 10px; font-weight: 500; box-shadow: none; }
button.ghost::after, .link-button::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 7px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease); }
button.ghost:hover:not(:disabled), .link-button:hover { background: transparent; border-color: transparent; color: var(--ink); }
button.ghost:hover:not(:disabled)::after, .link-button:hover::after { transform: scaleX(1); }
.link-button { min-height: 0; padding: 2px 0; margin-left: 8px; color: var(--accent); font-weight: 700; }
.link-button::after { left: 0; right: 0; bottom: -2px; }

input[type=text], input[type=password], input[type=search], input[type=number], textarea, select {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--field); color: var(--ink); font-size: 14px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
input[type=range], input[type=checkbox] { accent-color: var(--accent); }
input[type=color] { width: 52px; height: 38px; padding: 4px; cursor: pointer; border: 1px solid var(--line-2); border-radius: 10px; background: var(--field); }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }
label.field { display: grid; gap: 8px; color: var(--ink-2); font-size: 13px; }
details > summary { cursor: pointer; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 11px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--field); color: var(--ink-2); font-size: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; justify-self: start;
  padding: 5px 11px; border-radius: 999px; background: rgba(22, 163, 74, .1); color: var(--ok);
  font-size: 12px; font-weight: 600;
}
.badge.stamp { animation: stamp .7s var(--spring) both; }
@keyframes stamp { 0% { transform: scale(1.8) rotate(-8deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }

/* ---------- chrome ---------- */
.bar {
  position: sticky; top: 0; z-index: 20; view-transition-name: bar;
  height: var(--bar-h); padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 245, 245, .8);
  backdrop-filter: saturate(1.3) blur(18px);
  -webkit-backdrop-filter: saturate(1.3) blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.brand img { display: block; height: 30px; width: auto; transition: transform .3s var(--spring); }
.brand:hover img { transform: rotate(-2deg) scale(1.03); }
.brand-divider { width: 1px; height: 16px; background: var(--line-3); }
.bar-status { display: flex; align-items: center; gap: 18px; min-width: 0; }
.gear {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--field);
  color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.gear::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.gear[data-state=on]::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }

.toolchain-panel { display: flex; }
.wb-environment-trigger { gap: 8px; min-height: 0; padding: 4px 0; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; box-shadow: none !important; }
.wb-environment-trigger:hover:not(:disabled) { background: transparent; color: var(--ink); }
.wb-environment-trigger::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.wb-environment-trigger[data-status=ready]::before { background: #22c55e; }
.wb-environment-trigger[data-status=blocked]::before { background: #e0b341; }

.environment-banner {
  display: flex; align-items: center; gap: 16px; min-height: 42px; padding: 8px 24px;
  border-bottom: 1px solid rgba(224, 179, 65, .2); background: #fdf6e3; color: var(--warn); font-size: 12.5px;
}
.environment-banner .muted { flex: 1; color: rgba(154, 116, 16, .75); font-size: 12.5px; }

/* The three production stages: a pill of numbered nodes joined by short rails. */
.progress {
  display: flex; align-items: center; width: fit-content; max-width: calc(100% - 32px); margin: 20px auto 0; padding: 5px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
}
.progress span {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px;
  color: var(--faint); font-size: 12.5px; font-weight: 700; white-space: nowrap;
  transition: color .3s var(--ease), background .3s var(--ease);
}
.progress span::before {
  content: attr(data-step); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--line-3); font: 700 11px var(--mono); color: inherit;
  transition: background .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease);
}
.progress span:not(:last-child)::after { content: ""; width: 22px; height: 1.5px; margin-left: 4px; border-radius: 1px; background: var(--line-2); transition: background .3s var(--ease); }
.progress span.on { color: var(--ink-2); }
.progress span.on::before { content: "✓"; border-color: var(--accent); background: var(--accent); color: #fff; }
.progress span.on::after { background: var(--accent); }
.progress span.now { color: var(--accent-2); background: var(--accent-soft); }
.progress span.now::before { content: attr(data-step); border-color: var(--accent); background: var(--surface); color: var(--accent); box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); animation: node 2s var(--ease) infinite; }
.progress span.now::after { background: var(--line-2); }
@keyframes node { 50% { box-shadow: 0 0 0 7px rgba(59, 130, 246, .05); } }

.app { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 96px; display: grid; gap: 20px; align-content: start; }
.app:has(> .studio-layout), .app:has(> .login-card), .app:has(> .empty) { width: 100%; padding: 0; }
.app > .card { width: min(560px, 100%); justify-self: center; margin-top: 8vh; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translateX(-50%);
  max-width: min(520px, calc(100% - 32px)); padding: 12px 18px;
  border-radius: 14px; background: rgba(17, 17, 17, .94); color: var(--surface);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 48px rgba(17, 17, 17, .3); font-size: 13.5px;
  animation: rise .4s var(--spring);
}
.toast.bad { background: #b91c1c; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 12px) scale(.96); } }

/* Page changes cross-fade; the header stays put. */
::view-transition-old(root) { animation: vt-out .2s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .42s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- cards ---------- */
.card {
  position: relative; display: grid; gap: 16px; padding: 22px 24px;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow);
}
.card > h2 + p, .card > .section-kicker + h2 { margin-top: -8px; }
.card-head { display: flex; align-items: center; gap: 12px; }
.card-head > :nth-child(2) { margin-left: auto; }
.card > button.ghost { justify-self: start; }
.card.failed { border-color: rgba(220, 38, 38, .22); background: linear-gradient(180deg, rgba(220, 38, 38, .05), transparent 140px), var(--surface); }
.card.failed > h2 { color: var(--bad); }
.pop { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(17, 17, 17, .05), var(--shadow-lift); animation: pop .5s var(--spring); }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

/* Composer: one rounded field, send button inside, grows with the text. */
.composer {
  display: grid; gap: 4px; padding: 10px 10px 8px 14px;
  border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: var(--field);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  min-height: 24px; max-height: 180px; padding: 2px 0; border: 0; border-radius: 0; background: transparent;
  font-size: 14px; line-height: 1.6; resize: none; overflow-y: auto;
}
.composer textarea:focus { box-shadow: none; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-hint { color: var(--faint); font-size: 11px; opacity: 0; transition: opacity .2s var(--ease); }
.composer:focus-within .composer-hint { opacity: 1; }
.composer .send { margin-left: auto; min-height: 32px; padding: 0 12px; gap: 6px; border-color: transparent; background: var(--accent); color: #fff; font-size: 12.5px; }
.composer .send:hover:not(:disabled) { background: var(--accent); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(59, 130, 246, .3); }
.composer .send:disabled { opacity: 1; background: var(--surface-3); color: var(--faint); }

/* Level bars for every waiting state. --phase (set per render) keeps loops
   continuous when polling rebuilds the DOM. */
.wave { display: flex; align-items: center; justify-content: space-between; gap: 3px; height: 44px; }
.wave i {
  flex: 1; max-width: 4px; height: 100%; border-radius: 2px; background: linear-gradient(to top, var(--accent), transparent);
  transform: scaleY(.18); transform-origin: center;
  animation: level 1.4s var(--ease) infinite alternate;
  animation-delay: calc(var(--i) * -97ms - var(--phase, 0ms));
  opacity: .82;
}
.wave i:nth-child(3n) { animation-duration: 1.1s; opacity: .6; }
.wave i:nth-child(4n+1) { animation-duration: 1.7s; }
@keyframes level { 0% { transform: scaleY(.15); } 55% { transform: scaleY(.9); } 100% { transform: scaleY(.35); } }

.meter-row { display: flex; align-items: center; gap: 12px; }
.meter { position: relative; flex: 1; height: 12px; overflow: hidden; border-radius: 3px; background: var(--surface-3); }
/* Gaps cut the bar into segments, like a hardware level meter. */
.meter::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(90deg, transparent 0 8px, var(--surface) 8px 10px); }
.meter .fill { position: relative; height: 100%; overflow: hidden; background: linear-gradient(90deg, #93c5fd, var(--accent) 60%, var(--accent-2)); transition: width .6s var(--ease); }
.meter .fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent) no-repeat; background-size: 45% 100%; animation: shine 1.8s linear infinite; animation-delay: calc(0ms - var(--phase, 0ms)); }
@keyframes shine { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.meter-value { min-width: 4ch; color: var(--accent); font: 700 12.5px var(--mono); text-align: right; font-variant-numeric: tabular-nums; }
.strip .meter-row { flex: 1; }
.elapsed { color: var(--muted); font: 12.5px var(--mono); font-variant-numeric: tabular-nums; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; font-size: 14px; }
.steps li { position: relative; display: flex; align-items: center; gap: 12px; padding: 7px 0; color: var(--faint); }
.steps li::before { content: ""; width: 10px; height: 10px; flex: 0 0 10px; border-radius: 50%; border: 1.5px solid var(--line-3); background: var(--surface); }
.steps li:not(:last-child)::after { content: ""; position: absolute; left: 4.5px; top: calc(50% + 7px); height: calc(100% - 14px); width: 1px; background: var(--line-2); }
.steps li.done { color: var(--ink-2); }
.steps li.done::before { border-color: var(--accent); background: var(--accent); }
.steps li.now { color: var(--ink); font-weight: 580; }
.steps li.now::before { border-color: var(--signal); background: var(--surface); box-shadow: 0 0 0 4px rgba(59, 130, 246, .12); animation: led 1.6s ease-in-out infinite; animation-delay: calc(0ms - var(--phase, 0ms)); }

.skeleton { display: grid; gap: 10px; padding-top: 4px; }
.skeleton i { height: 46px; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%) 0 0 / 300% 100%; animation: shimmer 1.8s linear infinite; animation-delay: calc(0ms - var(--phase, 0ms)); }
.skeleton i:nth-child(2) { width: 88%; }
.skeleton i:nth-child(3) { width: 72%; }
@keyframes shimmer { to { background-position: -150% 0; } }

.choices { display: grid; gap: 8px; }
.choices button { justify-content: flex-start; min-height: 48px; padding: 10px 16px; text-align: left; white-space: normal; }
.choices button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent-2); transform: translateX(3px); }

/* ---------- home ---------- */
.studio-layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: calc(100vh - var(--bar-h)); }
.project-sidebar {
  position: sticky; top: var(--bar-h); align-self: start;
  height: calc(100vh - var(--bar-h)); overflow: auto;
  display: flex; flex-direction: column; gap: 8px; padding: 22px 16px 32px;
  border-right: 1px solid var(--line); background: rgba(250, 250, 250, .7);
}
.project-sidebar h2 { margin: 22px 6px 4px; color: var(--muted); font: 600 11px var(--mono); letter-spacing: .16em; text-transform: uppercase; }
.new-project { justify-content: flex-start; width: 100%; }
.wb-search { font-size: 13px; }
.list { display: grid; gap: 2px; }
.item {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 10px; align-items: center;
  padding: 9px 8px 9px 10px; border-radius: 10px; transition: background .16s var(--ease), box-shadow .16s var(--ease);
  animation: enter .5s var(--ease) both; animation-delay: calc(var(--row, 0) * 40ms);
}
.item:nth-child(2) { --row: 1; } .item:nth-child(3) { --row: 2; } .item:nth-child(4) { --row: 3; } .item:nth-child(n+5) { --row: 4; }
.item:hover, .item:focus-within { background: var(--field); box-shadow: var(--shadow); }
/* Each project is a tiny pedal in its own finish. */
.item-chip { position: relative; grid-row: 1 / 3; width: 16px; height: 26px; border-radius: 4px; background: linear-gradient(145deg, rgba(255, 255, 255, .3), transparent 55%), var(--chip); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08), 0 2px 4px rgba(17, 17, 17, .15); transition: transform .25s var(--spring); }
.item-chip::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: rgba(255, 255, 255, .7); box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.item:hover .item-chip { transform: rotate(-8deg) scale(1.08); }
.item-name { grid-column: 2; overflow: hidden; color: var(--ink); font-size: 13.5px; font-weight: 560; text-overflow: ellipsis; white-space: nowrap; }
.item-name::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.item .state { grid-column: 2; display: block; min-width: 0; overflow: hidden; color: var(--muted); font-size: 11.5px; white-space: nowrap; text-overflow: ellipsis; }
.item .state::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; vertical-align: 1px; background: #e0b341; }
.item[data-tone=ready] .state::before { background: #22c55e; }
.item[data-tone=final] .state::before { background: var(--ink); }
.item[data-tone=bad] .state::before { background: var(--bad); }
.item .remove { position: relative; z-index: 1; grid-column: 3; grid-row: 1 / 3; min-height: 28px; padding: 0 8px; font-size: 12px; color: var(--muted); opacity: 0; }
.item:hover .remove, .item:focus-within .remove { opacity: 1; }
.item .remove:hover:not(:disabled) { color: var(--bad); }
@media (hover: none) { .item .remove { opacity: 1; } }

.editor-pane { width: min(1180px, 100%); padding: clamp(28px, 5vw, 64px) clamp(20px, 4.5vw, 64px) 80px; }
.home-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 340px); gap: clamp(28px, 5vw, 72px); align-items: start; }
.hero-copy { display: grid; gap: 18px; min-width: 0; }
.hero-title { font-size: clamp(30px, 3.6vw, 48px); font-weight: 700; line-height: 1.12; letter-spacing: -.03em; }
.hero-title span { color: var(--ink-2); }
.hero-sub { max-width: 56ch; color: var(--ink-2); font-size: 15px; }
/* Entrance: a short cascade, top to bottom. */
.hero-copy > *, .hero-device { animation: enter .7s var(--ease) both; }
.hero-copy > :nth-child(2) { animation-delay: 60ms; }
.hero-copy > :nth-child(3) { animation-delay: 120ms; }
.hero-copy > :nth-child(4) { animation-delay: 180ms; }
.hero-device { animation-delay: 140ms; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }

.creation-form {
  display: grid; gap: 12px; margin-top: 10px; padding: 18px;
  border: 1px solid var(--line-2); border-radius: var(--radius-xl);
  background: var(--field); box-shadow: var(--shadow-lift);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.creation-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-lift); }
.composer-label { padding: 2px 4px 0; color: var(--muted); font: 600 11px var(--mono); letter-spacing: .14em; }
.creation-form textarea { min-height: 120px; padding: 4px; border: 0; background: transparent; font-size: 17px; line-height: 1.6; resize: none; }
.creation-form textarea:focus { box-shadow: none; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 0 2px; }
.examples .muted { margin-right: 2px; font-size: 12px; }
.examples .idea { min-height: 30px; padding: 0 12px; border-radius: 999px; background: var(--surface-2); border-color: transparent; color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.examples .idea:hover:not(:disabled) { background: var(--field); border-color: var(--line-3); color: var(--ink); }
.form-bottom { display: flex; align-items: center; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.form-bottom input { flex: 1; min-width: 0; max-width: 280px; background: var(--surface-2); border-color: transparent; }
.form-bottom .primary { margin-left: auto; }

/* Product stage: seamless paper backdrop, soft floor shadow. */
.hero-device, .pedal-wrap, .player-shell { position: relative; overflow: hidden; border: 1px solid var(--line); background: var(--backdrop); }
.hero-device { margin: 0; display: grid; justify-items: center; gap: 14px; padding: 22px 18px 18px; border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.instrument-drawing { position: relative; z-index: 1; width: min(240px, 100%); }
.hero-device figcaption { position: relative; z-index: 1; display: grid; gap: 2px; text-align: center; }
.hero-device figcaption strong { font-size: 14px; }
.hero-device figcaption span { color: var(--muted); font-size: 12px; }
.instrument-drawing .model-caption, .instrument-drawing .model-controls, .instrument-drawing .model-reset { display: none; }
/* A light sweep when the finish changes, like turning a product under a softbox. */
.sheen::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .7) 50%, transparent 65%) no-repeat;
  background-size: 250% 100%; animation: sheen .9s var(--ease) both;
}
@keyframes sheen { from { background-position: 130% 0; } to { background-position: -30% 0; } }

.finish-picker { position: relative; z-index: 1; display: grid; gap: 10px; width: 100%; }
.finish-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.finish-label { color: var(--muted); font: 600 11px var(--mono); letter-spacing: .14em; }
.finish-name { color: var(--ink); font-size: 13px; font-weight: 600; }
.finish-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.finish-swatch {
  position: relative; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .12);
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .55), transparent 46%), var(--swatch);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .15);
  transition: transform .25s var(--spring), box-shadow .2s var(--ease);
}
.finish-swatch:hover:not(:disabled) { transform: scale(1.14); border-color: rgba(0, 0, 0, .2); box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .15); }
.finish-swatch[aria-checked=true] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent); }
.finish-swatch[data-art=stripes]::after, .finish-swatch[data-art=waves]::after, .finish-swatch[data-art=contour]::after {
  content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 1px solid var(--swatch-line); opacity: .8;
}

.flow-index { color: var(--faint); font: 12px var(--mono); }

.server-creation { display: grid; gap: 16px; }
.capability-card { display: grid; gap: 12px; padding: 22px 24px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.capability-card h1 { font-size: 18px; }
.capability-card > p { color: var(--ink-2); font-size: 13.5px; }
.capability-card > .primary { justify-self: start; }
.pairing-code { margin-top: 8px; color: var(--ink); font: 700 34px/1.2 var(--mono); letter-spacing: .16em; }
.bridge-devices { display: grid; gap: 8px; }
.bridge-devices:empty { display: none; }
.bridge-device { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); font-size: 13px; }
.bridge-device .state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.bridge-device .state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.bridge-device .state.online { color: var(--ok); }
.bridge-device .state.online::before { background: #22c55e; }
.remote-consent { gap: 12px; }
.remote-consent label.row { align-items: flex-start; flex-wrap: nowrap; font-size: 14px; }
.remote-consent input[type=checkbox] { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; }
.creation-form .remote-consent { padding: 16px; border-radius: var(--radius); background: var(--surface-2); box-shadow: none; }

/* ---------- login & empty ---------- */
.login-card {
  width: min(420px, calc(100% - 32px)); margin: 16vh auto 0; padding: 36px;
  display: grid; gap: 18px; border: 1px solid var(--line-2); border-radius: var(--radius-xl);
  background: var(--surface); box-shadow: var(--shadow-lift); animation: enter .6s var(--ease) both;
}
.login-card h1 { font-size: 24px; }
.login-mark { color: var(--muted); font: 600 12px var(--mono); letter-spacing: .1em; }
.login-card .primary { min-height: 44px; }
.empty { min-height: 80vh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; }
.empty > * { animation: enter .7s var(--ease) both; }
.empty > :nth-child(2) { animation-delay: 80ms; } .empty > :nth-child(3) { animation-delay: 160ms; } .empty > :nth-child(4) { animation-delay: 240ms; }
.empty .muted { max-width: 44ch; font-size: 14px; }

/* ---------- project stage (describe → define → develop) ---------- */
.stage { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.side { display: grid; gap: 16px; min-width: 0; }
.pedal-wrap { position: sticky; top: calc(var(--bar-h) + 20px); display: grid; gap: 14px; padding: 26px 22px 20px; border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.pedal-wrap > .finish-picker { padding-top: 14px; border-top: 1px solid var(--line); }
/* While the agent builds, a scan line passes over the pedal like a light table. */
.pedal-wrap.crafting::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; z-index: 2; height: 30%; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, .75) 70%, rgba(59, 130, 246, .5) 71%, transparent 72%);
  animation: scan-y 2.8s var(--ease) infinite; animation-delay: calc(0ms - var(--phase, 0ms));
}
@keyframes scan-y { from { transform: translateY(-100%); } to { transform: translateY(340%); } }
.pedal-title { font-size: clamp(24px, 2.6vw, 32px); font-weight: 680; letter-spacing: -.03em; text-align: center; cursor: default; }
.pedal-title[title] { cursor: text; border-radius: 8px; transition: background .16s; }
.pedal-title[title]:hover { background: rgba(17, 17, 17, .04); }
.title-input { font-size: 22px !important; font-weight: 680; text-align: center; }

.pedal-model { position: relative; width: 100%; min-width: 0; }
.pedal-canvas { display: block; width: 100%; cursor: grab; }
.pedal-canvas:active { cursor: grabbing; }
.model-caption { display: block; padding: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.model-controls { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.model-controls button { min-height: 28px; padding: 0 10px; font-size: 12px; }
.model-reset { display: flex; min-height: 26px; margin: 6px auto 0; padding: 0 10px; border-color: transparent; background: transparent; color: var(--muted); font-size: 12px; box-shadow: none !important; }
.pedal-controls { width: 100%; max-width: 380px; margin: 12px auto; }
.pedal-controls label { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: 12px; }
.pedal-controls input[type=range] { flex: 1; min-width: 0; }
.pedal-controls output { min-width: 3em; font-family: var(--mono); }
.stage .pedal-controls, .stage .model-controls { display: none; }

/* Flat fallback panel. */
.pedal { display: block; width: 100%; height: auto; }
.pedal .body { fill: #8a949c; stroke: rgba(0, 0, 0, .15); stroke-width: .4; transition: fill .45s var(--ease); }
.pedal .halo { fill: transparent; stroke: transparent; stroke-width: .6; }
.pedal .cap { fill: #151618; stroke: #050506; stroke-width: .5; }
.pedal .pointer { stroke: #f4f0df; stroke-width: .9; stroke-linecap: round; }
.pedal .caption { fill: rgba(0, 0, 0, .72); font-size: 3px; font-weight: 800; letter-spacing: .25px; text-anchor: middle; }
.pedal .led { fill: #4a1917; stroke: rgba(0, 0, 0, .5); stroke-width: .4; }
.pedal .stomp-ring { fill: #7d837f; }
.pedal .stomp { fill: #c9cecb; stroke: #4f5551; stroke-width: .5; }
.pedal .knob[role=button] { cursor: pointer; }
.pedal .knob:focus { outline: none; }
.pedal .knob[role=button]:hover .halo, .pedal .knob.active .halo, .pedal .knob:focus-visible .halo { stroke: var(--ink); }
.pedal.dim { opacity: .45; }

.working { overflow: hidden; }
.working::before { content: ""; position: absolute; inset: -1px -1px auto; height: 2px; background: linear-gradient(90deg, transparent, var(--ink), transparent); animation: scan 2.4s linear infinite; animation-delay: calc(0ms - var(--phase, 0ms)); }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* Define: one knob at a time. */
.configure-card { gap: 0; padding: 0; overflow: hidden; }
.configure-card.thinking > :not(.thinking-banner) { opacity: .45; pointer-events: none; }
.thinking-banner { display: flex; align-items: center; gap: 14px; padding: 16px 24px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.thinking-banner .wave { width: 72px; height: 22px; flex: 0 0 auto; gap: 2px; }
.thinking-banner .wave i { max-width: 3px; }
.thinking-banner .lead { font-size: 14px; }
.sound-brief { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 24px; border-bottom: 1px solid var(--line); }
.sound-brief .chips { justify-self: end; }
.sound-brief .lead { grid-column: 1 / -1; max-width: 60ch; font-size: 16px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 22px 24px 14px; }
.section-heading h2 { display: flex; align-items: center; font-size: 18px; }
.section-heading p { max-width: 300px; color: var(--muted); font-size: 13px; text-align: right; }
.knob-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 24px; }
.knob-tab {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: center;
  min-width: 0; min-height: 70px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); text-align: left; box-shadow: none;
}
.knob-tab:hover:not(:disabled) { background: var(--field); border-color: var(--line-2); }
.knob-tab.active { border-color: var(--accent); background: var(--field); box-shadow: 0 0 0 3px var(--accent-soft); }
.knob-tab strong { min-width: 0; overflow: hidden; color: var(--ink); font-size: 13.5px; letter-spacing: .06em; text-overflow: ellipsis; white-space: nowrap; }
.knob-tab-value { color: var(--muted); font: 12px var(--mono); }
/* A tiny hardware knob: the arc is the default position. */
.knob-dial {
  --v: 50; position: relative; grid-row: 1 / 3; width: 40px; height: 40px; border-radius: 50%;
  background: conic-gradient(from 225deg, var(--accent) 0 calc(var(--v) * 2.7deg), var(--line-2) 0 270deg, transparent 0);
  transition: --v .45s var(--spring);
}
.knob-dial::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: radial-gradient(circle at 35% 28%, #3a3834, #121110 72%); box-shadow: inset 0 1px rgba(255, 255, 255, .14), 0 2px 5px rgba(17, 17, 17, .35); }
.knob-dial::after { content: ""; position: absolute; left: 50%; top: 7px; width: 2px; height: 8px; margin-left: -1px; border-radius: 1px; background: #f4f0e6; transform-origin: 50% 13px; transform: rotate(calc(-135deg + var(--v) * 2.7deg)); }
.knob-tab:not(.active) .knob-dial { opacity: .7; }
.configure-card .knob-rows { margin: 12px 24px 22px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); }
.knob-row { display: grid; gap: 20px; padding: 22px; background: var(--surface-2); animation: enter .35s var(--ease); }
.knob-editor-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.knob-number { align-self: center; color: var(--faint); font: 600 26px var(--mono); }
.knob-title-field, .default-field, .range-field, .color-field { display: grid; gap: 8px; }
.knob-title-field > span, .default-field > span:first-child, .range-field > span, .color-field > span { color: var(--muted); font-size: 12.5px; font-weight: 560; }
.knob-name { text-transform: uppercase; font-size: 17px !important; font-weight: 720; letter-spacing: .1em; }
.default-field { min-width: 132px; }
.default-input { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; background: var(--field); }
.default-input:focus-within { border-color: var(--line-3); box-shadow: 0 0 0 4px rgba(17, 17, 17, .06); }
.default-input input { width: 86px; padding: 10px 4px 10px 12px; border: 0 !important; box-shadow: none !important; background: transparent; font: 700 18px var(--mono); }
.default-input > span { padding-right: 12px; color: var(--muted); font-size: 14px; }
.knob-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; align-items: end; }
.range-field input { min-height: 64px; font-size: 14px; line-height: 1.45; }
.range-direction { padding-bottom: 20px; color: var(--muted); font-size: 18px; }
.knob-row-actions { min-height: 28px; margin-top: -8px; }
.knob-save { color: var(--ink) !important; text-decoration: underline; }
.secondary-settings { border-top: 1px solid var(--line); }
.secondary-settings summary { padding: 16px 24px; color: var(--ink-2); font-size: 14px; font-weight: 560; list-style: none; display: flex; justify-content: space-between; }
.secondary-settings summary::-webkit-details-marker { display: none; }
.secondary-settings summary::after { content: "+"; color: var(--muted); font-size: 18px; line-height: 1; transition: transform .25s var(--ease); }
.secondary-settings[open] summary { color: var(--ink); }
.secondary-settings[open] summary::after { transform: rotate(45deg); }
.secondary-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 18px; align-items: end; padding: 0 24px 22px; }
.secondary-content .composer { grid-column: 1 / -1; }
.setting-note { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.primary-actions { justify-content: flex-end; }
.primary-actions .primary { min-width: 168px; }

/* ---------- audition & final ---------- */
.audition { display: grid; gap: 18px; }
.audition-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 4px; }
.audition-title { display: grid; gap: 8px; }
.audition-title .pedal-title { text-align: left; font-size: clamp(26px, 3vw, 38px); }
.audition-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.versions { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); }
.versions button { min-height: 30px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; box-shadow: none; }
.versions button:hover:not(:disabled) { color: var(--ink); box-shadow: none; }
.versions button.on { background: var(--field); color: var(--ink); box-shadow: 0 1px 3px rgba(17, 17, 17, .12); }
.strip { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--field); color: var(--ink); font-size: 14px; box-shadow: var(--shadow); }

.audition-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.audition-main { display: grid; gap: 16px; min-width: 0; }
.player-shell { border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.player-shell:has(> .player[hidden]) { display: none; }
/* A new version arrives: the stage opens like a lid. */
.player-shell.reveal { animation: reveal 1.1s var(--ease) both; }
.player-shell.reveal::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .8) 50%, transparent 65%) no-repeat; background-size: 250% 100%; animation: sheen 1.2s .35s var(--ease) both; }
@keyframes reveal { from { clip-path: inset(0 0 100% 0 round var(--radius-xl)); transform: translateY(16px); } to { clip-path: inset(0 0 0 0 round var(--radius-xl)); } }
.player { display: block; width: 100%; height: 640px; border: 0; background: transparent; }
.inspector { position: sticky; top: calc(var(--bar-h) + 20px); display: grid; gap: 14px; min-width: 0; }
.inspector .card { padding: 20px; }
.decide > .primary { width: 100%; min-height: 46px; }
.decide > .ghost { justify-self: start; padding: 0; }
.plan p { color: var(--ink-2); font-size: 14px; }
.final-card .row .primary { flex: 1; }
.row:has(> .color-field) { align-items: flex-end; }

/* The finished pedal's label. */
.spec { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; padding: 14px 16px; border: 1px dashed var(--line-3); border-radius: var(--radius); background: var(--surface-2); font-size: 13px; }
.spec dt { color: var(--muted); font: 600 11px/1.9 var(--mono); letter-spacing: .12em; }
.spec dd { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-weight: 560; }
.led-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--led); box-shadow: 0 0 0 2px var(--field), 0 0 8px var(--led); }

.ab-card { gap: 14px; }
.ab-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ab-intro > div { display: grid; gap: 4px; }
.ab-card h2 { font-size: 18px; }
.ab-card > div:not(.ab-intro) { display: grid; gap: 12px; justify-items: start; }
.ab-card > div:not(.ab-intro):empty { display: none; }
.ab-card > div:not(.ab-intro) > p { color: var(--muted); font: 12.5px var(--mono); }
.comparison-switch { gap: 8px; }
.comparison-switch button:not(.primary) { min-width: 140px; min-height: 52px; font-weight: 600; }
.comparison-switch button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.comparison-switch .primary { min-height: 52px; }
.ab-card details { color: var(--muted); font-size: 13px; }
.ab-card details p { margin-top: 8px; }

.reviews { gap: 0; }
.reviews > summary { display: flex; align-items: center; justify-content: space-between; font-size: 15px; font-weight: 600; list-style: none; }
.reviews > summary::-webkit-details-marker { display: none; }
.reviews > summary::after { content: "+"; color: var(--muted); font-size: 18px; transition: transform .25s var(--ease); }
.reviews[open] > summary::after { transform: rotate(45deg); }
.reviews[open] > :not(summary) { margin-top: 14px; }
.reviews > p { color: var(--muted); font-size: 13px; }
.reviews > div:empty { display: none; }
.reviews a { color: var(--ink); font-size: 13px; text-decoration: underline; }
.reviews input[readonly] { margin-top: 8px; font: 12px var(--mono); color: var(--ink-2); }
.review-item { display: grid; gap: 8px; margin-top: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); font-size: 13px; }
.review-item summary { color: var(--ink); font-weight: 560; }
.review-item details p { margin-top: 6px; color: var(--ink-2); }
.review-item > button, .reviews > button { justify-self: start; }
.reviews > button.ghost { padding: 0; }

/* ---------- drawer (React island) ---------- */
.wb-drawer-body p { margin-bottom: 14px; font-size: 13px; line-height: 1.8; }
.wb-drawer-body button { margin-top: 12px; }
.wb-events section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.wb-event-heading { display: flex; gap: 12px; font-size: 13px; }
.wb-event-heading time { color: var(--muted); font-family: var(--mono); }
.wb-events pre { margin: 10px 0 0; padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font: 12px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
dialog { box-shadow: -24px 0 60px -30px rgba(17, 17, 17, .35); }
dialog[open] { animation: drawer .35s var(--ease); }
dialog::backdrop { background: rgba(17, 17, 17, .22) !important; backdrop-filter: blur(3px); }
@keyframes drawer { from { transform: translateX(24px); opacity: 0; } }

/* ---------- shared listening page (/listen/…) ---------- */
.review-page { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 40px 0 80px; display: grid; gap: 18px; }
.review-page > header { display: grid; gap: 10px; animation: enter .6s var(--ease) both; }
.review-page > header p { color: var(--ink-2); }
.review-logo { display: block; height: 30px; width: auto; margin-bottom: 18px; }
.review-page .intent { padding: 16px 18px; border-left: 2px solid var(--ink); border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface); color: var(--ink); }
.review-page h2 { margin-top: 12px; color: var(--muted); font: 600 12px var(--mono); letter-spacing: .14em; }
.review-page iframe { width: 100%; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--backdrop); box-shadow: var(--shadow); }
.review-page form fieldset { display: grid; gap: 10px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.review-page form legend { padding: 0 6px; color: var(--ink); font-weight: 600; }
.review-page form > label { display: grid; gap: 8px; color: var(--ink-2); font-size: 13px; }
.review-page form > .primary { justify-self: start; min-height: 44px; }

/* ---------- guide: header menu, "?" buttons, dialog ---------- */
.menu-trigger { min-height: 32px; padding: 0 12px; border-color: var(--line-2); font-size: 12.5px; white-space: nowrap; }
.menu-trigger::after { content: ""; width: 6px; height: 6px; margin-left: 2px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.guide-menu {
  position: fixed; inset: calc(var(--bar-h) - 4px) 24px auto auto; margin: 0; width: 240px; padding: 6px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface);
  box-shadow: 0 24px 60px -20px rgba(17, 17, 17, .3); color: var(--ink);
}
.guide-menu:popover-open { display: grid; animation: menu .22s var(--ease); }
@keyframes menu { from { opacity: 0; transform: translateY(-6px); } }
.guide-menu button, .guide-menu a {
  justify-content: flex-start; gap: 12px; width: 100%; min-height: 38px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-size: 13px; font-weight: 600; text-align: left;
}
.guide-menu button:hover, .guide-menu a:hover { background: var(--surface-2); transform: none; }
.guide-menu a { display: flex; align-items: center; color: var(--ink-2); font-weight: 500; }
.guide-menu hr { margin: 4px 6px; }
.guide-index { color: var(--accent); font: 700 11px var(--mono); letter-spacing: .06em; }

.help {
  display: inline-grid; place-items: center; width: 18px; height: 18px; min-height: 0; margin-left: 8px; padding: 0;
  border: 1px solid var(--line-3); border-radius: 50%; background: var(--field); color: var(--ink-2);
  font: 700 11px/1 var(--mono); vertical-align: middle; letter-spacing: 0;
}
.help:hover:not(:disabled) { border-color: var(--accent); background: var(--accent); color: #fff; transform: none; }

/* The site's WeChat modal: white card, 14px corners, dark blurred backdrop. */
dialog.guide {
  width: min(640px, calc(100vw - 32px)); max-height: min(720px, calc(100dvh - 48px)); margin: auto; padding: 0;
  border: 0; border-radius: var(--radius-xl); background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35); overflow: auto;
}
dialog.guide[open] { animation: guide-in .32s var(--spring); }
dialog.guide::backdrop { background: rgba(0, 0, 0, .55) !important; backdrop-filter: blur(6px); }
@keyframes guide-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.guide-head { position: relative; display: flex; align-items: center; gap: 14px; padding: 26px 28px 18px; }
.guide-head h2 { margin-top: 4px; font-size: 18px; letter-spacing: -.01em; }
.guide-close { position: absolute; top: 12px; right: 14px; min-height: 0; width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 22px; font-weight: 400; }
.guide-close:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.guide-tabs { display: flex; gap: 4px; padding: 0 22px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.guide-tab { position: relative; flex: 0 0 auto; min-height: 42px; padding: 0 10px; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.guide-tab:hover:not(:disabled) { background: transparent; color: var(--ink); }
.guide-tab[aria-selected=true] { color: var(--ink); }
.guide-tab[aria-selected=true]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); animation: grow .3s var(--ease); }
@keyframes grow { from { transform: scaleX(0); } }
.guide-body { padding: 22px 28px 8px; }
.guide-steps { list-style: none; display: grid; gap: 4px; margin: 0; padding: 0; }
.guide-steps li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px dashed var(--line-2); animation: enter .45s var(--ease) both; animation-delay: calc(var(--d) * 60ms); }
.guide-steps li:last-child { border-bottom: 0; }
.guide-steps .guide-index { padding-top: 2px; font-size: 13px; }
.guide-steps strong { font-size: 14px; }
.guide-steps p { margin-top: 2px; color: var(--ink-2); font-size: 13px; line-height: 1.7; }
.guide-note { margin-top: 10px; padding: 10px 12px; border-left: 2px solid var(--accent); background: var(--accent-soft); color: var(--ink-2); font-size: 12.5px; }
.guide-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 28px 24px; }
.guide-foot a { color: var(--muted); font-size: 12px; }
.guide-foot a:hover { color: var(--accent); }

/* The site's terminal quote: a blinking block cursor. */
.term::after { content: ""; display: inline-block; width: .5em; height: .95em; margin-left: .12em; vertical-align: -.08em; background: var(--accent); animation: term-cursor 1s steps(2, start) infinite; }
@keyframes term-cursor { to { visibility: hidden; } }

/* The knob-headed mascot twiddles while something is working. */
.mascot { display: block; width: 40px; height: 40px; flex: 0 0 auto; object-fit: contain; transform-origin: 50% 90%; }
.working .mascot, dialog.guide .mascot, .mascot.large { animation: twiddle 2.4s var(--ease) infinite; animation-delay: calc(0ms - var(--phase, 0ms)); }
.mascot.large { width: 96px; height: 96px; }
.card-head .mascot { width: 34px; height: 34px; margin: -6px -4px -6px 0; }
@keyframes twiddle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-9deg) translateY(-2px); } 45% { transform: rotate(7deg); } 70% { transform: rotate(-3deg) translateY(-1px); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .audition-body { grid-template-columns: 1fr; }
  .inspector { position: static; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
}
@media (max-width: 900px) {
  .studio-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .home-hero { grid-template-columns: 1fr; }
  .hero-device { grid-template-columns: 140px 1fr; justify-items: start; align-items: center; padding: 16px 20px; }
  .hero-device .finish-picker { grid-column: 1 / -1; }
  .hero-device figcaption { text-align: left; }
  .stage { grid-template-columns: minmax(250px, 320px) minmax(0, 1fr); gap: 24px; }
  .knob-editor-head { grid-template-columns: auto minmax(0, 1fr); }
  .default-field { grid-column: 2; }
}
@media (max-width: 760px) {
  .app { width: calc(100% - 28px); padding-top: 20px; }
  .stage { grid-template-columns: 1fr; }
  .pedal-wrap { position: static; width: 100%; max-width: 420px; justify-self: center; }
  .section-heading { flex-direction: column; align-items: start; gap: 6px; }
  .section-heading p { text-align: left; }
  .progress { margin-top: 14px; }
  .progress span { padding-right: 10px; font-size: 11.5px; }
  .progress span:not(:last-child)::after { width: 10px; }
}
@media (max-width: 640px) {
  .bar { padding: 0 16px; }
  .brand strong { font-size: 18px; }
  .brand-divider, .brand > span:last-child { display: none; }
  .toolchain-panel { display: none; }
  .studio-layout { display: flex; flex-direction: column-reverse; justify-content: flex-end; }
  .project-sidebar { position: static; height: auto; border-right: 0; border-top: 1px solid var(--line); }
  .editor-pane { padding: 28px 16px 48px; }
    .form-bottom { flex-wrap: wrap; }
  .form-bottom input { max-width: none; flex-basis: 100%; }
  .form-bottom .primary { width: 100%; }
  .creation-form { padding: 14px; border-radius: var(--radius-lg); }
  .sound-brief, .section-heading { padding-left: 18px; padding-right: 18px; }
  .knob-tabs { gap: 6px; margin: 0 12px; }
  .knob-tab { grid-template-columns: 1fr; justify-items: start; min-height: 0; padding: 10px; }
  .knob-dial { grid-row: auto; width: 32px; height: 32px; }
  .knob-dial::after { top: 6px; height: 6px; transform-origin: 50% 10px; }
  .configure-card .knob-rows { margin: 12px; }
  .knob-editor-head, .knob-range { grid-template-columns: 1fr; }
  .knob-number, .range-direction { display: none; }
  .default-field { grid-column: 1; }
  .secondary-content { grid-template-columns: 1fr; padding-left: 18px; padding-right: 18px; }
  .composer-hint { display: none; }
  .card { padding: 18px; }
  .inspector { grid-template-columns: 1fr; }
  .comparison-switch button:not(.primary) { min-width: 0; flex: 1; }
}
@media (max-width: 520px) {
  .progress span:not(.now) { gap: 0; padding-right: 5px; font-size: 0; }
  .progress span:not(.now):not(:last-child)::after { margin-left: 5px; }
  .brand img { height: 24px; }
  .bar-status { gap: 8px; }
  .gear { gap: 0; padding: 9px; font-size: 0; }
  .guide-menu { right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .wave i { transform: scaleY(.5); }
}
