/**
 * Legado TTS Console - Refined Modern Linear Style
 * Symmetrical balanced cards, compact density, border-driven elevation,
 * segmented provider bar, integrated playground tabs, and smooth bezier micro-interactions.
 */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  /* Dark Theme (Linear / Vercel Modern Minimal) */
  --bg-body: #0a0c10;
  --bg-panel: #12151c;
  --bg-subtle: #181c26;
  --bg-input: #0e1117;
  --bg-hover: #1e2330;
  --bg-active: #262c3d;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #64748b;
  
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.14);
  --accent-glow: 0 0 14px rgba(99, 102, 241, 0.25);
  
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --yellow: #f59e0b;
  --yellow-soft: rgba(245, 158, 11, 0.12);
  
  --radius: 10px;
  --radius-sm: 6px;
  --radius-pill: 9999px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);

  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.25, 1, 0.5, 1);
}

[data-theme="light"] {
  --bg-body: #f6f8fb;
  --bg-panel: #ffffff;
  --bg-subtle: #f1f4f9;
  --bg-input: #ffffff;
  --bg-hover: #e2e8f0;
  --bg-active: #cbd5e1;
  
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --border-focus: rgba(79, 70, 229, 0.5);
  
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.08);
  --accent-glow: 0 0 14px rgba(79, 70, 229, 0.18);
  
  --green-soft: rgba(16, 185, 129, 0.1);
  --red-soft: rgba(239, 68, 68, 0.1);
  --yellow-soft: rgba(245, 158, 11, 0.1);
  
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  transition: background-color 0.22s var(--ease-smooth), color 0.22s var(--ease-smooth);
}

button, input, select, textarea {
  color: inherit;
  font: inherit;
  outline: none;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  user-select: none;
}

a {
  color: inherit;
  text-decoration: none;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 500;
  transform: translateY(-160%);
  transition: transform 0.18s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ==========================================================================
   Main Centered App Shell
   ========================================================================== */

.app-shell {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* ==========================================================================
   1. Header Bar & Navigation Tabs (Fixed Active Background State)
   ========================================================================== */

.header {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease;
}

.header:hover {
  border-color: var(--border-strong);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.brand-title {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.version-tag {
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--green);
  background: var(--green-soft);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.status-badge.is-online {
  color: var(--green);
  background: var(--green-soft);
}

.status-badge.is-loading {
  color: var(--yellow);
  background: var(--yellow-soft);
}

.status-badge.is-error {
  color: var(--red);
  background: var(--red-soft);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: pulseSoft 2s infinite;
}

@keyframes pulseSoft {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}

/* Nav Tabs: Active state applies ONLY to the active tab */
.nav-tabs {
  display: flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-main);
}

.nav-tab-btn.is-active,
.nav-tab-btn.active {
  background: var(--bg-panel) !important;
  color: var(--text-main) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.18s ease;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* ==========================================================================
   2. Top Stats Strip
   ========================================================================== */

.stats-strip {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 16px;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease;
}

.stats-strip:hover {
  border-color: var(--border-strong);
}

.stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.stat-item:not(:last-child) {
  border-right: 1px solid var(--border);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 550;
}

.stat-val {
  font-size: 15.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-main);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-badge {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--green);
  background: var(--green-soft);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   3. Main Symmetrical Workspace Grid (No excessive whitespace)
   ========================================================================== */

.workspace-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.workspace-grid[hidden] {
  display: none;
}

/* Unified Box Card - Compact & Natural Height */
.box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease;
}

.box:hover {
  border-color: var(--border-strong);
}

.box-header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  min-height: 42px;
}

.box-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.box-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  flex: 1;
}

/* 5-Column Clean Provider Segment */
.provider-segment {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.provider-item {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 6px 2px;
  text-align: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.18s var(--ease-spring);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.provider-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.provider-item.is-active,
.provider-item.active {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), var(--accent-glow);
}

.provider-item .p-title {
  font-size: 11.5px;
  white-space: nowrap;
  font-weight: 600;
}

.provider-item .p-sub {
  font-size: 9.5px;
  opacity: 0.8;
  white-space: nowrap;
}

/* Form Elements */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.credential-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.credential-badge.is-ready {
  background: var(--green-soft);
  color: var(--green);
}

.credential-badge.is-missing {
  background: var(--yellow-soft);
  color: var(--yellow);
}

.input-control, .select-control, .textarea-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-control:focus, .select-control:focus, .textarea-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.input-control::placeholder,
.textarea-control::placeholder {
  color: var(--text-muted);
}

.select-control:disabled,
.input-control:disabled,
.textarea-control:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Info box */
.info-box {
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.info-box.success {
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--green);
  background: var(--green-soft);
}

/* Compact Toggle Switch */
.toggle-switch {
  position: relative;
  width: 30px;
  height: 16px;
  display: inline-block;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-active);
  border-radius: 20px;
  transition: .18s ease;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: #fff;
  border-radius: 50%;
  transition: .18s ease;
}

input:checked + .toggle-slider {
  background-color: var(--accent);
}

input:checked + .toggle-slider:before {
  transform: translateX(14px);
}

/* Integrated Clean Subscribe Bar & Buttons */
.subscribe-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
}

.subscribe-input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  outline: none;
  min-width: 0;
}

