:root {
  --bg-stage: #050911;
  --bg-panel: #0a111d;
  --bg-surface: #0f1929;
  --bg-elevated: #142237;
  --border-subtle: rgba(148, 185, 224, 0.14);
  --border-strong: rgba(56, 189, 248, 0.36);

  --text-primary: #e6f1fb;
  --text-secondary: #93acc5;
  --text-muted: #5d7690;

  --cyan: #38bdf8;
  --cyan-soft: rgba(56, 189, 248, 0.16);
  --emerald: #10b981;
  --emerald-soft: rgba(16, 185, 129, 0.16);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --crimson: #f43f5e;
  --crimson-soft: rgba(244, 63, 94, 0.18);

  --font-ui: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-card: 12px;
  --radius-ctrl: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

::selection {
  background: rgba(56, 189, 248, 0.28);
  color: #f8fafc;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-stage);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
  scrollbar-color: #1e334d var(--bg-panel);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-panel);
}
::-webkit-scrollbar-thumb {
  background: #1e334d;
  border-radius: 3px;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

button,
input,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.hidden {
  display: none !important;
}

/* Main Split Layout */
.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
  height: 100dvh;
  overflow: hidden;
}

.viewport-pane {
  position: relative;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 46%, #0b192c 0%, #050911 72%);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#xray-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#xray-canvas:active {
  cursor: grabbing;
}

.app-shell[data-alert-state="FALLEN"] .canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 64px rgba(244, 63, 94, 0.34);
  border: 1px solid rgba(244, 63, 94, 0.55);
  animation: alertPulse 1.1s ease-in-out infinite alternate;
}

@keyframes alertPulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

/* HUD Top Left */
.hud-top-left {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(460px, calc(100% - 32px));
  pointer-events: none;
}

.hud-top-left button {
  pointer-events: auto;
}

.brand-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: rgba(10, 17, 29, 0.84);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  width: fit-content;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.pulse-dot.is-ble {
  background: var(--emerald);
  box-shadow: 0 0 9px var(--emerald);
}

.pulse-dot.is-replay {
  background: var(--amber);
  box-shadow: 0 0 9px var(--amber);
}

.app-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.mode-pill,
.chip-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 500;
  background: var(--cyan-soft);
  color: #7dd3fc;
}

.chip-pill.is-adxl {
  background: rgba(34, 211, 238, 0.18);
  color: #67e8f9;
}

.chip-pill.is-bmi {
  background: var(--emerald-soft);
  color: #6ee7b7;
}

.posture-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 14px;
  background: rgba(10, 17, 29, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.app-shell[data-alert-state="PRE_FALL"] .posture-banner {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(28, 20, 10, 0.88);
}

.app-shell[data-alert-state="FALLEN"] .posture-banner {
  border-color: rgba(244, 63, 94, 0.75);
  background: rgba(38, 11, 20, 0.92);
}

.posture-main {
  display: flex;
  align-items: center;
  gap: 11px;
}

.posture-indicator {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--emerald);
  flex-shrink: 0;
}

.app-shell[data-alert-state="PRE_FALL"] .posture-indicator {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
}

.app-shell[data-alert-state="FALLEN"] .posture-indicator {
  background: var(--crimson);
  box-shadow: 0 0 12px var(--crimson);
}

