/* ===== fonts ======================================================= */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/vendor/Inter-Variable.woff2") format("woff2-variations"),
       url("/static/vendor/Inter-Variable.woff2") format("woff2");
}

/* ===== themes ======================================================
 *
 * Soft-black palette (was pure #000 — switched to #0b0b0c to avoid
 * OLED smearing and let the elevation system create depth via
 * progressively lighter surfaces).
 *
 * Light mode is opt-in via the ☀ button in the topbar (data-theme="light").
 * theme.js anchors that attribute on <html> and persists the choice in
 * localStorage so first paint matches.
 */

:root {
  /* Five-colour accent set. The lime is the primary accent (buttons,
   * focus rings); cyan/orange/purple/pink surface as chart-curve hues
   * and inline highlights. */
  --fg: #fafafa;
  --fg-muted: #a1a1aa;
  --fg-subtle: #71717a;
  /* Surfaces ~50% darker than the previous palette. The 3-tier
   * elevation system is preserved (bg < bg-card < bg-elev) so chips,
   * cards and hover states still pop off the page background — they
   * just sit closer to true black. Borders weren't darkened: keeping
   * them at the old contrast is what makes cards remain legible. */
  --bg: #040405;           /* near-black page background */
  --bg-card: #08080a;      /* elevated surface (legend, controls) */
  --bg-elev: #101013;      /* hover / focus / nested elements */
  --bg-overlay: rgba(8, 8, 10, 0.82); /* glass tooltips, scrim */
  --accent: #c3fc0d;       /* lime — primary action */
  --accent-fg: #000000;
  --accent-soft: #63ede0;  /* cyan — secondary highlight */
  --info: #38bdf8;         /* sky — hint/info states */
  --hot-pink: #f81d78;
  --hot-orange: #fd6c1d;
  --deep-violet: #470bf6;
  --border: #27272a;
  --border-strong: #3f3f46;
  --danger: #f81d78;
  --grid: #16161a; /* +50% contrast vs the #0b0b0c canvas (was #121215) */
  --axis: #6b7280;
  --guide: #a1a1aa;
  --tooltip-bg: rgba(8, 8, 10, 0.9);
  --tooltip-fg: #fafafa;

  /* radius scale — 10px is the sweet spot for modern UI; the chart
   * frame uses the larger 14px to feel like a "card". */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;

  /* layered shadow tokens — combine in 1-3 strands for depth without
   * the muddy "single big shadow" look. */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px var(--accent), 0 0 16px rgba(195, 252, 13, 0.25);

  /* motion tokens — every interactive should reference these so the
   * vibe stays coherent and reduced-motion users can null them. */
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 280ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03", "calt";
  font-optical-sizing: auto;
  color-scheme: dark;
}

/* Light mode = warm "parchment" palette (per user, modelled on an
   Obsidian-like paper theme): cream page, slightly lighter cream cards,
   warm near-black ink, dark-umber primary action (the screenshot's
   selected-sidebar-item look) and muted red/indigo semantics. The cool
   gray/white palette this replaced lives in git if ever needed. */
:root[data-theme="light"] {
  --fg: #2c2a25;
  --fg-muted: #5d574b;
  --fg-subtle: #7a7466;
  --bg: #ddd8c5;
  --bg-card: #e8e4d3;
  --bg-elev: #d2ccb7;
  --bg-overlay: rgba(232, 228, 211, 0.78);
  --accent: #433f37;       /* dark umber — primary action on parchment */
  --accent-fg: #ece8da;    /* cream text/icons on the umber */
  --accent-soft: #3a3ac9;  /* indigo — the screenshot's link colour */
  --info: #3a64c9;
  --hot-pink: #a8352c;     /* muted brick red (screenshot's red text) */
  --hot-orange: #b06a2c;
  --deep-violet: #3a3ac9;
  --border: #c4bda6;
  --border-strong: #a89f85;
  --danger: #a8352c;
  --grid: #d6d0bb; /* same ~contrast step off the cream card as dark mode */
  --axis: #6b6557;
  --guide: #8a8372;
  --tooltip-bg: rgba(43, 40, 34, 0.92); /* dark toolbar-like tooltip */
  --tooltip-fg: #ece8da;
  --shadow-sm: 0 1px 2px rgba(60, 52, 36, 0.10);
  --shadow-md: 0 1px 2px rgba(60, 52, 36, 0.08), 0 4px 12px rgba(60, 52, 36, 0.12);
  --shadow-lg: 0 1px 2px rgba(60, 52, 36, 0.08), 0 8px 24px rgba(60, 52, 36, 0.16);
  --shadow-glow: 0 0 0 1px var(--accent), 0 0 12px rgba(67, 63, 55, 0.35);
  color-scheme: light;
}

/* Light-mode chart tuning. The chart is designed for a black canvas: the
   neon glow and the light "reads-on-black" text colours fall apart on
   white. So in light mode we kill the glow entirely and darken the
   lightest on-chart text. (Curve lines + their name labels still use the
   palette so each label matches its line — only the glow, the region
   captions, and the gray metadata change.) */
:root[data-theme="light"] .chart-svg .curve {
  /* !important beats the inline drop-shadow filter set in chart.js. With
     it removed the computed filter is `none`, so the PNG export (which
     inlines computed styles) is glow-free too. */
  filter: none !important;
}
:root[data-theme="light"] .chart-svg .freq-region-label {
  filter: none;        /* drop the lime neon halo */
  fill: #3f6212;       /* dark lime — readable on white, keeps the green identity */
}
:root[data-theme="light"] .chart-svg .chart-rig {
  /* inline fill is the light TARGET_COLOR (#d1d5db) → invisible on white */
  fill: var(--fg-muted) !important;
}
:root[data-theme="light"] .chart-svg .target-curve {
  stroke: var(--fg-muted) !important; /* same light gray as the rig */
}
/* The target's on-chart name + eye inherit TARGET_COLOR inline (light
   gray for the black canvas) → illegible on the parchment. !important
   beats the inline fill/color chart.js sets. */
:root[data-theme="light"] .chart-svg .target-label {
  fill: var(--fg-muted) !important;
  color: var(--fg-muted) !important;
}

/* Honor users who opted out of motion in their OS settings. We zero
 * every animation/transition rather than reduce — anything less can
 * still trigger vestibular issues. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ===== layout ====================================================== */

* { box-sizing: border-box; }
body {
  margin: 0; color: var(--fg); background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}
a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
a:hover { opacity: 0.85; }
code { font-family: ui-monospace, "Cascadia Code", Menlo, monospace; font-size: 0.92em; }

/* Focus ring — single source of truth so every interactive matches. */
:where(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  /* Subtle backdrop blur if the user scrolls under it; the page itself
     is short today but Compare grows beyond viewport on small screens. */
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
}
.topbar .brand {
  font-weight: 800;
  font-size: 2.25rem;
  /* ≥1.2 or background-clip:text CLIPS descenders — the gradient only
     paints inside the line box, so with line-height:1 the "g" tail had no
     background and rendered cut off. */
  line-height: 1.2;
  letter-spacing: -0.03em; /* matches the About hero title */
  background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 22%, #a855f7 42%, #ec4899 60%, #f97316 80%, #facc15 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
  transition: filter var(--t-base) var(--ease);
}
.topbar .brand:hover { filter: brightness(1.15) saturate(1.1); text-decoration: none; }
/* Light theme: amarelo/ciano claros somem no branco — uso versões mais escuras
   e saturadas, e troco a ponta amarela por âmbar/laranja escuro. */
