/* ============================================================ */
/*  Propagation Lab — Styles                                      */
/*  Glassmorphism · sidebar · fullscreen                          */
/* ============================================================ */

:root {
  /* Palette */
  --bg-0: #06070d;
  --bg-1: #0c1020;
  --bg-2: #131830;
  --glass-bg: rgba(20, 25, 45, 0.55);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-border-strong: rgba(255, 255, 255, 0.12);

  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-faint: #64748b;

  --accent: #34d399;          /* emerald-400 */
  --accent-2: #22d3ee;        /* cyan-400 */
  --accent-3: #f472b6;        /* pink-400 */
  --warn: #fb923c;
  --danger: #f87171;
  --tracker: #f87171;
  --front: #facc15;

  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 50px rgba(52, 211, 153, 0.15);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sidebar-w: 220px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 60% 50% at 20% 10%, rgba(34, 211, 238, 0.18), transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 0%, rgba(52, 211, 153, 0.18), transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(244, 114, 182, 0.08), transparent 60%),
    linear-gradient(180deg, #0a0d1c 0%, #060810 100%);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}

body { display: flex; }

/* ============================================================ */
/*  SIDEBAR                                                       */
/* ============================================================ */

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: rgba(8, 11, 22, 0.7);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 1.2rem 0.8rem;
  position: relative;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.7rem 1.2rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 1rem;
}

.sidebar-logo svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(52, 211, 153, 0.6));
}

.sidebar-logo span {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  overflow-y: auto;
  padding-right: 0.3rem;
  margin-right: -0.3rem;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
}

.nav-category {
  padding: 0.9rem 0.8rem 0.35rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  pointer-events: none;
  user-select: none;
}

.nav-category:first-of-type {
  padding-top: 0.3rem;
}

.navbtn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 0.65rem 0.8rem;
  border-radius: var(--r-md);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  transition: all 0.18s ease;
  position: relative;
}

.navbtn svg { width: 18px; height: 18px; flex-shrink: 0; }

.navbtn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.navbtn.active {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.15), rgba(34, 211, 238, 0.15));
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--text);
}

.navbtn.active::before {
  content: '';
  position: absolute;
  left: -0.8rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px var(--accent);
}

.navbtn.active svg {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.6));
}

.sidebar-footer {
  padding: 0.6rem;
  font-size: 0.7rem;
  color: var(--text-faint);
}

.hint-mini {
  padding: 0.5rem 0.6rem;
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: var(--r-sm);
  color: var(--accent);
  font-size: 0.7rem;
  line-height: 1.4;
}

/* ============================================================ */
/*  MAIN                                                          */
/* ============================================================ */

.main {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ----- TOP BAR ----- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.6rem;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(10, 13, 28, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
  gap: 1rem;
  /* Position + z-index pour que la popover de Réglages s'affiche
     AU-DESSUS des cartes du content-area (qui ont leurs propres
     contextes d'empilement via backdrop-filter). */
  position: relative;
  z-index: 50;
}

.title-group { min-width: 0; }

.title-group h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.title-group .subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* ----- Settings popover (langue / canal / périphérique) ----- */
.settings-wrap {
  position: relative;
  display: inline-flex;
}

.settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(15, 18, 30, 0.96);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem 0.9rem;
  min-width: 320px;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.settings-popover[hidden] { display: none; }

.settings-popover h3 {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.55rem;
  flex-wrap: nowrap;
}

.settings-row label {
  flex: 0 0 90px;
  font-size: 0.76rem;
  color: var(--text-dim);
  font-weight: 500;
}

.settings-row > .lang-switch,
.settings-row > .output-switch {
  flex: 0 0 auto;
}

.settings-row-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}
.settings-row-stacked label {
  flex: 0 0 auto;
}

.device-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}
.device-select:focus { border-color: var(--accent); }

.settings-hint {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-faint);
  font-style: italic;
  line-height: 1.4;
  min-height: 1em;
}

/* ----- Audio output switch (stereo / mono L / mono R) ----- */
.output-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.output-btn {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  border-radius: 999px;
  transition: all 0.15s ease;
  min-width: 30px;
}

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

