/* ─── Wisprical Developer Console — Styles ─────────────────────── */
/* Design: Warm stone light + charcoal sidebar + teal accent       */

/* ─── Tokens ──────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-body:           #F8F7F5;
  --bg-surface:        #FFFFFF;
  --bg-surface-raised: #FFFFFF;
  --bg-sidebar:        #1C1E26;
  --bg-sidebar-hover:  #252833;
  --bg-sidebar-active: #2C3040;
  --bg-code:           #F3F2EF;
  --bg-code-header:    #EBEAE6;
  --bg-input:          #FFFFFF;
  --bg-badge-success:  #F0FDF4;
  --bg-badge-error:    #FEF2F2;
  --bg-badge-warning:  #FEF9EE;
  --bg-badge-info:     #EFF6FF;
  --bg-badge-neutral:  #F5F5F3;

  /* Borders */
  --border-default:     #E8E6E0;
  --border-subtle:      #F0EEE9;
  --border-sidebar:     #2A2D37;
  --border-input:       #D9D6D0;
  --border-input-focus: #2A9D8F;

  /* Text */
  --text-primary:        #1A1A1A;
  --text-secondary:      #4A4A4A;
  --text-tertiary:       #9A9A9A;
  --text-sidebar:        #A0A4B0;
  --text-sidebar-active: #FFFFFF;

  /* Accent */
  --accent:       #2A9D8F;
  --accent-hover: #238578;
  --accent-light: #E6F5F2;

  /* Status */
  --status-success:    #16A34A;
  --status-warning:    #CA8A04;
  --status-error:      #DC2626;
  --status-info:       #2563EB;

  /* Channel colors */
  --ch-grpc:  #2A9D8F;
  --ch-http:  #E89B3E;
  --ch-ws:    #7C6EDB;
  --ch-relay: #DC2626;

  /* JSON syntax */
  --jt-key:  #1A7F71;
  --jt-str:  #B35309;
  --jt-num:  #7C3AED;
  --jt-bool: #DC2626;
  --jt-null: #DC2626;
  --jt-punc: var(--text-secondary);
}

/* ─── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ──────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ─── Sidebar ─────────────────────────────────────────────────── */
#sidebar {
  width: 240px;
  min-width: 240px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-sidebar);
  transition: width 200ms ease, min-width 200ms ease;
  overflow: hidden;
}
#sidebar.collapsed { width: 64px; min-width: 64px; }

.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-sidebar);
}
.sb-logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700;
}
.sb-logo-text {
  color: white;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 150ms ease;
}
#sidebar.collapsed .sb-logo-text { opacity: 0; pointer-events: none; }

.sb-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.sb-section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #555A6B;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 150ms ease;
}
#sidebar.collapsed .sb-section-label { opacity: 0; height: 0; padding: 0; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  height: 36px;
  color: var(--text-sidebar);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
  user-select: none;
  position: relative;
}
.sb-item:hover { background: var(--bg-sidebar-hover); color: #CDD0D8; }
.sb-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  border-left-color: var(--accent);
}
.sb-item svg { flex-shrink: 0; }
.sb-item-label { font-size: 13px; font-weight: 500; transition: opacity 150ms ease; }
#sidebar.collapsed .sb-item-label { opacity: 0; pointer-events: none; }

.sb-divider { height: 1px; background: var(--border-sidebar); margin: 8px 0; }

.sb-status {
  padding: 12px 16px;
  border-top: 1px solid var(--border-sidebar);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--status-success);
}
.sb-dot.warn { background: var(--status-warning); }
.sb-dot.err  { background: var(--status-error); }
.sb-dot.ok   { animation: pulse-dot 2s infinite; }
@keyframes pulse-dot {
  0%,100% { opacity: 1; } 50% { opacity: 0.5; }
}
.sb-status-text { font-size: 11px; color: var(--text-sidebar); white-space: nowrap; transition: opacity 150ms; }
#sidebar.collapsed .sb-status-text { opacity: 0; }