:root[data-theme="light"] .topbar .brand {
  background: linear-gradient(90deg, #0891b2 0%, #2563eb 22%, #7c3aed 42%, #db2777 60%, #ea580c 80%, #b45309 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.topbar nav { flex: 1; }
.topbar nav a { color: var(--fg-muted); margin-right: 1rem; }
.topbar nav a:hover { color: var(--fg); opacity: 1; }
.topbar-meta { color: var(--fg-muted); font-size: 0.875rem; }
.topbar-meta a { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
/* Language picker — same chip styling as the theme toggle beside it. */
.topbar .lang-select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.topbar .lang-select:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
}
.topbar .theme-toggle {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--fg);
  font-size: 1rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.topbar .theme-toggle:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.topbar .theme-toggle:active { transform: translateY(0); }

main   { max-width: 100%; margin: 1rem auto; padding: 0 1rem; }
footer { max-width: 100%; margin: 1.5rem auto 1rem; padding: 0 1rem; color: var(--fg-muted); font-size: 0.875rem; }
/* Global tagline footer (base.html) — tighter margins so the pinned
   compare layout (fitLayoutHeight reserves its box) wastes less height. */
.site-foot { text-align: center; margin: 0.5rem auto 0.75rem; line-height: 1.5; }
.site-foot .foot-copy { display: block; color: var(--fg); }
.site-foot .foot-tagline { display: block; }

/* ===== home ======================================================== */

.hero { text-align: center; padding: 2rem 0; }
.hero h1 { font-size: 2.5rem; margin: 0 0 0.5rem; color: var(--fg); }
.hero .stats { color: var(--fg-muted); margin: 1.5rem 0; }
.hero .stats strong { color: var(--fg); }
.hero .cta { display: inline-block; padding: 0.6rem 1.2rem; background: var(--accent); color: var(--accent-fg); border-radius: var(--radius); font-weight: 500; }
.hero .cta:hover { text-decoration: none; opacity: 0.9; }

/* ===== filters, tables, detail ===================================== */

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 1.5rem; }
.filters input, .filters select, .filters button {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--fg); font: inherit;
}
.filters button { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); cursor: pointer; font-weight: 500; }
.filters button:hover { opacity: 0.9; }

.measurements-wrap { overflow-x: auto; }
table.measurements { width: 100%; border-collapse: collapse; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 480px; }
table.measurements th, table.measurements td { padding: 0.6rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); }
table.measurements th { background: var(--bg-elev); font-weight: 600; font-size: 0.875rem; color: var(--fg-muted); }
table.measurements tr:last-child td { border-bottom: 0; }
table.measurements tr:hover td { background: var(--bg-elev); }

.meta { color: var(--fg-muted); font-size: 0.875rem; margin-top: 0.75rem; }
.empty { color: var(--fg-muted); padding: 2rem; text-align: center; background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius); }

.crumbs { color: var(--fg-muted); font-size: 0.875rem; margin-bottom: 0.5rem; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.5rem; background: var(--bg-card); padding: 1rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); }
dl.props dt { color: var(--fg-muted); font-size: 0.875rem; }
dl.props dd { margin: 0; }

.chart-placeholder { margin-top: 1.5rem; padding: 2rem; text-align: center; background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius); color: var(--fg-muted); }

/* ===== chart ======================================================= */

.chart-frame {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  /* Only the outer (right) corner is rounded — the left edge butts
     up against .compare-left and the bottom edge against
     .chart-controls inside the same column. */
  border-radius: 0 var(--radius-lg) 0 0;
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  margin: 1rem 0;
  /* Fluid height: fills the viewport minus topbar / footer / chart-
     controls / gaps. Clamps so it never collapses on small screens
     and doesn't grow absurdly tall on giant monitors. */
  min-height: clamp(420px, calc(100vh - 220px), 1200px);
}
.chart-svg   { width: 100%; height: auto; display: block; font: 11px ui-sans-serif, system-ui, sans-serif; }
.chart-svg .domain      { stroke: var(--axis); }
.chart-svg text         { fill: var(--fg-muted); }
.chart-svg .grid        { stroke: var(--grid); }
.chart-svg .axis-label  { font-size: 12px; fill: var(--fg-muted); font-weight: 500; }
/* Axis numbers drawn INSIDE the plot (mobile, squig.link-style): faint so
   they read as a subtle scale under the curves, not as chart data. */
.chart-svg .axis-inside { font-size: 10px; opacity: 0.4; }
/* Desktop got the inset numbers too (squig parity) — the bigger plot can
   afford slightly larger, more readable digits than the phone strip. */
@media (min-width: 801px) {
  .chart-svg .axis-inside { font-size: 12px; opacity: 0.5; }
}
.chart-svg .guide       { stroke: var(--guide); stroke-dasharray: 3 3; pointer-events: none; }
/* Hover-isolate: when a label is hovered, chart.js adds .isolating to the
   <svg> and .is-hover to the matching path. Every other line fades to a
   ghost so the focused response stands out. The opacity transition lives
   on the curves themselves so entering/leaving isolation is smooth. */
.chart-svg .curve, .chart-svg .target-curve { transition: opacity var(--t-base) var(--ease); }
.chart-svg.isolating .curve:not(.is-hover),
.chart-svg.isolating .target-curve:not(.is-hover) { opacity: 0.12; }
/* The isolated curve gets a touch more weight so it pops even in crowded
   mode, where the base stroke is thinned (CSS beats the stroke-width ATTR
   chart.js sets, so one rule covers both base widths). */
.chart-svg.isolating .curve.is-hover { stroke-width: 1.68; }
.chart-svg .chart-label { cursor: default; }
.chart-svg .tooltip-dot { stroke: var(--bg-card); stroke-width: 1.5; pointer-events: none; }
/* Smart annotation in the tooltip ("— Ear gain", "— Sibilance peak"):
   italic + slightly dimmed so it reads as a note on the dB value, not a
   second reading. The tooltip bg is dark in BOTH themes, so no remap. */
.chart-tooltip .tip-peak { font-style: italic; opacity: 0.85; }
.chart-svg .zero-line   { stroke: var(--guide); stroke-dasharray: 2 4; stroke-width: 1; }
/* Frequency-region hover highlight (squig.link-style): a subtle band shaded
   over the hovered region's frequency range. Theme-aware via --fg-muted
   (light band on the dark canvas, dark band on white); JS toggles opacity. */
.chart-svg .region-highlight { fill: var(--fg-muted); pointer-events: none; transition: opacity var(--t-fast) var(--ease); }
.chart-svg .chart-label {
  font-size: 40px;
  /* 490 = 700 thinned 30 % (Inter Variable handles the non-standard
     weight); 0.8 = 0.7 made 15 % more opaque. Both per user request. */
  font-weight: 490;
  letter-spacing: 0.005em;
  opacity: 0.8;
}
/* Rig caption inherits opacity from .chart-label per user request,
   but the 40 px main-label size would be too dominant for metadata. */
