/* ─────────────────────────────────────────
   NeuroRest — style.css
   Neumorphism Light Theme (v2.0)
   Background #F0F0F3 · Soft dual shadows · Glass accents
───────────────────────────────────────── */

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

:root {
  /* ── Base palette ── */
  --bg: #f0f0f3;
  --bg-soft: #eaeaef;
  --surface: #f0f0f3;
  --surface2: #e8e8ed;
  --surface-press: #e2e2e8;

  /* ── Binaural beat background gradient stops ── */
  --bg-1: #fbf8f3;
  --bg-2: #f0eef5;

  /* ── Text ── */
  --text: #2d3748;
  --text-strong: #1a202c;
  --text-muted: #8a92a6;
  --text-soft: #b0b6c4;

  /* ── Brand accents (kept) ── */
  --accent1: #7c3aed;
  --accent2: #06b6d4;
  --accent3: #f59e0b;

  /* ── Pastel palette (Apple Vision Pro–style) ── */
  --pastel-peach:    #ffd8b5;
  --pastel-blush:    #ffc7d3;
  --pastel-pink:     #ffd0e4;
  --pastel-rose:     #ffb5c5;
  --pastel-sky:      #c7d8ff;
  --pastel-blue:     #b9d0ff;
  --pastel-mint:     #c8efe0;
  --pastel-sage:     #d6ecdc;
  --pastel-lavender: #dccffa;
  --pastel-violet:   #e1d3ff;
  --pastel-cream:    #fff1de;
  --pastel-lemon:    #fff0c2;

  /* ── Pastel gradients (for accent strips, badges, hero cards) ── */
  --grad-peach-blush:   linear-gradient(135deg, #ffd8b5 0%, #ffc7d3 100%);
  --grad-blush-violet:  linear-gradient(135deg, #ffc7d3 0%, #dccffa 100%);
  --grad-sky-mint:      linear-gradient(135deg, #c7d8ff 0%, #c8efe0 100%);
  --grad-mint-sky:      linear-gradient(135deg, #c8efe0 0%, #b9d0ff 100%);
  --grad-violet-sky:    linear-gradient(135deg, #dccffa 0%, #c7d8ff 100%);
  --grad-cream-blush:   linear-gradient(135deg, #fff1de 0%, #ffd0e4 100%);
  --grad-rose-peach:    linear-gradient(135deg, #ffb5c5 0%, #ffd8b5 100%);
  --grad-brand:         linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  --grad-dark:          linear-gradient(135deg, #3a3a44 0%, #14141c 100%);
  --grad-dark-soft:     linear-gradient(135deg, #4a4a55 0%, #1f1f2a 100%);

  /* ── Status colors (kept for data semantics, slightly desaturated) ── */
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --pink: #ec4899;
  --violet: #a855f7;

  /* ── Neumorphism shadows (softer, warm-tinted) ── */
  /* Raised card (large) */
  --shadow-out: -10px -10px 28px rgba(255, 255, 255, 0.95),
                 12px  14px 32px rgba(174, 165, 195, 0.32);
  /* Raised card (small / button) */
  --shadow-out-sm: -6px -6px 14px rgba(255, 255, 255, 0.9),
                    6px  8px 16px rgba(174, 165, 195, 0.28);
  /* Tiny float (pill / badge) */
  --shadow-out-xs: -3px -3px 8px rgba(255, 255, 255, 0.85),
                    3px  4px 10px rgba(174, 165, 195, 0.22);
  /* Pressed / inset */
  --shadow-in: inset  6px  6px 12px rgba(174, 165, 195, 0.28),
               inset -6px -6px 12px rgba(255, 255, 255, 0.95);
  --shadow-in-sm: inset 3px 3px 6px rgba(174, 165, 195, 0.20),
                  inset -3px -3px 6px rgba(255, 255, 255, 0.9);
  /* Subtle hover lift (with warm violet glow) */
  --shadow-hover: -12px -12px 30px rgba(255, 255, 255, 1),
                   14px  16px 36px rgba(180, 150, 220, 0.28);

  /* ── Glass surfaces (frosted card on pastel bg) ── */
  --glass-card-bg:    rgba(255, 255, 255, 0.55);
  --glass-card-bg-2:  rgba(255, 255, 255, 0.40);
  --glass-bg:         rgba(255, 255, 255, 0.55);
  --glass-border:     rgba(255, 255, 255, 0.65);
  --glass-shadow:     0 10px 36px rgba(174, 165, 195, 0.22);

  /* ── Hairline border (very faint, optional) ── */
  --border: rgba(174, 165, 195, 0.18);

  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 26px;
  --header-h: 64px;
  --font: 'Inter', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html {
  scroll-behavior: smooth;
}

/* ─────────────── LINE ICONS ─────────────── */
.icon {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.18em;
  flex-shrink: 0;
  display: inline-block;
}

/* Icon size variants */
.icon-tab    { width: 1.05em; height: 1.05em; vertical-align: -0.20em; }
.icon-h1     { width: 1.05em; height: 1.05em; vertical-align: -0.16em; margin-right: 4px; }
.icon-title  { width: 1.15em; height: 1.15em; vertical-align: -0.22em; margin-right: 6px; }
.icon-fc     { width: 32px; height: 32px; stroke-width: 1.6; }
.icon-inline { width: 1.1em; height: 1.1em; vertical-align: -0.18em; margin-right: 4px; }
.icon-btn    { width: 1.05em; height: 1.05em; vertical-align: -0.18em; margin-right: 4px; }

/* ── Per-icon brand colours ────────────────────────────
   :has() targets the wrapping <svg> by which symbol it references.
   :not(.icon-btn) keeps button-context icons inheriting the button's
   own text colour (white on dark gradient buttons). */
.icon:not(.icon-btn):has(use[href="#i-bolt"])      { color: #f59e0b; }  /* amber — band power */
.icon:not(.icon-btn):has(use[href="#i-motion"])    { color: #06b6d4; }  /* cyan — motion */
.icon:not(.icon-btn):has(use[href="#i-target"])    { color: #ef4444; }  /* coral — performance */
.icon:not(.icon-btn):has(use[href="#i-command"])   { color: #a855f7; }  /* violet — mental command */
.icon:not(.icon-btn):has(use[href="#i-gear"])      { color: #64748b; }  /* slate — system */
.icon:not(.icon-btn):has(use[href="#i-signal"])    { color: #0891b2; }  /* deep cyan — device/signal */
.icon:not(.icon-btn):has(use[href="#i-brain"])     { color: #7c3aed; }  /* purple — EEG */
.icon:not(.icon-btn):has(use[href="#i-face"])      { color: #ec4899; }  /* pink — facial */
.icon:not(.icon-btn):has(use[href="#i-eye"])       { color: #0891b2; }  /* teal — eye */
.icon:not(.icon-btn):has(use[href="#i-face-up"])   { color: #10b981; }  /* green — upper face */
.icon:not(.icon-btn):has(use[href="#i-face-down"]) { color: #f97316; }  /* orange — lower face */
.icon:not(.icon-btn):has(use[href="#i-heart"])     { color: #ef4444; }  /* red — heart */
.icon:not(.icon-btn):has(use[href="#i-wind"])      { color: #06b6d4; }  /* sky — breathing */
.icon:not(.icon-btn):has(use[href="#i-chart"])     { color: #10b981; }  /* emerald — chart/history */
.icon:not(.icon-btn):has(use[href="#i-back"])      { color: #64748b; }  /* slate — back arrow */

body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 700px at 12% -10%, #ffe9d6 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 20%, #d8e4ff 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, #e4d8ff 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--surface2);
  border-radius: 10px;
  box-shadow: inset 1px 1px 2px rgba(174, 174, 192, 0.3),
              inset -1px -1px 2px #ffffff;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--grad-dark);
  opacity: 0.7;
}

/* ─────────────── HEADER ─────────────── */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: 0 4px 24px rgba(174, 174, 192, 0.22);
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--glass-card-bg);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  border: 1px solid var(--glass-border);
  padding: 6px;
}

.brand-icon svg {
  width: 28px;
  height: 28px;
}

.brand-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #000000;
  letter-spacing: -0.5px;
}

.brand-badge {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--green);
  background: var(--bg);
  border-radius: 6px;
  padding: 3px 8px;
  box-shadow: var(--shadow-in-sm);
  animation: pulse-badge 2s infinite;
}

.headset-name {
  display: inline-flex;
  display: none !important;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #0891b2;
  background: var(--bg);
  border-radius: 8px;
  padding: 4px 10px;
  margin-left: 4px;
  white-space: nowrap;
  box-shadow: var(--shadow-out-xs);
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ── TAB NAV ── */
html { scroll-behavior: smooth; }

/* Anchor sections in panel-pow leave room for the fixed header
   so they don't disappear under it on scroll-into-view. */
.pow-grid-wrapper[id^="sec-"] {
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.tab-nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 4px;
  background: var(--glass-card-bg-2);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: var(--shadow-in-sm);
}

.tab-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn,
.tab-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 1.1rem;
  letter-spacing: .02em;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: all 0.25s ease;
}

.tab-btn:hover,
.tab-link:hover {
  color: var(--accent1);
}

.tab-btn.active,
.tab-link.active {
  color: var(--accent1);
  background: var(--bg);
  box-shadow: var(--shadow-out-xs);
  font-weight: 600;
}

/* .tab-icon — now handled by .icon.icon-tab on inline SVGs */

/* ── STATUS ── */
.header-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-soft);
  box-shadow: var(--shadow-in-sm);
  transition: all 0.3s;
}

.status-dot.connected {
  background: var(--green);
  box-shadow: 0 0 10px var(--green), inset 1px 1px 2px rgba(255, 255, 255, 0.4);
}

.status-dot.demo {
  background: var(--yellow);
  box-shadow: 0 0 10px var(--yellow), inset 1px 1px 2px rgba(255, 255, 255, 0.4);
}

.status-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

#loginBtnHeader,
.login-btn-header {
  display: none !important;
}

.login-btn-header {
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.25s ease;
  letter-spacing: 0.2px;
}

.login-btn-header:hover {
  color: var(--accent1);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.login-btn-header:active {
  box-shadow: var(--shadow-in-sm);
  transform: translateY(0);
}

/* ─────────────── MAIN ─────────────── */
.main {
  margin-top: var(--header-h);
  padding: 18px 32px 36px 32px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

/* ── PANELS ── */
.tab-panel {
  display: none;
  animation: fadeIn 0.35s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: var(--header-h);
  z-index: 90;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  padding: 18px 22px;
  max-width: 1336px;
  margin: -18px auto 28px auto;
  border-bottom: 1px solid var(--glass-border);
  border-radius: 0 0 18px 18px;
  box-shadow: 0 8px 24px rgba(174, 174, 192, 0.22);
}

.panel-header-text {
  flex: 1;
}

.panel-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-strong);
}

.panel-header h1 span {
  font-size: 1rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

.panel-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ── CSV Export Button ── */
.csv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 45%),
    var(--grad-dark);
  color: #fff;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: -4px -4px 10px rgba(255, 255, 255, 0.9),
                4px  4px 12px rgba(40, 40, 56, 0.35),
              inset 1px 1px 0 rgba(255, 255, 255, 0.18);
  transition: all 0.22s ease;
}

.csv-btn:hover {
  transform: translateY(-2px);
  box-shadow: -5px -5px 14px rgba(255, 255, 255, 1),
                6px  6px 18px rgba(40, 40, 56, 0.45),
              inset 1px 1px 0 rgba(255, 255, 255, 0.22);
}

.csv-btn:active {
  transform: translateY(0);
  box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.30),
              inset -3px -3px 6px rgba(255, 255, 255, 0.10);
}

/* ── CSV Button Wrapper + Live Clock ── */
.csv-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

.csv-live-clock {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  text-align: right;
  white-space: nowrap;
  padding: 0 2px;
  transition: color 0.3s;
}

.csv-live-clock:not(:empty) {
  animation: clock-tick 1s steps(1) infinite;
}

@keyframes clock-tick {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.55; }
}

/* ── RAW BOX ── */
.raw-box {
  margin-top: 24px;
  background: var(--glass-card-bg-2);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-in);
}

.raw-label {
  padding: 10px 18px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.4);
  border-bottom: 1px solid var(--border);
}

.raw-box pre {
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--accent1);
  padding: 14px 18px;
  max-height: 130px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─────────────── EEG ─────────────── */
.eeg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.eeg-channel {
  background: var(--glass-card-bg);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.3s ease;
}

.eeg-channel:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.eeg-ch-name {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.eeg-ch-val {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent1);
}

.eeg-ch-unit {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-wrap {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 18px;
  height: 200px;
  box-shadow: var(--shadow-in);
}

#eegCanvas {
  width: 100%;
  height: 100%;
}

/* ─────────────── MOTION ─────────────── */
.motion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
  margin-top: 0 !important;
  padding: 18px !important;
  background: var(--bg) !important;
}

.motion-card {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* 100% width top strip — sensor's representative colour */
.motion-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #06b6d4;          /* Quaternion — cyan */
}

.motion-card:nth-child(2)::after { background: #10b981; }  /* Accelerometer — green */
.motion-card:nth-child(3)::after { background: #f59e0b; }  /* Magnetometer — amber */

.motion-card:hover {
  box-shadow: var(--shadow-hover);
}

.mc-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 14px;
  text-transform: uppercase;
}

.mc-values {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow-in-sm);
}

.mv-row span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}

.mv-row span:last-child {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--accent1);
  font-weight: 600;
}

/* ─────────────── DEVICE ─────────────── */
.dev-top {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.battery-card,
.signal-card {
  flex: 1;
  min-width: 200px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-out);
  position: relative;
  overflow: hidden;
}

/* 100% width top strip — semantic colour */
.battery-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: #10b981;          /* battery — green */
  border-radius: 0;
}

.signal-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: #0891b2;          /* signal — deep cyan */
  border-radius: 0;
}

.bat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.bat-bar-wrap {
  width: 100%;
  height: 14px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-in-sm);
  padding: 2px;
}

.bat-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  border-radius: 6px;
  transition: width 0.5s ease;
  box-shadow: 0 1px 4px rgba(124, 58, 237, 0.4);
}

.bat-pct {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.signal-ring {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-in);
  padding: 4px;
}

.signal-ring svg {
  width: 76px;
  height: 76px;
}

.signal-ring svg circle:first-of-type {
  stroke: var(--surface2) !important;
}

.signal-ring span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent1);
}

#signalArc {
  transition: stroke-dashoffset 0.5s ease;
}

.cq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  margin-top: 18px;
}

.cq-card {
  background: var(--glass-card-bg);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow-out-xs);
  transition: all 0.3s;
}

.cq-card:hover {
  box-shadow: var(--shadow-out-sm);
  transform: translateY(-2px);
}

.cq-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
  font-weight: 700;
}