/* ─── Content ─────────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-body);
}
.page { display: none; padding: 32px; max-width: 1400px; margin: 0 auto; }
.page.active { display: block; animation: fade-in 150ms ease; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.page-header { margin-bottom: 24px; }
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); }
.page-sub { font-size: 13px; color: var(--text-tertiary); margin-top: 4px; }

/* ─── Grid ────────────────────────────────────────────────────── */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-8-4 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ─── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* ─── KPI Card ────────────────────────────────────────────────── */
.kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.kpi-delta { font-size: 11px; color: var(--text-tertiary); margin-top: 6px; }
.kpi-delta.up   { color: var(--status-success); }
.kpi-delta.down { color: var(--status-error); }

/* ─── Alert Banner ────────────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 40px;
  border-left: 3px solid var(--status-warning);
  background: var(--bg-badge-warning);
  border-radius: 6px;
  margin-bottom: 16px;
}
.alert-banner.err { border-left-color: var(--status-error); background: var(--bg-badge-error); }
.alert-text { flex: 1; font-size: 12px; font-weight: 500; }
.alert-dismiss { background: none; border: none; color: var(--text-tertiary); font-size: 16px; line-height: 1; padding: 4px; }

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 16px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  border: none; transition: all 120ms ease;
}
.btn-primary {
  background: var(--accent); color: white;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(42,157,143,0.25);
}
.btn-primary:active { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { opacity: 0.5; pointer-events: none; }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover { background: var(--bg-body); border-color: var(--border-input); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* ─── Record Button ───────────────────────────────────────────── */
.btn-record {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  transition: transform 200ms ease, box-shadow 200ms ease, background 200ms ease;
  box-shadow: 0 2px 8px rgba(42,157,143,0.2);
}
.btn-record:hover { transform: scale(1.04); box-shadow: 0 4px 16px rgba(42,157,143,0.3); }
.btn-record:active { transform: scale(0.97); }
.btn-record.recording {
  background: var(--status-error);
  animation: record-pulse 2s infinite;
}
@keyframes record-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(220,38,38,0.4); }
  70%  { box-shadow: 0 0 0 12px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0   rgba(220,38,38,0); }
}

/* ─── Inputs ──────────────────────────────────────────────────── */
.inp {
  height: 36px; padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  font-size: 13px; color: var(--text-primary);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}
.inp:focus {
  border-color: var(--border-input-focus);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.1);
}
.inp::placeholder { color: var(--text-tertiary); }

select.inp {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9A9A' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
textarea.inp { height: auto; padding: 10px 12px; resize: vertical; }

.form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 11px; font-weight: 500; color: var(--text-secondary); }

/* ─── Tab Pills ───────────────────────────────────────────────── */
.tab-pills {
  display: inline-flex;
  background: var(--bg-badge-neutral);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.tab-pill {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  background: none; border: none;
  cursor: pointer;
  transition: all 120ms ease;
}
.tab-pill.active {
  background: var(--accent);
  color: white;
}
.tab-content { display: none; }
.tab-content.active { display: block; }
.studio-mode { display: none; }
.studio-mode.active { display: block; }

/* ─── Code Panel ──────────────────────────────────────────────── */
.code-panel {
  background: var(--bg-code);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
}
.code-panel-header {
  background: var(--bg-code-header);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border-default);
  height: 36px;
}
.code-tab {
  padding: 0 12px;
  height: 36px;
  font-size: 12px; font-weight: 500;
  color: var(--text-tertiary);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: color 120ms ease, border-color 120ms ease;
}
.code-tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.code-tab-badge {
  font-size: 10px;
  background: var(--accent-light);
  color: var(--accent);
  padding: 1px 5px;
  border-radius: 10px;
}
.code-panel-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: 4px;
}
.code-body {
  padding: 14px 16px;
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
}
.code-body pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre;
}
.code-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}