.chart-svg .chart-rig {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Frequency-region captions under the x-axis. Plain text only — same
   muted color and font as the x-axis tick labels (.chart-svg text). */
.chart-svg .freq-region-label {
  /* Lime accent (the theme's signature colour) per user request. */
  fill: var(--accent);
  /* 50% larger than the x-axis tick labels (~11 px). MARGIN.bottom
     in chart.js was bumped in lockstep so the text isn't clipped. */
  font-size: 16px;
  /* Lime neon glow to match the curves' colored halo. */
  filter: drop-shadow(0 0 6px rgba(195, 252, 13, 0.45));
  pointer-events: none;
}

/* 2-column compare layout:
   left  = brand/model picker (chips + filters + product list)
   right = chart on top, chart-controls below (the "customs" strip). */
.compare-layout {
  display: grid;
  /* Left = just the IEM picker now (the selected-curves legend column was
     removed — the picker rows toggle add/remove, and the chart shows the
     selected names on-chart). Keep it narrow so the chart fills the rest. */
  grid-template-columns: minmax(300px, 360px) 1fr;
  /* No gap — left card and chart frame share their adjacent edge.
     The touching corners are flattened below so the join is clean. */
  gap: 0;
  /* Both columns share the same vertical reach (the row height comes
     from the left column's max-height below). align-items: stretch
     makes the right column fill the same row, so the chart-controls
     can flex: 1 to occupy any gap below the chart. */
  align-items: stretch;
}
.compare-right { min-width: 0; display: flex; flex-direction: column; gap: 0; }
.compare-right .chart-frame {
  margin: 0;
  /* Fill the height left after the controls (natural height) and allow
     shrinking, so the whole compare view fits the viewport with no page
     scroll. min-height:0 lets flex shrink it below the base clamp; the
     chart SVG (height:auto) re-flows to whatever height it gets. The
     layout's overall height is pinned to the viewport in JS
     (fitLayoutHeight). */
  flex: 1 1 0;
  min-height: 0;
  /* Drop the bottom border at the chart→controls join to avoid the
     double-border seam. */
  border-bottom: none;
}
/* Take whatever vertical space is left over after the chart. With
   align-items: stretch the right column equals the left column's
   height, so this flex:1 closes the gap that used to sit below the
   "customs" strip. */
.compare-right .chart-controls { margin: 0; flex: 0 0 auto; align-content: flex-start; }
/* The PEQ panel is the last item in the right column — drop its bottom margin
   (1rem) so its bottom lines up with the picker card on the left (align-items:
   stretch makes both columns the same height; a margin here would leave the
   panel 1rem short and disconnect the two cards). Product page keeps the base
   margin since that layout scrolls. */
.compare-right .peq-panel { margin: 0; }

/* Unified card: .compare-left wraps both the picker (Lista de IEMs)
   and the legend (IEMs selecionados) inside a single visual surface.
   The two panes share one background, one border, one radius — only
   a 1px vertical divider (border-right on the picker) separates them.
   Individual card styling on #legend and .add-curve-panel is null'd
   below to avoid double-borders / double-backgrounds. */
.compare-left {
  min-width: 0;
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  /* Only the outer (left) corners are rounded — the right edge butts
     up against .chart-frame / .chart-controls, so those corners are
     flattened for a flush join. */
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  /* Right border doubles up with the chart's left border at the join;
     dropping it here avoids a 2px visual seam. */
  border-right: none;
  box-shadow: var(--shadow-sm);
  overflow: hidden; /* clip child radii to parent's corner radius */
  /* Loose pre-JS guard ONLY: stops the (tall) product list from inflating
     the layout for one frame before fitLayoutHeight() pins .compare-layout
     to the viewport height. It must stay LARGER than that pinned height so
     it never binds — otherwise the card's bottom wouldn't line up with the
     controls (the old calc(100vh-100px) cap caused exactly that). Once the
     layout has a definite height, align-items:stretch sizes this card and
     the list scrolls inside it. */
  max-height: 100vh;
}

/* The selected-curves legend column was removed from the view. #legend
   STAYS in the DOM (hidden) because chart.js reads #curve-ids + the
   .legend-item data attributes from it to know what to draw and how to
   label each curve — it's the source of truth for the selection. */
.compare-left > #legend { display: none; }
.compare-left .add-curve-panel {
  flex: 1; display: flex; flex-direction: column;
  min-height: 0;
  padding: 1rem 1.15rem;
  /* No divider: the picker is the only pane in the left card now. */
}
.compare-left .add-curve-list {
  max-height: none; flex: 1; min-height: 120px;
  background: transparent;
  border: none;
  border-radius: 0;
}

@media (max-width: 800px) {
  /* Single column. The four components live in two wrapper divs
     (.compare-left = picker + legend, .compare-right = chart + controls),
     so a plain stack would group by wrapper. display:contents unwraps
     both wrappers, making all four direct flex items of .compare-layout,
     so `order` can interleave them across the old column boundary into
     the mobile order:
       1. chart   2. on-chart legend   3. IEM picker   4. controls. */
  .compare-layout { display: flex; flex-direction: column; gap: 0.75rem; }
  .compare-left, .compare-right { display: contents; }

  /* Mobile order: chart first, then the on-chart legend ("IEMs
     selecionados") directly under it, then the IEM picker ("Lista de
     IEMs"), then the controls. The brand title sits above all this in
     the centered topbar. */
  .compare-right .chart-frame        { order: 1; }
  .compare-right .rig-warning        { order: 1; } /* after the chart (DOM order breaks the tie) */
  .compare-right .region-delta-strip { order: 1; }
  .compare-left > #legend            { order: 2; }
  .compare-left .add-curve-panel     { order: 3; }
  .compare-right .chart-controls     { order: 4; }
  .compare-right .peq-panel          { order: 5; } /* below the controls */

  /* Stacked, each component is its own card. The desktop "unified card"
     joins (clipped corners, dropped borders, shared edges, 50/50 flex)
     only make sense side-by-side — restore full borders/radius/bg here. */
  .compare-left .add-curve-panel,
  .compare-left > #legend,
  .compare-right .chart-frame,
  .compare-right .rig-warning,
  .compare-right .region-delta-strip,
  .compare-right .chart-controls,
  .compare-right .peq-panel {
    margin: 0;
    flex: initial;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
  }
  .compare-left .add-curve-list { max-height: 360px; flex: 1 1 auto; min-height: 120px; }

  /* squig.link-style full-bleed chart: drop the tall min-height clamp (the
     frame wraps the short wide chart), kill the padding, and cancel main's
     1rem side padding with negative margins so the plot reaches the window
     edges. Side borders/radius off so it reads as a clean full-width band;
     keep the top/bottom border to divide it from the brand + picker. */
  .compare-right .chart-frame {
    min-height: 0;
    padding: 0;
    margin-left: -1rem;
    margin-right: -1rem;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  /* Product-page chart: same as compare, the mobile SVG is short-and-wide
     (height = width·0.6), but this frame isn't `.compare-right` so it kept the
     desktop `min-height: clamp(420px, 100vh−220px, …)` ≈ 592px — leaving a big
     empty band below the curve. Drop the clamp so the frame wraps the chart. */
  .product-chart .chart-frame { min-height: 0; }

  /* squig.link-style header: brand name centered at the very top; the
     theme toggle tucks into the corner so it doesn't break the centering.
     .topbar keeps position:sticky (which is also the positioning context
     the absolute toggle anchors to — don't override it). */
  .topbar { flex-direction: column; align-items: center; text-align: center; gap: 0.2rem; }
  /* Let nav items wrap as WHOLE units to a second row instead of "How To
     Read" breaking mid-phrase into 3 lines (which clipped "About" off the
     edge on narrow phones). nowrap keeps each label intact; flex-wrap +
     row-gap handle the overflow cleanly. */
  .topnav { flex: 0 1 auto; flex-wrap: wrap; justify-content: center; gap: 0.3rem 0.85rem; font-size: 0.9rem; }
  .topnav a { white-space: nowrap; }
  .topbar .brand { font-size: 2rem; }
  .topbar-meta { font-size: 0.78rem; }
  /* The lone toggle used to tuck into the corner (absolute), but with the
     language picker beside it the cluster is ~120px wide and collides with
     the centered brand on narrow screens — so on mobile the pair stays in
     flow, centered under the nav as its own row. */
  .topbar-actions { margin-top: 0.2rem; }
  .topbar .lang-select { font-size: 0.78rem; padding: 0.35rem 0.4rem; }
}

/* Lives inside .chart-controls now — pushed to the far right via
   margin-left: auto, aligned vertically with the <label> stacks. */
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0 auto; align-self: flex-end; }
.chart-toolbar button {
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.chart-toolbar button:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.chart-toolbar button:active { transform: translateY(0); box-shadow: none; }
/* Share-link button text picks up the same lime accent as the
   footer's "source" link (and other <a> tags). The 💾 export button
   stays neutral so the emoji color isn't overridden. */
.chart-toolbar #btn-copy-link { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.chart-toolbar #btn-copy-link svg { display: block; }
/* Clear-all moved here from the (removed) legend column — left of 🎲. */
.chart-toolbar #btn-clear-all { color: var(--fg-muted); display: inline-flex; align-items: center; justify-content: center; }
.chart-toolbar #btn-clear-all svg { display: block; }
.chart-toolbar #btn-clear-all:hover { color: var(--danger); border-color: var(--danger); }
.chart-toolbar .toolbar-status { color: var(--fg-muted); font-size: 0.85rem; align-self: center; margin-left: auto; }

/* Export menu — a zero-JS <details> dropdown (PNG quality / SVG / CSV /
   JSON). The <summary> mimics the toolbar buttons; the panel floats
   UPWARD (the toolbar sits near the bottom of the fit-to-viewport layout,
   so opening downward would clip off-screen). */
.chart-toolbar .export-menu { position: relative; display: inline-flex; }
.chart-toolbar .export-menu > summary {
  list-style: none;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.chart-toolbar .export-menu > summary::-webkit-details-marker { display: none; }
.chart-toolbar .export-menu > summary::marker { content: ""; }
.chart-toolbar .export-menu[open] > summary,
.chart-toolbar .export-menu > summary:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
}
.export-menu-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 4px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 9.5rem;
  padding: 0.3rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}
.chart-toolbar .export-menu-panel button {
  padding: 0.45rem 0.6rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-align: left;
  white-space: nowrap;
}
.chart-toolbar .export-menu-panel button:hover {
  background: var(--bg-elev);
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

/* Auto per-region Δ strip — appears between chart and controls whenever
   exactly two products are selected (filled by chart.js). One chip per
   frequency band with the mean A−B in dB. */
.region-delta-strip {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.35rem 0.8rem;
  padding: 0.45rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.74rem;
  color: var(--fg-muted);
}
/* display:flex beats the UA [hidden] rule — make hidden actually hide. */
.region-delta-strip[hidden] { display: none; }
.region-delta-strip .rd-title {
  font-weight: 600; color: var(--fg);
  margin-right: 0.4rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 34ch;
}
.region-delta-strip .rd-chip { display: inline-flex; align-items: baseline; gap: 0.3rem; white-space: nowrap; }
.region-delta-strip .rd-chip b { font-weight: 600; font-size: 0.7rem; }
.region-delta-strip .rd-pos,
.region-delta-strip .rd-neg  { color: var(--fg); font-weight: 600; }
.region-delta-strip .rd-zero { color: var(--fg-subtle); }
/* Desktop: the strip is a MIDDLE SLAB of the chart column — flush against
   the chart frame above and the controls below (matching their corner-
   clipped join): no margins, no radius, and no own horizontal borders
   (the neighbours' edges are the dividers). Mobile restores the
   standalone-card look (see the ≤800px block). */
.compare-right .region-delta-strip {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 0;
  border-top: none;
  border-bottom: none;
}

/* Cross-rig guard banner — chart.js shows it when the selection mixes
   couplers (IEC 711 × B&K 5128); curves above ~5 kHz aren't comparable
   across rigs. Amber = warning, distinct from the lime accent. */
.rig-warning {
  padding: 0.45rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.74rem;
  font-weight: 600;
  color: #fbbf24;
}
:root[data-theme="light"] .rig-warning { color: #92400e; }
/* Desktop: middle slab of the chart column, flush like the Δ strip above. */
.compare-right .rig-warning {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 0;
  border-top: none;
  border-bottom: none;
}

/* Optional rig-compensation toggle inside the cross-rig banner. Its own line,
   normal weight + neutral colour (the warning text above stays amber). */
.rig-comp-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
}
.rig-comp-toggle input { cursor: pointer; }

/* ---- Parametric EQ panel ------------------------------------------- */
/* Fused onto the controls strip above it into one continuous card
   (chart → controls → PEQ): the controls drop their bottom border/radius
   (rule below), so the PEQ carries the card's bottom-right corner + shadow.
   Only the bottom-RIGHT corner rounds — the left edge butts the picker card
   and the top butts the controls, exactly like .chart-controls does. */
.peq-panel {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) 0;
  box-shadow: var(--shadow-sm);
  margin: 0 0 1rem;
  font-size: 0.85rem;
}
/* Desktop: fuse the controls strip into the card so there's no seam
   between it and the PEQ panel below. (Mobile keeps them as separate
   stacked cards — see the ≤800px block.) */
@media (min-width: 801px) {
  .chart-controls:has(+ .peq-panel) {
    margin-bottom: 0;
    border-bottom: none;
    border-radius: 0;
    box-shadow: none;
  }
}
.peq-summary {
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.6rem 1.15rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}
.peq-summary::-webkit-details-marker { display: none; }
.peq-caret { color: var(--accent); transition: transform var(--t-fast) var(--ease); }
.peq-panel[open] .peq-caret { transform: rotate(90deg); }
.peq-state {
  margin-left: 0.35rem; padding: 0.1rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent); color: var(--accent-fg);
  font-size: 0.7rem; letter-spacing: 0.02em;
}
/* Usage note + AutoEQ/export status, RIGHT of the title. Sentence-case
   (reset the summary's uppercase/spacing), muted; takes the remaining row
   width and wraps under the title on narrow widths. Errors turn amber. */
