/* ================================================================== */
/*  Magic Wand Console — Professional Dark UI                          */
/* ================================================================== */

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface2:    #1c2333;
  --border:      #30363d;
  --accent:      #58a6ff;
  --accent2:     #3fb950;
  --warn:        #d29922;
  --danger:      #f85149;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --recording:   #f0a500;
  --thinking:    #58a6ff;
  --success:     #3fb950;
  --unknown:     #f85149;
  --font-mono:   'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-ui:     'Inter', 'Segoe UI', system-ui, sans-serif;
  --radius:      8px;
  --radius-lg:   12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  /* iOS Safari viewport height fix:
     1) 100vh is wrong on mobile (counts URL/tab bar areas as visible)
     2) --vh fallback set by JS polyfill (window.innerHeight * 0.01)
     3) -webkit-fill-available works on iOS Safari WebKit
     4) 100dvh (dynamic viewport height) is the modern correct unit */
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  flex-direction: column;
  /* iOS Safari: 100vh includes the URL/tab bars → bottom nav overflows.
     Use dvh (dynamic viewport height, the "modern correct" unit) with
     fallbacks for older browsers. See body{} above for full explanation. */
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  height: -webkit-fill-available;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar .logo span { color: var(--accent); }

.nav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-ui);
  transition: all 0.15s;
  white-space: nowrap;
}

.nav-btn:hover { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--surface2); color: var(--accent); font-weight: 600; }

.status-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
}