/* JSON syntax colors */
.jt-key  { color: var(--jt-key); }
.jt-str  { color: var(--jt-str); }
.jt-num  { color: var(--jt-num); }
.jt-bool { color: var(--jt-bool); }
.jt-null { color: var(--jt-null); font-style: italic; }

/* ─── Tables ──────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  padding: 8px 12px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary);
  background: var(--bg-body);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.tbl td {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.tbl tbody tr:hover { background: var(--bg-body); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.selected { background: var(--accent-light); }

/* ─── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px; font-weight: 500;
  white-space: nowrap;
}
.badge-success { background: var(--bg-badge-success); color: var(--status-success); }
.badge-error   { background: var(--bg-badge-error);   color: var(--status-error); }
.badge-warning { background: var(--bg-badge-warning); color: var(--status-warning); }
.badge-info    { background: var(--bg-badge-info);    color: var(--status-info); }
.badge-neutral { background: var(--bg-badge-neutral); color: var(--text-secondary); }
.badge-grpc    { background: rgba(42,157,143,0.12);   color: var(--ch-grpc); }
.badge-http    { background: rgba(232,155,62,0.12);   color: var(--ch-http); }
.badge-ws      { background: rgba(124,110,219,0.12);  color: var(--ch-ws); }
.badge-relay   { background: rgba(220,38,38,0.12);    color: var(--ch-relay); }

/* ─── File Drop Zone ──────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-input);
  border-radius: 10px;
  height: 120px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease;
  color: var(--text-tertiary);
}
.drop-zone:hover, .drop-zone.drag { border-color: var(--accent); background: var(--accent-light); }
.drop-zone-text { font-size: 12px; }

/* ─── Waveform ────────────────────────────────────────────────── */
#wave-canvas {
  width: 100%; height: 48px;
  display: block;
  opacity: 0.4;
  transition: opacity 300ms;
}
#wave-canvas.active { opacity: 1; }

/* ─── WS Frame Log ────────────────────────────────────────────── */
.frame-log { max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.frame-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 120ms;
}
.frame-item:hover { background: var(--bg-body); }
.frame-dir {
  width: 18px; height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
}
.frame-dir.sent { background: rgba(42,157,143,0.12); color: var(--accent); }
.frame-dir.recv { background: rgba(124,110,219,0.12); color: var(--ch-ws); }
.frame-ts { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-tertiary); flex-shrink: 0; padding-top: 1px; }
.frame-text { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.frame-detail { display: none; padding: 8px 26px 4px; }
.frame-detail.open { display: block; }

/* ─── Side Detail Panel ───────────────────────────────────────── */
#detail-panel {
  position: fixed;
  top: 0; right: -440px;
  width: 420px; height: 100vh;
  background: var(--bg-surface);
  box-shadow: -8px 0 24px rgba(0,0,0,0.06);
  transition: right 250ms ease;
  display: flex; flex-direction: column;
  z-index: 100;
}
#detail-panel.open { right: 0; }
.dp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.dp-title { font-size: 13px; font-weight: 600; }
.dp-close { background: none; border: none; color: var(--text-tertiary); font-size: 20px; line-height: 1; padding: 2px 6px; cursor: pointer; }
.dp-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.dp-row { display: flex; flex-direction: column; gap: 2px; }
.dp-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.dp-value { font-size: 12px; color: var(--text-primary); }
.dp-value.mono { font-family: 'JetBrains Mono', monospace; }
.dp-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── Pool Account Card ───────────────────────────────────────── */
.pool-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.pool-card-head { display: flex; align-items: center; gap: 10px; }
.pool-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pool-email { font-size: 12px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }
.pool-expiry { font-size: 11px; color: var(--text-tertiary); }
.pool-expiry.expired { color: var(--status-error); }
.pool-bar { height: 4px; background: var(--bg-body); border-radius: 2px; overflow: hidden; }
.pool-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 500ms ease; }