.peq-msg {
  flex: 1 1 12rem;
  min-width: 0;
  margin-left: auto;
  text-align: right;
  font-size: 0.74rem;
  font-weight: 400;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: normal;
  color: var(--fg-muted);
}
.peq-msg:empty { display: none; }
.peq-msg.is-error { color: #f59e0b; }
/* max-height + internal scroll so opening the panel shrinks the chart
   (flex:1) instead of overflowing the fit-to-viewport compare layout. */
.peq-body {
  padding: 0 1.15rem 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  max-height: 42vh; overflow-y: auto;
}
.peq-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.peq-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.peq-row .peq-type,
.peq-field input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--fg);
  font: inherit; font-size: 0.82rem;
}
.peq-field { display: inline-flex; align-items: center; gap: 0.25rem; }
.peq-field input { width: 4.6rem; }
.peq-unit { color: var(--fg-muted); font-size: 0.72rem; }
.peq-remove {
  margin-left: auto;
  width: 1.7rem; height: 1.7rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--fg-muted);
  cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.peq-remove:hover { color: #ef4444; border-color: #ef4444; }
.peq-actions, .peq-export { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.peq-export-label {
  color: var(--fg-muted); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.peq-btn {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--fg);
  font: inherit; font-size: 0.82rem; cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.peq-btn:hover { border-color: var(--accent); }
.peq-btn-accent { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.peq-btn-accent:hover { filter: brightness(1.05); }
.peq-preamp { color: var(--fg-muted); font-size: 0.78rem; margin-left: auto; }

.chart-controls {
  display: flex; flex-wrap: wrap;
  gap: 0.85rem 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  /* Only the outer (bottom-right) corner is rounded — touches
     .compare-left on the left and .chart-frame on top. */
  border-radius: 0 0 var(--radius-lg) 0;
  box-shadow: var(--shadow-sm);
  margin: 0 0 1rem;
}
.chart-controls label {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Custom-styled select — strip the browser appearance, draw a chevron
   via SVG background. Same treatment as inputs so the controls strip
   reads as one cohesive surface. */
.chart-controls select,
.chart-controls input[type="number"],
#filter-brand,
#filter-search {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  letter-spacing: -0.005em;
  transition: border-color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.chart-controls select,
#filter-brand {
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 4.5l3 3 3-3' stroke='%23a1a1aa' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  cursor: pointer;
  min-width: 140px;
}
.chart-controls input[type="number"] { width: 140px; }
.chart-controls select:hover,
.chart-controls input[type="number"]:hover,
#filter-brand:hover,
#filter-search:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-card);
}
.chart-controls select:focus,
.chart-controls input[type="number"]:focus,
#filter-brand:focus,
#filter-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(195, 252, 13, 0.15);
}

/* Glassmorphism tooltip — fits the soft-black palette, reads cleanly
   over both dark surfaces and the chart's light grid. */
.chart-tooltip {
  position: absolute;
  background: var(--tooltip-bg);
  color: var(--tooltip-fg);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  pointer-events: none;
  line-height: 1.45;
  /* Keep the card at its natural width: without this, parking it near
     the container's right edge squeezes it and wraps every line (the
     smart-annotation rows got unreadable). chart.js flips it to the
     LEFT of the cursor instead when it wouldn't fit. */
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
}
.chart-tooltip .tip-region { color: var(--fg-muted); font-weight: 600; font-size: 0.72rem; }

#legend {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.15rem;
}

.legend-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin: 0 0 0.85rem; flex-wrap: wrap; }
.legend-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; flex: 1; min-width: 0; }

/* squig.link-style colored chip. The swatch becomes the left accent
   bar; chart.js sets the chip color via --curve-color on the <li>.
   The pop-in animation runs every time htmx swaps the legend, which
   is exactly when a chip is added — feels alive without being noisy. */
