/**
 * InputLab — Netrunner Cybernetic Stylesheet
 * Zero external CSS frameworks — pure custom properties, flex/grid, container queries, and native dialogs.
 * Built mobile-first: starts at 2005 phone screen size (240px-320px) and scales smoothly upward to full desktop canvas.
 */

:root {
  --bg-deep: #06090f;
  --bg-surface: #0a111a;
  --bg-panel: #0d1a10;
  --bg-panel-dark: #08110a;
  --bg-card: #101926;
  --border-subtle: rgba(43, 202, 109, 0.2);
  --border-highlight: rgba(43, 202, 109, 0.45);
  --border-panel: rgba(43, 202, 109, 0.3);

  /* Brand Accents */
  --accent-emerald: #2bca6d;
  --accent-teal: #2dd4bf;
  --accent-pink: #ff4d80;
  --accent-amber: #f59e0b;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* 4-State Visual Color Tokens */
  --state-grey-base: #141d2b;
  --state-grey-border: #28374d;
  --state-grey-text: #94a3b8;

  --state-teal-base: #0d383b;
  --state-teal-border: #14b8a6;
  --state-teal-text: #2dd4bf;

  --state-yellow-base: #713f12;
  --state-yellow-border: #eab308;
  --state-yellow-text: #fef08a;

  --state-green-base: #14532d;
  --state-green-border: #22c55e;
  --state-green-text: #86efac;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* ==========================================================================
   Header & Navigation (Mobile-First: 240px - 320px base)
   ========================================================================== */

.app-header {
  background: rgba(10, 17, 26, 0.95);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 6px 8px;
  height: auto;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-title {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.05em;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulseLed 2s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes pulseLed {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.brand-sub {
  font-family: monospace;
  font-size: 9px;
  color: var(--text-dim);
  display: none;
}

/* Module Selector Tabs */
.module-tabs {
  display: flex;
  background: #101824;
  border: 1px solid #1e2c40;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
  width: 100%;
}

.tab-btn {
  flex: 1;
  padding: 5px 6px;
  font-size: 8.5px;
  font-family: "Press Start 2P", monospace;
  font-weight: bold;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #ffffff;
}

.tab-btn.active {
  background: rgba(45, 212, 191, 0.15);
  border-color: rgba(45, 212, 191, 0.4);
  color: var(--accent-teal);
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.15);
}

/* Top Action Buttons */
.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.tactile-btn {
  padding: 5px 8px;
  font-family: monospace;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 0.03em;
  background: #141f2e;
  border: 1px solid #24354d;
  border-radius: 4px;
  color: #e2e8f0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  white-space: nowrap;
  touch-action: manipulation;
}

.tactile-btn:hover {
  background: #1c2b3f;
  border-color: var(--accent-teal);
  color: #ffffff;
}

.tactile-btn:active {
  transform: translateY(1px);
}

.tactile-btn--emerald {
  background: var(--accent-emerald);
  color: #06090f;
  border-color: var(--accent-emerald);
}

.tactile-btn--emerald:hover {
  background: #39e67f;
  color: #000000;
  box-shadow: 0 0 10px rgba(43, 202, 109, 0.4);
}

.tactile-btn--teal {
  border-color: rgba(45, 212, 191, 0.4);
  color: var(--accent-teal);
}

.tactile-btn--teal:hover {
  border-color: var(--accent-teal);
  background: rgba(45, 212, 191, 0.15);
}

.tactile-btn--sm {
  padding: 3px 7px;
  font-size: 8px;
}

.tactile-btn.active {
  background: rgba(43, 202, 109, 0.25);
  border-color: var(--accent-emerald);
  color: #ffffff;
}

.btn-label-long {
  display: none;
}

.btn-label-short {
  display: inline;
}

/* ==========================================================================
   Hardware Telemetry Strip
   ========================================================================== */

.hw-status-strip {
  background: #080d14;
  border-bottom: 1px solid rgba(43, 202, 109, 0.15);
  padding: 4px 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hw-strip-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
}

.hw-badge-list {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 5px;
  font-family: monospace;
  font-size: 9px;
  min-width: max-content;
}

.hw-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #101824;
  border: 1px solid #1e2c40;
  border-radius: 3px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.hw-badge-val {
  color: var(--accent-teal);
  font-weight: bold;
}

/* ==========================================================================
   Secondary Legend & Controls Bar
   ========================================================================== */

.secondary-bar {
  background: #06090f;
  border-bottom: 1px solid #162232;
  padding: 4px 6px;
}

.secondary-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  font-size: 9px;
}

.color-legend {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  gap: 8px;
  font-family: monospace;
  white-space: nowrap;
  padding-bottom: 2px;
}

.legend-title {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 8px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 8.5px;
}

.legend-color-box {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}

.color-grey { background: var(--state-grey-base); border: 1px solid var(--state-grey-border); }
.color-teal { background: var(--state-teal-base); border: 1px solid var(--state-teal-border); }
.color-yellow { background: var(--state-yellow-base); border: 1px solid var(--state-yellow-border); }
.color-green { background: var(--state-green-base); border: 1px solid var(--state-green-border); }

.container-width-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: monospace;
  font-size: 9px;
}

.width-btn-group {
  display: flex;
  background: #0f1722;
  border: 1px solid #1c2b3f;
  border-radius: 4px;
  padding: 2px;
  gap: 2px;
}

.width-btn {
  padding: 2px 6px;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: monospace;
  font-size: 8.5px;
}

.width-btn.active {
  background: rgba(45, 212, 191, 0.2);
  color: var(--accent-teal);
  font-weight: bold;
}

/* ==========================================================================
   Main Stage & Responsive Width Simulation
   ========================================================================== */

.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 0.5rem 2.5rem 0.5rem;
  width: 100%;
  transition: max-width 0.25s ease;
  container-type: inline-size;
  container-name: stage;
}

