/* ============================================================
   ArduPilot Log Viewer — Stylesheet
   Aesthetic: refined engineering / cockpit instrumentation
   Display:   JetBrains Mono (technical, monospace authority)
   Body:      Outfit (clean, modern, legible)
   ============================================================ */

:root {
  /* Spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;

  /* Type */
  --font-display: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Radii */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ---- DARK THEME (default) — HUD / cockpit at night ---- */
:root[data-theme='dark'] {
  --bg: #0a0e14;
  --bg-1: #0f141c;
  --bg-2: #161c26;
  --bg-3: #1d2532;
  --bg-elev: #1a212c;

  --border: #232c3a;
  --border-strong: #2e3a4d;

  --fg: #e6ecf3;
  --fg-muted: #8794a8;
  --fg-dim: #5b6677;

  --accent: #ffb84d;        /* amber HUD */
  --accent-soft: #ffb84d22;
  --accent-2: #4dd6ff;      /* cyan */
  --accent-2-soft: #4dd6ff22;
  --danger: #ff6b7a;
  --success: #6ee7a7;

  --grid-color: rgba(77, 214, 255, 0.04);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.03), 0 8px 24px rgba(0, 0, 0, 0.4);

  /* Plot palette — a cohesive set of telemetry-channel colors */
  --p1: #ffb84d;
  --p2: #4dd6ff;
  --p3: #ff7eb6;
  --p4: #6ee7a7;
  --p5: #c490ff;
  --p6: #ffd166;
  --p7: #66d9ef;
  --p8: #ff9966;
}

/* ---- LIGHT THEME — engineering blueprint ---- */
:root[data-theme='light'] {
  --bg: #f6f5f0;
  --bg-1: #ffffff;
  --bg-2: #f0eee7;
  --bg-3: #e6e3d8;
  --bg-elev: #ffffff;

  --border: #d9d5c7;
  --border-strong: #b8b4a4;

  --fg: #14161a;
  --fg-muted: #5b6677;
  --fg-dim: #8a93a3;

  --accent: #c2410c;        /* burnt orange — print-shop accent */
  --accent-soft: #c2410c1a;
  --accent-2: #0e4d8a;      /* deep blueprint blue */
  --accent-2-soft: #0e4d8a1a;
  --danger: #c2410c;
  --success: #166534;

  --grid-color: rgba(14, 77, 138, 0.05);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.6), 0 6px 18px rgba(20, 22, 26, 0.06);

  --p1: #c2410c;
  --p2: #0e4d8a;
  --p3: #9d174d;
  --p4: #166534;
  --p5: #6b21a8;
  --p6: #92400e;
  --p7: #155e75;
  --p8: #9a3412;
}

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

/* The native [hidden] rule has the same specificity as a class selector,
 * so any class with `display: flex` (.drop-zone, .parse-status, etc.)
 * will silently win the cascade and leave the section visible. Force it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

button { font-family: inherit; }
input { font-family: inherit; }

/* =========== DECORATIVE GRID BG =========== */
.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at 50% 0%, rgba(0,0,0,1) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
}

/* =========== HEADER =========== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--accent);
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

/* The HCR logo uses navy blue + orange on a white background. On the
 * light theme it sits naturally on the page. On the dark theme the
 * navy blue strokes get hard to read against the dark background, so
 * we lift them with a subtle white drop-shadow that doesn't change
 * the colour palette. */
[data-theme='dark'] .brand-logo {
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.5));
}

.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.15em;
  color: var(--fg);
}

.brand-sub {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.log-info {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-1);
  font-family: var(--font-mono);
  font-size: 12px;
}

.log-info-name {
  color: var(--fg);
  font-weight: 500;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-info-size {
  color: var(--fg-muted);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-1);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.icon-btn:hover {
  background: var(--bg-2);
  border-color: var(--border-strong);
  color: var(--accent);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.icon-sun, .icon-moon {
  position: absolute;
  transition: opacity 0.2s var(--ease), transform 0.3s var(--ease);
}
:root[data-theme='dark'] .icon-sun {
  opacity: 1; transform: rotate(0deg) scale(1);
}
:root[data-theme='dark'] .icon-moon {
  opacity: 0; transform: rotate(-90deg) scale(0.6);
}
:root[data-theme='light'] .icon-sun {
  opacity: 0; transform: rotate(90deg) scale(0.6);
}
:root[data-theme='light'] .icon-moon {
  opacity: 1; transform: rotate(0deg) scale(1);
}
#themeToggle { position: relative; }

/* =========== MAIN =========== */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--s-5) var(--s-6);
}

/* =========== DROP ZONE =========== */
.drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--bg-1);
  padding: var(--s-7);
  min-height: 360px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-inner {
  text-align: center;
  max-width: 480px;
}