.legend-item {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.55rem 0.3rem 0.65rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--curve-color, var(--fg-muted));
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
  animation: chip-in var(--t-base) var(--ease);
}
.legend-item:hover { background: var(--bg-card); border-color: var(--border-strong); transform: translateY(-1px); }
@keyframes chip-in {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.swatch { display: none; }  /* legacy — chip's left border replaces it */
.legend-label { color: var(--curve-color, var(--fg)); }
.remove-btn {
  border: none; background: transparent;
  color: var(--fg-subtle);
  cursor: pointer; font-size: 1rem; line-height: 1;
  padding: 0 0.15rem;
  border-radius: var(--radius-sm);
  transition: color var(--t-fast) var(--ease);
}
.remove-btn:hover { color: var(--danger); }

.clear-all-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg-muted);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.4rem 0.45rem;
  border-radius: var(--radius);
  cursor: pointer; flex-shrink: 0;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.clear-all-btn svg { display: block; }
.clear-all-btn:hover { color: var(--danger); border-color: var(--danger); background: rgba(248, 29, 120, 0.08); }

.empty-legend {
  color: var(--fg-muted);
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  /* Empty-state row with the inline SVG hint added in compare_legend.html */
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.empty-legend svg { color: var(--accent-soft); flex-shrink: 0; }

.add-curve-panel { display: flex; flex-direction: column; gap: 0.65rem; min-height: 0; flex: 1; }
.add-curve-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
/* "Sort by target match" toggle — compact, sits with the picker filters. */
.picker-targetsort {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: var(--fg-muted); cursor: pointer;
  user-select: none;
}
.picker-targetsort input { cursor: pointer; }
.picker-targetsort:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.filter-pills { display: inline-flex; gap: 0.3rem; padding: 0.2rem; background: var(--bg-elev); border-radius: var(--radius-pill); }
.filter-pills .pill {
  background: transparent;
  border: 1px solid transparent;
  color: var(--fg-muted);
  font: inherit; font-size: 0.78rem;
  font-weight: 500;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.filter-pills .pill:hover { color: var(--fg); }
.filter-pills .pill.is-active {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

#filter-brand { min-width: 140px; font-size: 0.85rem; padding: 0.4rem 0.7rem; }
#filter-search { flex: 1; min-width: 160px; font-size: 0.85rem; padding: 0.4rem 0.7rem; }

/* Live-filtered product list. Scrolls vertically with a custom
   scrollbar; each row is a clickable button with a "+" affordance
   on the right. Max-height keeps the page from ballooning when the
   user clears all filters and 880 rows render. */
.add-curve-list {
  display: flex; flex-direction: column;
  max-height: 360px;
  overflow-y: auto; overflow-x: hidden;
  /* Don't let the browser re-anchor scroll when a brand expands/collapses —
     keep the clicked header put and let its models grow below it. */
  overflow-anchor: none;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.add-curve-list::-webkit-scrollbar { width: 10px; }
.add-curve-list::-webkit-scrollbar-track { background: transparent; }
.add-curve-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-elev);
}
.add-curve-list::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.add-curve-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.95rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font: inherit; font-size: 0.9rem;
  letter-spacing: -0.005em;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast) var(--ease), padding-left var(--t-fast) var(--ease);
}
.add-curve-item:last-child { border-bottom: none; }
.add-curve-item:hover {
  background: var(--bg-card);
  padding-left: 1.15rem;
}
.add-curve-item:hover::before {
  content: "";
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
/* `display: flex` above beats the user-agent `[hidden] { display: none }`
   rule by specificity, so without this override the JS filter that
   sets `row.hidden = true` would have zero visible effect. */
.add-curve-item[hidden] { display: none; }
/* Adherence % pill shown on each row in "Sort by target match" mode. Sits at
   the row's right edge, just left of the "+". */
.add-curve-rankpct {
  flex-shrink: 0; margin-left: auto;
  font-size: 0.72rem; font-weight: 600;
  color: var(--accent-fg); background: var(--accent);
  border-radius: var(--radius-pill); padding: 0.04rem 0.45rem;
}
.add-curve-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.add-curve-plus {
  color: var(--fg-subtle);
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 0.75rem;
  transition: color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.add-curve-item:hover .add-curve-plus {
  color: var(--accent);
  transform: rotate(90deg) scale(1.15);
}
/* Selected (already on the chart): persistent accent bar + the "+" rotates
   45° into an "×" in danger red, signalling "click to remove". The picker
   row is a toggle now that the legend column is gone. */
.add-curve-item.is-selected { background: var(--bg-card); padding-left: 1.15rem; }
.add-curve-item.is-selected::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.add-curve-item.is-selected .add-curve-plus { color: var(--danger); transform: rotate(45deg); }
.add-curve-item.is-selected:hover .add-curve-plus { color: var(--danger); transform: rotate(45deg) scale(1.15); }

/* Brand-group headers — collapsible "Brand (N)" rows that group the picker
   by manufacturer (the flat ~700-row list "looked like a raw database").
   Hidden while searching: the list then flattens to a ranked result set. */
.brand-group-header {
  display: flex; align-items: center; gap: 0.55rem;
  width: 100%;
  padding: 0.5rem 0.95rem;
  background: var(--bg-card);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast) var(--ease);
}
.brand-group-header:hover { background: var(--bg); }
.brand-group-header:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.brand-group-header[hidden] { display: none; }
.brand-group-caret {
  flex-shrink: 0; color: var(--fg-subtle); font-size: 0.7rem;
  line-height: 1; width: 0.8em;
  transition: transform var(--t-fast) var(--ease);
  transform: rotate(90deg); /* expanded → points down */
}
.brand-group-header.is-collapsed .brand-group-caret { transform: rotate(0deg); }
.brand-group-name { flex: 1 1 auto; }
.brand-group-count {
  flex-shrink: 0; color: var(--fg-subtle);
  font-size: 0.72rem; font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}
/* Expanded brand: lime fill + black text so the open group clearly stands
   out from the collapsed (subtle) ones. The :hover variant repeats the fill
   (equal specificity to the base :hover above → needs to win on expanded). */
.brand-group-header:not(.is-collapsed),
.brand-group-header:not(.is-collapsed):hover {
  background: var(--accent);
  color: var(--accent-fg);
}
.brand-group-header:not(.is-collapsed) .brand-group-caret,
.brand-group-header:not(.is-collapsed) .brand-group-count {
  color: var(--accent-fg);
}
.brand-group-header:not(.is-collapsed) .brand-group-count {
  border-color: rgba(0, 0, 0, 0.28);
}
/* Items indent under their brand header in browse mode; flat while searching. */
.add-curve-list:not(.is-searching) .add-curve-item { padding-left: 1.7rem; }
.add-curve-list:not(.is-searching) .add-curve-item:hover,
.add-curve-list:not(.is-searching) .add-curve-item.is-selected { padding-left: 1.9rem; }
.add-curve-list.is-searching .brand-group-header { display: none; }

.add-curve-empty { color: var(--fg-muted); font-size: 0.85rem; margin: 0.5rem 0 0; text-align: center; }

/* Advanced spec filters — a collapsible panel under the search/pills. */
.add-curve-advanced { margin-top: 0.5rem; }
.adv-toggle {
  display: flex; align-items: center; gap: 0.4rem;
  width: 100%;
  padding: 0.35rem 0.2rem;
  background: none; border: none;
  color: var(--fg-muted);
  font: inherit; font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.01em; text-transform: uppercase;
  cursor: pointer;
}
.adv-toggle:hover { color: var(--fg); }
.adv-caret {
  font-size: 0.7rem; color: var(--fg-subtle);
  transition: transform var(--t-fast) var(--ease);
}
.adv-toggle.is-open .adv-caret { transform: rotate(90deg); }
.adv-panel {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.5rem 0.2rem 0.25rem;
}
.adv-panel[hidden] { display: none; }
.adv-panel label {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  font-size: 0.8rem; color: var(--fg-muted);
}
.adv-panel label span { flex-shrink: 0; }
.adv-panel select {
  flex: 1 1 auto; min-width: 0; max-width: 60%;
  padding: 0.3rem 0.4rem;
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.8rem;
}
.adv-clear {
  align-self: flex-end;
  margin-top: 0.1rem; padding: 0.25rem 0.6rem;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--fg-muted); font: inherit; font-size: 0.75rem; cursor: pointer;
}
.adv-clear:hover { color: var(--fg); border-color: var(--border-strong); }
.add-curve-specnote {
  margin: 0.35rem 0.2rem 0;
  font-size: 0.75rem; color: var(--fg-subtle); font-style: italic;
}
.add-curve-specnote[hidden] { display: none; }