.output-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.3);
}

/* ----- Language switcher ----- */
.lang-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  border-radius: 999px;
  transition: all 0.15s ease;
  min-width: 30px;
}

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

.lang-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.3);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-dim);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.status-pill.playing {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--accent);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.2s ease;
}

.status-pill.playing .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 1.2s ease-out infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0   rgba(52, 211, 153, 0.6); }
  100% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
}

.status-text { font-weight: 500; }
.status-freq {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
  padding-left: 0.4rem;
  border-left: 1px solid var(--glass-border);
}

.icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-md);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.18s ease;
  padding: 0;
}

.icon-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.icon-btn:hover {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--accent);
}

.icon-btn:disabled,
.icon-btn[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.icon-btn.play-btn.playing {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #06121a;
}
.icon-btn.play-btn.playing:hover { filter: brightness(1.1); }

/* ----- CONTENT AREA ----- */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.4rem 1.6rem 2rem;
  scroll-behavior: smooth;
}

.content-area::-webkit-scrollbar { width: 10px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
}
.content-area::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

/* ============================================================ */
/*  PANELS & GRID                                                 */
/* ============================================================ */

.panel { display: none; animation: fadeIn 0.35s ease; }
.panel.active { display: block; }

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

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.card.span-2 { grid-column: span 2; }
.card.span-4 { grid-column: span 4; }

@media (max-width: 1200px) {
  .card.span-2, .card.span-4 { grid-column: span 4; }
}

/* ============================================================ */
/*  CARDS                                                         */
/* ============================================================ */

.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-lg);
  padding: 1.3rem 1.5rem;
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, transform 0.2s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent 50%);
  pointer-events: none;
  border-radius: var(--r-lg);
}

.card:hover { border-color: var(--glass-border-strong); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  gap: 1rem;
}

.card-header h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.caption-inline {
  font-size: 0.75rem;
  color: var(--text-faint);
  font-style: italic;
}

.zone-badge {
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.25);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 500;
}

.card h3 {
  margin: 1.4rem 0 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.card-desc {
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0 0 1rem;
}

/* ============================================================ */
/*  CANVAS                                                        */
/* ============================================================ */

.sim-card {
  padding-bottom: 1rem;
}

.canvas-wrap {
  position: relative;
  background: #0a0d18;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}

canvas#simCanvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.canvas-overlay {
  position: absolute;
  left: 0.8rem;
  bottom: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  pointer-events: none;
  font-size: 0.7rem;
  color: var(--text-dim);
}

.overlay-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(10, 13, 28, 0.6);
  backdrop-filter: blur(8px);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  width: fit-content;
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.tracker { background: var(--tracker); box-shadow: 0 0 6px var(--tracker); }
.dot.front { background: var(--front); box-shadow: 0 0 6px var(--front); }

/* ============================================================ */
/*  METRICS                                                       */
/* ============================================================ */

.metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
}

.metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* ============================================================ */
/*  CONTROLS                                                      */
/* ============================================================ */

.control-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 0;
  flex-wrap: wrap;
}

.control-row label {
  min-width: 130px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

.toggle-row { padding: 0.35rem 0; }

input[type="range"] {
  flex: 1;
  min-width: 120px;
  accent-color: var(--accent);
  height: 4px;
  background: rgba(255,255,255,0.08);
  -webkit-appearance: none;
  appearance: none;
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.6);
  border: 2px solid #06121a;
}

input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.6);
  border: 2px solid #06121a;
}

input[type="number"] {
  width: 95px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.15s ease;
  -moz-appearance: textfield;
}

input[type="number"]:focus { border-color: var(--accent); }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.7rem;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
select:focus { border-color: var(--accent); }

.readout {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  min-width: 70px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
}

/* ----- Segmented buttons ----- */
.seg {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.seg-btn {
  background: transparent;
  color: var(--text-dim);
  border: none;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s ease;
}

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

.seg-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(52, 211, 153, 0.3);
}

/* ----- Toggle buttons ----- */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.toggle-btn .toggle-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--accent);
}