/* ── Connect bar (always visible below topbar) ───────────────────────── */
.connect-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.connect-bar .combo {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.connect-bar input[type="text"] {
  width: 100%;
  padding: 5px 28px 5px 8px;
  font-size: 13px;
  box-sizing: border-box;
}

/* ── Bottom tab bar (mobile nav only) ───────────────────────────────── */
.bottom-nav {
  display: none;  /* shown on mobile via @media below */
}

/* ── Mobile breakpoint (all phones in portrait, small tablets) ───────── */
@media (max-width: 768px) {
  /* Topbar: shrink to logo + status only — no connect controls, no nav */
  .topbar {
    padding: 0 12px;
    gap: 8px;
    height: 44px;
    flex-shrink: 0;
  }

  .topbar .logo {
    font-size: 15px;
  }

  /* Hide desktop nav and connect controls in topbar */
  .topbar .nav,
  .topbar .topbar-connect {
    display: none !important;
  }

  /* Connect bar: override desktop max-width + padding on mobile */
  .connect-bar {
    padding: 5px 10px;
  }

  .connect-bar .combo {
    max-width: none;  /* full width on mobile */
    min-width: 0;
  }

  .connect-bar input[type="text"] {
    font-size: 13px;
  }

  /* Bottom tab bar: pinned, single row, never wraps.
   * Total chrome on screen: topbar(44) + connect-bar(44) + bottom-nav(48)
   * = 136px, leaving ~580px content on iPhone 14 (812px). */
  .bottom-nav {
    display: flex;
    flex-shrink: 0;
    flex-wrap: nowrap;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .bottom-nav .nav-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 6px 2px;
    font-size: 10px;
    line-height: 1.2;
    border-radius: 0;
    height: 48px;
    overflow: hidden;
    white-space: nowrap;
  }

  .bottom-nav .nav-btn .nav-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
  }

  /* Content area: flex-grows to fill remaining space between connect-bar
   * and bottom-nav. Extra bottom padding prevents last card being hidden. */
  .content {
    flex: 1;
    padding: 12px;
    padding-bottom: calc(48px + env(safe-area-inset-bottom, 8px) + 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;  /* required for flex child to scroll correctly */
  }

  /* Stack all grids to single column on mobile */
  .grid-2, .grid-3 {
    grid-template-columns: 1fr !important;
  }

  /* Reduce card padding on mobile */
  .card {
    padding: 14px;
  }
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.status-dot.idle       { background: var(--text-muted); }
.status-dot.recording  { background: var(--recording); box-shadow: 0 0 6px var(--recording); animation: pulse 1s infinite; }
.status-dot.thinking   { background: var(--thinking);  box-shadow: 0 0 6px var(--thinking); }
.status-dot.connected  { background: var(--success); }
.status-dot.disconnected { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.page { display: none; }
.page.active { display: block; }

/* ── Cards ─────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── 3D Canvas ─────────────────────────────────────────────────────── */

/* The Three.js / Chart.js renderers set explicit pixel width/height
 * on their <canvas> elements at init, ignoring our CSS. Constrain
 * with max-width so they never overflow their parent card on mobile. */
#orientation-canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 300px;
  border-radius: var(--radius);
  background: var(--bg);
}

/* ── Charts ────────────────────────────────────────────────────────── */

.chart-wrap {
  position: relative;
  height: 180px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.chart-wrap canvas {
  border-radius: var(--radius);
  max-width: 100% !important;
  display: block;
}

/* All cards fit within their column on mobile (no overflow). */
.card {
  min-width: 0;
  overflow: hidden;
}

/* ── Metric tiles ──────────────────────────────────────────────────── */

.metrics {
  display: grid;
  /* 3 columns: ax/ay/az on row 1, gx/gy/gz on row 2.
     Was 6 columns — too cramped on mobile and made values unreadable. */
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
}

.metric-value.ax { color: #ff7b72; }
.metric-value.ay { color: #79c0ff; }
.metric-value.az { color: #3fb950; }
.metric-value.gx { color: #ffa657; }
.metric-value.gy { color: #d2a8ff; }
.metric-value.gz { color: #56d364; }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 500;
}

.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.1); }

.btn-success { background: var(--accent2); border-color: var(--accent2); color: #000; font-weight: 600; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger  { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover  { background: var(--danger); color: #fff; }

.btn-warn    { background: transparent; border-color: var(--warn); color: var(--warn); }
.btn-warn:hover    { background: var(--warn); color: #000; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ── Gesture Library ───────────────────────────────────────────────── */

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

.gesture-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}

.gesture-row:hover { border-color: var(--accent); }

.gesture-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

/* ──── Collapsible gesture cards (Library) ──────────────────────── */
.gesture-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}
.gesture-card:hover { border-color: var(--accent); }

.gesture-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.gesture-card-header:hover { background: rgba(88,166,255,0.05); }

.gesture-card-caret {
  font-size: 12px;
  color: var(--text-muted);
  width: 14px;
  text-align: center;
  transition: transform 0.15s;
}

.gesture-card-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.gesture-card-spacer { flex: 1; }

/* Right-aligned badge cluster: fixed column widths so badges line up
   vertically across all gesture cards regardless of label length. */
.gesture-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Compact badges — count is just the number, status is just the icon. */
.gesture-card-count {
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.gesture-card-status {
  min-width: 28px;
  text-align: center;
}

/* ⋮ menu trigger button on each gesture card row */
.gesture-card-menu-btn {
  font-size: 18px;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.gesture-card-menu-btn:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

/* ── Floating action menu (rendered into <body>, positioned fixed) ───── */
.row-menu {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  min-width: 160px;
  z-index: 1000;
  font-size: 13px;
  overflow: hidden;
}
.row-menu-item {
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.08s;
}
.row-menu-item:hover {
  background: var(--surface2);
}
.row-menu-item-danger {
  color: var(--danger);
}
.row-menu-item-danger:hover {
  background: rgba(248, 81, 73, 0.12);
}

/* ── Bulk action bar (top of expanded card body when ≥1 tile selected) ── */
.gesture-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.gesture-bulk-bar.visible {
  background: rgba(33, 136, 255, 0.08);
  border-bottom: 1px solid var(--accent);
}
.gesture-bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ── Tile selection state ─────────────────────────────────────────────── */
.gesture-tile {
  position: relative;
  cursor: pointer;
}
.gesture-tile.selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(33, 136, 255, 0.12);
}
.gesture-tile-check {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface);
}
.gesture-tile.selected .gesture-tile-check {
  display: flex;
}

/* ── Modal (Move-to dialog, etc.) ─────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.12s ease-out;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  min-width: 380px;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  font-size: 15px;
  color: var(--text);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 16px 18px;
  flex: 1 1 auto;
  overflow: auto;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.move-preview {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface2);
  font-size: 12px;
  color: var(--text-muted);
  min-height: 1.3em;
}

/* Combo classes used by the move-to dialog (mirror the recorder combo styling) */
.combo-wrap   { position: relative; }
.combo-input  { width: 100%; padding: 8px 36px 8px 10px; }
.combo-toggle {
  position: absolute; right: 4px; top: 4px; bottom: 4px;
  width: 28px; padding: 0;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 12px; cursor: pointer;
}
.combo-toggle:hover { color: var(--text); }
.combo-list {
  list-style: none; margin: 4px 0 0; padding: 4px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  max-height: 260px; overflow-y: auto;
  position: absolute; left: 0; right: 0; top: 100%;
  z-index: 10; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.combo-item {
  padding: 6px 12px; cursor: pointer; color: var(--text);
}
.combo-item:hover { background: var(--surface2); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Plane comparison thumbnails (Settings → Visualization Plane) ── */
.plane-thumb {
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.plane-thumb:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.plane-thumb.active {
  border-color: var(--success);
  box-shadow: 0 0 0 1px var(--success), 0 4px 12px rgba(63, 185, 80, 0.2);
  background: rgba(63, 185, 80, 0.06);
}
.plane-thumb.active::before {
  content: "✓ active";
  display: inline-block;
  background: var(--success);
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 6px;
}
.plane-thumb-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  image-rendering: pixelated;          /* keep 64×64 crisp when scaled up */
  display: block;
  margin: 0 auto 8px;
}
.plane-thumb-meta {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}

.gesture-card-body {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.gesture-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}

.gesture-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: transform 0.1s, border-color 0.1s;
}
.gesture-tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.gesture-tile-img {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  border-radius: 4px;
  display: block;
  background: var(--bg);
}

.gesture-tile-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.gesture-tile-del {
  padding: 2px 8px;
  font-size: 10px;
  width: 100%;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.badge-green  { background: rgba(63,185,80,0.15);  color: var(--accent2); border: 1px solid rgba(63,185,80,0.3); }
.badge-yellow { background: rgba(210,153,34,0.15); color: var(--warn);    border: 1px solid rgba(210,153,34,0.3); }
.badge-gray   { background: var(--surface);        color: var(--text-muted); border: 1px solid var(--border); }

/* ── Classifier result ─────────────────────────────────────────────── */

.result-box {
  text-align: center;
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  transition: all 0.3s;
}

.result-box.known    { border-color: var(--success); background: rgba(63,185,80,0.05); }
.result-box.unknown  { border-color: var(--danger);  background: rgba(248,81,73,0.05); }

.result-label {
  font-size: 36px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: -1px;
}

.result-confidence {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.confidence-bars { margin-top: 16px; }

.conf-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
}

.conf-bar-label { width: 120px; text-align: right; font-family: var(--font-mono); color: var(--text-muted); }
.conf-bar-track { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.conf-bar-fill  { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s ease; }
.conf-bar-pct   { width: 40px; font-family: var(--font-mono); color: var(--text-muted); }

/* ── Click-to-save behaviour on confidence bars (active learning) ───── */
.conf-bars-hint {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.conf-bar-row.clickable {
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.conf-bar-row.clickable:hover {
  background: rgba(33, 136, 255, 0.06);
  border-color: var(--accent);
}
.conf-bar-row.clickable:hover .conf-bar-action {
  opacity: 1;
}

/* The "+ save" hint on the right of each row — invisible until hover so
   the row stays uncluttered, then a clear call-to-action when targeting it. */
.conf-bar-action {
  width: 64px;
  text-align: center;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.1s;
  font-family: var(--font-mono);
}

/* Brief flash when a row is clicked (saved successfully) */
.conf-bar-row.saved-flash {
  background: rgba(63, 185, 80, 0.18) !important;
  border-color: var(--success) !important;
  animation: savedPulse 0.4s ease-out;
}
.conf-bar-row.saved-flash .conf-bar-action {
  opacity: 1;
  color: var(--success);
}
.conf-bar-row.saved-dimmed {
  opacity: 0.35;
  pointer-events: none;
}
@keyframes savedPulse {
  0%   { transform: scale(1.0); }
  50%  { transform: scale(1.02); }
  100% { transform: scale(1.0); }
}

/* ── Action Config ─────────────────────────────────────────────────── */

.action-table { width: 100%; border-collapse: collapse; }
.action-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.action-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.action-table tr:last-child td { border-bottom: none; }
.action-table tr:hover td { background: var(--surface2); }

.action-table input,
.action-table select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 5px 8px;
  font-size: 13px;
  font-family: var(--font-ui);
  width: 100%;
}

.action-table input:focus,
.action-table select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Recorder state overlay ────────────────────────────────────────── */

.recorder-hint {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.recorder-hint .icon { font-size: 48px; margin-bottom: 12px; }
.recorder-hint h3 { font-size: 16px; color: var(--text); margin-bottom: 6px; }

.recording-active {
  border: 2px solid var(--recording) !important;
  box-shadow: 0 0 20px rgba(240,165,0,0.15);
}

/* ── Toast notifications ───────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  animation: slide-in 0.2s ease;
  max-width: 320px;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.info    { border-color: var(--accent);  color: var(--accent); }

@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Form elements ─────────────────────────────────────────────────── */

input[type="text"], input[type="number"], select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--font-ui);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; }

.form-row { margin-bottom: 12px; }

/* ── Divider ───────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Board indicator badge ─────────────────────────────────────────── */
.board-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  margin-left: 4px;
  user-select: none;
  white-space: nowrap;
  cursor: help;
}
.board-badge.real {
  background: rgba(63, 185, 80, 0.15);
  color: #3fb950;
  border: 1px solid rgba(63, 185, 80, 0.4);
}
.board-badge.mock {
  background: rgba(255, 165, 0, 0.18);
  color: #ffa500;
  border: 1px solid rgba(255, 165, 0, 0.45);
  animation: mock-pulse 2s ease-in-out infinite;
}
.board-badge.offline {
  background: rgba(248, 81, 73, 0.12);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.35);
}
@keyframes mock-pulse {
  0%, 100% { opacity: 1.0; }
  50%      { opacity: 0.7; }
}

/* ── Class-selector chips (Train tab) ───────────────────────────────
   Modern pill toggles for choosing which gesture classes participate
   in a training run. Outline = unselected, solid = selected.
   Inspired by GitHub/Linear filter chips. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  line-height: 1;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip.selected:hover { filter: brightness(1.08); }
.chip-count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Lightweight text-button used in toolbar lines like 'Select all · none' */
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-size: 12px;
}
.btn-link:hover { text-decoration: underline; }

/* ── Confusion matrix grid (Train tab) ───────────────────────────────
   Rows = true label, Columns = predicted label. Diagonal cells are
   correct predictions (tinted green); off-diagonal cells are mistakes
   (tinted red). Cell darkness is proportional to count within the
   correct/incorrect bucket. */
.confusion-table {
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.confusion-table th, .confusion-table td {
  padding: 6px 9px;
  text-align: center;
  border: 1px solid var(--border);
}
.confusion-table th {
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.02);
}
.confusion-table th.row-label {
  text-align: right;
  padding-right: 10px;
}
.confusion-table td.cm-cell {
  min-width: 32px;
  font-weight: 500;
  cursor: default;
}
.confusion-table td.cm-cell.zero { color: var(--border); }
.confusion-table td.cm-cell.diag { color: #fff; }     /* on green tint */
.confusion-table td.cm-cell.miss { color: #fff; }     /* on red tint */
.confusion-table td.row-acc {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  padding-left: 10px;
  border: none;
  white-space: nowrap;
}
