:root {
  --orange: #ff6a00;
  --orange-2: #ff8c1a;
  --orange-3: #ffe6cf;
  --white: #ffffff;
  --cream: #fff8f1;
  --text: #19110b;
  --muted: #7b6b5d;
  --line: rgba(255, 106, 0, .18);
  --shadow: 0 28px 110px rgba(255, 106, 0, .18);
  --radius: 34px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Assistant, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 90% 10%, rgba(255, 106, 0, .22), transparent 34rem),
    radial-gradient(circle at 4% 96%, rgba(255, 183, 77, .22), transparent 32rem),
    linear-gradient(180deg, #fffdfb, var(--cream));
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app {
  width: 100vw;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-header {
  width: 100%;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(16px, env(safe-area-inset-top)) clamp(16px, 4vw, 42px) 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--orange), #ffb21d);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 24px;
  box-shadow: 0 14px 32px rgba(255, 106, 0, .28);
}

.brand strong {
  display: block;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.03em;
}

.brand span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  font-weight: 700;
}

.price-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(16px);
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--orange);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 14px 40px rgba(255, 106, 0, .10);
}

.stage-wrap {
  width: 100%;
  min-height: calc(100vh - 76px);
  display: grid;
  place-items: center;
  padding: 18px clamp(12px, 4vw, 56px) clamp(22px, 5vh, 60px);
}

.wizard,
.generation,
.result {
  width: min(100%, 1040px);
  min-height: min(680px, calc(100vh - 128px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .84);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  padding: clamp(18px, 4vw, 42px);
  display: flex;
  flex-direction: column;
}

.progress-area { width: 100%; }
.progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 900;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--orange);
  font-weight: 900;
  padding: 6px 0;
}

.progress-bar {
  height: 10px;
  background: rgba(255, 106, 0, .11);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar span {
  display: block;
  width: 10%;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), #ffb21d);
  border-radius: inherit;
  transition: width .3s ease;
}

#songWizard {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.step {
  display: none;
  width: min(100%, 790px);
  margin: 0 auto;
  text-align: center;
  animation: stepIn .22s ease both;
}
.step.active { display: block; }

@keyframes stepIn {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.micro {
  margin: 0 0 14px;
  color: var(--orange);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .02em;
}

h1, h2 {
  margin: 0 auto 24px;
  max-width: 820px;
  font-size: clamp(34px, 6vw, 78px);
  line-height: .92;
  letter-spacing: -.055em;
}
h2 { font-size: clamp(34px, 5vw, 62px); }

.big-input,
.big-textarea,
.compact-grid input {
  width: 100%;
  border: 1px solid rgba(25, 17, 11, .10);
  outline: none;
  border-radius: 26px;
  background: #fff;
  color: var(--text);
  padding: 21px 22px;
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 800;
  text-align: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .75), 0 12px 30px rgba(25, 17, 11, .04);
  transition: .18s ease;
}
.big-textarea {
  min-height: 190px;
  resize: vertical;
  text-align: right;
  line-height: 1.45;
}
.big-input:focus,
.big-textarea:focus,
.compact-grid input:focus {
  border-color: rgba(255, 106, 0, .55);
  box-shadow: 0 0 0 6px rgba(255, 106, 0, .10), 0 18px 45px rgba(255, 106, 0, .10);
}