.toggle-btn.active .toggle-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ----- Buttons ----- */
.action-row {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.2rem;
}

button.primary, button.danger, button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--glass-border);
  padding: 0.6rem 1.1rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.15s ease;
  font-weight: 500;
}

button:hover {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--accent);
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(52, 211, 153, 0.25);
}

button.primary:hover {
  filter: brightness(1.1);
  color: #06121a;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(52, 211, 153, 0.35);
}

button.danger {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--danger);
}
button.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ============================================================ */
/*  PRESETS                                                       */
/* ============================================================ */

.presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.5rem;
}

.preset {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.78rem;
  text-align: left;
  line-height: 1.3;
  transition: all 0.15s ease;
  font-family: inherit;
  position: relative;
  overflow: hidden;
}

.preset::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.6;
}

.preset:hover {
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.06);
  transform: translateY(-1px);
  color: var(--text);
}

.preset.active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.4);
}

.preset .freq {
  display: block;
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
}

.preset .desc {
  color: var(--text-dim);
  font-size: 0.7rem;
  margin-top: 0.15rem;
  display: block;
}

/* ============================================================ */
/*  NOTES & TABLES                                                */
/* ============================================================ */

.notes {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.notes li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.notes li::before {
  content: '•';
  position: absolute;
  left: 0.2rem;
  top: 0;
  color: var(--accent);
  font-weight: 700;
}

.notes.compact li { font-size: 0.78rem; }

.formulas {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.formulas li {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  padding: 0.55rem 0.8rem;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.formulas code {
  background: rgba(52, 211, 153, 0.1);
  color: var(--accent);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 0.82rem;
}

.reftable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.reftable th, .reftable td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.reftable th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}

.reftable td { color: var(--text-dim); }
.reftable td:nth-child(2) { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }

kbd {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--glass-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-size: 0.75rem;
  color: var(--text);
}

/* ============================================================ */
/*  ONGLET PHÉNOMÈNES                                             */
/* ============================================================ */

.phen-modes {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.phen-mode-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  color: var(--text-dim);
  padding: 0.6rem 1rem;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1 1 auto;
  min-width: 130px;
}

.phen-mode-btn:hover {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--text);
}

.phen-mode-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  font-weight: 600;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(52, 211, 153, 0.3);
}

canvas#phenCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0d18;
}

/* ============================================================ */
/*  ONGLET MA VOIX                                                */
/* ============================================================ */

.voice-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.voice-status .status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.2s ease;
}

.voice-status .status-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.2s ease-out infinite;
}

.voice-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

#voiceMicBtn {
  font-size: 0.9rem;
  padding: 0.7rem 1.4rem;
}

canvas#voiceWaveform,
canvas#voiceSpectrum,
canvas#voiceSpectrogram,
canvas#voiceParticles,
canvas#recWaveform,
canvas#recSpectrogram {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0d18;
}

/* ============================================================ */
/*  ONGLET EFFETS (recorder)                                      */
/* ============================================================ */

.rec-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
}

.rec-row button {
  flex: 1;
  min-width: 90px;
}

.rec-row button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.recording {
  animation: rec-pulse 1s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(248, 113, 113, 0); }
}

.rec-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.8rem;
}

.rec-progress.play .rec-progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.rec-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--danger);
  border-radius: 999px;
  transition: width 0.1s linear;
}

.rec-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  margin-bottom: 0.5rem;
}

.rec-status-row .metric-value {
  font-size: 0.85rem;
}

button.playing {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06121a;
  border: none;
}

#recLoopBtn.active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--accent);
}

.control-hint {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-style: italic;
  margin: -0.3rem 0 0.5rem 0.2rem;
  padding-left: 130px;
}

@media (max-width: 800px) {
  .control-hint { padding-left: 0; }
}

/* ============================================================ */
/*  ONGLET HARMONIQUES                                            */
/* ============================================================ */

.harm-sliders {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.6rem;
  padding: 0.5rem 0.2rem;
  align-items: end;
  min-height: 220px;
}

.harm-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  height: 100%;
}