/* ─── Toast ───────────────────────────────────────────────────── */
#toast-rack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-sidebar);
  color: white;
  border-radius: 8px;
  font-size: 12px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 240px;
  animation: toast-in 200ms ease;
}
.toast.err { background: #7F1D1D; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast-dismiss { background: none; border: none; color: rgba(255,255,255,0.6); font-size: 16px; margin-left: auto; cursor: pointer; }

/* ─── Skeleton ────────────────────────────────────────────────── */
.skel {
  background: var(--bg-body);
  border-radius: 4px;
  animation: skel-pulse 1.5s ease-in-out infinite;
}
@keyframes skel-pulse {
  0%,100% { opacity: 0.4; } 50% { opacity: 1; }
}

/* ─── Misc ────────────────────────────────────────────────────── */
.mono { font-family: 'JetBrains Mono', monospace; }
.text-sm { font-size: 11px; }
.text-muted { color: var(--text-tertiary); }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8  { gap: 8px; }
.flex   { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Studio layout ───────────────────────────────────────────── */
/* Live mode: single column (inspector col hidden). Batch/file: two columns */
.studio-layout {
  display: grid;
  grid-template-columns: 55fr 45fr;
  gap: 20px;
  align-items: start;
}
.studio-layout.live-mode {
  grid-template-columns: 1fr;
}
.studio-layout.live-mode #studio-inspector-col {
  display: none !important;
}
/* Left column: mode panels (always full-width within its grid column) */
.studio-panels { min-width: 0; }
/* Legacy alias kept for any residual references */
.tx-layout { display: grid; grid-template-columns: 55fr 45fr; gap: 20px; align-items: start; }
.tx-result { margin-top: 16px; }
.tx-result-text {
  background: var(--accent-light);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  min-height: 60px;
}
.tx-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.tx-meta-item { display: flex; flex-direction: column; gap: 2px; }

/* ─── Frames drawer (DevTools-style, slides from right) ──────── */
.frames-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 998;
}
.frames-backdrop.open { display: block; }

.frames-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 999;
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
}
.frames-drawer.open {
  transform: translateX(0);
}
.frames-drawer-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.frames-drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}
.frames-drawer-close {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms, color 150ms;
}
.frames-drawer-close:hover { background: var(--border-subtle); color: var(--text-primary); }
.frames-drawer .frame-log { flex: 1; overflow-y: auto; }

/* Frames badge counter */
.frames-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  padding: 0 5px;
  min-width: 16px;
  text-align: center;
  line-height: 16px;
  vertical-align: middle;
  margin-left: 2px;
}

/* ─── Transcript timeline (accordion, like Recent Requests) ──── */
.seg-list {
  min-height: 160px;
  display: flex;
  flex-direction: column;
}
.seg-empty {
  padding: 24px 16px;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
}
/* Partial in-progress text */
.seg-partial {
  padding: 8px 16px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-tertiary);
  font-style: italic;
  animation: seg-in 200ms ease;
}

/* Accordion row */
.seg-row {
  border-bottom: 1px solid var(--border-subtle);
  animation: seg-in 220ms ease;
}
.seg-row:last-child { border-bottom: none; }
.seg-row-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 120ms;
  user-select: none;
}
.seg-row-summary:hover { background: var(--accent-light); }
.seg-row.expanded .seg-row-summary { background: var(--accent-light); }

