:root {
  color-scheme: light dark;
  --paper: #f7f3ea;
  --paper-2: #ede7db;
  --ink: #172b3b;
  --muted: #5f6b73;
  --line: #c9c2b7;
  --accent: #d94835;
  --accent-strong: #b93425;
  --accent-soft: #f4c5bd;
  --surface: rgba(255, 253, 248, 0.78);
  --shadow: rgba(58, 43, 33, 0.18);
  --radius: 18px;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #122331;
    --paper-2: #192f3f;
    --ink: #f2eee5;
    --muted: #b6c1c7;
    --line: #425766;
    --accent: #f0715f;
    --accent-strong: #ff8c7b;
    --accent-soft: #723f3b;
    --surface: rgba(20, 43, 58, 0.82);
    --shadow: rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 14%, color-mix(in srgb, var(--accent) 14%, transparent) 0 10%, transparent 24%),
    linear-gradient(135deg, transparent 0 49.6%, color-mix(in srgb, var(--line) 28%, transparent) 50%, transparent 50.4%) 0 0 / 28px 28px,
    var(--paper);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

.page-shell {
  width: min(100% - 32px, 1220px);
  margin: 0 auto;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff8f1;
  background: var(--accent);
  border-radius: 50%;
  transform: rotate(-7deg);
}

.topbar p { margin: 0; color: var(--muted); font-size: 14px; }

.site-nav { display: flex; gap: 22px; align-items: center; }
.site-nav a { color: var(--muted); font-size: 14px; font-weight: 800; text-decoration: none; }
.site-nav a:hover, .site-nav a.active { color: var(--accent-strong); }

.hero {
  min-height: min(670px, calc(100dvh - 72px));
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(330px, 0.8fr);
  align-items: center;
  gap: 32px;
  padding: 56px 0 68px;
}

.hero-copy { position: relative; z-index: 1; }

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

h1 {
  max-width: 800px;
  margin: 0;
  font-size: clamp(49px, 5.5vw, 78px);
  line-height: 1.04;
  letter-spacing: -0.065em;
}

h1 em {
  display: inline-block;
  color: var(--accent);
  font-style: normal;
}

.hero-intro {
  max-width: 490px;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.7;
}

.record-stage {
  position: relative;
  width: min(40vw, 480px);
  aspect-ratio: 1;
  justify-self: end;
}

.record {
  position: absolute;
  inset: 11%;
  display: grid;
  place-items: center;
  border: 1px solid #364651;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at center, transparent 0 8px, rgba(255,255,255,.075) 9px 10px),
    #142631;
  box-shadow: 0 32px 55px var(--shadow), inset 0 0 0 18px rgba(0,0,0,.07);
}

.record::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
}

.record-label {
  display: grid;
  width: 35%;
  aspect-ratio: 1;
  place-items: center;
  padding-bottom: 2px;
  color: #fff9f1;
  background: var(--accent);
  border-radius: 50%;
  font-size: clamp(17px, 2.2vw, 27px);
  font-weight: 900;
  line-height: 1.12;
  text-align: center;
  transform: rotate(-8deg);
}

.tonearm {
  position: absolute;
  top: 8%;
  right: 5%;
  width: 16%;
  height: 58%;
  border: 10px solid var(--ink);
  border-bottom: 0;
  border-left: 0;
  border-radius: 0 34px 0 0;
  transform: rotate(13deg);
  transform-origin: top right;
}

.orbit {
  position: absolute;
  z-index: 2;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 999px;
  box-shadow: 4px 5px 0 var(--ink);
  font-size: 14px;
  font-weight: 800;
}
.orbit-one { top: 7%; left: 1%; transform: rotate(-10deg); }
.orbit-two { top: 42%; right: -3%; transform: rotate(8deg); }
.orbit-three { bottom: 6%; left: 7%; transform: rotate(5deg); }