.drop-icon {
  color: var(--accent);
  display: inline-block;
  margin-bottom: var(--s-4);
}
.drop-icon svg { width: 56px; height: 56px; }

.drop-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 var(--s-3) 0;
  color: var(--fg);
}

.drop-sub {
  color: var(--fg-muted);
  margin: 0 0 var(--s-5) 0;
  font-size: 14px;
}

.drop-sub code {
  font-family: var(--font-mono);
  background: var(--bg-2);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--accent);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.15s var(--ease), filter 0.15s var(--ease);
}

.upload-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.drop-hint {
  margin-top: var(--s-4);
  font-size: 12px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* =========== PARSE STATUS =========== */
.parse-status {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-7);
}

.parse-inner {
  display: flex;
  align-items: flex-start;
  gap: var(--s-5);
  max-width: 480px;
  width: 100%;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.parse-text { flex: 1; }
.parse-text h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 var(--s-1) 0;
  color: var(--fg);
}

.parse-detail {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  margin: 0 0 var(--s-3) 0;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--bg-2);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s var(--ease);
}

/* =========== ERROR =========== */
.error-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s-7);
}

.error-panel h2 {
  font-family: var(--font-display);
  color: var(--danger);
  margin: 0 0 var(--s-3) 0;
}

.error-panel p {
  color: var(--fg-muted);
  max-width: 480px;
  margin: 0 0 var(--s-5) 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* =========== WORKSPACE =========== */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-5);
  position: relative;
}

.tab {
  background: none;
  border: none;
  padding: var(--s-3) var(--s-4);
  cursor: pointer;
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  transition: color 0.15s var(--ease);
}

.tab .tab-num {
  font-size: 10px;
  color: var(--fg-dim);
}

.tab:hover { color: var(--fg); }

.tab.active {
  color: var(--accent);
}

.tab.active .tab-num { color: var(--accent); }

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

.tabs-meta {
  margin-left: auto;
  align-self: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  padding: 0 var(--s-3);
}

.tab-panel {
  flex: 1;
  display: none;
}
.tab-panel.active { display: flex; }

#tab-plot { gap: var(--s-5); }
@media (max-width: 900px) {
  #tab-plot { flex-direction: column; }
}

/* =========== PLOT TAB =========== */
.plot-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

@media (max-width: 900px) {
  .plot-sidebar { width: 100%; }
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.sidebar-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: var(--s-1);
}

.text-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 13px;
  font-family: var(--font-body);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elev);
}

.text-input.wide { flex: 1; min-width: 220px; }

.msg-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  padding: var(--s-1);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.msg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.1s var(--ease);
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.msg-item:hover { background: var(--bg-2); }

.msg-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.msg-item .count {
  font-size: 10px;
  color: var(--fg-dim);
}

.msg-item.active .count {
  color: var(--accent);
  opacity: 0.8;
}

.field-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  padding: var(--s-1);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.field-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.1s var(--ease);
}

.field-item:hover { background: var(--bg-2); }

.field-item input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--bg-elev);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.field-item input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.field-item input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.field-item .field-name {
  flex: 1;
  color: var(--fg);
}

.field-item .field-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.btn {
  padding: 8px 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: filter 0.15s var(--ease);
}

.btn:hover { filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-2);
  border-color: var(--border-strong);
  filter: none;
}

.btn.full { width: 100%; }

.plot-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  position: relative;
  min-height: 480px;
}

.plot-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  padding: 0 0 var(--s-3) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-3);
}

.lock-zoom {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.lock-zoom:hover {
  background: var(--bg-elev);
  color: var(--fg);
}

.lock-zoom input[type='checkbox'] {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 2px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.lock-zoom input[type='checkbox']:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.lock-zoom input[type='checkbox']:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.lock-zoom input[type='checkbox']:checked + .lock-zoom-icon,
.lock-zoom:has(input:checked) {
  color: var(--accent);
}

.lock-zoom-icon {
  font-size: 13px;
  line-height: 1;
}

.plot-container {
  flex: 1;
  min-height: 420px;
  width: 100%;
}

.plot-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  pointer-events: none;
}

.plot-empty.hidden { display: none; }

.series-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}

.series-legend:empty { display: none; }

.series-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}

.series-chip .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* =========== TABLES =========== */
#tab-params, #tab-messages {
  flex-direction: column;
}

.param-toolbar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.table-wrap, .messages-wrap {
  flex: 1;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
  max-height: calc(100vh - 280px);
  min-height: 400px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-2);
}

.data-table th {
  text-align: left;
  padding: 10px var(--s-4);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 8px var(--s-4);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--bg-2); }

.data-table .param-name { color: var(--fg); font-weight: 500; }
.data-table .param-value { color: var(--accent); font-weight: 500; }

