:root {
  --bg-a: #f2f8f5;
  --bg-b: #fff7ec;
  --ink: #17313b;
  --muted: #55727f;
  --panel: rgba(255, 255, 255, 0.84);
  --line: #cfe0df;
  --accent: #0f8396;
  --accent-strong: #0b6578;
  --accent-sub: #ec8135;
  --danger: #b32236;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", sans-serif;
  background:
    radial-gradient(130% 100% at 10% 0%, rgba(15, 131, 150, 0.16), transparent 55%),
    radial-gradient(100% 90% at 90% 10%, rgba(236, 129, 53, 0.2), transparent 50%),
    linear-gradient(155deg, var(--bg-a), var(--bg-b));
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(46px);
  opacity: 0.45;
  z-index: -1;
  pointer-events: none;
  animation: drift 8s ease-in-out infinite alternate;
}

.orb-left {
  left: -80px;
  top: -120px;
  background: radial-gradient(circle at 30% 30%, rgba(15, 131, 150, 0.85), rgba(15, 131, 150, 0));
}

.orb-right {
  right: -130px;
  top: 120px;
  animation-delay: 1.2s;
  background: radial-gradient(circle at 30% 30%, rgba(236, 129, 53, 0.85), rgba(236, 129, 53, 0));
}

.app {
  max-width: 1160px;
  margin: 0 auto;
  padding: 42px 20px 66px;
}

.hero {
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  font-family: "M PLUS Rounded 1c", sans-serif;
  line-height: 1.2;
}

h1 {
  font-size: clamp(30px, 5vw, 50px);
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 720px;
}

.studio {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 20px;
  align-items: start;
}

.panel {
  border: 1px solid rgba(207, 224, 223, 0.95);
  border-radius: 20px;
  padding: 22px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow:
    0 24px 50px rgba(19, 49, 59, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.section-heading h2 {
  font-size: clamp(21px, 3vw, 28px);
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

label {
  display: block;
  margin: 16px 0 8px;
  font-weight: 700;
  font-size: 14px;
}

.speaker-head {
  margin-top: 2px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.speaker-head label {
  margin: 16px 0 8px;
}

select,
textarea,
input[type="range"] {
  width: 100%;
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
}

select:focus,
textarea:focus,
input[type="range"]:focus {
  outline: 2px solid rgba(15, 131, 150, 0.28);
  outline-offset: 1px;
}

textarea {
  min-height: 180px;
  line-height: 1.6;
  resize: vertical;
}

.hint {
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.style-meta {
  margin: 10px 0 2px;
  min-height: 1.3em;
  font-size: 13px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.control-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px 12px;
  background: rgba(255, 255, 255, 0.7);
}

.range-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 7px;
}

.range-head output {
  font-family: "M PLUS Rounded 1c", sans-serif;
  color: var(--accent-strong);
}

input[type="range"] {
  accent-color: var(--accent);
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

button {
  appearance: none;
  border-radius: 12px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

#synthesizeBtn {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-sub));
  box-shadow: 0 14px 24px rgba(12, 92, 108, 0.25);
}

#synthesizeBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 28px rgba(12, 92, 108, 0.29);
}

#synthesizeBtn:disabled {
  opacity: 0.85;
  cursor: wait;
}

.alt-btn {
  padding: 8px 12px;
  border-radius: 10px;
  border-color: var(--line);
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.8);
}

.alt-btn:hover {
  transform: translateY(-1px);
  background: rgba(243, 252, 251, 0.95);
}

.alt-btn.is-active {
  border-color: rgba(15, 131, 150, 0.4);
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-sub));
}