/* Width Simulation Classes for Testing on Desktop */
.app-main.width-240 {
  max-width: 240px;
  margin: 0 auto;
}

.app-main.width-320 {
  max-width: 320px;
  margin: 0 auto;
}

.app-main.width-768 {
  max-width: 768px;
  margin: 0 auto;
}

.app-main.width-1024 {
  max-width: 1024px;
  margin: 0 auto;
}

/* ==========================================================================
   Keyboard Diagnostic Module Styles (Mobile-First)
   ========================================================================== */

.kb-tester-root {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.kb-control-panel, .mouse-control-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 6px;
  padding: 8px 10px;
}

.kb-metrics-summary, .mouse-metrics-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  align-items: baseline;
}

.kb-metric-badge, .mouse-metric-badge {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: monospace;
}

.kb-metric-label, .mouse-metric-label {
  font-size: 8px;
  color: var(--text-dim);
  font-weight: bold;
}

.kb-metric-val, .mouse-metric-val {
  font-size: 13px;
  font-weight: bold;
  color: #ffffff;
}

.kb-metric-val--peak, .mouse-metric-val--peak {
  color: var(--accent-amber);
}

.kb-metric-sub, .mouse-metric-sub {
  font-size: 8px;
  color: var(--text-muted);
}

.kb-metric-divider, .mouse-metric-divider {
  color: var(--text-dim);
  margin: 0 1px;
}

.kb-rollover-meter, .mouse-gauge-row {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.kb-modifiers-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.kb-mod-chip {
  padding: 2px 6px;
  font-family: monospace;
  font-size: 8px;
  background: #08110a;
  border: 1px solid rgba(43, 202, 109, 0.2);
  border-radius: 3px;
  color: var(--text-dim);
  transition: all 0.15s ease;
}

.kb-mod-chip.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--accent-amber);
  color: #fef08a;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
}