.seg-row-time {
  font-size: 11px;
  color: var(--text-tertiary);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  flex-shrink: 0;
}
.seg-row-words {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}
.seg-row-preview {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
/* Two-chip latency pair in summary row */
.seg-row-latency-pair {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.seg-latency-chip {
  font-size: 10px;
  background: var(--bg-badge-neutral);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.seg-latency-chip.seg-latency-total {
  background: var(--accent-light);
  border-color: rgba(42, 157, 143, 0.2);
  color: var(--accent);
}

/* Audio quality dot */
.seg-quality-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.seg-quality-dot.good    { background: var(--status-success, #2ecc71); }
.seg-quality-dot.warn    { background: var(--status-warning, #f39c12); }
.seg-quality-dot.poor    { background: var(--status-error, #e74c3c); }
.seg-quality-dot.unknown { background: var(--text-tertiary); }

/* Keep old single-latency chip class for any other usages */
.seg-row-latency {
  font-size: 11px;
  background: var(--bg-badge-neutral);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}
.seg-row-chevron {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 200ms;
}
.seg-row.expanded .seg-row-chevron { transform: rotate(90deg); }

/* Expanded detail panel */
.seg-row-detail {
  padding: 0 16px 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-body);
}
.seg-detail-block { margin-top: 12px; }
.seg-detail-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.seg-detail-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}
.seg-detail-raw {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
}
.seg-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.seg-meta-chip {
  background: var(--bg-badge-neutral);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.seg-meta-chip.warn {
  background: rgba(220, 38, 38, 0.07);
  border-color: rgba(220, 38, 38, 0.25);
  color: var(--status-error);
}

/* Legacy chip names kept for backward compat */
.seg-meta-item { background: var(--bg-badge-neutral); border: 1px solid var(--border-default); border-radius: 4px; padding: 1px 6px; color: var(--text-tertiary); white-space: nowrap; font-size: 11px; }
.seg-meta-item.warn { background: rgba(220,38,38,0.07); border-color: rgba(220,38,38,0.25); color: var(--status-error); }

/* Partial live segment (in-progress) — kept for compat */
.live-segment {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-tertiary);
  animation: seg-in 200ms ease;
  padding: 8px 16px;
  font-style: italic;
}
@keyframes seg-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.live-cursor { display: inline-block; width: 2px; height: 1em; background: var(--accent); animation: blink 1s infinite; vertical-align: text-bottom; margin-left: 2px; }
@keyframes blink { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }

/* Canvas chart */
.chart-wrap { position: relative; }
canvas { display: block; }

/* Inspector sticky */
.inspector-sticky { position: sticky; top: 32px; }

/* ─── Small input variant ─────────────────────────────────────── */
.inp-sm {
  padding: 5px 8px;
  font-size: 12px;
}

/* ─── Channel picker (segmented control) ─────────────────────── */
.ch-picker {
  display: flex;
  border: 1px solid var(--border-input);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-input);
  height: 24px;
  align-self: center;
}
.ch-btn {
  flex: 1;
  padding: 0 7px;
  border: none;
  border-right: 1px solid var(--border-default);
  background: transparent;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
  line-height: 1;
}
.ch-btn:last-child { border-right: none; }
.ch-btn:hover:not(.active) { background: var(--accent-light); color: var(--accent); }
.ch-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ─── History summary bar ─────────────────────────────────────── */
.hist-summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.hist-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 100px;
}
.hist-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
.hist-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.hist-stat-value.ok { color: var(--status-success); }
.hist-stat-value.warn { color: var(--status-warning); }
.hist-stat-value.err { color: var(--status-error); }

/* ─── History table enhancements ──────────────────────────────── */
.tbl-time-primary {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text-primary);
}
.tbl-time-rel {
  font-size: 10px;
  color: var(--text-tertiary);
  display: block;
  margin-top: 1px;
}
.tbl-preview {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 12px;
  font-style: italic;
}
.tbl-preview.empty { color: var(--text-tertiary); font-style: normal; }
/* Latency color coding */
.lat-ok   { color: var(--status-success); font-weight: 600; }
.lat-warn { color: var(--status-warning); font-weight: 600; }
.lat-err  { color: var(--status-error);   font-weight: 600; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1200px) {
  #sidebar { width: 64px; min-width: 64px; }
  #sidebar .sb-logo-text,
  #sidebar .sb-item-label,
  #sidebar .sb-section-label,
  #sidebar .sb-status-text { opacity: 0; pointer-events: none; }
}
@media (max-width: 900px) {
  .studio-layout { grid-template-columns: 1fr; }
  .tx-layout { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-8-4 { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