.cq-bar-wrap {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
  box-shadow: var(--shadow-in-sm);
  padding: 1px;
}

.cq-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.4s ease;
}

.cq-val {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

/* ─────────────── METRICS ─────────────── */
.met-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.met-card {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.3s ease;
}

.met-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* 100% width top strip — each metric uses its semantic colour */
.met-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 0;
  background: #06b6d4;
}

/* Engagement / Excitement / LongExcite / Stress / Relax / Interest / Focus */
.met-card:nth-child(1)::after { background: #06b6d4; }  /* 投入度 — cyan */
.met-card:nth-child(2)::after { background: #f59e0b; }  /* 興奮度 — amber */
.met-card:nth-child(3)::after { background: #f59e0b; }  /* 長期興奮 — amber */
.met-card:nth-child(4)::after { background: #ef4444; }  /* 壓力 — red */
.met-card:nth-child(5)::after { background: #10b981; }  /* 放鬆度 — green */
.met-card:nth-child(6)::after { background: #a78bfa; }  /* 興趣度 — lavender */
.met-card:nth-child(7)::after { background: #7c3aed; }  /* 專注度 — purple */

.met-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad-brand);
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: 3px;
}

.met-card.active-metric::before {
  opacity: 1;
}

.met-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  font-weight: 700;
}

.met-val {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-strong);
  margin-bottom: 10px;
}

.met-bar-wrap {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-in-sm);
  padding: 1px;
}

.met-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  transition: width 0.4s ease;
}

.met-active-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.met-active-badge.on {
  background: var(--bg);
  color: var(--green);
  box-shadow: var(--shadow-in-sm);
}

.met-active-badge.off {
  background: var(--bg);
  color: var(--text-muted);
  box-shadow: var(--shadow-in-sm);
}

/* ─────────────── BAND POWER ─────────────── */

/* ── Averaged chart block ── */
.pow-avg-block {
  background: var(--glass-card-bg);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-out);
}