.kb-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* SVG Keyboard Stage */
.kb-svg-stage-wrapper {
  background: #090e16;
  border: 1px solid #1a283b;
  border-radius: 6px;
  padding: 8px 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.kb-touch-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 6.5px;
  color: var(--accent-emerald);
  margin-bottom: 6px;
  text-align: center;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.kb-svg-container {
  width: 100%;
  min-width: 540px;
  transition: min-width 0.2s ease;
}

/* In Fit Mode: fit entire SVG onto narrow screen */
.kb-svg-stage-wrapper.mode-fit .kb-svg-container {
  min-width: 0 !important;
  width: 100% !important;
}

.kb-matrix-svg {
  width: 100%;
  height: auto;
  display: block;
}

/* SVG Key Styling by 4-State Cycle (Hardware Matrix Monitor) */
.key-group {
  cursor: default;
  pointer-events: none;
  transition: all 0.1s ease;
}

.key-outer {
  stroke-width: 1.2;
}

.key-inner {
  stroke-width: 0.8;
}

.key-label {
  font-family: monospace;
  font-weight: bold;
  font-size: 10px;
  pointer-events: none;
}

.key-label--center {
  text-anchor: middle;
  dominant-baseline: central;
}

.key-sublabel {
  font-family: monospace;
  font-size: 8px;
  pointer-events: none;
}

/* State Grey (Default) */
.state-grey .key-outer { fill: #131a26; stroke: #26354a; }
.state-grey .key-inner { fill: #1a2434; stroke: #33445e; }
.state-grey .key-label { fill: #cbd5e1; }
.state-grey .key-sublabel { fill: #64748b; }

/* State Teal (Ready) */
.state-teal .key-outer { fill: #0d282b; stroke: #14b8a6; }
.state-teal .key-inner { fill: #0f3b3e; stroke: #2dd4bf; }
.state-teal .key-label { fill: #5eead4; }
.state-teal .key-sublabel { fill: #2dd4bf; }

/* State Yellow (Active / Held Down) */
.state-yellow .key-outer { fill: #451a03; stroke: #eab308; }
.state-yellow .key-inner { fill: #713f12; stroke: #facc15; }
.state-yellow .key-label { fill: #fef08a; }
.state-yellow .key-sublabel { fill: #fde047; }
.state-yellow { filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.5)); }

/* State Green (Tested / Released) */
.state-green .key-outer { fill: #052e16; stroke: #22c55e; }
.state-green .key-inner { fill: #14532d; stroke: #4ade80; }
.state-green .key-label { fill: #bbf7d0; }
.state-green .key-sublabel { fill: #86efac; }
.state-green { filter: drop-shadow(0 0 4px rgba(34, 197, 94, 0.3)); }

/* Bottom Telemetry Split (Mobile-First: Stacked column) */
.kb-bottom-telemetry, .mouse-stage-split {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.terminal-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-panel-dark);
  border-bottom: 1px solid rgba(43, 202, 109, 0.25);
  font-family: "Press Start 2P", monospace;
  font-size: 7.5px;
}

.panel-header-tag {
  color: var(--accent-emerald);
}

.panel-header-sub {
  color: var(--text-dim);
  font-family: monospace;
}

.kb-live-box, .kb-history-box, .mouse-chassis-panel, .mouse-pad-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-panel);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.kb-live-details {
  padding: 10px;
}

.kb-live-idle {
  font-family: monospace;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 14px 0;
}

.kb-live-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-family: monospace;
}

.live-col {
  display: flex;
  flex-direction: column;
}

.live-meta-label {
  font-size: 8px;
  color: var(--text-dim);
}

.live-meta-val {
  font-size: 12px;
  font-weight: bold;
  color: #ffffff;
}

.live-meta-val--accent {
  color: var(--accent-emerald);
  font-size: 14px;
}

/* History Table */
.kb-history-table-wrapper {
  max-height: 180px;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.kb-history-table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-size: 9px;
  min-width: 260px;
}

.kb-history-table th {
  background: #08110a;
  padding: 5px 8px;
  text-align: left;
  color: var(--text-dim);
  font-size: 8px;
  position: sticky;
  top: 0;
}

.kb-history-table td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(43, 202, 109, 0.1);
}

.table-empty {
  text-align: center;
  padding: 14px !important;
  color: var(--text-dim);
}

/* ==========================================================================
   Mouse & Pointer Diagnostic Module Styles (Mobile-First)
   ========================================================================== */

.mouse-svg-wrapper {
  padding: 1rem;
  display: flex;
  justify-content: center;
  background: #070d14;
}

.mouse-chassis-svg {
  width: 150px;
  max-width: 100%;
  height: 200px;
}

.mouse-shell-outer { fill: #111a28; stroke: #24354c; stroke-width: 2; }
.mouse-shell-inner { fill: #162235; stroke: #2e4360; stroke-width: 1; }
.mouse-wheel-bg { fill: #0b121c; stroke: #1d2c40; stroke-width: 1; }

.mouse-btn-part {
  fill: #1a273b;
  stroke: #2e4360;
  stroke-width: 1.5;
  cursor: pointer;
  transition: all 0.1s ease;
  touch-action: manipulation;
}

.mouse-svg-label {
  font-family: monospace;
  font-size: 10px;
  font-weight: bold;
  fill: #94a3b8;
  text-anchor: middle;
  pointer-events: none;
}

.mouse-svg-sublabel {
  font-family: monospace;
  font-size: 8px;
  fill: #64748b;
  text-anchor: middle;
  pointer-events: none;
}

.mouse-wheel-arrow {
  fill: #475569;
  cursor: pointer;
  transition: fill 0.1s ease;
}

.mouse-wheel-arrow.active {
  fill: var(--accent-emerald);
  filter: drop-shadow(0 0 6px var(--accent-emerald));
}

.mouse-buttons-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--bg-panel-dark);
}

.mouse-btn-card {
  background: var(--state-grey-base);
  border: 1px solid var(--state-grey-border);
  border-radius: 4px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: monospace;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-card-title {
  font-size: 8px;
  color: var(--text-dim);
}

.btn-card-count {
  font-size: 12px;
  font-weight: bold;
  color: #ffffff;
}

/* Mouse Button States */
.mouse-btn-part.state-yellow, .mouse-btn-card.state-yellow {
  fill: #713f12;
  background: #713f12;
  border-color: #eab308;
  stroke: #eab308;
  filter: drop-shadow(0 0 6px rgba(234, 179, 8, 0.4));
}

.mouse-btn-part.state-green, .mouse-btn-card.state-green {
  fill: #14532d;
  background: #14532d;
  border-color: #22c55e;
  stroke: #22c55e;
}

/* Tracking Pad Interactive Grid */
.mouse-pad-interactive {
  position: relative;
  height: 220px;
  background: #080f18;
  outline: none;
  cursor: crosshair;
  overflow: hidden;
  touch-action: none; /* Critical for mobile touch drawing without page scroll */
}

.mouse-grid-matrix {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 1.5px;
  padding: 3px;
}

.grid-cell {
  background: rgba(22, 34, 52, 0.5);
  border: 1px solid rgba(46, 67, 96, 0.3);
  border-radius: 2px;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.grid-cell.traversed {
  background: rgba(43, 202, 109, 0.35);
  border-color: var(--accent-emerald);
  box-shadow: inset 0 0 6px rgba(43, 202, 109, 0.3);
}

.mouse-pad-overlay-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 17, 10, 0.85);
  border: 1px solid rgba(43, 202, 109, 0.3);
  border-radius: 4px;
  padding: 3px 8px;
  font-family: monospace;
  font-size: 7.5px;
  color: var(--accent-emerald);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ==========================================================================
   Modals (Native HTML5 <dialog>)
   ========================================================================== */

.seraphim-dialog {
  margin: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8), 0 0 20px rgba(43, 202, 109, 0.2);
  color: var(--text-main);
  max-width: 680px;
  width: 95vw;
  padding: 0;
  overflow: hidden;
}

.seraphim-dialog::backdrop {
  background: rgba(4, 7, 12, 0.8);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-panel-dark);
  border-bottom: 1px solid var(--border-subtle);
  font-family: "Press Start 2P", monospace;
  font-size: 8.5px;
}

.dialog-title {
  color: var(--accent-emerald);
}

.dialog-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
}

.dialog-close-btn:hover {
  color: #ffffff;
}

.dialog-body {
  padding: 10px;
}

.dialog-pre {
  background: #06090f;
  border: 1px solid #162232;
  border-radius: 4px;
  padding: 8px;
  font-family: monospace;
  font-size: 8.5px;
  line-height: 1.35;
  color: #a7f3d0;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre;
}

.dialog-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: stretch;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-panel-dark);
  border-top: 1px solid var(--border-subtle);
}

.dialog-footer button {
  flex: 1;
  text-align: center;
  justify-content: center;
}

/* ==========================================================================
   SCALED UPWARDS MEDIA QUERIES (Mobile-First Progressive Enhancement)
   ========================================================================== */

/* Phablets & Mid-size screens (>= 480px) */
@media (min-width: 480px) {
  .btn-label-long {
    display: inline;
  }
  .btn-label-short {
    display: none;
  }
  .header-actions {
    gap: 6px;
  }
  .tactile-btn {
    padding: 6px 10px;
    font-size: 10px;
  }
  .brand-sub {
    display: inline-block;
  }
  .mouse-pad-interactive {
    height: 260px;
  }
  .mouse-buttons-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Tablets (>= 768px) */
@media (min-width: 768px) {
  .header-container {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    padding: 8px 12px;
  }
  .module-tabs {
    width: auto;
  }
  .tab-btn {
    padding: 6px 12px;
    font-size: 10px;
  }
  .header-actions {
    width: auto;
  }
  .secondary-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    font-size: 10.5px;
  }
  .color-legend {
    font-size: 10px;
  }
  .app-main {
    padding: 1rem 1rem 3rem 1rem;
  }
  .kb-control-panel, .mouse-control-panel {
    flex-direction: row;
    justify-content: space-between;
    padding: 10px 14px;
  }
  .kb-metrics-summary, .mouse-metrics-summary {
    display: flex;
    gap: 14px;
  }
  .kb-metric-val, .mouse-metric-val {
    font-size: 15px;
  }
  .kb-svg-container {
    min-width: 100%;
  }
  .mouse-stage-split {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
  }
  .mouse-pad-interactive {
    height: 320px;
  }
  .mouse-chassis-svg {
    width: 180px;
    height: 240px;
  }
  .kb-bottom-telemetry {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 12px;
  }
  .dialog-pre {
    font-size: 10px;
    max-height: 300px;
  }
  .dialog-footer {
    justify-content: flex-end;
  }
  .dialog-footer button {
    flex: 0 0 auto;
  }
}

/* Desktop & Widescreen Monitors (>= 1024px) */
@media (min-width: 1024px) {
  .header-container {
    height: 56px;
    flex-wrap: nowrap;
    padding: 0 1rem;
  }
  .brand-title {
    font-size: 13px;
  }
  .tab-btn {
    padding: 6px 14px;
    font-size: 11px;
  }
  .app-main {
    padding: 1.25rem 1rem 3rem 1rem;
  }
  .mouse-stage-split {
    grid-template-columns: 340px 1fr;
    gap: 1rem;
  }
  .mouse-pad-interactive {
    height: 380px;
  }
  .mouse-chassis-svg {
    width: 200px;
  }
  .kb-bottom-telemetry {
    grid-template-columns: 340px 1fr;
    gap: 1rem;
  }
  .kb-history-table-wrapper {
    max-height: 240px;
  }
}

/* ==========================================================================
   CONTAINER QUERIES FOR ADAPTIVE EMBEDDING & SIMULATOR
   ========================================================================== */

@container stage (max-width: 480px) {
  .kb-control-panel, .mouse-control-panel {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .kb-metrics-summary, .mouse-metrics-summary {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .mouse-stage-split, .kb-bottom-telemetry {
    display: flex !important;
    flex-direction: column !important;
  }
  .mouse-pad-interactive {
    height: 220px !important;
  }
}

@container stage (max-width: 320px) {
  .kb-metric-val, .mouse-metric-val {
    font-size: 12px !important;
  }
  .kb-mod-chip {
    font-size: 7.5px !important;
    padding: 1px 4px !important;
  }
  .mouse-chassis-svg {
    width: 140px !important;
  }
}
