:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --stone: #f5f2ef;
  --ink: #000000;
  --body: #4e4e4e;
  --muted: #6b655f;
  --line: #e5e5e5;
  --line-soft: rgba(0, 0, 0, 0.05);
  --cyan: #7fffff;
  --r-card: 24px;
  --r-panel: 20px;
  --r-item: 14px;
  --shadow-card: rgba(0, 0, 0, 0.06) 0 0 0 1px, rgba(0, 0, 0, 0.04) 0 1px 2px, rgba(0, 0, 0, 0.04) 0 2px 4px;
  --shadow-lift: rgba(0, 0, 0, 0.4) 0 0 1px, rgba(0, 0, 0, 0.04) 0 4px 4px;
  --shadow-warm: rgba(78, 50, 23, 0.04) 0 6px 16px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0.16px;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, a { font: inherit; color: inherit; }

button { cursor: pointer; }

button, a, summary, input { touch-action: manipulation; }

body { -webkit-tap-highlight-color: transparent; }

a { color: inherit; }

::selection { background: var(--cyan); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.mono { font-family: var(--mono); }

/* ------------------------------------------------------------- top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 64px;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
}

.brand-name {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.engine {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--body);
  white-space: nowrap;
}

.engine-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #17a673;
  box-shadow: 0 0 0 3px rgba(23, 166, 115, 0.12);
}

.engine-sep { color: var(--muted); }

.engine-model { color: var(--muted); }

/* ---------------------------------------------------------------- shell */
.shell {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 20px;
  max-width: 1240px;
  margin: 28px auto 0;
  padding: 0 32px;
  align-items: start;
}

/* ------------------------------------------------------------- controls */
.controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.eyebrow {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.controls h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.96px;
}

.controls-sub {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--body);
  max-width: 32ch;
}

#gen-form { margin-top: 28px; }

.field {
  border: 0;
  padding: 0;
  margin: 0 0 22px;
  min-width: 0;
}

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.vibes {
  display: grid;
  gap: 6px;
}

.vibe {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-item);
  transition: border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.vibe:hover { border-color: #b9b4ae; }

.vibe[aria-checked="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.vibe-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--v0), var(--v1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.vibe-text { display: grid; gap: 1px; min-width: 0; }

.vibe-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vibe-meta {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.vibe[aria-checked="true"] .vibe-meta { color: #a8a29c; }

.vibe-check {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #9a948d;
  justify-self: end;
  position: relative;
}

.vibe[aria-checked="true"] .vibe-check {
  border-color: #fff;
  background: #fff;
}

.vibe[aria-checked="true"] .vibe-check::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--ink);
}

.two-up {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
}

.seed-row { display: flex; gap: 6px; }

#seed {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 12px;
}

#seed::placeholder { color: var(--muted); }

#seed:focus { border-color: var(--ink); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 9999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--shadow-lift);
  transition: border-color 120ms ease, background 120ms ease;
}

.btn-ghost:hover { border-color: #b9b4ae; background: #fafafa; }

#dice { width: 40px; flex: 0 0 auto; padding: 0; border-radius: 10px; box-shadow: none; }

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--stone);
  border-radius: 10px;
}

.seg-btn {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--body);
  font-size: 12px;
  font-weight: 500;
}

.seg-btn.is-on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
}

.advanced {
  border-top: 1px solid var(--line-soft);
  padding-top: 6px;
  margin: 0 0 12px;
}

.advanced-sum {
  display: block;
  padding: 10px 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  list-style: none;
}

.advanced-sum::-webkit-details-marker { display: none; }

.advanced-sum::after {
  content: "+";
  float: right;
  font-size: 14px;
  line-height: 1;
}

.advanced[open] .advanced-sum::after { content: "–"; }

.advanced-body { padding: 14px 0 2px; }

#steps {
  width: 100%;
  accent-color: var(--ink);
}

#steps-val { color: var(--ink); margin-left: 4px; }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 54px;
  padding: 0 10px 0 22px;
  border: 0;
  border-radius: 9999px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  box-shadow: var(--shadow-warm);
  transition: transform 120ms ease, opacity 120ms ease;
}

.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }

.btn-primary:disabled {
  background: #d8d4cf;
  color: #777169;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-arrow {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.fine {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.fine-foot { margin-top: 12px; }

/* ---------------------------------------------------------------- stage */
.stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  min-height: 610px;
  overflow: hidden;
}

.view { padding: 32px; }

/* empty */
#view-empty {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 40px;
  align-items: center;
  min-height: 544px;
}

.empty-sleeve {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-panel);
  background: var(--stone);
  border: 1px solid var(--line);
  overflow: hidden;
}

.empty-hole {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--ink);
}

.empty-sleeve::before {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 50%;
}

.empty-sleeve::after {
  content: "";
  position: absolute;
  inset: 32%;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 50%;
}