.pow-avg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.pow-avg-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 0.3px;
}

.pow-avg-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.leg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.pow-avg-vals {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.pav-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  background: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.85) !important;
  border-radius: 14px;
  padding: 12px 16px;
  flex: 1;
  min-width: 150px;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

/* 100% width top accent strip — each band uses its representative semantic colour */
.pav-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 0;
  background: linear-gradient(135deg, #3a3a44, #14141c); /* default: 大腦平均頻率 dark */
}

.pav-ratio::after { background: linear-gradient(90deg, #f59e0b, #ef4444); } /* θ/α */
.pav-theta::after { background: #a855f7; }                                  /* Theta */
.pav-alpha::after { background: #06b6d4; }                                  /* Alpha */
.pav-beta::after  { background: #10b981; }                                  /* Beta */
.pav-gamma::after { background: #ef4444; }                                  /* Gamma */

.pav-item:hover {
  box-shadow: var(--shadow-out-sm);
  transform: translateY(-1px);
}

.pav-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.pav-name {
  font-size: 1rem;
  color: var(--text-muted);
  flex: 1;
  white-space: nowrap;
  font-weight: 600;
}

.pav-val {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-strong);
  width: 100%;
  text-align: right;
  margin-top: 4px;
}

.pav-ratio .pav-val { color: var(--accent3); }
.pav-theta .pav-val { color: var(--violet); }
.pav-alpha .pav-val { color: #0891b2; }
.pav-beta  .pav-val { color: var(--green); }
.pav-gamma .pav-val { color: var(--red); }

.pow-avg-chart-wrap {
  height: 220px;
  position: relative;
  width: 100%;
  min-width: 1300px;
  overflow-x: auto;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-in);
}

#powAvgCanvas,
#bleChartCanvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.pow-grid,
.pow-table-box,
.motion-grid,
.fac-grid,
.eeg-grid,
.com-center,
.pow-avg-block {
  transition: max-height 0.4s ease, margin 0.4s ease, opacity 0.4s ease, padding 0.4s ease;
  overflow: hidden;
  max-height: 2000px;
  opacity: 1;
}

#metTableWrapper,
#powTableWrapper {
  margin-top: 0 !important;
}

.pow-grid.collapsed,
.pow-table-box.collapsed,
.motion-grid.collapsed,
.fac-grid.collapsed,
.eeg-grid.collapsed,
.com-center.collapsed,
.pow-avg-block.collapsed {
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  border-top: none;
  border-bottom: none;
  box-shadow: none;
}

.pow-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.pow-grid-wrapper {
  border-radius: var(--radius);
  background: transparent;
}

.pow-grid-header {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 14px 22px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.pow-grid-header::before {
  display: none;          /* top accent strip removed per request */
}

.pow-grid-header:hover {
  box-shadow: var(--shadow-hover);
}

.pow-grid-header.active {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  box-shadow: -6px -6px 14px rgba(255, 255, 255, 0.95),
                6px  6px 14px rgba(174, 174, 192, 0.25);
}

.pow-grid-header .toggle-icon {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: transform 0.3s;
}

.pow-grid-header.active .toggle-icon {
  transform: rotate(180deg);
  color: var(--accent1);
}

@media (max-width: 1200px) {
  .pow-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

.pow-card {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* 100% width top strip — band power's representative colour (amber) */
.pow-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: #f59e0b;
}

.pow-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.pow-ch {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent1);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

.pow-bands {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pow-band-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pow-band-name {
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 44px;
  flex-shrink: 0;
  font-weight: 600;
}

.pow-band-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow-in-sm);
  padding: 1px;
}

.pow-band-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.pow-band-val {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 600;
}

.band-theta { background: var(--violet); }
.band-alpha { background: #06b6d4; }
.band-betaL { background: var(--green); }
.band-betaH { background: var(--accent3); }
.band-gamma { background: var(--red); }

/* ── Band Power History Table ── */
.pow-table-box {
  margin-top: 0;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-out-sm);
}

.pow-table-scroll {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.pow-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.3);
}

.pow-table-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: 0.3px;
}

.pow-table-count {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 8px;
  box-shadow: var(--shadow-in-sm);
  font-weight: 600;
}

.pow-history-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: auto;
}

.pow-history-table th {
  background: var(--bg-soft);
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.pow-history-table th:first-child {
  text-align: left;
  width: 22%;
  max-width: 160px;
}

.pow-history-table td {
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 0.88rem;
  text-align: center;
  color: var(--text);
  border-bottom: 1px solid rgba(174, 174, 192, 0.1);
  white-space: nowrap;
}

.pow-history-table td:first-child {
  text-align: left;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.pow-history-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.5);
}

.pow-history-table tbody tr:hover {
  background: rgba(124, 58, 237, 0.08);
}

.pow-table-empty td,
.fac-table-empty td,
.met-table-empty td {
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
  font-family: var(--font);
  font-style: italic;
}

/* ─────────────── MENTAL COMMAND ─────────────── */
.com-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  margin-bottom: 24px;
  padding: 36px !important;
  background: var(--bg) !important;
}

.com-action-wrap {
  text-align: center;
}

.com-ring {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-out),
              inset 0 0 0 4px rgba(255, 255, 255, 0.4);
  position: relative;
  transition: all 0.3s;
}