.speaker-filters {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-btn {
  padding: 7px 12px;
  border-radius: 999px;
  border-color: var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  box-shadow: none;
}

.chip-btn:hover {
  transform: none;
  background: rgba(238, 247, 246, 0.95);
  color: var(--ink);
}

.chip-btn.is-active {
  color: var(--accent-strong);
  border-color: rgba(15, 131, 150, 0.35);
  background: linear-gradient(130deg, rgba(15, 131, 150, 0.18), rgba(236, 129, 53, 0.2));
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.download {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.65);
  pointer-events: none;
  opacity: 0.45;
}

.download.ready {
  pointer-events: auto;
  opacity: 1;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.output-device-box {
  margin-top: 14px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.output-head {
  margin-top: 0;
  align-items: center;
}

.output-head label {
  margin: 0 0 8px;
}

.output-refresh-btn {
  font-size: 12px;
  padding: 6px 10px;
}

.output-note {
  margin: 8px 0 0;
  min-height: 1.3em;
}

.output-note.error {
  color: var(--danger);
}

.status {
  margin: 14px 0;
  min-height: 1.35em;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--danger);
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  white-space: nowrap;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0)) 0 0 / 120px 100% no-repeat,
    linear-gradient(90deg, var(--accent), var(--accent-sub));
  transition: width 0.24s ease;
}

.fx-stage {
  margin-top: 14px;
  height: 210px;
  border-radius: 18px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 30% 20%, rgba(15, 131, 150, 0.2), transparent 45%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.95), rgba(223, 242, 241, 0.82));
}

.ring {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 150px;
  height: 150px;
  border-radius: 999px;
  border: 2px solid rgba(15, 131, 150, 0.25);
  opacity: 0;
  transform: scale(0.8);
}

.ring-two {
  width: 180px;
  height: 180px;
}

.core {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 62px;
  height: 62px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.95), rgba(15, 131, 150, 0.45));
  box-shadow: 0 0 0 0 rgba(15, 131, 150, 0.35);
  transform: scale(0.95);
}

.bars {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  margin: 0 auto;
  width: min(92%, 320px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.bars span {
  width: 6%;
  max-width: 13px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(15, 131, 150, 0.8));
  opacity: 0.3;
  transform-origin: bottom;
  animation: equalizer 0.9s ease-in-out infinite;
  animation-play-state: paused;
}

.bars span:nth-child(2n) {
  animation-duration: 1.1s;
}

.bars span:nth-child(3n) {
  animation-duration: 1.3s;
}

.bars span:nth-child(4n) {
  animation-duration: 1s;
}

.is-generating .bars span {
  animation-play-state: running;
  opacity: 1;
}

.is-generating .ring-one {
  animation: ringPulse 1.6s ease-out infinite;
}

.is-generating .ring-two {
  animation: ringPulse 1.6s 0.5s ease-out infinite;
}

.is-generating .core {
  animation: corePulse 1.3s ease-in-out infinite;
}

.is-generating #synthesizeBtn {
  position: relative;
}

.is-generating #synthesizeBtn::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  display: inline-block;
  margin-left: 8px;
  vertical-align: -2px;
  animation: spin 0.75s linear infinite;
}

audio {
  margin-top: 14px;
  width: 100%;
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: revealUp 0.75s var(--delay, 0s) cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0% {
    transform: translate3d(0, 0, 0);
  }

  100% {
    transform: translate3d(20px, 14px, 0);
  }
}

@keyframes equalizer {
  0%,
  100% {
    transform: scaleY(0.35);
  }

  50% {
    transform: scaleY(1.8);
  }
}

@keyframes ringPulse {
  0% {
    opacity: 0.55;
    transform: scale(0.5);
  }

  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@keyframes corePulse {
  0%,
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(15, 131, 150, 0.3);
  }

  55% {
    transform: scale(1.12);
    box-shadow: 0 0 0 20px rgba(15, 131, 150, 0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .studio {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 24px 12px 40px;
  }

  .panel {
    padding: 16px;
    border-radius: 16px;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .speaker-head {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .speaker-head label {
    margin-bottom: 0;
  }

  .alt-btn,
  .chip-btn {
    width: fit-content;
  }

  .status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .fx-stage {
    height: 180px;
  }
}
