:root {
  --page: #f7f8fc;
  --surface: #ffffff;
  --soft: #f0f2f8;
  --line: #e2e5ed;
  --line-strong: #cfd4e0;
  --navy: #07152f;
  --text: #182238;
  --muted: #747d90;
  --blue: #4267f5;
  --blue-soft: #eef1ff;
  --danger: #d84f4a;
  --sans: "Inter", sans-serif;
  --mono: "DM Mono", monospace;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--page);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, a, summary, input[type="range"] { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--navy);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
}

.brand-symbol {
  display: flex;
  width: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 50%;
  background: var(--navy);
}

.brand-symbol i {
  width: 2px;
  border-radius: 2px;
  background: #fff;
}

.brand-symbol i:nth-child(1), .brand-symbol i:nth-child(5) { height: 6px; }
.brand-symbol i:nth-child(2), .brand-symbol i:nth-child(4) { height: 12px; }
.brand-symbol i:nth-child(3) { height: 18px; }

.workspace {
  width: min(1280px, calc(100% - 56px));
  margin: 0 auto;
}

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

.studio-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.65fr);
  align-items: end;
  gap: 70px;
  padding: 42px 0 54px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 19px;
  color: var(--blue);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
}

.eyebrow span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px var(--blue-soft);
}

h1 {
  margin: 0;
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(68px, 7vw, 108px);
  font-weight: 400;
  line-height: 0.91;
  letter-spacing: 0;
}

h1 em { color: var(--blue); font-weight: 400; }