.com-ring::before {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--shadow-in);
  display: flex;
}

.com-ring > * {
  position: relative;
  z-index: 1;
}

.com-action-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 6px;
  font-weight: 700;
}

.com-action {
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: capitalize;
}

.com-power-wrap {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.cp-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.cp-bar-wrap {
  height: 14px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: var(--shadow-in-sm);
  padding: 2px;
}

.cp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  border-radius: 6px;
  transition: width 0.4s ease;
}

.cp-val {
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--accent1);
  font-weight: 700;
}

.com-history {
  width: 100%;
  max-width: 420px;
}

.ch-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  font-weight: 700;
}

#comHistoryList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#comHistoryList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--glass-card-bg);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  font-size: 0.92rem;
  box-shadow: var(--shadow-out-xs);
  animation: slideIn 0.25s ease;
  position: relative;
  overflow: hidden;
}

#comHistoryList li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 24%;
  bottom: 24%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--grad-blush-violet);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

#comHistoryList li span:last-child {
  font-family: var(--mono);
  color: var(--accent1);
  font-weight: 600;
}

/* ─────────────── FACIAL ─────────────── */
.fac-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px !important;
  margin-bottom: 0 !important;
  padding: 18px !important;
  background: var(--bg) !important;
}

.fac-card {
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* 100% width top strip — facial region's representative colour */
.fac-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 0;
  background: #0891b2;            /* Eye — teal/cyan */
}

