:root {
  --fg: #1a1a1a;
  --fg-muted: #6b6b6b;
  --bg: #ffffff;
  --accent: #1a1a1a;
  --accent-fg: #ffffff;
  --border: #e2e2e2;
  --error-bg: #fdecec;
  --error-fg: #a32020;
  --error-border: #e0a3a3;
  --radius: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
}

.container {
  max-width: 620px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  text-align: left;
}

.page-header {
  margin-bottom: 32px;
  text-align: center;
}

h1 {
  font-size: 1.875rem;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--fg-muted);
  font-size: 1rem;
  line-height: 1.45;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: -1px;
}

.tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg-muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab:hover:not(.is-active) {
  color: var(--fg);
}

.tab.is-active {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

.input-field[hidden] {
  display: none;
}

.text-input,
.textarea-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus,
.textarea-input:focus {
  border-color: var(--fg);
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.08);
}

.textarea-input {
  min-height: 180px;
  resize: vertical;
  font-family: inherit;
}

.length-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.length-option {
  flex: 1 1 0;
  appearance: none;
  background: var(--bg);
  border: 0;
  padding: 10px 14px;
  margin: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.length-option + .length-option {
  border-left: 1px solid var(--border);
}

.length-option:hover:not(.is-active) {
  color: var(--fg);
}

.length-option.is-active {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.primary-button {
  display: block;
  width: 100%;
  padding: 14px 20px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.primary-button:hover:not(:disabled) {
  opacity: 0.9;
}

.primary-button:disabled,
.primary-button[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.privacy-disclaimer {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--fg-muted);
  text-align: center;
}

.error-mount {
  padding: 12px 14px;
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.error-mount[hidden] {
  display: none;
}

.progress-mount {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.progress-mount[hidden] {
  display: none;
}

.progress-heading {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--fg);
}

.progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9375rem;
  color: var(--fg-muted);
}

.progress-step-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  flex: none;
  display: inline-block;
  box-sizing: border-box;
}

.progress-step[data-state="active"] {
  color: var(--fg);
  font-weight: 600;
}

.progress-step[data-state="active"] .progress-step-icon {
  border-color: var(--accent);
  border-top-color: transparent;
  animation: progress-spin 0.8s linear infinite;
}

.progress-step[data-state="done"] {
  color: var(--fg);
}

.progress-step[data-state="done"] .progress-step-icon {
  background: var(--accent);
  border-color: var(--accent);
}

.progress-step[data-state="pending"] {
  color: var(--fg-muted);
  opacity: 0.7;
}

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

#input-controls-mount.is-busy .text-input,
#input-controls-mount.is-busy .textarea-input {
  opacity: 0.55;
  background: #f5f5f5;
}

#input-controls-mount.is-busy .tab,
#input-controls-mount.is-busy .length-option {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-button[hidden] {
  display: none;
}

#result-panel[hidden] {
  display: none;
}

#input-panel[hidden] {
  display: none;
}

.result-title {
  margin: 0 0 4px;
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.result-audio {
  display: block;
  width: 100%;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.result-download {
  display: inline-block;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.result-download:hover {
  opacity: 0.9;
}

.result-again {
  appearance: none;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.result-again:hover {
  border-color: var(--fg);
  background: #fafafa;
}

.result-transcript {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fafafa;
}

.result-transcript > summary {
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
  list-style: revert;
  user-select: none;
}

.result-transcript-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--fg);
}

.result-transcript-body p {
  margin: 0 0 10px;
}

.result-transcript-body p:last-child {
  margin-bottom: 0;
}

@media (max-width: 520px) {
  .container {
    padding: 32px 18px 48px;
  }
  h1 {
    font-size: 1.625rem;
  }
}