.chart-frame .empty { padding: 4rem 2rem; color: var(--fg-muted); text-align: center; }

/* ===== IEM hover preview (picker) ================================== */
/* Floating card shown on hovering a picker row: catalog specs (optional,
   from data/products.json) + a live mini-FR. position/left/top set in JS;
   pointer-events:none so it never intercepts the hover it's previewing. */
.iem-preview {
  position: fixed;
  z-index: 50;
  width: 300px;
  max-width: calc(100vw - 16px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.85rem 0.95rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.iem-preview.is-visible { opacity: 1; transform: none; }
.iem-preview-head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.iem-preview-title { font-weight: 600; font-size: 1rem; color: var(--fg); letter-spacing: -0.01em; }
.iem-preview-badge {
  font-size: 0.68rem; font-weight: 500; color: var(--accent-fg);
  background: var(--accent); border-radius: var(--radius-pill);
  padding: 0.1rem 0.5rem; white-space: nowrap;
}
.iem-preview-meta { display: flex; gap: 0.75rem; margin: 0.35rem 0 0; font-size: 0.82rem; }
.iem-preview-rating { color: var(--accent); font-weight: 600; }
.iem-preview-price { color: var(--fg); font-weight: 600; }
.iem-preview-specs {
  display: grid; grid-template-columns: max-content 1fr; gap: 0.18rem 0.7rem;
  margin: 0.6rem 0 0; font-size: 0.8rem;
}
.iem-preview-specs dt { color: var(--fg-muted); }
.iem-preview-specs dd { margin: 0; color: var(--fg); text-align: right; }
.iem-preview-frwrap { margin: 0.7rem 0 0; }
.iem-preview-frlabel { display: block; font-size: 0.7rem; color: var(--fg-muted); margin-bottom: 0.15rem; }
.iem-preview-pref { margin: 0.7rem 0 0; font-size: 0.82rem; color: var(--fg); }
.iem-preview-pref b { color: var(--accent); font-size: 1rem; }
.iem-preview-prefmax { color: var(--fg-subtle); font-size: 0.74rem; }
.iem-preview-est {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--fg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 0 0.3rem; vertical-align: middle;
}
.iem-preview-fr {
  display: block; width: 100%; height: 72px;
  color: var(--accent-soft); /* mini-FR line; theme-aware accent */
}
.iem-preview-frstats { margin: 0.7rem 0 0; }
.iem-preview-frstats .iem-preview-specs { margin-top: 0.25rem; }
.iem-preview-similar { margin: 0.7rem 0 0; }
.iem-preview-similar ul { list-style: none; margin: 0; padding: 0; font-size: 0.78rem; color: var(--fg); }
.iem-preview-similar li { display: flex; align-items: baseline; gap: 0.45rem; padding: 0.12rem 0; }
.iem-preview-simpct {
  flex-shrink: 0; font-size: 0.68rem; font-weight: 600;
  color: var(--accent-fg); background: var(--accent);
  border-radius: var(--radius-pill); padding: 0.04rem 0.4rem;
}
.iem-preview-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.6rem 0 0; }
.iem-preview-tags span {
  font-size: 0.68rem; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 0.08rem 0.5rem;
}

/* ⓘ affordance per picker row (mobile only — JS-injected). margin-left:auto
   parks it (and the +) on the right while the label keeps the left. */
.iem-info-btn {
  flex: 0 0 auto;
  margin-left: auto; margin-right: 0.55rem;
  width: 1.7rem; height: 1.7rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem; line-height: 1;
  color: var(--fg-muted);
  border-radius: var(--radius-pill);
}
.iem-info-btn:active { background: var(--bg-elev); color: var(--accent); }

/* Bottom-sheet: the condensed card on mobile, opened from ⓘ. */
.iem-sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: flex-end;
}
.iem-sheet-backdrop[hidden] { display: none; }
.iem-sheet {
  position: relative; width: 100%;
  max-height: 85vh; overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 1.1rem 1.1rem 1.5rem;
  animation: iem-sheet-up var(--t-base) var(--ease);
}
@keyframes iem-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
.iem-sheet::before {
  content: ""; display: block; width: 2.5rem; height: 0.25rem; margin: 0 auto 0.8rem;
  background: var(--border); border-radius: var(--radius-pill);
}
.iem-sheet-close {
  position: absolute; top: 0.5rem; right: 0.6rem;
  width: 2rem; height: 2rem; padding: 0;
  font-size: 1.4rem; line-height: 1;
  color: var(--fg-muted); background: transparent; border: none; cursor: pointer;
}
/* In the sheet the condensed card is plain flow — the sheet provides the
   chrome, so neutralise the floating-card positioning. */
.iem-preview--sheet {
  position: static; width: auto; max-width: none;
  background: none; border: none; box-shadow: none; padding: 0;
  opacity: 1; transform: none; pointer-events: auto;
}
.iem-preview--sheet .iem-preview-fr { height: 96px; }
body.iem-sheet-open { overflow: hidden; }

/* ===== top nav ===================================================== */
.topnav { flex: 1; display: flex; gap: 1.25rem; align-items: center; }
.topnav a {
  color: var(--fg-muted); font-weight: 500; font-size: 0.95rem;
  text-decoration: none; transition: color var(--t-fast) var(--ease);
}
.topnav a:hover { color: var(--fg); }

/* Change Log nav link: the "New" badge is hidden until theme.js adds
   .is-new (an unseen entry exists). Plain "Change Log" otherwise. */
.nav-changelog { position: relative; display: inline-flex; align-items: center; }
.nav-changelog .cl-new { display: none; }
.nav-changelog.is-new .cl-new {
  display: inline-block;
  position: absolute; top: -0.55em; right: -1.4em;
  font-size: 0.6rem; font-weight: 700; line-height: 1;
  padding: 0.12em 0.3em; border-radius: var(--radius-sm, 4px);
  background: #f5c518; color: #111; letter-spacing: 0.02em;
}
.nav-changelog.is-new { color: var(--fg); }

/* ===== catalog (plain, paginated, alphabetical list) =============== */
.catalog-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin: 0 0 1.1rem;
}
.catalog-head h1 { font-size: 1.6rem; margin: 0; color: var(--fg); }
.catalog-search-form { flex: 0 1 320px; min-width: 220px; }
.catalog-search-form input {
  width: 100%; padding: 0.5rem 0.8rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--fg); font: inherit;
}

.catalog-list {
  list-style: none; margin: 0; padding: 0; overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.catalog-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem 1rem; flex-wrap: wrap;
  padding: 0.7rem 1rem; border-bottom: 1px solid var(--border);
}
.catalog-row:last-child { border-bottom: none; }
.catalog-row:hover { background: var(--bg-elev); }
.catalog-row-name { font-weight: 600; font-size: 0.95rem; color: var(--fg); text-decoration: none; }
.catalog-row-name:hover { text-decoration: underline; }
.catalog-row-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.catalog-row-tags .tag {
  font-size: 0.68rem; color: var(--fg-muted); white-space: nowrap;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 0.1rem 0.55rem;
}
.catalog-row-tags .tag-brand { color: var(--fg); border-color: var(--border-strong); }
.catalog-row-tags .tag-type { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); }
.catalog-row-meas { font-size: 0.7rem; color: var(--fg-subtle); font-style: italic; white-space: nowrap; align-self: center; }

/* Browse mode: brand groups as native <details>, styled like the home
   picker's .brand-group-header — collapsed rows, count pill, caret that
   rotates open, lime fill + black text while expanded. */