.harm-amp {
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

.harm-slider {
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 18px;
  height: 130px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  accent-color: var(--accent);
}

.harm-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

canvas#harmWaveform,
canvas#harmSpectrum {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0d18;
}

/* ============================================================ */
/*  ONGLET ACCORDEUR                                              */
/* ============================================================ */

.tuner-display-card {
  text-align: center;
}

.tuner-note {
  font-size: 5.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
  margin-top: 0.5rem;
}

.tuner-octave {
  font-size: 1.2rem;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 1.2rem;
  min-height: 1.5rem;
}

.tuner-cents-wrap {
  margin: 0.5rem 0 1rem;
}

.tuner-cents-bar {
  position: relative;
  height: 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  overflow: visible;
  margin: 0 1rem;
}

.tuner-cents-tick {
  position: absolute;
  left: 50%;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: rgba(255,255,255,0.4);
  transform: translateX(-50%);
}

.tuner-cents-needle {
  position: absolute;
  left: 50%;
  top: -6px;
  width: 4px;
  height: 26px;
  background: var(--accent);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.12s ease, background 0.12s ease;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.6);
}

.tuner-cents-labels {
  display: flex;
  justify-content: space-between;
  margin: 0.4rem 1rem 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.tuner-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 1rem;
}

.tuner-stats > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.4rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
}

