/* Deepgram Voice Studio — dark theme, no gradients, no shadows, single accent */
:root {
  --bg: #0b0d0f;
  --bg-2: #0e1113;
  --panel: #111417;
  --panel-2: #15191d;
  --border: #1e2429;
  --border-strong: #2a3238;
  --text: #e8edf2;
  --text-2: #8b949e;
  --text-3: #5c6670;
  --accent: #2dd4bf;
  --accent-dim: #134e4a;
  --accent-text: #04211d;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  --r-lg: 8px;
  --topbar-h: 52px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-dim); color: var(--text); }

h1, h2, h3 { letter-spacing: -0.01em; margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--panel); color: var(--text); padding: 8px 12px; z-index: 200;
}
.skip-link:focus { left: 8px; top: 8px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.view {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 64px;
  max-width: 1160px;
}
.topbar { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
.brand-name { font-weight: 600; font-size: 14px; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav { list-style: none; margin: 8px 0; padding: 0 8px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  color: var(--text-2);
  font-size: 13.5px;
  text-decoration: none;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); background: var(--panel); text-decoration: none; }
.nav a.active {
  color: var(--text);
  background: var(--panel-2);
  border-color: var(--border-strong);
}
.nav a.active .nav-ic { color: var(--accent); }
.nav-ic { width: 17px; height: 17px; display: inline-flex; color: var(--text-3); }
.nav-ic svg { width: 100%; height: 100%; }
.sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.health-line { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.health-dot.ok { background: var(--ok); }
.health-dot.bad { background: var(--danger); }
.health-pill { font-size: 12px; color: var(--text-2); margin-left: auto; display: flex; align-items: center; gap: 7px; }

/* ---------- panels / cards ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-bottom: 16px;
}
.panel-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.panel-title h2 { display: flex; align-items: center; gap: 8px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--text-2); font-size: 13px; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 140px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.char-count {
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  text-align: right; margin-top: 4px; font-variant-numeric: tabular-nums;
}
.char-count.over { color: var(--danger); }

/* toggle switches */
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.toggle {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  user-select: none;
  background: var(--bg-2);
}
.toggle:hover { border-color: var(--border-strong); color: var(--text); }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track {
  width: 28px; height: 16px; border-radius: 8px;
  background: var(--border-strong);
  position: relative; flex-shrink: 0;
  transition: background 0.15s;
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .track { background: var(--accent-dim); }
.toggle input:checked + .track::after { transform: translateX(12px); background: var(--accent); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  padding: 7px 13px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #4be0cb; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn .spin { width: 13px; height: 13px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: var(--r);
  color: var(--text-2); cursor: pointer; padding: 5px;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
.icon-btn svg { width: 17px; height: 17px; }

.spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- error / notice blocks ---------- */
.error-block {
  background: rgba(248, 113, 113, 0.07);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-top: 12px;
}
.error-block .err-title { color: var(--danger); font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.error-block pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: var(--panel-2);
  border-radius: var(--r);
  padding: 10px 13px;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 14px;
}

pre, code { font-family: var(--mono); font-size: 12.5px; }
pre.code-block {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.55;
  margin: 0;
}
.code-wrap { position: relative; }
.code-wrap .copy-btn { position: absolute; top: 8px; right: 8px; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; color: var(--text-3); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.tnum { font-variant-numeric: tabular-nums; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--border-strong); color: var(--text-2);
}
.badge.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); }
.badge.err { color: var(--danger); border-color: rgba(248, 113, 113, 0.4); }
.badge.accent { color: var(--accent); border-color: var(--accent-dim); }

/* ---------- voice picker / cards ---------- */
.voice-picker { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.voice-picker-head { padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.voice-groups { max-height: 340px; overflow-y: auto; }
.voice-group-label {
  padding: 8px 12px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em;
  position: sticky; top: 0; background: var(--panel);
}
.voice-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; cursor: pointer; border: 1px solid transparent;
}
.voice-item:hover { background: var(--panel-2); }
.voice-item.selected { background: var(--panel-2); border-color: var(--border-strong); }
.voice-item .flag { font-size: 15px; }
.voice-item .vname { font-weight: 500; font-size: 13px; }
.voice-item .vid { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.voice-item .spacer { flex: 1; }
.voice-item .feat { color: var(--warn); }

.voice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.voice-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.voice-card:hover { border-color: var(--border-strong); }
.voice-card .vc-top { display: flex; align-items: center; gap: 9px; }
.voice-card .flag { font-size: 18px; }
.voice-card .vname { font-weight: 600; font-size: 14px; }
.voice-card .vlang { font-size: 12px; color: var(--text-3); }
.voice-card .vid { font-family: var(--mono); font-size: 11px; color: var(--text-3); word-break: break-all; }
.voice-card .vc-actions { display: flex; gap: 8px; margin-top: 2px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 11px; border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: transparent; color: var(--text-2);
  font-size: 12px; font-family: inherit; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 34px 20px;
  text-align: center;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: var(--text-3); }
.dropzone.drag { border-color: var(--accent); background: rgba(45, 212, 191, 0.05); color: var(--text); }
.dropzone svg { width: 26px; height: 26px; color: var(--text-3); margin-bottom: 8px; }
.dropzone .dz-main { font-size: 14px; color: var(--text); font-weight: 500; }
.dropzone .dz-sub { font-size: 12px; margin-top: 3px; }
.file-pill {
  display: inline-flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 7px 12px; font-size: 13px; margin-top: 12px;
}

/* ---------- stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.stat-card .s-label { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-card .s-value { font-size: 24px; font-weight: 600; margin-top: 5px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-card .s-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* CSS-only bar chart */
.bar-chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 170px; padding: 12px 4px 0;
}
.bar-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; height: 100%; gap: 6px;
}
.bar-stack { width: 100%; max-width: 46px; display: flex; flex-direction: column-reverse; gap: 1px; }
.bar-seg { width: 100%; border-radius: 2px 2px 0 0; min-height: 2px; }
.bar-seg.tts { background: var(--accent); }
.bar-seg.stt { background: var(--text-3); }
.bar-label {
  font-size: 10.5px; color: var(--text-3); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.bar-val { font-size: 10.5px; color: var(--text-2); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend .lg { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .sw.tts { background: var(--accent); }
.legend .sw.stt { background: var(--text-3); }

/* ---------- misc ---------- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.audio-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
audio { height: 36px; max-width: 100%; }
.empty {
  padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 13px;
  border: 1px dashed var(--border); border-radius: var(--r-lg);
}
details.raw-json { margin-top: 14px; }
details.raw-json summary {
  cursor: pointer; font-size: 12.5px; color: var(--text-2);
  padding: 6px 0; user-select: none;
}
details.raw-json summary:hover { color: var(--text); }

.transcript-box {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}

.toasts {
  position: fixed; bottom: 18px; right: 18px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
}
.toast {
  background: var(--panel-2); border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--r); padding: 10px 14px; font-size: 13px;
  animation: toast-in 0.18s ease-out;
}
.toast.err { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-2); font-size: 13px; font-family: inherit; font-weight: 500;
  padding: 8px 12px; cursor: pointer; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .topbar {
    display: flex; align-items: center; gap: 10px;
    height: var(--topbar-h);
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-2);
    position: sticky; top: 0; z-index: 100;
  }
  .topbar-title { font-weight: 600; font-size: 14px; }
  .shell { display: block; min-height: calc(100vh - var(--topbar-h)); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 150;
    width: 260px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .nav-overlay {
    position: fixed; inset: 0; z-index: 140;
    background: rgba(0, 0, 0, 0.55);
  }
  .view { padding: 18px 16px 56px; max-width: none; }
  .ellipsis { max-width: 160px; }
}
@media (min-width: 901px) {
  .nav-overlay { display: none; }
}
