:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #1c2424;
  --muted: #63706d;
  --line: #d9e1de;
  --accent: #176b5b;
  --accent-strong: #0f4f43;
  --warning: #a46a13;
  --danger: #b42318;
  --focus: #2b74d7;
  --shadow: 0 16px 44px rgba(24, 40, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

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

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  line-height: 1.35;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

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

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

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

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

label,
dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select,
input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(43, 116, 215, 0.14);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.provider-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.provider-button[aria-selected="true"] {
  border-color: var(--accent);
  background: #dff1eb;
  color: var(--accent-strong);
  font-weight: 750;
}

.provider-button:disabled {
  color: #9aa5a2;
  cursor: not-allowed;
  background: #f3f5f5;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  align-items: center;
  gap: 12px;
}

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

output {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.secondary-button {
  padding: 0 14px;
  border-color: var(--line);
  background: #fff;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 700;
}

.status-pill {
  min-width: 84px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 7px 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.status-pill.ready {
  border-color: #9dd7c6;
  background: #e7f6f1;
  color: var(--accent-strong);
}

.status-pill.error {
  border-color: #f0b5ae;
  background: #fff0ee;
  color: var(--danger);
}

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

.output-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.result-state {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--muted);
  font-weight: 650;
}

.result-state.error {
  border-color: #f0b5ae;
  background: #fff8f7;
  color: var(--danger);
}

.result-state.busy {
  border-color: #e5c47b;
  background: #fffaf0;
  color: var(--warning);
}

.audio-player {
  width: 100%;
}

.result-actions {
  min-height: 42px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.meta-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

dd {
  margin: 6px 0 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 750;
}

.debug-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.debug-panel summary {
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.debug-stack {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.debug-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.debug-output {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101b1b;
  color: #e7f6f1;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 24px, 620px);
    padding-top: 20px;
  }

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

  .workspace,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }
}