.catalog-groups {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.catalog-brand summary {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.55rem 0.95rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  list-style: none; /* hide the UA disclosure triangle (we draw our own) */
  transition: background var(--t-fast) var(--ease);
}
.catalog-brand summary::-webkit-details-marker { display: none; }
.catalog-brand summary:hover { background: var(--bg); }
.catalog-brand summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.catalog-brand .brand-group-caret { transform: rotate(0deg); }
.catalog-brand[open] > summary,
.catalog-brand[open] > summary:hover {
  background: var(--accent);
  color: var(--accent-fg);
}
.catalog-brand[open] > summary .brand-group-caret { transform: rotate(90deg); color: var(--accent-fg); }
.catalog-brand[open] > summary .brand-group-count { color: var(--accent-fg); border-color: rgba(0, 0, 0, 0.28); }
.catalog-brand:last-child > summary { border-bottom: none; }
.catalog-brand[open]:last-child > summary { border-bottom: 1px solid var(--border); }
/* Per-brand link (↗) in the browse header → /brand/{slug}. Navigates away,
   so the <summary> toggle side-effect is moot. */
.brand-group-link {
  flex-shrink: 0; text-decoration: none; color: var(--fg-subtle);
  font-size: 0.85rem; line-height: 1; padding: 0.1rem 0.3rem; border-radius: var(--radius-sm);
}
.brand-group-link:hover { color: var(--accent); background: var(--bg-elev); }
.catalog-brand[open] > summary .brand-group-link { color: var(--accent-fg); }

/* Brand page (/brand/{slug}) — reuses .catalog styling. */
.brand-crumbs { font-size: 0.78rem; color: var(--fg-subtle); width: 100%; margin-bottom: 0.2rem; }
.brand-crumbs a { color: var(--fg-muted); text-decoration: none; }
.brand-crumbs a:hover { color: var(--accent); }
.brand-intro { font-size: 0.85rem; color: var(--fg-muted); margin: 0.3rem 0 0; max-width: 60ch; line-height: 1.5; }
.product-brand-link { color: inherit; text-decoration: none; }
.product-brand-link:hover { color: var(--accent); text-decoration: underline; }
/* Nested rows reuse .catalog-list but flat (the group frame carries the border). */
.catalog-brand .catalog-list {
  border: none; border-radius: 0;
  border-bottom: 1px solid var(--border);
}
.catalog-brand:last-child .catalog-list { border-bottom: none; }
.catalog-brand .catalog-row { padding-left: 1.7rem; }

.catalog-pager {
  display: flex; gap: 0.4rem; justify-content: center; align-items: center;
  flex-wrap: wrap; margin: 1.25rem 0;
}
.catalog-pager a, .catalog-pager span {
  padding: 0.35rem 0.6rem; min-width: 2rem; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.85rem; color: var(--fg-muted); text-decoration: none;
}
.catalog-pager a:hover { color: var(--fg); border-color: var(--border-strong); }
.catalog-pager .is-current { color: var(--accent-fg); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.catalog-pager .is-disabled { opacity: 0.4; }
.catalog-empty { color: var(--fg-muted); text-align: center; padding: 2rem; }

/* ===== product page ================================================ */
.product { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 1.25rem; align-items: start; }
.product-info {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm);
}
.product-back { color: var(--fg-muted); font-size: 0.85rem; text-decoration: none; }
.product-back:hover { color: var(--fg); }
.product-title { font-size: 1.4rem; margin: 0.5rem 0 0.6rem; color: var(--fg); letter-spacing: -0.01em; }
.product-badges { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 0.85rem; }
.product-badge { font-size: 0.7rem; background: var(--accent); color: var(--accent-fg); border-radius: var(--radius-pill); padding: 0.12rem 0.55rem; }
.product-rating { color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.product-price { color: var(--fg); font-weight: 600; font-size: 0.85rem; }
.product-specs { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 0.8rem; font-size: 0.85rem; margin: 0 0 0.85rem; }
.product-specs dt { color: var(--fg-muted); }
.product-specs dd { margin: 0; text-align: right; color: var(--fg); }
.product-nospecs { color: var(--fg-muted); font-size: 0.85rem; margin: 0 0 0.85rem; }
.product-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0 0 0.95rem; }
.product-tags span { font-size: 0.68rem; color: var(--fg-muted); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0.08rem 0.5rem; }
.product-compare {
  display: inline-block; background: var(--accent); color: var(--accent-fg);
  font-weight: 600; font-size: 0.9rem; padding: 0.5rem 0.9rem;
  border-radius: var(--radius); text-decoration: none;
}
.product-compare:hover { filter: brightness(1.05); }

/* "Sound profile" — curve-derived tonality metrics (frstats.go). */
.product-frstats { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.product-frstats .product-specs { margin: 0.6rem 0 0; }

/* Sound-signature analyzer: profile label badge + 0–10 region bars. */
.sig-label {
  display: inline-block; vertical-align: middle;
  margin-left: 0.4rem;
  font-size: 0.7rem; font-weight: 600;
  color: var(--accent-fg); background: var(--accent);
  border-radius: var(--radius-pill); padding: 0.08rem 0.5rem;
  letter-spacing: 0; text-transform: none;
}
.sig-bars { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.7rem 0 0.4rem; }
.sig-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.78rem; }
.sig-row .sig-name { flex: 0 0 3.2rem; color: var(--fg-muted); }
.sig-row b { flex: 0 0 auto; color: var(--fg); font-size: 0.74rem; }
.sig-bar {
  flex: 1 1 auto; height: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden;
}
.sig-bar span {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 999px;
}
.iem-preview-sig { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0 0.1rem; }
.iem-preview-sig .sig-label { margin-left: 0; }
.iem-preview-sigscores { font-size: 0.72rem; color: var(--fg-muted); }

/* "Similar IEMs" — FR-nearest neighbours, ranked by shape distance. */
.product-similar { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.product-similar-title { margin: 0; font-size: 0.95rem; font-weight: 600; }
.product-similar-sub { margin: 0.1rem 0 0.6rem; font-size: 0.72rem; color: var(--fg-subtle); }
.product-similar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.product-similar-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.4rem 0; border-bottom: 1px solid var(--border);
}
.product-similar-list li:last-child { border-bottom: none; }
.product-similar-list a { color: var(--fg); text-decoration: none; font-size: 0.88rem; }
.product-similar-list a:hover { color: var(--accent); }
.sim-pct {
  flex-shrink: 0; font-size: 0.74rem; font-weight: 600; color: var(--accent-fg);
  background: var(--accent); border-radius: var(--radius-pill); padding: 0.06rem 0.45rem;
}
/* "Target match" — weighted, rig-matched adherence to each reference target. */
.product-targetfit { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.targetfit-list { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.targetfit-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.8rem; }
.targetfit-name { flex: 0 0 8.5rem; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.targetfit-row .sig-bar { flex: 1 1 auto; }
.targetfit-pct { flex: 0 0 auto; color: var(--fg); font-size: 0.76rem; }
.targetfit-dev { flex: 0 0 auto; color: var(--fg-subtle); font-size: 0.7rem; }

/* "Preference score" — Olive in-ear predicted-preference estimate (0–100). */
.product-prefscore { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.product-prefscore .pref-est {
  font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent-fg); background: var(--accent);
  border-radius: var(--radius-pill); padding: 0.08rem 0.45rem; vertical-align: middle;
}
.prefscore-row { display: flex; align-items: baseline; gap: 0.5rem; margin-top: 0.4rem; }
.prefscore-num { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.prefscore-max { font-size: 0.9rem; color: var(--fg-subtle); }
.prefscore-target {
  margin-left: auto; align-self: center;
  font-size: 0.7rem; color: var(--fg-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9rem;
}

.product-chart { min-width: 0; }

/* ===== prose (about) =============================================== */
.prose { max-width: 720px; }
.prose h1 { font-size: 1.8rem; margin: 0 0 1rem; color: var(--fg); }
.prose p { color: var(--fg-muted); line-height: 1.7; margin: 0 0 1rem; }

/* ===== About page ================================================== */
.about { max-width: 720px; margin: 0 auto; padding: 1.5rem 0 3rem; }
.about-hero { margin-bottom: 2rem; }
.about-hero h1 {
  font-size: clamp(2rem, 5vw, 2.8rem);
  font-weight: 800; /* same treatment as the topbar brand */
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
  color: var(--fg);
}
/* "Songbird" in the same spectrum gradient as the topbar brand. */
.about-brand {
  background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 22%, #a855f7 42%, #ec4899 60%, #f97316 80%, #facc15 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* Light theme: same darker/saturated gradient the topbar brand uses (the
   light cyan/yellow ends vanish on white). */
:root[data-theme="light"] .about-brand {
  background: linear-gradient(90deg, #0891b2 0%, #2563eb 22%, #7c3aed 42%, #db2777 60%, #ea580c 80%, #b45309 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.about-lede {
  font-size: 1.15rem; line-height: 1.65;
  color: var(--fg-muted); margin: 0;
}
.about-body p { color: var(--fg-muted); line-height: 1.75; margin: 0 0 1.1rem; }
.about-body strong { color: var(--fg); }

/* ===== change log (curated, blog-style site history) ============== */
.changelog { max-width: 720px; margin: 0 auto; padding: 1.5rem 0 3rem; }
.changelog-list { list-style: none; margin: 0; padding: 0; }
.changelog-entry {
  padding: 1.25rem 0; border-top: 1px solid var(--border);
}
.changelog-entry:first-child { border-top: none; }
.changelog-date {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--accent); letter-spacing: 0.03em; margin-bottom: 0.25rem;
}
.changelog-entry-title { font-size: 1.15rem; margin: 0 0 0.4rem; color: var(--fg); }
.changelog-summary { color: var(--fg-muted); line-height: 1.7; margin: 0; }
.changelog-tags { margin-top: 0.6rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.changelog-tag {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill, 999px);
  background: var(--surface-2, rgba(127,127,127,0.12)); color: var(--fg-muted);
}
.changelog-empty { color: var(--fg-muted); }

/* Pull-quote: the project's stance, set apart with the lime accent. */
.about-quote {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.about-quote p {
  font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--fg); margin: 0 0 0.6rem;
}
.about-quote footer { color: var(--fg-muted); line-height: 1.65; font-size: 0.95rem; }

.about h2 {
  font-size: 1.05rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--accent);
  margin: 2.2rem 0 0.9rem;
}
.about-list { list-style: none; margin: 0; padding: 0; }
.about-list li {
  position: relative;
  padding: 0.55rem 0 0.55rem 1.9rem;
  color: var(--fg-muted); line-height: 1.5;
  border-bottom: 1px solid var(--border);
}
.about-list li:last-child { border-bottom: none; }
.about-list li::before {
  content: "✓";
  position: absolute; left: 0.3rem;
  color: var(--accent); font-weight: 700;
}
.about-why p { color: var(--fg-muted); line-height: 1.75; margin: 0 0 1.1rem; }
.about-why em { color: var(--fg); font-style: italic; }

/* Contact CTA at the end of About (the old .about-foot closing line moved
   to the global .site-foot footer). Mirrors the .hero .cta button look. */
.about-cta {
  margin: 2.5rem 0 0; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.about-cta a {
  display: inline-block; padding: 0.6rem 1.2rem;
  background: var(--accent); color: var(--accent-fg);
  border-radius: var(--radius); font-weight: 500;
}
.about-cta a:hover { text-decoration: none; opacity: 0.9; }

/* ===== How To Read guide (reuses .about scaffolding) =============== */

.guide-table-wrap { overflow-x: auto; margin: 1rem 0; }
.guide-table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.guide-table th, .guide-table td {
  padding: 0.6rem 0.75rem; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.guide-table th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--fg-muted);
}
.guide-table tbody tr:last-child td { border-bottom: none; }
.guide-table td:first-child { white-space: nowrap; }
.guide-dot {
  display: inline-block; width: 0.65em; height: 0.65em;
  border-radius: 50%; margin-right: 0.45em;
}
.guide-dot-bass   { background: #ef4444; }
.guide-dot-mids   { background: #34d399; }
.guide-dot-upper  { background: #38bdf8; }
.guide-dot-treble { background: #eab308; }
.guide-figure { margin: 1.5rem 0; }
.guide-figure svg {
  width: 100%; height: auto; display: block;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.guide-figure figcaption {
  margin-top: 0.5rem; font-size: 0.85rem; font-style: italic;
  color: var(--fg-subtle); text-align: center;
}
.guide-svg-note { font-size: 13px; fill: var(--fg-muted); }
.guide-svg-zone { font-size: 13px; font-weight: 700; letter-spacing: 0.08em; text-anchor: middle; }
.guide-svg-tick { font-size: 11px; fill: var(--fg-subtle); }
.guide-personalities li + li { margin-top: 0.6rem; }

@media (max-width: 800px) {
  .product { grid-template-columns: 1fr; }
}

/* ===== admin ======================================================= */

.admin-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin: 0 0 1.25rem; }
.admin-section h2 { margin: 0 0 0.75rem; font-size: 1.1rem; color: var(--fg); }
.admin-status { margin-left: 0.75rem; font-size: 0.85rem; color: var(--fg-muted); }
.admin-status.error { color: var(--danger); }

#upload-form { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: end; }
#upload-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--fg-muted); }
#upload-form input[type="text"], #upload-form input[type="file"], #upload-form select {
  padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--fg); font: inherit; min-width: 160px;
}
#upload-form button { padding: 0.45rem 1rem; background: var(--accent); color: var(--accent-fg); border: 1px solid var(--accent); border-radius: var(--radius); font: inherit; cursor: pointer; font-weight: 500; }
#upload-form button:hover { opacity: 0.9; }

#admin-reindex button { padding: 0.45rem 1rem; background: var(--accent); color: var(--accent-fg); border: 1px solid var(--accent); border-radius: var(--radius); font: inherit; cursor: pointer; margin-right: 0.75rem; }
#admin-reindex label { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; color: var(--fg-muted); margin-right: 0.75rem; }

.admin-search { width: 100%; max-width: 320px; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--fg); font: inherit; margin-bottom: 0.75rem; }
.admin-table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 720px; }
table.admin-table th, table.admin-table td { padding: 0.4rem 0.6rem; text-align: left; border-bottom: 1px solid var(--border); }
table.admin-table th { background: var(--bg-elev); font-weight: 600; color: var(--fg-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.admin-table tr.dragging { opacity: 0.4; }
table.admin-table input, table.admin-table select { background: transparent; color: var(--fg); border: 1px solid transparent; border-radius: 3px; padding: 0.25rem 0.4rem; font: inherit; width: 100%; min-width: 80px; }
table.admin-table input:hover, table.admin-table select:hover { border-color: var(--border); }
table.admin-table input:focus, table.admin-table select:focus { outline: none; border-color: var(--accent); background: var(--bg-elev); }
table.admin-table input.saved { background: var(--bg-elev); transition: background 0.5s; }
table.admin-table input.error-field { border-color: var(--danger); }

.fav-btn, .delete-btn, .delete-target-btn { background: transparent; border: none; color: var(--fg-muted); cursor: pointer; font-size: 1rem; padding: 0.2rem 0.4rem; }
.fav-btn[data-on="1"] { color: var(--accent); }
.delete-btn:hover, .delete-target-btn:hover { color: var(--danger); }
.drag-handle { color: var(--fg-muted); cursor: grab; user-select: none; text-align: center; }

.admin-targets { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
.admin-targets li { display: flex; align-items: center; gap: 1rem; padding: 0.4rem 0.6rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-targets li code { color: var(--fg-muted); font-size: 0.78rem; flex: 1; }

/* ===== mobile ====================================================== */

@media (max-width: 640px) {
  main { margin: 1rem auto; }
  .topbar { gap: 0.75rem; padding: 0.5rem 0.85rem; flex-wrap: wrap; }
  .topbar nav a { margin-right: 0.75rem; }
  .hero h1 { font-size: 2rem; }
  .filters { flex-direction: column; }
  .filters input, .filters select, .filters button { width: 100%; }
  dl.props { grid-template-columns: 1fr; }
  dl.props dt { margin-top: 0.5rem; }
  .chart-controls { flex-direction: column; gap: 0.5rem; }
  .chart-controls label { width: 100%; }
  .chart-controls select { width: 100%; }
  .chart-toolbar .toolbar-status { width: 100%; margin: 0; text-align: left; }
}