.posture-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.posture-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.posture-metrics {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.mini-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.mini-stat-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-reset-alert {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(251, 113, 133, 0.55);
  background: rgba(244, 63, 94, 0.22);
  color: #ffe4e6;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-reset-alert:hover {
  background: rgba(244, 63, 94, 0.35);
}

/* HUD Top Right */
.hud-top-right {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.cam-group {
  display: inline-flex;
  background: rgba(10, 17, 29, 0.86);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  padding: 3px;
  gap: 2px;
}

.cam-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.cam-btn:hover {
  color: var(--text-primary);
}

.cam-btn.is-active {
  background: var(--bg-elevated);
  color: #7dd3fc;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  background: rgba(10, 17, 29, 0.86);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.hud-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface);
}

/* Vector Legend */
.vector-legend {
  position: absolute;
  left: 16px;
  bottom: 14px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 11px;
  background: rgba(8, 14, 24, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  font-size: 0.74rem;
  color: var(--text-secondary);
  pointer-events: none;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.swatch-fused { background: var(--cyan); }
.swatch-adxl { background: #22d3ee; }
.swatch-bmi { background: var(--emerald); }
.swatch-stress { background: var(--crimson); }

/* Dedicated Bottom Recording & Timeline Replay Bar */
.replay-dock {
  flex-shrink: 0;
  z-index: 12;
  background: #08101c;
  border-top: 1px solid var(--border-subtle);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dock-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.record-actions,
.clip-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.dock-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--crimson);
}

.dock-btn.is-recording {
  border-color: rgba(244, 63, 94, 0.7);
  background: var(--crimson-soft);
  color: #ffe4e6;
}

.dock-btn.is-recording .rec-dot {
  animation: blinkRec 0.85s ease-in-out infinite alternate;
}

@keyframes blinkRec {
  from { opacity: 0.3; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); }
}

.btn-back-live {
  border-color: rgba(245, 158, 11, 0.55);
  background: var(--amber-soft);
  color: #fef3c7;
}

.ctrl-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  padding: 5px 9px;
  font-size: 0.78rem;
  color: var(--text-primary);
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.speed-select {
  max-width: 112px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

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

.dock-scrubber-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--cyan-soft);
  color: #7dd3fc;
  cursor: pointer;
  flex-shrink: 0;
}

.play-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  border-color: var(--border-subtle);
}

.time-readout {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  color: var(--text-secondary);
  min-width: 52px;
  text-align: center;
}

.scrubber-track-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  height: 24px;
}

.scrubber-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scrubber-marker {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 3px;
  border-radius: 2px;
  transform: translateX(-50%);
}
.scrubber-marker.is-fall {
  background: var(--crimson);
  box-shadow: 0 0 6px var(--crimson);
}
.scrubber-marker.is-warn {
  background: var(--amber);
}

.scrubber-range {
  width: 100%;
  appearance: none;
  height: 5px;
  border-radius: 999px;
  background: #1a2b42;
  cursor: pointer;
}

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

.scrubber-range::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--cyan);
  border: 2px solid #050911;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.7);
}

.loop-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

/* Right Clinical Control Sidebar */
.control-sidebar {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100%;
}

.panel-section {
  padding: 13px 15px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.section-header h2 {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

/* Sensor Chip Source Switch */
.chip-switch-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  background: #060b14;
  padding: 4px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-subtle);
}

.chip-mode-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.chip-mode-btn:hover {
  color: var(--text-primary);
}