.empty-serial {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.empty-label {
  position: absolute;
  left: 16px;
  bottom: 15px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.empty-copy h2 {
  margin: 0;
  font-size: 36px;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.6px;
  max-width: 15ch;
}

.empty-copy p:last-child {
  margin: 14px 0 0;
  max-width: 44ch;
  font-size: 14px;
  line-height: 1.6;
  color: var(--body);
}

/* progress */
#view-progress { min-height: 544px; display: grid; align-items: center; }

.progress-top {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 44px;
  align-items: center;
}

.render-sleeve {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-panel);
  background: linear-gradient(140deg, var(--p0, #1b1035), var(--p1, #5b2a86));
  overflow: hidden;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
}

.render-sleeve::before {
  content: "";
  position: absolute;
  width: 74%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: spin 9s linear infinite;
}

.render-sleeve::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.render-pct {
  position: relative;
  z-index: 1;
  font-size: 46px;
  font-weight: 300;
  letter-spacing: -1.5px;
  line-height: 1;
}

.render-status {
  position: relative;
  z-index: 1;
  font-size: 10px;
  letter-spacing: 0.16em;
  opacity: 0.8;
}

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.progress-copy h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.progress-detail {
  margin: 10px 0 0;
  min-height: 44px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--body);
}

.bar {
  height: 3px;
  margin: 18px 0 22px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  border-radius: 999px;
  transition: width 350ms ease;
}

.steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.step-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid #8f8982;
  flex: none;
}

.steps li.is-done { color: var(--body); }
.steps li.is-done .step-dot { background: var(--ink); border-color: var(--ink); }

.steps li.is-now { color: var(--ink); font-weight: 500; }
.steps li.is-now .step-dot { background: var(--ink); border-color: var(--ink); animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: 0.35; } }

/* result */
.release {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.art-wrap { min-width: 0; }

.res-main { min-width: 0; }

.art {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--r-panel);
  background: var(--stone);
  box-shadow: var(--shadow-lift);
}

.res-id {
  margin: 4px 0 8px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.res-title {
  margin: 0;
  font-size: 42px;
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -1.2px;
  text-wrap: balance;
}

.res-meta {
  margin: 12px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--body);
}

.player {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 24px;
  padding: 8px 14px 8px 8px;
  background: var(--stone);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 16px;
}

.play-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
}

.play-btn:hover { transform: scale(1.03); }

.wave {
  display: block;
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  height: 56px;
  cursor: pointer;
}

.time {
  flex: none;
  font-size: 10px;
  color: var(--body);
  min-width: 78px;
  text-align: right;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.btn-dark {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 9999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: var(--shadow-lift);
}

.btn-dark:hover { background: #1a1a1a; }

.lyrics-panel {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
}

.lyrics-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.lyrics-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.1px;
}

.lyrics-head .mono { font-size: 10px; color: var(--muted); }

.lyrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, auto);
  grid-auto-flow: column;
  gap: 20px 32px;
}

.lyrics.is-single {
  grid-template-columns: 1fr;
  grid-template-rows: none;
  grid-auto-flow: row;
}

.lyric-block { min-width: 0; }

.lyric-label {
  margin: 0 0 5px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.lyric-block p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--body);
  white-space: pre-line;
}

/* error */
.stage-error {
  min-height: 400px;
  display: grid;
  align-content: center;
  max-width: 48ch;
}

.stage-error h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 300;
  letter-spacing: -0.5px;
}

.stage-error p {
  margin: 12px 0 0;
  color: var(--body);
  font-size: 13px;
}

/* -------------------------------------------------------------- recent */
.recent-wrap {
  max-width: 1240px;
  margin: 34px auto 0;
  padding: 0 32px;
}

.recent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.recent-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.recent-head .mono { font-size: 10px; color: var(--muted); }

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.recent-card {
  display: block;
  width: 100%;
  padding: 8px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.recent-card:hover {
  transform: translateY(-2px);
  border-color: #cfcac3;
  box-shadow: var(--shadow-lift);
}

.recent-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: var(--stone);
}

.recent-title {
  display: block;
  margin: 9px 2px 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  display: block;
  margin: 2px 2px 3px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-empty {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* -------------------------------------------------------------- footer */
.foot {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  max-width: 1240px;
  margin: 40px auto 0;
  padding: 22px 32px 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.foot .mono { font-size: 10px; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .shell { grid-template-columns: 1fr; max-width: 760px; }
  .stage { min-height: 0; }
  #view-empty, #view-progress { min-height: 420px; }
  .controls-sub { max-width: 46ch; }
}

@media (max-width: 720px) {
  .topbar { padding: 0 20px; height: 58px; }
  .engine-model, .engine-sep { display: none; }
  .shell { padding: 0 16px; margin-top: 16px; gap: 14px; }
  .controls { padding: 22px 20px; border-radius: 20px; }
  .controls h1 { font-size: 34px; }
  .view { padding: 22px 20px; }
  #view-empty, #view-progress { grid-template-columns: 1fr; gap: 28px; }
  .empty-sleeve, .render-sleeve { width: min(78vw, 300px); }
  .empty-copy h2 { font-size: 30px; max-width: 18ch; }
  .progress-top { grid-template-columns: 1fr; gap: 28px; }
  .release { grid-template-columns: 1fr; gap: 22px; }
  .art-wrap { width: min(100%, 360px); }
  .res-title { font-size: 34px; }
  .lyrics { grid-template-columns: 1fr; grid-template-rows: none; grid-auto-flow: row; gap: 16px; }
  .recent-wrap { padding: 0 16px; margin-top: 26px; }
  .recent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .foot { padding: 20px 20px 28px; flex-direction: column; gap: 8px; margin-top: 28px; }
  .player { gap: 10px; padding-right: 10px; }
  .time { min-width: 66px; font-size: 9px; }
  #seed, #dice, .btn-ghost, .btn-dark { height: 44px; }
  #seed { font-size: 16px; }
  #dice { width: 44px; }
  .seg-btn { height: 44px; }
  .advanced-sum { padding: 15px 0; }
  #steps { height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}