.tuner-stats span:first-child {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.tuner-stats span:last-child {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ============================================================ */
/*  ONGLET AUDITION                                               */
/* ============================================================ */

canvas#hearingCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: #0a0d18;
  border-radius: var(--r-sm);
}

.hearing-current {
  margin-top: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.hearing-current strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.hearing-legend {
  display: flex;
  gap: 1.2rem;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  justify-content: center;
}

/* ============================================================ */
/*  FX (Effets) — Console d'effets minimaliste                    */
/* ============================================================ */

.fx-play-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.fx-play-row button {
  font-size: 0.85rem;
}

.fx-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  min-height: 36px;
  flex-wrap: nowrap;
}

.fx-row > .fx-label,
.fx-row > .fx-toggle {
  flex-shrink: 0;
  min-width: 110px;
  font-size: 0.82rem;
}

.fx-row > .toggle-btn.fx-toggle {
  justify-content: flex-start;
}

.fx-row > .seg.compact {
  flex-shrink: 0;
}
.fx-row > .seg.compact .seg-btn {
  padding: 0.3rem 0.6rem;
  font-size: 0.72rem;
}

.fx-row > .fx-sublabel {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 0.3rem;
}

.fx-row > input[type="range"] {
  flex: 1;
  min-width: 60px;
}

.fx-row > .readout {
  flex-shrink: 0;
  min-width: 56px;
  font-size: 0.78rem;
  text-align: right;
}

.fx-divider {
  height: 1px;
  background: var(--glass-border);
  margin: 0.4rem 0;
}

@media (max-width: 1100px) {
  .fx-row { flex-wrap: wrap; }
  .fx-row > input[type="range"] { min-width: 120px; }
}

/* Enregistreur compact (status inline) */
.rec-status-inline {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.rec-status-inline .rec-duration {
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ============================================================ */
/*  PORTÉ DEPUIS SOUND-LAB                                        */
/* ============================================================ */

/* Variables additionnelles pour les zones fréquentielles */
:root {
  --infra: #60a5fa;
  --aud: #22d3ee;
  --ultra: #f87171;
}

/* ----- Oscillateur : freq hero ----- */
.freq-hero {
  text-align: center;
  padding: 0.5rem 0 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 1.2rem;
}
.freq-value {
  font-size: 4.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(52, 211, 153, 0.3);
}
.freq-value .unit {
  font-size: 1.6rem;
  color: var(--text-dim);
  margin-left: 0.3rem;
  font-weight: 400;
  -webkit-text-fill-color: var(--text-dim);
}

/* ----- Audible bar ----- */
.audible-bar { margin-top: 1.6rem; }

.audible-bar-track {
  position: relative;
  height: 26px;
  border-radius: var(--r-sm);
  overflow: hidden;
  display: flex;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: ew-resize;
  user-select: none;
  transition: filter 0.15s ease;
}
.audible-bar-track:hover { filter: brightness(1.1); }
.audible-bar-track:active { filter: brightness(1.2); }

.zone { height: 100%; }
.zone.infrasound { background: var(--infra); width: 25%; opacity: 0.65; }
.zone.audible {
  width: 50%; opacity: 0.85;
  background: linear-gradient(90deg, #06b6d4 0%, #34d399 30%, #facc15 60%, #fb7185 100%);
}
.zone.ultrasound { background: var(--ultra); width: 25%; opacity: 0.65; }

.audible-bar-labels {
  position: relative;
  height: 18px;
  margin-top: 4px;
  font-size: 0.65rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.audible-bar-labels span { position: absolute; transform: translateX(-50%); }

.cursor {
  position: absolute;
  top: -3px;
  width: 2.5px;
  height: 32px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9), 0 0 24px rgba(52, 211, 153, 0.6);
  transition: left 0.08s linear;
  pointer-events: none;
  border-radius: 2px;
}

.audible-legend {
  margin-top: 0.8rem;
  display: flex;
  gap: 1.2rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  justify-content: center;
  flex-wrap: wrap;
}

.dot.infra { background: var(--infra); box-shadow: 0 0 6px var(--infra); }
.dot.aud { background: var(--aud); box-shadow: 0 0 6px var(--aud); }
.dot.ultra { background: var(--ultra); box-shadow: 0 0 6px var(--ultra); }

/* ----- Preset bar colors ----- */
.preset.infra::before { background: var(--infra); }
.preset.aud::before { background: var(--aud); }
.preset.ultra::before { background: var(--ultra); }

/* ----- Musical notes keyboard ----- */
.notes-octaves {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.notes-row { display: flex; align-items: center; gap: 0.5rem; }
.notes-row-label {
  width: 60px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.notes-row-keys {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
  flex: 1;
}
.note-btn {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 0.55rem 0.4rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transition: all 0.15s ease;
  position: relative;
}
.note-btn:hover {
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.15), rgba(52, 211, 153, 0.05));
  border-color: rgba(52, 211, 153, 0.4);
  transform: translateY(-1px);
}
.note-btn .note-name { font-size: 0.95rem; color: var(--text); font-weight: 700; }
.note-btn .note-octave { font-size: 0.65rem; color: var(--text-faint); }
.note-btn .note-freq {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.note-btn.A4 { border-color: rgba(34, 211, 238, 0.4); }
.note-btn.A4 .note-freq { color: var(--accent-2); }

/* ----- Captions, hints ----- */
.caption {
  margin-top: 0.7rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.caption strong { color: var(--accent); font-variant-numeric: tabular-nums; }

.hint {
  padding: 0.6rem 0.8rem;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 0.82rem;
  margin: 0.6rem 0;
}
.hint strong { color: var(--accent-2); }

.hint-inline {
  font-size: 0.72rem;
  color: var(--text-faint);
  font-style: italic;
}

/* ----- Tables (harmonics + ref) ----- */
.harmonics {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.harmonics th {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}
.harmonics td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-dim);
}
.harmonics tr { transition: background 0.12s ease; }
.harmonics tr:hover { background: rgba(52, 211, 153, 0.05); }
.harmonics .play-mini {
  background: var(--accent);
  color: #06121a;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}
.harmonics .play-mini:hover { filter: brightness(1.15); }

/* ----- Stream FPS grid ----- */
.fps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .fps-grid { grid-template-columns: 1fr 1fr; }
}
.fps-grid h4 {
  font-size: 0.78rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  color: var(--text-dim);
}
.fps-select {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
}

/* Sound-lab canvases */
canvas#tubeCanvas,
canvas#chladniCanvas,
canvas#waterCanvas,
canvas#streamCanvas,
canvas#oscSpectrumCanvas,
canvas#oscWaveformCanvas {
  display: block;
  width: 100%;
  height: auto;
  background: #060a12;
  border-radius: var(--r-sm);
}