.fac-card:nth-child(2)::before { background: #10b981; }   /* Upper face — green */
.fac-card:nth-child(3)::before { background: #f97316; }   /* Lower face — orange */

.fac-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.fc-icon {
  font-size: 2rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.fc-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
  font-weight: 700;
}

.fc-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-strong);
  text-transform: capitalize;
}

.fc-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 500;
}

.fc-sub span {
  font-family: var(--mono);
  color: var(--accent1);
  font-weight: 700;
}

/* ─────────────── SYSTEM LOGS ─────────────── */
.system-logs-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 24px;
}

.log-section-title {
  color: var(--text-muted);
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.sys-log-wrap {
  height: 340px;
  background: var(--glass-card-bg-2);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  overflow-y: auto;
  box-shadow: var(--shadow-in);
  padding: 6px;
}

.sys-log {
  list-style: none;
}

.sys-log-empty {
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-style: italic;
}

.sys-log li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.92rem;
  animation: fadeIn 0.3s ease;
}

.sys-log li:last-child {
  margin-bottom: 0;
}

.sys-time {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 600;
}

.sys-msg {
  color: var(--text);
  flex: 1;
}

.sys-tag {
  margin-left: auto;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 8px;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.4px;
}

.sys-tag.info {
  background: rgba(6, 182, 212, 0.15);
  color: #0891b2;
}