.intro-aside {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hero-signal {
  display: flex;
  width: min(100%, 480px);
  height: 92px;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.hero-signal span {
  width: 4px;
  height: 12px;
  flex: 0 0 4px;
  border-radius: 999px;
  background: #6f88ff;
  box-shadow: 0 0 12px rgba(66, 103, 245, 0.16);
  animation: signal-idle 2.4s ease-in-out infinite alternate;
  transform-origin: center;
}

.hero-signal span:nth-child(2n) { height: 27px; animation-delay: -1.4s; }
.hero-signal span:nth-child(3n) { height: 48px; animation-delay: -0.7s; }
.hero-signal span:nth-child(4n) { height: 67px; animation-delay: -2s; }
.hero-signal span:nth-child(5n) { height: 36px; animation-delay: -0.3s; }
.hero-signal span:nth-child(7n) { height: 82px; animation-delay: -1.8s; }

@keyframes signal-idle {
  0% { transform: scaleY(0.72); opacity: 0.45; }
  100% { transform: scaleY(1); opacity: 1; }
}

body:has(.status.working) .hero-signal span {
  animation-duration: 520ms;
}

.intro-copy {
  max-width: 420px;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.7;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.7fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(20, 35, 70, 0.08);
}

.composer, .settings-panel { padding: 32px; }

.settings-panel {
  border-left: 1px solid var(--line);
  background: #fafbfe;
}

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

.panel-heading > div { display: flex; align-items: center; }
.section-number { display: none; }

.studio-kicker {
  margin-right: 12px;
  padding: 5px 8px;
  border-radius: 4px;
  color: var(--blue);
  background: var(--blue-soft);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
}

h2 {
  margin: 0;
  color: var(--navy);
  font-size: 19px;
  font-weight: 600;
}

#char-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px;
  border-radius: 7px;
  background: var(--soft);
}

.mode-tab {
  display: flex;
  min-width: 0;
  height: 55px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.mode-tab span { font-size: 11px; font-weight: 600; }

.mode-tab small {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-tab:hover { color: var(--navy); }

.mode-tab.active {
  color: var(--navy);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(20, 35, 70, 0.08);
}

.text-field {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.script-section .text-field {
  border-color: #d8deea;
  background: #fbfcff;
  box-shadow: inset 0 1px 3px rgba(20, 35, 70, 0.03);
}

.script-section textarea {
  min-height: 310px;
  background: transparent;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.text-field > label {
  position: absolute;
  top: 17px;
  left: 19px;
  z-index: 1;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  color: var(--text);
  background: var(--surface);
  transition: border-color 150ms, box-shadow 150ms;
}

input, select { min-height: 47px; padding: 0 13px; font-size: 14px; }

textarea {
  min-height: 245px;
  padding: 50px 19px 42px;
  border: 0;
  resize: vertical;
  font-size: 20px;
  line-height: 1.65;
}

textarea::placeholder, input::placeholder { color: #b0b5c0; }

input:focus, textarea:focus, select:focus {
  border-color: rgba(66, 103, 245, 0.65);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.language-tag,
.editor-meta {
  position: absolute;
  right: 17px;
  bottom: 14px;
  color: #9aa1b0;
  font-family: var(--mono);
  font-size: 9px;
}

.editor-meta {
  display: flex;
  gap: 14px;
  align-items: center;
}

.editor-meta span + span {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.expression-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid #dce2f3;
  border-radius: 8px;
  background: var(--blue-soft);
}

.expression-bar select {
  min-width: 230px;
  background: var(--surface);
}

.expression-bar .secondary {
  min-height: 47px;
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.expression-control {
  display: grid;
  grid-template-columns: minmax(150px, 0.6fr) minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
}

.expression-control label {
  margin-bottom: 4px;
  color: var(--navy);
}

.expression-control span {
  color: var(--muted);
  font-size: 10px;
}

.mode-panel {
  margin-top: 14px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafbfe;
}

.clone-panel {
  margin-top: 0;
  padding: 24px;
  border-color: #dce2f3;
  background: #f8f9ff;
  box-shadow: inset 4px 0 0 var(--blue);
}

.script-section {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.script-heading > div {
  display: flex;
  align-items: center;
  gap: 14px;
}

.script-heading label {
  margin: 0 0 3px;
  color: var(--navy);
}

.script-heading span { color: var(--muted); font-size: 10px; }

.step-number {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid #ccd5f4;
  border-radius: 50%;
  color: var(--blue);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 9px;
}

.clone-grid, .upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
}

.clone-grid {
  grid-template-columns: minmax(0, 1fr) 45px;
}

.active-voice-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #cfd8ff;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(66, 103, 245, 0.08);
}

.active-voice-icon {
  display: flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 50%;
  background: var(--blue-soft);
}

.active-voice-icon span {
  width: 2px;
  height: 11px;
  border-radius: 2px;
  background: var(--blue);
}

.active-voice-icon span:nth-child(2) {
  height: 22px;
}

.active-voice-card label {
  margin-bottom: 4px;
  color: var(--blue);
  font-size: 8px;
}

.active-voice-card strong,
.active-voice-card span {
  display: block;
}

.active-voice-card strong {
  overflow: hidden;
  color: var(--navy);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.active-voice-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.active-voice-card .secondary {
  min-height: 40px;
}

.clone-intro {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 24px;
}

.clone-intro h3 {
  margin: 0 0 4px;
  color: var(--navy);
  font-size: 15px;
  font-weight: 600;
}

.clone-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.clone-orb {
  display: flex;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 50%;
  background: var(--blue-soft);
}

.clone-orb span {
  width: 2px;
  height: 10px;
  border-radius: 2px;
  background: var(--blue);
}

.clone-orb span:nth-child(2) { height: 20px; }

.upload-grid {
  grid-template-columns: minmax(220px, 0.72fr) minmax(320px, 1.28fr);
  gap: 18px;
}

.icon-button {
  width: 45px;
  height: 45px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--danger);
  background: var(--surface);
  font-size: 20px;
  cursor: pointer;
}

.upload-drawer {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.upload-drawer summary {
  padding: 15px 0 2px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.upload-drawer form { padding-top: 18px; }
.upload-drawer form > label { margin-top: 16px; }

.reference-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
}

.reference-heading label {
  margin: 0;
}

.reference-heading span {
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--blue);
  background: var(--blue-soft);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
}

.audio-upload input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.audio-source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 6px;
  background: var(--soft);
}

.audio-source-tab {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.audio-source-tab.active {
  color: var(--navy);
  background: var(--surface);
  box-shadow: 0 1px 5px rgba(20, 35, 70, 0.08);
}

.record-source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 94px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.record-button {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--navy);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.record-button:hover {
  border-color: var(--blue);
}

.record-button.recording {
  border-color: #f0b8b5;
  color: var(--danger);
  background: #fff7f6;
}

.record-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

.recording .record-dot {
  border-radius: 2px;
  animation: record-pulse 700ms infinite alternate;
}

@keyframes record-pulse {
  to { opacity: 0.35; }
}

.record-time {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.record-preview {
  grid-column: 1 / -1;
  width: 100%;
  height: 38px;
}

.file-drop {
  display: flex;
  min-height: 94px;
  align-items: center;
  gap: 13px;
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}

.file-drop:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.file-drop > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.file-drop strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-drop small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
}

.upload-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 17px;
}

.small-textarea {
  min-height: 108px;
  margin-top: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  font-size: 16px;
  line-height: 1.7;
}

.hint, .muted { color: var(--muted); font-size: 10px; }

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 15px;
}

.upload-actions .hint { margin: 0; line-height: 1.5; }
.upload-submit { min-width: 145px; }

body:not(.is-development) .upload-drawer {
  margin-top: 0;
  border-top: 0;
}

body.has-active-voice:not(.is-development) .upload-drawer {
  display: none;
}

body:not(.is-development) .upload-drawer > summary {
  display: none;
}

.settings-panel .panel-heading { margin-bottom: 35px; }

.control {
  padding: 0 0 31px;
  border-bottom: 1px solid var(--line);
}

.control + .control { padding-top: 29px; }

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.field-label-row label { margin: 0; }

output {
  color: var(--blue);
  font-family: var(--mono);
  font-size: 11px;
}

input[type="range"] {
  min-height: 0;
  height: 4px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--line);
  accent-color: var(--blue);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  color: #a1a7b3;
  font-family: var(--mono);
  font-size: 9px;
}

.engine-specs { margin-top: 28px; }

.engine-specs div {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.engine-specs span { color: var(--muted); }
.engine-specs strong { color: var(--navy); font-weight: 600; }

.transport {
  position: relative;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  min-height: 92px;
  align-items: center;
  gap: 28px;
  padding: 18px 28px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(20, 35, 70, 0.08);
}

.progress-track {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  overflow: hidden;
  background: transparent;
  opacity: 0;
  transition: opacity 180ms ease;
}

.progress-track span {
  display: block;
  width: 38%;
  height: 100%;
  border-radius: 0 999px 999px 0;
  background: var(--blue);
  transform: translateX(-110%);
}

.transport:has(.status.working) .progress-track {
  opacity: 1;
  background: var(--blue-soft);
}

.transport:has(.status.working) .progress-track span {
  animation: progress-sweep 1.3s ease-in-out infinite;
}

.progress-track.determinate span {
  width: var(--progress, 0%);
  transform: none;
  transition: width 180ms ease;
  animation: none !important;
}

@keyframes progress-sweep {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(130%); }
  100% { transform: translateX(290%); }
}

.visualizer {
  display: flex;
  height: 34px;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.visualizer span {
  width: 2px;
  height: 4px;
  flex: 0 0 2px;
  border-radius: 3px;
  background: var(--blue);
  opacity: 0.35;
}

.visualizer span:nth-child(3n) { height: 12px; }
.visualizer span:nth-child(4n) { height: 21px; }
.visualizer span:nth-child(5n) { height: 8px; }
.visualizer span:nth-child(7n) { height: 29px; }

.transport:has(.status.working) .visualizer span { animation: waveform 650ms ease-in-out infinite alternate; opacity: 0.8; }
.transport:has(.status.working) .visualizer span:nth-child(2n) { animation-delay: -240ms; }
.transport:has(.status.working) .visualizer span:nth-child(3n) { animation-delay: -410ms; }
.transport:has(.status.working) .visualizer span:nth-child(5n) { animation-delay: -130ms; }

@keyframes waveform { to { height: 31px; } }

.status {
  display: flex;
  min-width: 155px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #36b37e;
}

.status.working { color: var(--blue); }
.status.working .status-dot { background: var(--blue); animation: pulse 500ms infinite alternate; }
.status.error { color: var(--danger); }
.status.error .status-dot { background: var(--danger); }

@keyframes pulse { to { opacity: 0.25; } }

.actions { display: flex; gap: 8px; }

.primary, .secondary {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.primary {
  min-width: 178px;
  border: 1px solid var(--navy);
  color: #fff;
  background: var(--navy);
}

.primary:hover { background: #14284d; }

.secondary {
  border: 1px solid var(--line-strong);
  color: var(--navy);
  background: var(--surface);
}

.secondary:hover { background: var(--soft); }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.play-icon { margin-right: 9px; font-size: 8px; }
.hidden { display: none !important; }
.dev-only { display: none; }
body.is-development .dev-only { display: block; }

footer {
  display: flex;
  justify-content: space-between;
  padding: 25px 2px 38px;
  color: #a1a7b3;
  font-family: var(--mono);
  font-size: 9px;
}

@media (max-width: 900px) {
  .intro { gap: 38px; }
  .studio-grid { grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr); }
  .composer, .settings-panel { padding: 25px; }
}

@media (max-width: 760px) {
  .workspace { width: min(100% - 32px, 1280px); }
  .topbar { height: 70px; }
  .intro { grid-template-columns: 1fr; gap: 25px; padding: 32px 0 40px; }
  .intro-aside { gap: 18px; }
  .hero-signal { width: 390px; height: 82px; }
  .intro-copy { max-width: 560px; }
  .studio-grid { grid-template-columns: 1fr; }
  .settings-panel { border-top: 1px solid var(--line); border-left: 0; }
  .transport { grid-template-columns: 1fr auto; }
  .visualizer { display: none; }
}

@media (max-width: 520px) {
  .studio-label { display: none; }
  h1 { font-size: 62px; }
  .hero-signal { width: 100%; height: 76px; gap: 5px; }
  .hero-signal span { width: 3px; flex-basis: 3px; }
  .mode-tab { height: 50px; padding: 0 10px; text-align: center; }
  .mode-tab small { display: none; }
  textarea { min-height: 215px; font-size: 16px; }
  .upload-grid { grid-template-columns: 1fr; }
  .active-voice-card { grid-template-columns: auto minmax(0, 1fr); }
  .active-voice-card .secondary { grid-column: 1 / -1; width: 100%; }
  .design-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-actions { align-items: stretch; flex-direction: column; }
  .upload-submit { width: 100%; }
  .transport { grid-template-columns: 1fr; padding: 18px; }
  .actions { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .primary { min-width: 0; }
  .expression-bar { grid-template-columns: 1fr; }
  .expression-control { grid-template-columns: 1fr; gap: 9px; }
  .expression-bar .secondary { width: 100%; }
}
