:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #17202a;
  --muted: #64717f;
  --line: #d9e1e8;
  --accent: #047a7a;
  --accent-strong: #005f63;
  --accent-soft: #dff4f1;
  --warn: #b42318;
  --warn-soft: #ffe7e4;
  --shadow: 0 18px 50px rgba(28, 39, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(224, 242, 241, 0.8), rgba(245, 247, 251, 0) 360px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.hidden {
  display: none !important;
}

.shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 36px;
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.status.ready {
  border-color: rgba(4, 122, 122, 0.32);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.side {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.composer,
.playback,
.details {
  padding: 18px;
}

.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panelHead p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
select,
input[type="number"],
input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 260px;
  padding: 14px;
  line-height: 1.55;
  resize: vertical;
}

select,
input[type="number"],
input[type="text"] {
  height: 44px;
  padding: 0 12px;
}

.readonlyField {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  font-weight: 700;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(4, 122, 122, 0.14);
}

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

.controls {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) 92px;
  gap: 12px;
  margin-top: 14px;
}

.modeSwitch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.modeSwitch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.modeSwitch button.active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 6px 18px rgba(28, 39, 49, 0.08);
}

.cloneBox,
.srtBox {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(4, 122, 122, 0.2);
  border-radius: 8px;
  background: #f7fbfb;
}

.cloneBox input[type="file"],
.srtBox input[type="file"] {
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.refText {
  min-height: 86px;
}

.fileHint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.savedVoiceActions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.savedVoiceActions p {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.savedVoiceButtons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dangerButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(180, 35, 24, 0.24);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  cursor: pointer;
  font-weight: 800;
}

.compact {
  align-content: end;
}

.primaryButton,
.secondaryButton,
.iconButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

.primaryButton {
  width: 100%;
  min-height: 50px;
  margin-top: 16px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
}

.secondaryButton {
  width: 100%;
  min-height: 44px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

.iconButton {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}

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

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.message.error {
  background: var(--warn-soft);
  color: var(--warn);
}

.progressBlock {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(4, 122, 122, 0.22);
  border-radius: 8px;
  background: var(--accent-soft);
}

.progressMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.progressHint {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

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

.estimateGrid div {
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid rgba(4, 122, 122, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.estimateGrid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.estimateGrid strong {
  color: var(--accent-strong);
  font-size: 16px;
}

.progressTrack {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(4, 122, 122, 0.16);
}

.progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #45a29e);
  transition: width 0.35s ease;
}

.audioStage {
  display: grid;
  place-items: center;
  height: 190px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}

.audioStage.hasAudio {
  border-color: rgba(4, 122, 122, 0.25);
  background:
    linear-gradient(135deg, rgba(4, 122, 122, 0.16), rgba(100, 113, 127, 0.08)),
    var(--surface-2);
  color: var(--accent-strong);
}

.stageIcon,
.largeIcon {
  font-size: 34px;
  line-height: 1;
}

.largeIcon {
  font-size: 22px;
  color: var(--accent-strong);
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(4, 122, 122, 0.22);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.metric span {
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  font-size: 18px;
}

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

.downloadButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 1px solid rgba(4, 122, 122, 0.28);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

dl div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  border-bottom: 1px solid var(--line);
}

dl div:last-child {
  border-bottom: 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  font-weight: 800;
}

.spin {
  display: inline-block;
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 880px) {
  .shell {
    padding: 16px;
  }

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

  .grid,
  .controls,
  .modeSwitch,
  .estimateGrid,
  .savedVoiceActions {
    grid-template-columns: 1fr;
  }

  .savedVoiceButtons {
    justify-content: stretch;
  }

  .savedVoiceButtons button {
    flex: 1;
  }

  h1 {
    font-size: 32px;
  }
}