.sys-tag.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.sys-tag.error {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

/* ─────────────── MODAL ─────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(174, 174, 192, 0.45);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background:
    linear-gradient(135deg, rgba(255, 216, 181, 0.30), rgba(220, 207, 250, 0.30), rgba(199, 216, 255, 0.30)),
    rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-radius: 26px;
  padding: 44px;
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: -14px -14px 40px rgba(255, 255, 255, 0.95),
                14px  16px 44px rgba(180, 150, 220, 0.30),
                0 0 0 1px rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.modal-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.modal-logo svg {
  filter: drop-shadow(0 4px 12px rgba(124, 58, 237, 0.25));
}

.modal-logo h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: #000000;
  letter-spacing: -0.5px;
}

.modal-desc {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-desc code {
  font-family: var(--mono);
  color: var(--accent1);
  font-size: 0.88rem;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 6px;
  box-shadow: var(--shadow-in-sm);
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-field label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.modal-field input {
  background: var(--bg);
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-strong);
  font-family: var(--font);
  font-size: 0.95rem;
  outline: none;
  box-shadow: var(--shadow-in);
  transition: all 0.25s ease;
}

.modal-field input:focus {
  box-shadow: var(--shadow-in),
              0 0 0 2px rgba(124, 58, 237, 0.4);
}

.modal-field input::placeholder {
  color: var(--text-soft);
}

.modal-btn {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 50%),
    var(--grad-dark);
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  box-shadow: -5px -5px 14px rgba(255, 255, 255, 0.95),
                5px  5px 16px rgba(40, 40, 56, 0.4),
              inset 1px 1px 0 rgba(255, 255, 255, 0.20);
  transition: all 0.22s ease;
}

.modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: -6px -6px 18px rgba(255, 255, 255, 1),
                7px  7px 22px rgba(40, 40, 56, 0.5),
              inset 1px 1px 0 rgba(255, 255, 255, 0.24);
}

.modal-btn:active {
  transform: translateY(0);
  box-shadow: inset 3px 3px 6px rgba(0, 0, 0, 0.30),
              inset -3px -3px 6px rgba(255, 255, 255, 0.10);
}

/* ── TOGGLE SWITCH ── */
.modal-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: 14px;
  box-shadow: var(--shadow-in-sm);
}

.toggle-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
}