/* Code Preview */
.config-preview {
  max-height: 120px;
  overflow: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #38bdf8;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 550;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s var(--ease-spring);
  white-space: nowrap;
  user-select: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 4px rgba(99, 102, 241, 0.3), var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red-soft);
  border-color: rgba(239, 68, 68, 0.25);
  color: var(--red);
}

.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11.5px;
}

.btn[aria-busy="true"]::before {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 0.6s linear infinite;
}

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

/* Save status chip */
.save-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.save-chip.is-saved {
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.2);
  background: var(--green-soft);
}

.save-chip.is-dirty {
  color: var(--yellow);
  border-color: rgba(245, 158, 11, 0.2);
  background: var(--yellow-soft);
}

/* ==========================================================================
   Right Column Sub-Tabs & Playground
   ========================================================================== */

.sub-tabs {
  display: flex;
  gap: 3px;
}

.sub-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.sub-tab-btn:hover {
  color: var(--text-main);
}

.sub-tab-btn.is-active,
.sub-tab-btn.active {
  background: var(--bg-panel) !important;
  color: var(--text-main) !important;
  border-color: var(--border) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  font-weight: 600;
}

.audio-player-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.audio-player {
  width: 100%;
  height: 32px;
  border-radius: var(--radius-sm);
  filter: invert(0.88) hue-rotate(180deg);
}

[data-theme="light"] .audio-player {
  filter: none;
}

.audio-player[hidden] {
  display: none;
}

/* Metrics Mini Grid */
.metrics-mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.mini-metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.mini-metric .m-lbl {
  font-size: 9.5px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.mini-metric .m-val {
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
}

/* Live Logs Feed */
.log-container {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 160px;
  overflow-y: auto;
}

.activity-line {
  display: grid;
  grid-template-columns: 60px minmax(65px, 0.6fr) minmax(90px, 1.2fr) auto auto;
  gap: 6px;
  align-items: center;
  padding: 3px 6px;
  background: var(--bg-subtle);
  border-radius: 4px;
  font-size: 10.5px;
}

.activity-line.is-error {
  color: var(--red);
}

.activity-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-line .activity-ok {
  color: var(--green);
}

.empty-state {
  padding: 20px 10px;
  color: var(--text-muted);
  font-size: 11.5px;
  text-align: center;
}

/* ==========================================================================
   4. Custom Voice Manager (Redesigned & Polished)
   ========================================================================== */

.custom-voice-manager {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.custom-voice-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
}

.custom-voice-provider {
  font-size: 10px;
  padding: 1px 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-pill);
}

.custom-voice-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-voice-form-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.custom-voice-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.custom-voice-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.custom-voice-item.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.custom-voice-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.custom-voice-copy strong {
  font-size: 11.5px;
}

.custom-voice-copy small {
  font-size: 9.5px;
  color: var(--text-muted);
}

.custom-voice-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.custom-voice-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.14s ease;
}

.custom-voice-icon:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.custom-voice-icon.is-danger:hover {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
  background: var(--red-soft);
}

/* ==========================================================================
   5. Maintenance Grid View
   ========================================================================== */

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

.maint-grid[hidden] {
  display: none;
}

/* ==========================================================================
   Inline Feedback Alerts
   ========================================================================== */

.inline-feedback {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.inline-feedback[hidden] {
  display: none;
}

.inline-feedback.is-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(16, 185, 129, 0.2);
}

.inline-feedback.is-warning {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-color: rgba(245, 158, 11, 0.2);
}

.inline-feedback.is-error {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Voice Library Dialog Modal
   ========================================================================== */

.voice-dialog {
  width: min(820px, calc(100% - 28px));
  max-height: min(80vh, 640px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-main);
  box-shadow: var(--shadow);
}

.voice-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  display: flex;
  flex-direction: column;
  max-height: min(80vh, 640px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.dialog-close {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dialog-close:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.dialog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}

.voice-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 12px 16px;
  overflow-y: auto;
}

.voice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.voice-card.is-current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.voice-card-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.voice-card-copy strong {
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-card-copy small {
  font-size: 9.5px;
  color: var(--text-muted);
}

.voice-card-actions {
  display: flex;
  gap: 4px;
}

.voice-card-actions .btn {
  padding: 3px 8px;
  font-size: 10.5px;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */

.toast-region {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  animation: toastIn 0.22s var(--ease-spring);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast.is-success { border-left: 3px solid var(--green); }
.toast.is-warning { border-left: 3px solid var(--yellow); }
.toast.is-error { border-left: 3px solid var(--red); }

.toast-message {
  flex: 1;
}

.toast-close {
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
}

.toast-close:hover {
  color: var(--text-main);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.footer a:hover {
  color: var(--text-main);
}

/* ==========================================================================
   Animations & Responsive
   ========================================================================== */

.fade-in {
  animation: fadeInSlide 0.22s var(--ease-spring);
}

@keyframes fadeInSlide {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-item:nth-child(2) {
    border-right: none;
  }
  .maint-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 10px 12px 24px;
  }
  .header {
    height: auto;
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand-section {
    flex: 1 1 auto;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
  }
  .nav-tab-btn {
    flex: 1;
    text-align: center;
  }
  .provider-segment {
    grid-template-columns: repeat(3, 1fr);
  }
  .provider-item:last-child {
    grid-column: span 2;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}