.chip-mode-btn.is-active[data-sensor-mode="fused"] {
  background: var(--cyan-soft);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.chip-mode-btn.is-active[data-sensor-mode="adxl367"] {
  background: rgba(34, 211, 238, 0.18);
  border-color: rgba(34, 211, 238, 0.5);
  color: #67e8f9;
}

.chip-mode-btn.is-active[data-sensor-mode="bmi270"] {
  background: var(--emerald-soft);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

/* Dual BLE Slots */
.hz-live {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.73rem;
  color: #7dd3fc;
  background: var(--cyan-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

.dual-ble-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.ble-slot {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ble-slot.is-connected {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.08);
}

.slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slot-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text-primary);
}

.slot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #475569;
}

.ble-slot.is-connected .slot-dot {
  background: var(--emerald);
  box-shadow: 0 0 7px var(--emerald);
}

.slot-hz {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.71rem;
  color: var(--text-muted);
}

.ble-slot.is-connected .slot-hz {
  color: #6ee7b7;
}

.slot-dev {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ble-slot.is-connected .slot-dev {
  color: var(--text-secondary);
}

.slot-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px;
}

.btn-slot-connect {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  background: #0284c7;
  color: #f8fafc;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-slot-connect:hover {
  background: #0369a1;
}

.ble-slot.is-connected .btn-slot-connect {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fecdd3;
}

.btn-slot-pause {
  padding: 5px 7px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: 0.73rem;
  cursor: pointer;
}

.btn-slot-pause:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-subtle {
  padding: 5px 10px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.btn-subtle:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

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

.field-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.rate-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.num-input {
  width: 60px;
  padding: 4px 7px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: 0.8rem;
}

.ble-hint {
  margin: 7px 0 0;
  font-size: 0.73rem;
  color: var(--text-muted);
}

/* Simulator Buttons */
.link-btn {
  border: none;
  background: none;
  padding: 2px 4px;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.sim-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.sim-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sim-btn.is-active {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.sim-btn-span2 {
  grid-column: span 2;
}

.sim-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-ok { background: var(--emerald); }
.dot-warn { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot-crit { background: var(--crimson); }

/* Inspect Foot Tabs */
.inspect-tabs {
  display: inline-flex;
  background: #060b14;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.tab-foot {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-foot.is-active {
  background: var(--bg-elevated);
  color: #7dd3fc;
}

/* Waveform Chart & Telemetry Readouts */
.chart-box {
  background: #060b14;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  padding: 7px 8px 6px;
  margin-bottom: 9px;
}

#wave-canvas {
  display: block;
  width: 100%;
  height: 104px;
}

.chart-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 5px;
  padding: 0 2px;
}

.c-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 4px;
}
.c-fused { background: var(--cyan); }
.c-adxl { background: var(--emerald); }
.c-tilt { background: var(--amber); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 9px;
}

.metric-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.m-label {
  font-size: 0.71rem;
  color: var(--text-muted);
}

.m-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.raw-table {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #070d17;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-ctrl);
  padding: 8px 10px;
}

.raw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.73rem;
  transition: opacity 150ms ease;
}

.raw-row.is-bypassed {
  opacity: 0.34;
  text-decoration: line-through;
}

.chip-name {
  color: var(--text-secondary);
}
.chip-adxl { color: #67e8f9; }
.chip-bmi { color: #6ee7b7; }
.chip-gyro { color: #c4b5fd; }

.raw-nums {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  font-size: 0.72rem;
}

.raw-align-note {
  padding-top: 4px;
  margin-top: 2px;
  border-top: 1px dashed var(--border-subtle);
}

.raw-align-note .raw-nums {
  color: #7dd3fc;
  font-size: 0.71rem;
}

/* Event Log */
.log-section {
  flex: 1;
  border-bottom: none;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-empty {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 6px 0;
}

.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-ctrl);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
}

.event-item.is-fall {
  border-color: rgba(244, 63, 94, 0.42);
  background: rgba(244, 63, 94, 0.10);
}

.event-item.is-warn {
  border-color: rgba(245, 158, 11, 0.36);
}

.event-time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.event-title {
  font-weight: 600;
  color: var(--text-primary);
}

.event-meta {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-size: 0.71rem;
}

/* Responsive Tablet & Mobile Layout */
@media (max-width: 960px) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .viewport-pane {
    height: auto;
  }

  .canvas-wrap {
    flex: none;
    height: 450px;
  }

  .control-sidebar {
    border-left: none;
    border-top: 1px solid var(--border-subtle);
    height: auto;
    overflow: visible;
  }

  .hud-top-left {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 6px;
    max-width: none;
  }

  .posture-banner {
    padding: 8px 11px;
  }

  .posture-label {
    font-size: 0.9rem;
  }

  .posture-sub {
    font-size: 0.72rem;
  }

  .hud-top-right {
    top: auto;
    bottom: 10px;
    right: 10px;
    left: 10px;
    justify-content: space-between;
    gap: 6px;
  }

  .vector-legend {
    display: none;
  }

  .replay-dock {
    padding: 10px 12px;
  }

  .ctrl-select {
    max-width: 180px;
  }
}

@media (max-width: 480px) {
  .canvas-wrap {
    height: 430px;
  }

  .cam-group .cam-btn {
    padding: 4px 7px;
    font-size: 0.71rem;
  }

  .hud-btn {
    padding: 5px 8px;
  }

  .hud-btn span {
    display: none;
  }

  .record-actions {
    width: 100%;
    justify-content: space-between;
  }

  .record-actions .dock-btn {
    flex: 1;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  .clip-controls {
    width: 100%;
  }

  .clip-controls .ctrl-select {
    flex: 1;
    max-width: none;
  }

  .dock-scrubber-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .scrubber-track-wrap {
    order: -1;
    flex: 0 0 100%;
  }
}