.toggle-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border-radius: 26px;
  cursor: pointer;
  box-shadow: var(--shadow-in-sm);
  transition: all 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: var(--bg);
  border-radius: 50%;
  box-shadow: var(--shadow-out-xs);
  transition: all 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0) 50%),
    var(--grad-dark);
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.30),
              inset -1px -1px 2px rgba(255, 255, 255, 0.10);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ─────────────── RESPONSIVE ─────────────── */
@media (max-width: 768px) {
  .tab-label { display: none; }
  .tab-btn,
  .tab-link { padding: 7px 11px; }
  .header { gap: 12px; padding: 0 16px; }
  .main { padding: 22px 16px; }
  .brand-name { font-size: 1rem; }
  .system-logs-container { grid-template-columns: 1fr; }
  .panel-header { padding: 14px 16px; margin: -14px -16px 24px -16px; }
}

/* ─────────────────────────────────────────
   NO-SUBSCRIPTION OVERLAY
───────────────────────────────────────── */
.tab-panel {
  position: relative;
}

.no-sub-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(240, 240, 243, 0.8);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-radius: var(--radius);
  text-align: center;
  padding: 44px 28px;
  animation: fadeIn 0.3s ease;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

.no-sub-icon {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 4px 14px rgba(124, 58, 237, 0.35));
}

.no-sub-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
}

.no-sub-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 340px;
}

.no-sub-desc code {
  color: var(--accent1);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.85rem;
  box-shadow: var(--shadow-in-sm);
}

/* ─────────────── FFT SPECTRUM ─────────────── */
.fft-dominant-display {
  text-align: center;
  padding: 22px 18px 26px;
  margin-bottom: 22px;
  background:
    linear-gradient(135deg, rgba(255, 216, 181, 0.35), rgba(220, 207, 250, 0.35), rgba(199, 216, 255, 0.35));
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(170%);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  border-radius: var(--radius);
  box-shadow: var(--shadow-in);
}

.fft-dominant-label {
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 10px;
  font-weight: 700;
}

.fft-dominant-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}

.fft-dominant-band-name {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  transition: color 0.3s;
}

.fft-dominant-hz {
  font-family: var(--mono);
  font-size: 2.2rem;
  font-weight: 700;
  transition: color 0.3s;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.fft-band-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.fft-band-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.85) !important;
  background: #ffffff !important;
  box-shadow: var(--shadow-out-sm);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

#fftCard-Delta::after,
#fftCard-Theta::after,
#fftCard-Alpha::after,
#fftCard-Beta::after,
#fftCard-Gamma::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 0;
  transition: opacity 0.25s ease;
}
#fftCard-Delta::after { background: #ec4899; }  /* δ Delta — pink */
#fftCard-Theta::after { background: #a855f7; }  /* θ Theta — violet */
#fftCard-Alpha::after { background: #06b6d4; }  /* α Alpha — cyan */
#fftCard-Beta::after  { background: #10b981; }  /* β Beta — green */
#fftCard-Gamma::after { background: #ef4444; }  /* γ Gamma — red */

.fft-band-card:hover {
  box-shadow: var(--shadow-out-sm);
  transform: translateY(-2px);
}

.fft-band-card::before {
  /* removed top accent bar — dominant state now uses inset shadow */
  display: none;
}

/* Dominant band — pressed-in (inset) neumorphism look */
.fft-band-card.fft-dominant {
  transform: none;
  background: var(--surface2) !important;
  box-shadow: var(--shadow-in) !important;
  border-color: transparent !important;
}

.fft-band-card.fft-dominant::after {
  opacity: 0.5;
}

.fft-band-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.fft-band-card.fft-dominant .fft-band-dot {
  animation: fft-pulse 1.5s infinite;
}

@keyframes fft-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.fft-band-info {
  flex: 1;
  min-width: 0;
}

.fft-band-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.fft-band-range {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.fft-band-values {
  text-align: right;
  flex-shrink: 0;
}

.fft-band-hz {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.3px;
}

.fft-band-mag {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.fft-channel-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 8px;
  background: var(--bg);
  border-radius: 12px;
  box-shadow: var(--shadow-in-sm);
}

.fft-ch-label {
  font-size: 1rem;
  color: var(--text-muted);
  margin-right: 4px;
  font-weight: 600;
  padding-left: 6px;
}

.fft-ch-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s;
}

.fft-ch-btn:hover {
  color: var(--accent1);
}

.fft-ch-btn.active {
  color: var(--accent1);
  background: var(--bg);
  box-shadow: var(--shadow-out-xs);
}

#fftCanvas {
  width: 100%;
  height: 100%;
}

