:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #0f141b;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #a9b4bf;
  --primary: #2f81f7;
  --primary-2: #1f6feb;
  --success: #238636;
  --warn: #d29922;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 20% -10%, #1d2430 0%, var(--bg) 55%);
  color: var(--text);
}

.container {
  max-width: 900px;
  margin: 32px auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}

h1 { margin-top: 0; margin-bottom: 12px; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }

label { display:block; margin: 8px 0 6px; font-weight: 600; color: #d8e0e9; }
textarea, input, select, button {
  width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 10px 12px;
}

.text-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.text-input-wrap textarea {
  flex: 1;
}

.icon-btn {
  width: 42px !important;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions button { width: auto; padding: 10px 16px; cursor: pointer; }
button { background: var(--success); border: none; font-weight: 600; }
button.secondary { background: #30363d; }
button:hover { filter: brightness(1.07); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.mode-switch {
  margin: 14px 0 16px;
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.mode-btn {
  width: auto;
  min-width: 120px;
  padding: 9px 14px;
  background: transparent;
  color: var(--muted);
  border: none;
}
.mode-btn.active {
  color: #fff;
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
}

.selected-ref {
  min-height: 42px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: #c4d0dc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.design-section,
.ref-audio {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.01);
}

.fast-toggle {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.fast-toggle label {
  margin: 0 0 6px;
  font-weight: 500;
  color: var(--muted);
}

.preset-row { margin-bottom: 12px; }
.preset-select-row { width: 100%; }
.preset-select-row select {
  width: min(100%, 440px);
  min-width: 260px;
}
.preset-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.preset-actions-row button {
  width: auto;
  min-width: 140px;
  padding: 10px 16px;
}
.preset-hint { color: var(--muted); font-size: 0.85rem; display: block; margin-top: 6px; }

.hidden { display: none !important; }

audio { width: 100%; margin-top: 14px; }
pre {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 8px;
  min-height: 40px;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .preset-select-row select {
    width: 100%;
    min-width: 0;
  }
  .preset-actions-row {
    flex-wrap: wrap;
  }
}

.manage-voices {
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
}

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.voice-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.voice-meta > span,
.voice-meta > strong {
  display: inline;
}

.voice-description {
  color: var(--muted);
  font-size: 0.9rem;
}

button.danger {
  width: auto;
  background: #8b2e2e;
}


.progress-wrap {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.progress-text {
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #273042;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #46a0ff);
  transition: width 120ms linear;
}

.api-status {
  font-size: 0.7em;
  vertical-align: middle;
  margin-left: 6px;
  color: #555;
  transition: color 0.3s;
}
.api-status.online  { color: #4caf50; }
.api-status.offline { color: #f44336; }
