:root {
  color-scheme: dark;
  --bg: #080a0d;
  --panel: rgba(20, 23, 27, 0.82);
  --panel-strong: #15181c;
  --line: rgba(255, 255, 255, 0.09);
  --muted: #8f969e;
  --text: #f4f3ee;
  --accent: #d8ff5f;
  --accent-soft: rgba(216, 255, 95, 0.12);
  --orange: #ff7657;
  --font-display: "Manrope", sans-serif;
  --font-body: "DM Sans", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

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

button, select, input[type="range"], input[type="radio"] { cursor: pointer; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.1;
  pointer-events: none;
}

.ambient-one { top: -12rem; right: -8rem; background: var(--accent); }
.ambient-two { bottom: -18rem; left: -12rem; background: var(--orange); }

.topbar {
  width: min(1400px, calc(100% - 64px));
  height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.7px;
  text-decoration: none;
}

.brand > span:last-child span { color: var(--accent); }

.brand-mark, .button-icon {
  display: inline-flex;
  height: 28px;
  align-items: center;
  gap: 3px;
}

.brand-mark i, .button-icon i {
  display: block;
  width: 3px;
  border-radius: 10px;
  background: var(--accent);
}

.brand-mark i:nth-child(1), .brand-mark i:nth-child(5) { height: 8px; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 17px; }
.brand-mark i:nth-child(3) { height: 26px; }

.model-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--muted);
  font-size: 12px;
}