.messages-table .ts-col {
  width: 110px;
  color: var(--fg-muted);
}

.messages-table td:first-child {
  color: var(--fg-muted);
  white-space: nowrap;
}

.messages-table tr.msg-row {
  cursor: zoom-in;
}

.messages-table tr.msg-row:hover td {
  background: var(--accent-2-soft);
  color: var(--fg);
}

.messages-table tr.msg-row.flash td {
  background: var(--accent-2);
  color: var(--bg);
  transition: background 0.1s var(--ease), color 0.1s var(--ease);
}

.muted { color: var(--fg-muted); }
.small { font-size: 11px; font-family: var(--font-mono); }

/* =========== FOOTER =========== */
.app-footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  text-align: center;
  letter-spacing: 0.05em;
}

/* =========== SCROLLBAR =========== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }

/* =========== RESPONSIVE =========== */
@media (max-width: 900px) {
  .brand-text { display: none; }
  .brand-divider { display: none; }
  .brand-logo { height: 32px; }
}

@media (max-width: 700px) {
  .app-header { padding: var(--s-3) var(--s-4); }
  .app-main { padding: var(--s-3); }
  .log-info { display: none; }
  .drop-title { font-size: 22px; }
  .drop-zone { padding: var(--s-5); }
  .tabs-meta { display: none; }
  .tab .tab-num { display: none; }
  .brand-logo { height: 28px; }
}

/* =========== HARDWARE VIEW =========== */
.hardware-wrap {
  flex: 1;
  min-width: 0;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  overflow: auto;
}

.hardware-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--s-4);
  align-content: start;
}

.hw-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.hw-section-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
}

.hw-subsection {
  background: var(--bg-1);
  border-left: 2px solid var(--accent-2);
  padding: var(--s-2) var(--s-3);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.hw-subsection-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: var(--s-2);
}

.hw-items {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  gap: 6px var(--s-3);
  font-size: 12px;
  font-family: var(--font-mono);
}

.hw-items dt {
  color: var(--fg-muted);
}

.hw-items dd {
  margin: 0;
  color: var(--fg);
  word-break: break-word;
}


/* Instance suffix in message list ("IMU[0]" → emphasised brackets) */
.msg-instance {
  color: var(--accent-2);
  font-size: 0.85em;
  opacity: 0.8;
  margin-left: 1px;
  font-weight: 400;
}

/* =========== MULTI-PLOT STACK =========== */
.plot-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.plot-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  position: relative;
  min-height: 360px;
  /* Subtle accent on the active panel so the user knows where the
   * "Fields" checkbox clicks will land. */
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.plot-panel.active {
  border-color: var(--accent);
}

.plot-panel-header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  margin-bottom: var(--s-2);
}

.plot-panel.active .plot-panel-label {
  color: var(--accent);
  font-weight: 500;
}

.plot-panel-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.plot-panel-active-pill {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  display: none;
}

.plot-panel.active .plot-panel-active-pill {
  display: inline-block;
}

.plot-panel-actions {
  margin-left: auto;
  display: flex;
  gap: var(--s-2);
}

.plot-panel-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.plot-panel-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.plot-panel .plot-container {
  flex: 1;
  min-height: 280px;
  width: 100%;
}

.plot-panel .plot-empty {
  position: absolute;
  inset: var(--s-3);
  top: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 12px;
  pointer-events: none;
  text-align: center;
  padding: var(--s-3);
}

.plot-panel .plot-empty.hidden { display: none; }

.plot-panel .series-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid var(--border);
  min-height: 18px;
}

.plot-panel .series-legend:empty {
  display: none;
}

.toolbar-spacer { flex: 1; }

.btn-sm {
  font-size: 11px;
  padding: 5px 10px;
}


/* =========== EXPORT DOWNLOAD LINK =========== */
/* When the export data is ready, we swap the button for an <a> link.
   This needs to look like an actionable element — more prominent than
   the ghost button so the user notices the state change. */
a.export-ready {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
  animation: export-pulse 1.5s ease-in-out 2;
}
a.export-ready:hover {
  filter: brightness(1.1);
}
@keyframes export-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}


/* =========== PARAMETER DEFAULTS =========== */
.param-changed-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.param-changed-toggle input[type="checkbox"] {
  accent-color: var(--accent);
}

tr.param-changed .param-name {
  color: var(--accent);
  font-weight: 500;
}

tr.param-changed .param-value {
  color: var(--accent);
  font-weight: 500;
}

.param-default {
  color: var(--fg-dim);
  font-size: 11px;
  opacity: 0.7;
}

.param-default-col {
  color: var(--fg-dim);
  font-size: 10px;
}

/* Hover on any param row shows a subtle highlight */
.data-table tbody tr[title]:hover {
  background: var(--bg-elev);
}