.workbench {
  margin-bottom: 80px;
  padding: clamp(24px, 4vw, 52px);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: var(--radius);
  box-shadow: 0 28px 70px var(--shadow), inset 0 1px 0 rgba(255,255,255,.32);
  backdrop-filter: blur(14px);
}

#song-form {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(290px, .75fr);
  gap: 36px 52px;
}

.field-heading { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.field-heading label, legend { font-size: clamp(20px, 2.4vw, 28px); font-weight: 880; letter-spacing: -.035em; }
#word-count { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.field-help { margin: 8px 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: 18px 20px;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  font-size: 17px;
  line-height: 1.75;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

textarea::placeholder { color: color-mix(in srgb, var(--muted) 82%, transparent); }
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); transform: translateY(-1px); }

.word-preview { min-height: 36px; display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 0 0; }
.word-preview span { padding: 5px 9px; color: var(--accent-strong); background: color-mix(in srgb, var(--accent-soft) 60%, transparent); border-radius: 999px; font-size: 12px; font-weight: 700; }

.sample-button, .copy-button, .again-button, #close-overlay {
  margin-top: 10px;
  padding: 8px 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid currentColor;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 17px; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-option { position: relative; display: grid; min-height: 104px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.style-option:first-child { grid-column: 1 / -1; }
.style-option:hover { transform: translateY(-2px); border-color: var(--accent); }
.style-option:has(input:checked) { color: #fff8f2; background: var(--accent); border-color: var(--accent); box-shadow: 0 7px 0 color-mix(in srgb, var(--accent-strong) 80%, var(--ink)); transform: translateY(-4px); }
.style-option input { position: absolute; opacity: 0; pointer-events: none; }
.style-option:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 3px; }
.style-option strong { align-self: end; font-size: 16px; }
.style-option small { align-self: start; margin-top: 3px; color: inherit; opacity: .82; line-height: 1.35; }
.style-number { justify-self: end; font-size: 12px; font-weight: 900; opacity: .76; }

.form-error { grid-column: 1 / -1; min-height: 24px; margin: -8px 0 -20px; color: var(--accent-strong); font-size: 14px; font-weight: 750; }

.magic-button {
  grid-column: 1 / -1;
  display: flex;
  min-height: 96px;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #fffaf4;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 10px 0 var(--ink);
  cursor: pointer;
  font-size: clamp(24px, 3.4vw, 42px);
  font-weight: 950;
  letter-spacing: -.04em;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.magic-button:hover { background: var(--accent-strong); transform: translateY(-2px); box-shadow: 0 12px 0 var(--ink); }
.magic-button:active { transform: translateY(7px); box-shadow: 0 3px 0 var(--ink); }
.magic-button:focus-visible, button:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.magic-button:disabled { cursor: wait; opacity: .68; }
.button-note { font-size: 1.35em; transform: rotate(8deg); }

.result {
  margin: 0 0 80px;
  padding: clamp(26px, 6vw, 72px);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 28px 70px var(--shadow);
}
.result[hidden] { display: none; }
.result-meta { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.result-meta p { margin: 0; }
.song-heading { display: grid; grid-template-columns: 1fr minmax(250px, .55fr); gap: 44px; align-items: end; padding: 48px 0; }
.result-kicker { margin: 0 0 8px; color: var(--accent-strong); font-weight: 800; }
h2 { margin: 0; font-size: clamp(44px, 7vw, 82px); line-height: 1.06; letter-spacing: -.06em; }
.song-concept { max-width: 600px; margin: 20px 0 0; color: var(--muted); line-height: 1.8; }
.hook-card { padding: 24px; color: #fff9f3; background: var(--accent); border-radius: 14px; transform: rotate(1.5deg); box-shadow: 7px 8px 0 var(--ink); }
.hook-card span { display: block; margin-bottom: 12px; font-size: 12px; font-weight: 750; opacity: .8; }
.hook-card strong { font-size: 20px; line-height: 1.55; }
.song-lyrics { max-width: 760px; margin: 0; padding: 40px 0; white-space: pre-wrap; color: var(--ink); background: transparent; border: 0; font-family: var(--font); font-size: clamp(17px, 2vw, 20px); line-height: 2; }
.coverage { padding: 18px 20px; color: var(--ink); background: var(--paper-2); border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; line-height: 1.6; }
.coverage strong { color: var(--accent-strong); }
.result-actions { display: flex; gap: 28px; margin-top: 24px; }
.copy-button, .again-button { font-size: 15px; }

footer { padding: 0 0 48px; color: var(--muted); text-align: center; font-size: 14px; }

.making-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff9f2;
  background: color-mix(in srgb, #142b3a 96%, transparent);
  backdrop-filter: blur(20px);
}
.making-overlay[hidden] { display: none; }
.making-inner { width: min(620px, 100%); text-align: center; }
.making-record { display: grid; width: 170px; aspect-ratio: 1; margin: 0 auto 34px; place-items: center; border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 8px, rgba(255,255,255,.1) 9px 10px), #091923; box-shadow: 0 0 0 18px rgba(255,255,255,.06); }
.making-record span { display: grid; width: 55px; aspect-ratio: 1; place-items: center; color: white; background: var(--accent); border-radius: 50%; font-size: 28px; }
.making-inner p { min-height: 44px; margin: 0 0 22px; font-size: clamp(22px, 4vw, 34px); font-weight: 850; }
.making-line { height: 5px; overflow: hidden; background: rgba(255,255,255,.16); border-radius: 99px; }
.making-line span { display: block; width: 38%; height: 100%; background: var(--accent); border-radius: inherit; animation: loading 1.5s ease-in-out infinite alternate; }
#close-overlay { color: #fff; margin-top: 28px; }

@keyframes loading { from { transform: translateX(-10%); } to { transform: translateX(175%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float-one { 50% { transform: translate(10px, -12px) rotate(-5deg); } }

@media (prefers-reduced-motion: no-preference) {
  .record, .making-record { animation: spin 12s linear infinite; }
  .record-label, .making-record span { animation: spin 12s linear infinite reverse; }
  .orbit { animation: float-one 4s ease-in-out infinite; }
  .result:not([hidden]) { animation: reveal .65s cubic-bezier(.16, 1, .3, 1) both; }
  @keyframes reveal { from { opacity: 0; transform: translateY(28px); } }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 820px) {
  .topbar p { display: none; }
  .hero { min-height: auto; grid-template-columns: 1fr; padding: 50px 0; }
  .record-stage { width: min(88vw, 440px); justify-self: center; }
  #song-form { grid-template-columns: 1fr; }
  .form-error, .magic-button { grid-column: auto; }
  .song-heading { grid-template-columns: 1fr; }
  .hook-card { max-width: 420px; }
}

@media (max-width: 540px) {
  .page-shell { width: min(100% - 24px, 1220px); }
  .topbar { min-height: 62px; }
  .hero { padding: 40px 0 48px; }
  h1 { font-size: clamp(43px, 13vw, 62px); }
  .record-stage { width: min(88vw, 350px); }
  .workbench { margin-bottom: 48px; padding: 20px 16px 25px; }
  #song-form { gap: 32px; }
  .field-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .style-grid { grid-template-columns: 1fr; }
  .style-option:first-child { grid-column: auto; }
  .magic-button { min-height: 82px; font-size: 27px; }
  .result { padding: 28px 20px; }
  .result-meta { flex-direction: column; gap: 6px; }
  .song-heading { gap: 28px; padding: 34px 0; }
  .hook-card { transform: none; }
  .result-actions { align-items: flex-start; flex-direction: column; gap: 8px; }
}

@supports not (backdrop-filter: blur(2px)) {
  .workbench { background: var(--paper); }
  .making-overlay { background: #142b3a; }
}