.model-pill strong { color: #c8ccd0; font-weight: 500; }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

main {
  width: min(1240px, calc(100% - 64px));
  margin: 0 auto;
}

.hero { padding: 76px 0 55px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.7px;
  text-transform: uppercase;
}

.eyebrow span { color: var(--accent); }
.eyebrow i { width: 26px; height: 1px; background: #44494e; }

.hero h1 {
  margin: 0;
  max-width: 900px;
  font-family: var(--font-display);
  font-size: clamp(48px, 7vw, 92px);
  font-weight: 600;
  letter-spacing: -5px;
  line-height: 0.98;
}

.hero h1 em {
  color: var(--accent);
  font-family: Georgia, serif;
  font-weight: 400;
}

.hero p {
  max-width: 560px;
  margin: 29px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.studio {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.75fr);
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.editor-panel { padding: 30px; }
.controls-panel { padding: 30px; }

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
}

.panel-heading > div:first-child { display: flex; align-items: center; gap: 12px; }
.panel-heading h2 { margin: 0; font-family: var(--font-display); font-size: 18px; letter-spacing: -0.5px; }

.step {
  display: inline-grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid rgba(216, 255, 95, 0.25);
  border-radius: 7px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 700;
}

.text-stats { display: flex; gap: 16px; color: #737a81; font-size: 11px; }
.text-stats span + span { padding-left: 16px; border-left: 1px solid var(--line); }

.textarea-wrap { position: relative; }

#text {
  width: 100%;
  min-height: 300px;
  padding: 25px;
  resize: vertical;
  outline: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(6, 8, 10, 0.54);
  color: #e6e7e4;
  font-size: 18px;
  line-height: 1.68;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

#text:focus {
  border-color: rgba(216, 255, 95, 0.38);
  box-shadow: 0 0 0 4px rgba(216, 255, 95, 0.045);
}

#text::placeholder { color: #555b60; }

.corner-mark {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  border-radius: 0 0 12px;
  opacity: 0.6;
  pointer-events: none;
}

.style-section { margin-top: 25px; }
.style-section > label, .control-group > label, .label-row label { display: block; margin-bottom: 11px; color: #b9bdc1; font-size: 12px; font-weight: 600; }

.preset-list { display: flex; flex-wrap: wrap; gap: 7px; }

.preset {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  transition: 150ms ease;
}

.preset:hover { border-color: rgba(255, 255, 255, 0.2); color: var(--text); }
.preset.active { border-color: rgba(216, 255, 95, 0.3); color: var(--accent); background: var(--accent-soft); }

#instructions {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(6, 8, 10, 0.45);
  color: #c9cdd0;
  font-size: 12px;
  line-height: 1.5;
}

#instructions:focus { border-color: rgba(216, 255, 95, 0.3); }

.compact { margin-bottom: 30px; }
.control-group { margin-bottom: 27px; }

.select-wrap { position: relative; }

select {
  width: 100%;
  padding: 13px 39px 13px 14px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: #0e1114;
  color: #e5e5e2;
  font-size: 13px;
}

.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.5;
  pointer-events: none;
}

.quality-note { margin-top: 9px; color: #71777d; font-size: 10px; }
.quality-note span { margin-right: 6px; color: var(--accent); font-weight: 700; text-transform: uppercase; }

.label-row { display: flex; align-items: center; justify-content: space-between; }
.label-row label { margin: 0; }
.label-row output { color: var(--accent); font-size: 12px; font-weight: 700; }

input[type="range"] {
  width: 100%;
  height: 3px;
  margin: 17px 0 7px;
  appearance: none;
  border-radius: 10px;
  outline: none;
  background: linear-gradient(90deg, var(--accent) 20%, #373c3f 20%);
}

input[type="range"]::-webkit-slider-thumb {
  width: 15px;
  height: 15px;
  appearance: none;
  border: 4px solid #101315;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 4px solid #101315;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.range-labels { display: flex; justify-content: space-between; color: #666c72; font-size: 9px; }

.format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.format-grid label { position: relative; }
.format-grid input { position: absolute; opacity: 0; pointer-events: none; }

.format-grid span {
  display: flex;
  min-height: 54px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #b4b9bd;
  background: rgba(8, 10, 12, 0.4);
  font-size: 10px;
  font-weight: 700;
  transition: 150ms ease;
}

.format-grid small { margin-top: 3px; color: #5e6469; font-size: 8px; font-weight: 500; }
.format-grid input:checked + span { border-color: rgba(216, 255, 95, 0.4); color: var(--accent); background: var(--accent-soft); }
.format-grid input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.generate-button {
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #10120b;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.generate-button:hover { transform: translateY(-2px); box-shadow: 0 12px 35px rgba(216, 255, 95, 0.17); }
.generate-button:active { transform: translateY(0); }
.generate-button:disabled { cursor: wait; opacity: 0.7; }
.generate-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.button-icon { height: 17px; gap: 2px; }
.button-icon i { width: 2px; background: #10120b; }
.button-icon i:nth-child(1), .button-icon i:nth-child(5) { height: 5px; }
.button-icon i:nth-child(2), .button-icon i:nth-child(4) { height: 10px; }
.button-icon i:nth-child(3) { height: 15px; }

.generate-button.loading .button-icon i { animation: pulse 700ms ease-in-out infinite alternate; }
.generate-button.loading .button-icon i:nth-child(2) { animation-delay: 100ms; }
.generate-button.loading .button-icon i:nth-child(3) { animation-delay: 200ms; }
.generate-button.loading .button-icon i:nth-child(4) { animation-delay: 300ms; }
.generate-button.loading .button-icon i:nth-child(5) { animation-delay: 400ms; }

@keyframes pulse { to { height: 3px; } }

.disclosure { margin: 12px 10px 0; color: #5e6469; font-size: 9px; line-height: 1.45; text-align: center; }

.result-panel {
  min-height: 96px;
  margin-top: 16px;
  padding: 19px 22px;
  display: grid;
  grid-template-columns: minmax(200px, 0.65fr) minmax(300px, 1fr) auto;
  align-items: center;
  gap: 24px;
}

.result-panel[hidden] { display: none; }
.result-info { display: flex; align-items: center; gap: 13px; }
.result-info > div:last-child { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.result-info strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.result-label { color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }

.result-icon {
  width: 43px;
  height: 43px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
}

.result-icon span { width: 12px; height: 12px; border: 3px solid var(--accent); border-radius: 50%; box-shadow: 0 0 16px rgba(216, 255, 95, 0.5); }

audio { width: 100%; height: 42px; filter: invert(0.9) hue-rotate(33deg); }
.pcm-hint { color: var(--muted); font-size: 12px; }

.download-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #cdd0d1;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.download-button:hover { border-color: rgba(216, 255, 95, 0.3); color: var(--accent); }
.download-button svg { width: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.error-message {
  margin-top: 16px;
  padding: 14px 17px;
  border: 1px solid rgba(255, 118, 87, 0.3);
  border-radius: 10px;
  background: rgba(255, 118, 87, 0.08);
  color: #ffad9a;
  font-size: 13px;
}

footer {
  width: min(1240px, calc(100% - 64px));
  margin: 70px auto 0;
  padding: 28px 0 38px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: #565c61;
  font-size: 10px;
}

footer span { color: #777e84; font-family: var(--font-display); font-weight: 700; }
footer p { margin: 0; }

@media (max-width: 900px) {
  .studio { grid-template-columns: 1fr; }
  .controls-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 30px; }
  .controls-panel .panel-heading, .controls-panel .generate-button, .controls-panel .disclosure { grid-column: 1 / -1; }
  .result-panel { grid-template-columns: 1fr auto; }
  .result-panel audio, .pcm-hint { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 620px) {
  .topbar, main, footer { width: min(100% - 30px, 1240px); }
  .topbar { height: 74px; }
  .model-pill span:not(.status-dot) { display: none; }
  .hero { padding: 53px 0 38px; }
  .hero h1 { font-size: clamp(43px, 14vw, 65px); letter-spacing: -3px; }
  .hero p { font-size: 14px; }
  .editor-panel, .controls-panel { padding: 21px; }
  .text-stats span:first-child { display: none; }
  #text { min-height: 255px; padding: 18px; font-size: 16px; }
  .controls-panel { display: block; }
  .format-grid { grid-template-columns: repeat(3, 1fr); }
  .result-panel { grid-template-columns: 1fr; gap: 15px; }
  .result-panel audio, .pcm-hint { grid-column: auto; grid-row: auto; }
  .download-button { justify-content: center; }
  footer { margin-top: 45px; flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