.choice-grid {
  width: min(100%, 780px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }

.choice {
  border: 1px solid rgba(25, 17, 11, .09);
  background: #fff;
  color: var(--text);
  border-radius: 24px;
  min-height: 74px;
  padding: 16px;
  font-size: 20px;
  font-weight: 900;
  transition: .18s ease;
  box-shadow: 0 12px 34px rgba(25, 17, 11, .045);
}
.choice:hover,
.choice.selected {
  transform: translateY(-1px);
  border-color: var(--orange);
  background: linear-gradient(145deg, var(--orange), var(--orange-2));
  color: #fff;
  box-shadow: 0 20px 42px rgba(255, 106, 0, .22);
}

.compact-grid {
  width: min(100%, 720px);
  display: grid;
  gap: 12px;
  margin: 0 auto 14px;
}
.compact-grid input { font-size: 20px; padding: 17px 18px; }

.nav-actions {
  width: min(100%, 790px);
  margin: 28px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-btn,
.next-btn,
.pay-btn,
.secondary-btn {
  border: 0;
  border-radius: 999px;
  padding: 16px 24px;
  font-size: 18px;
  font-weight: 900;
  text-decoration: none;
  transition: .18s ease;
}
.back-btn,
.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid rgba(25, 17, 11, .08);
}
.next-btn,
.pay-btn {
  background: linear-gradient(145deg, var(--orange), #ff9d19);
  color: #fff;
  box-shadow: 0 18px 44px rgba(255, 106, 0, .23);
}
.pay-btn {
  width: min(100%, 720px);
  margin: 8px auto 0;
  display: block;
  font-size: 22px;
  padding: 20px 26px;
}
button:disabled { opacity: .55; cursor: not-allowed; }

.hidden { display: none !important; }

.generation {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.generation p:not(.micro) {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 21px;
  font-weight: 700;
}
.loader-orb {
  width: 118px;
  height: 118px;
  border-radius: 40px;
  background: rgba(255, 106, 0, .10);
  display: grid;
  place-items: center;
  margin-bottom: 24px;
}
.loader-orb span {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 6px solid rgba(255, 106, 0, .17);
  border-top-color: var(--orange);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result {
  gap: 18px;
  overflow: auto;
}
.cover {
  min-height: 230px;
  border-radius: 30px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.36), transparent 20rem),
    linear-gradient(145deg, var(--orange), #15100c);
  color: #fff;
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.cover span { font-weight: 900; opacity: .8; }
.cover strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(34px, 5vw, 70px);
  line-height: .9;
  letter-spacing: -.05em;
}

audio { width: 100%; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.secondary-btn { display: inline-flex; justify-content: center; align-items: center; }

details {
  background: #fff;
  border: 1px solid rgba(25, 17, 11, .08);
  border-radius: 24px;
  padding: 16px 18px;
}
summary { cursor: pointer; font-weight: 900; font-size: 18px; }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Assistant, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.7;
  color: #35271b;
  margin: 14px 0 0;
}
.feedback-box {
  border: 1px solid var(--line);
  background: var(--orange-3);
  border-radius: 24px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.stars { direction: ltr; display: flex; gap: 4px; }
.stars button {
  border: 0;
  background: transparent;
  color: rgba(25, 17, 11, .25);
  font-size: 28px;
  padding: 0 2px;
}
.stars button.active { color: var(--orange); }

.toast {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  background: #15100c;
  color: #fff;
  border-radius: 18px;
  padding: 13px 16px;
  font-weight: 800;
  box-shadow: 0 22px 70px rgba(0,0,0,.24);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 760px) {
  .app-header { min-height: 68px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 15px; }
  .brand strong { font-size: 22px; }
  .brand span { font-size: 13px; }
  .price-chip { font-size: 18px; padding: 8px 14px; }
  .stage-wrap { min-height: calc(100vh - 68px); padding: 8px 10px 16px; place-items: stretch; }
  .wizard, .generation, .result {
    width: 100%;
    min-height: calc(100vh - 92px);
    border-radius: 28px;
    padding: 16px;
  }
  #songWizard { justify-content: center; }
  h1 { font-size: clamp(38px, 12vw, 58px); margin-bottom: 18px; }
  .micro { margin-bottom: 10px; }
  .choice-grid, .choice-grid.three { grid-template-columns: 1fr 1fr; gap: 9px; }
  .choice { min-height: 62px; padding: 12px; font-size: 17px; border-radius: 19px; }
  .big-input, .big-textarea { font-size: 20px; border-radius: 22px; padding: 18px 16px; }
  .big-textarea { min-height: 170px; }
  .nav-actions { margin-top: 18px; }
  .back-btn, .next-btn, .pay-btn { padding: 14px 20px; font-size: 17px; }
  .pay-btn { font-size: 19px; }
  .feedback-box { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 420px) {
  .choice-grid, .choice-grid.three { grid-template-columns: 1fr; }
  .nav-actions { position: sticky; bottom: 0; padding-top: 12px; background: linear-gradient(0deg, rgba(255,255,255,.96), rgba(255,255,255,0)); }
  .back-btn, .next-btn { flex: 1; }
}