/* ─────────────── BLINK / PULSE ANIMATIONS ─────────────── */
@keyframes btn-blink {
  0%   { transform: scale(1);    box-shadow: var(--shadow-out-sm); }
  50%  { transform: scale(1.04); box-shadow: -6px -6px 16px rgba(255,255,255,1), 6px 6px 18px rgba(59, 130, 246, 0.55); }
  100% { transform: scale(1);    box-shadow: var(--shadow-out-sm); }
}

.blink-active {
  animation: btn-blink 1s infinite alternate;
}

/* ─────────────── INLINE OVERRIDES (HTML inline-style remediation) ─────────────── */
/* Many elements in index.html use inline-style background:rgba(...)/border-color:rgba(...) for dark theme.
   We harmonize them to neumorphism while preserving accent tints. */

.pav-item[style*="rgba(239, 68, 68, 0.08)"],
.pav-item[style*="rgba(245, 158, 11, 0.08)"],
.pav-item[style*="rgba(16, 185, 129, 0.08)"],
.pav-item[style*="rgba(6, 182, 212, 0.08)"],
.pav-item[style*="rgba(168, 85, 247, 0.08)"],
.pav-item[style*="rgba(255, 255, 255, 0.05)"] {
  background: var(--bg) !important;
  border-color: transparent !important;
  box-shadow: var(--shadow-out-xs);
}

.fft-band-card[style*="rgba(236, 72, 153, 0.06)"] { background: var(--bg) !important; box-shadow: var(--shadow-out-xs); }
.fft-band-card[style*="rgba(168, 85, 247, 0.06)"] { background: var(--bg) !important; box-shadow: var(--shadow-out-xs); }
.fft-band-card[style*="rgba(6, 182, 212, 0.06)"]  { background: var(--bg) !important; box-shadow: var(--shadow-out-xs); }
.fft-band-card[style*="rgba(16, 185, 129, 0.06)"] { background: var(--bg) !important; box-shadow: var(--shadow-out-xs); }
.fft-band-card[style*="rgba(239, 68, 68, 0.06)"]  { background: var(--bg) !important; box-shadow: var(--shadow-out-xs); }

/* Inline gradient/select element override */
select#powChartMode {
  background: var(--bg) !important;
  color: var(--text-strong) !important;
  border: none !important;
  border-radius: 10px !important;
  padding: 6px 12px !important;
  box-shadow: var(--shadow-in-sm);
  font-weight: 600;
}

/* ── Coloured action buttons (inherit .csv-btn sizing/glass feel) ── */
/* These buttons all use class="csv-btn", so they get the base layout
   (padding 9px 18px, border-radius 12px, font-size 0.9rem, font-weight 600,
   letter-spacing 0.3px, transition, box-shadow). We only override the
   background to apply their unique semantic colour while preserving the
   subtle white glass-highlight overlay used on .csv-btn. */

/* Record Start — emerald green */
button#btnRecordStart {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 45%),
    linear-gradient(135deg, #10b981 0%, #047857 100%) !important;
  box-shadow: -4px -4px 10px rgba(255, 255, 255, 0.9),
                4px  4px 12px rgba(16, 185, 129, 0.30),
              inset 1px 1px 0 rgba(255, 255, 255, 0.22) !important;
}
button#btnRecordStart:hover {
  box-shadow: -5px -5px 14px rgba(255, 255, 255, 1),
                6px  6px 18px rgba(16, 185, 129, 0.45),
              inset 1px 1px 0 rgba(255, 255, 255, 0.28) !important;
}

/* Record Stop & Polar H9 — red/coral */
button#btnRecordStop,
button#connectBleBtn {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 45%),
    linear-gradient(135deg, #ef4444 0%, #b91c1c 100%) !important;
  box-shadow: -4px -4px 10px rgba(255, 255, 255, 0.9),
                4px  4px 12px rgba(239, 68, 68, 0.30),
              inset 1px 1px 0 rgba(255, 255, 255, 0.22) !important;
}
button#btnRecordStop:hover,
button#connectBleBtn:hover {
  box-shadow: -5px -5px 14px rgba(255, 255, 255, 1),
                6px  6px 18px rgba(239, 68, 68, 0.45),
              inset 1px 1px 0 rgba(255, 255, 255, 0.28) !important;
}

/* ESP32 Release — dark gradient (consistent with brand dark buttons) */
button#espReleaseBtn {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 50%),
    var(--grad-dark) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* ESP32 status dot inline-style override - keep colored dot */
span#espStatusDot {
  box-shadow: 0 0 8px currentColor;
}

/* Status text alignment */
span#espStatusText,
span#recordTimeRange,
span#recordStopwatch {
  color: var(--text-muted) !important;
}
