:root {
  --bg: #09090d;
  --panel: rgba(20, 20, 29, 0.82);
  --panel-strong: #171722;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f6f4ff;
  --muted: #aaa7b8;
  --accent: #a777ff;
  --accent-2: #5ce1e6;
  --success: #63e6be;
  --danger: #ff7c9d;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(121, 77, 255, 0.16), transparent 40%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }

.bg-orb {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.12;
  pointer-events: none;
}
.orb-a { background: #8b5cf6; top: 8%; left: -18rem; }
.orb-b { background: #22d3ee; right: -20rem; top: 42%; }

.topbar {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: 0.08em;
  font-weight: 800;
}
.brand-text b { color: var(--accent-2); }
.brand-mark {
  width: 34px;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.brand-mark span {
  width: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  animation: pulseBars 1.5s ease-in-out infinite;
}
.brand-mark span:nth-child(1), .brand-mark span:nth-child(5) { height: 10px; }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(4) { height: 20px; animation-delay: .15s; }
.brand-mark span:nth-child(3) { height: 28px; animation-delay: .3s; }
@keyframes pulseBars { 50% { transform: scaleY(.55); opacity: .7; } }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--muted);
  font-size: 0.78rem;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 14px var(--success);
}

.shell {
  width: min(1120px, calc(100% - 34px));
  margin: 0 auto;
}
.hero {
  text-align: center;
  padding: 88px 0 42px;
}
.eyebrow, .mini-label {
  margin: 0 0 14px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--accent-2);
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 8vw, 6.8rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}
.hero h1 span {
  color: transparent;
  background: linear-gradient(100deg, #fff 5%, #c7b6ff 46%, #76e8ec 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-copy {
  max-width: 680px;
  margin: 26px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.7;
}

.studio-card, .result-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(25, 25, 36, 0.95), rgba(14, 14, 21, 0.9));
  backdrop-filter: blur(20px);
  border-radius: 26px;
  box-shadow: var(--shadow);
}
.studio-card { padding: clamp(20px, 4vw, 38px); }
.prompt-wrap label {
  display: block;
  margin-bottom: 12px;
  font-weight: 750;
  font-size: 1.05rem;
}
textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 18px;
  background: rgba(3, 3, 7, 0.44);
  color: var(--text);
  padding: 20px;
  line-height: 1.6;
  outline: none;
  transition: .25s ease;
}
textarea:focus, input:focus, select:focus {
  border-color: rgba(167,119,255,.8);
  box-shadow: 0 0 0 4px rgba(167,119,255,.12);
}
textarea::placeholder { color: #706d7d; }
.prompt-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 9px;
  color: #777382;
  font-size: .72rem;
}
.privacy-note { text-align: right; }
.controls-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr .8fr .9fr;
  gap: 14px;
  margin-top: 24px;
}
.control-block {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  border-radius: 15px;
  padding: 14px;
}
.control-head {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.control-head label { color: var(--muted); font-size: .78rem; font-weight: 700; }
.control-head output { font-size: .76rem; color: var(--text); }
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
input[type="text"], select {
  width: 100%;
  height: 38px;
  color: var(--text);
  background: rgba(3,3,7,.42);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  padding: 0 10px;
}
select option { background: #171722; }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  cursor: pointer;
  font-size: 1.15rem;
}
.generate-btn {
  width: 100%;
  min-height: 58px;
  margin-top: 22px;
  border: 0;
  border-radius: 15px;
  background: linear-gradient(105deg, #8657f3, #9f6fff 46%, #58dce5);
  color: #07070b;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 14px 40px rgba(136, 89, 244, .23);
  transition: transform .2s ease, filter .2s ease;
}
.generate-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.generate-btn:disabled { cursor: not-allowed; opacity: .65; transform: none; }
.btn-icon { font-size: 1.2rem; }

.progress-area { margin-top: 22px; }
.progress-copy {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: .78rem;
  margin-bottom: 9px;
}
.progress-track {
  height: 8px;
  background: rgba(255,255,255,.07);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  transition: width .2s ease;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr);
  gap: 18px;
  margin-top: 22px;
}
.result-card { padding: 24px; }
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.result-head h2, .analysis-card h3, .history-section h2 {
  margin: 0;
  letter-spacing: -.03em;
}
.engine-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(92,225,230,.25);
  color: var(--accent-2);
  background: rgba(92,225,230,.07);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .69rem;
  font-weight: 750;
}
#waveform {
  width: 100%;
  height: 170px;
  margin: 22px 0 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(2,2,5,.38);
}
audio { width: 100%; height: 48px; }
.result-actions { display: flex; gap: 10px; margin-top: 16px; }
.secondary-btn, .ghost-btn {
  min-height: 42px;
  border-radius: 11px;
  padding: 0 16px;
  font-weight: 780;
  cursor: pointer;
}
.secondary-btn { border: 0; color: #0b0b0e; background: var(--text); }
.ghost-btn { border: 1px solid var(--line); background: transparent; }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }
.tag {
  border: 1px solid rgba(167,119,255,.2);
  background: rgba(167,119,255,.08);
  color: #d8c9ff;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: .72rem;
}
.scene-details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.scene-details div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  font-size: .78rem;
}
.scene-details div + div { border-top: 1px solid var(--line); }
.scene-details span { color: var(--muted); }
.scene-details b { text-align: right; }
.scene-explanation { color: var(--muted); line-height: 1.6; font-size: .82rem; margin: 16px 0 0; }

.history-section { padding: 62px 0 70px; }
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}
.text-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.history-list { display: grid; gap: 10px; }
.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.025);
  border-radius: 14px;
  padding: 15px 17px;
}
.history-item p { margin: 0; color: #d8d5e1; line-height: 1.4; font-size: .84rem; }
.history-item span { color: #706d7c; font-size: .7rem; }
.history-item button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 9px;
  padding: 8px 10px;
  cursor: pointer;
}
.empty-history { color: #6e6b77; margin: 0; }

footer {
  width: min(1120px, calc(100% - 34px));
  min-height: 84px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #696674;
  font-size: .72rem;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #f5f3fb;
  color: #111118;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
  font-weight: 750;
  font-size: .8rem;
  transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 850px) {
  .controls-grid { grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 68px; }
}
@media (max-width: 560px) {
  .topbar { min-height: 72px; }
  .status-pill span:last-child { display: none; }
  .status-pill { padding: 9px; }
  .hero { padding: 58px 0 32px; }
  .hero h1 { font-size: clamp(2.6rem, 14vw, 4.2rem); }
  .controls-grid { grid-template-columns: 1fr; }
  .prompt-meta { display: block; }
  .privacy-note { display: block; margin-top: 5px; text-align: left; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .history-item { grid-template-columns: 1fr; }
  .history-item button { width: 100%; }
  footer { flex-direction: column; justify-content: center; text-align: center; }
}
