:root {
  --bg: #0e0e0f;
  --surface: #1a1a1e;
  --surface2: #252529;
  --border: #333338;
  --accent: #e05a00;
  --accent2: #ff7a20;
  --text: #e8e8ec;
  --text-muted: #9a9aa2; /* 4.5:1+ on every surface up to #333338 (WCAG AA) */
  --green: #2ecc71;
  --red: #e74c3c;

  --cat-dynamics: #e8a838;
  --cat-wah: #cc4444;
  --cat-drive: #dd4444;
  --cat-amp: #22aa77;
  --cat-cab: #2277aa;
  --cat-eq: #5555aa;
  --cat-mod: #aa55aa;
  --cat-pitch: #aaaa33;
  --cat-delay: #22aaaa;
  --cat-reverb: #3399aa;
}

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

/* Keeps keyboard-focused elements from landing hidden behind the sticky
   64px header (WCAG 2.4.11 Focus Not Obscured) — native scroll-into-view
   (e.g. from Tab navigation) otherwise scrolls a focused element to the very
   top of the viewport, right under the header. */
html { scroll-padding-top: var(--header-h, 64px); }

/* Visually hidden but available to screen readers */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Header */
header {
  background: linear-gradient(135deg, #111113 0%, #1a1a1e 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.logo-img {
  height: 35px;
  width: auto;
  object-fit: contain;
  filter: brightness(1.1);
}

.logo-sub {
  font-size: 0.9rem;
  color: var(--accent2);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: -6px auto 6px;
  align-self: center;
}
.logo-sub-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
.logo-sub-btn:hover { color: var(--text); }

header .spacer { flex: 1; }

.header-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0.2rem;
}
.nav-link {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.85rem;
  border-radius: 20px;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active {
  color: #000;
  background: var(--accent);
  font-weight: 600;
}

/* Home was removed from the desktop menu (logo links home instead) but
   should still show up in the mobile hamburger dropdown — hidden by
   default, re-enabled inside the max-width:720px block below. */
.nav-link-mobile-only { display: none; }

/* Hamburger toggle — hidden on desktop */
.nav-toggle {
  display: none;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s;
  flex-shrink: 0;
}
.nav-toggle:hover { color: var(--text); border-color: var(--accent); }

/* Desktop only — the header kept accumulating items (Community, account,
   Buy me a coffee...) until the nav pill row got squeezed against them.
   Pushes .header-nav onto its own row below everything else via `order`
   (visual position only, DOM order/mobile dropdown markup untouched) +
   flex-basis:100% (forces a wrap once it's the last flex item). Mobile
   (<=720px, see the max-width:720px block below) already renders nav as an
   absolutely-positioned dropdown outside normal flow, so it's unaffected
   and deliberately left alone here — nav.js measures the real rendered
   header height into --header-h either way (mobile's is unchanged, ~64px).
   min-width:721px so the two breakpoints can't both match at once. */
@media (min-width: 721px) {
  /* row-gap split out from the base `gap: 1.5rem` shorthand so the space
     above the wrapped nav row (a flex row-gap) can be smaller than the
     space between row 1's own buttons (column-gap, left at 1.5rem). */
  header { flex-wrap: wrap; row-gap: 0.5rem; padding-top: 0.6rem; padding-bottom: 0; height: auto; }
  .header-nav {
    order: 10;
    /* flex-basis:100% would only size the box to the header's *content*
       box (i.e. inside its 2rem side padding) — a negative margin-left then
       shifts that box left without growing it, closing the gap on the left
       but leaving it short by 2×2rem on the right (confirmed live: box
       stayed 1236px wide against a 1300px viewport). Sizing explicitly to
       content-box + both paddings restored, then shifting left by one
       padding-width, lands both edges flush with the header's own edges. */
    flex-basis: auto;
    flex-shrink: 0;
    width: calc(100% + 4rem);
    margin: 0 0 0 -2rem;
    justify-content: center;
    border-radius: 0;
  }
}

/* Main layout */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
}

/* Hero search */
.search-hero {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
  padding: 0 0 2.5rem;
}

.search-hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #e8e8ec, #888890);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-hero h1 span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.search-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.search-box {
  display: flex;
  gap: 0.75rem;
  position: relative;
}

.search-actions {
  display: flex;
  gap: 0.75rem;
}

.search-input-wrap {
  flex: 1;
  position: relative;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1rem;
}

#searchInput {
  width: 100%;
  padding: 0.9rem 1rem 0.9rem 2.75rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--text-muted); }

#generateBtn {
  padding: 0.9rem 1.75rem;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.btn-credit-note {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.75;
}

#generateBtn:hover { background: var(--accent2); transform: translateY(-1px); }
#generateBtn:active { transform: translateY(0); }
#generateBtn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
/* Purple variant keeps white text — black fails against #7c3aed/#6d28d9 (3.69:1/2.96:1),
   white passes (5.70:1/7.10:1). Must override explicitly since the base rule above is now black. */
#generateBtn.generate-api { background: #7c3aed; color: #fff; }
#generateBtn.generate-api:hover { background: #6d28d9; color: #fff; }
/* Credits variant — a darker green than var(--green) so it doesn't read
   as a "success" toast color next to the orange/purple variants. Black
   text still passes comfortably (6.37:1 base, 4.73:1 hover); white on
   either fails (well under 4.5:1). Distinct hue so API (purple) and
   credits (green) read apart at a glance. */
#generateBtn.generate-credits { background: #16a34a; color: #000; padding-top: 0.5rem; padding-bottom: 0.5rem; }
#generateBtn.generate-credits:hover { background: #128a3e; color: #000; }

/* Hero secondary row: AI disclaimer + "Get started" toggle side by side */

/* Status row — selected generation mode + NAM A2 state, with Get started
   pushed to the right via .spacer. */
.rig-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.rig-status-row .spacer { flex: 1; }
.rig-status-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rig-status-item {
  font-size: 0.78rem;
  color: var(--green);
  padding: 0.35rem 0.75rem;
  background: rgba(46,204,113,0.08);
  border: 1px solid var(--green);
  border-radius: 20px;
  white-space: nowrap;
}

.hero-secondary-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2.5rem;
}

.get-started-btn { flex-shrink: 0; flex-direction: row; align-items: center; gap: 0.4rem; line-height: 1.15; text-align: left; }
.get-started-text { display: inline-block; }

.get-started-box {
  margin-top: 0.75rem;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
/* Right under the Rig Generator heading (Get started sits in it) */
.gen-header + .get-started-box { margin: -0.25rem 0 1rem; }
.get-started-box .help-body { padding: 1rem 1.25rem; }
.get-started-box .help-body h3:first-child { margin-top: 0; }
/* .help-body's own font-size is inherited, but .search-hero p sets font-size
   directly on every <p> in this section — a direct match always beats an
   inherited value regardless of source order, so it must be overridden
   explicitly here to keep this paragraph the same size as the list items. */
.get-started-box .help-body p { font-size: inherit; }

/* Credit mode notice */
.credit-notice-row { display: flex; align-items: stretch; gap: 0.6rem; max-width: 640px; margin: 0 auto 2.5rem; }
.credit-notice-row .credit-mode-notice { flex: 1; min-width: 0; margin: 0; }
.credit-mode-notice {
  max-width: 640px;
  margin: 0 auto 1rem;
  padding: 0.6rem 1rem;
  background: rgba(46,204,113,0.08);
  border: 1px solid var(--green);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* AI disclaimer */
.ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  background: rgba(224,90,0,0.06);
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: inset 0 0 14px rgba(224,90,0,0.3);
  min-width: 0;
  text-align: left;
}

.ai-disclaimer-icon {
  flex-shrink: 0;
  margin-top: 0.05rem;
  color: var(--accent2);
}
.ai-disclaimer-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.ai-disclaimer p {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.ai-disclaimer strong {
  color: var(--text);
  font-weight: 600;
}

/* Loading */
#loadingState {
  display: none;
  text-align: center;
  padding: 1rem;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

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

#loadingState p { color: var(--text-muted); font-size: 0.9rem; }

/* Result panel — slides in from the right, same pattern as modules.html's
   .detail-panel (block info drawer under Block Library), adapted to a
   fixed overlay since rig.html's <main> is a normal scrolling page rather
   than modules.html's fixed-height sidebar+grid layout. */
.rig-panel-backdrop {
  display: none;
  position: fixed;
  inset: var(--header-h, 64px) 0 0 0;
  background: rgba(0,0,0,0.5);
  z-index: 89;
}
body.rig-panel-open .rig-panel-backdrop { display: block; }

#resultSection {
  position: fixed;
  top: var(--header-h, 64px); right: 0; bottom: 0;
  width: 800px;
  min-width: 800px;
  max-width: 100vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0,0,0,0.45);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 90;
  padding: 1.5rem 2rem 2rem;
}
body.rig-panel-open #resultSection { transform: translateX(0); }

/* Same pattern as modules.html's .detail-close: sits on top of the panel
   content in the corner rather than a sticky bar — scrolls away with the
   rest of the content, that's fine. */
.rig-panel-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.rig-panel-close:hover { color: var(--text); border-color: var(--accent); }

@media (max-width: 860px) {
  #resultSection { width: 100vw; min-width: 0; }
}

.rig-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.rig-title-area h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.rig-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.tag {
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tag-genre { background: rgba(224,90,0,0.15); color: var(--accent2); border: 1px solid rgba(224,90,0,0.3); }
.tag-artist { background: rgba(46,204,113,0.1); color: #2ecc71; border: 1px solid rgba(46,204,113,0.2); }
.tag-shared { background: rgba(52,152,219,0.12); color: #3498db; border: 1px solid rgba(52,152,219,0.35); }

.rig-subheader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.rig-description-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
  max-width: 440px;
}

.rig-description {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  max-width: 440px;
}

.rig-imported-marker {
  color: var(--text);
}

.rig-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
}
.rig-actions .btn {
  width: 100%;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent2); }

#toggleModifyBtn {
  flex-direction: column;
  gap: 0.15rem;
  line-height: 1.2;
}
#toggleModifyBtn .btn-credit-note { opacity: 0.6; }

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent2); }

/* Destructive action (Delete account) — same red already used app-wide for
   error text (#e74c3c), so it reads as "danger" via an already-established
   association rather than an unfamiliar new color. Black text: 5.50:1 on
   the base color; the hover color is lighter (never darker), so it can
   only have higher contrast with black, never lower — no separate check
   needed for it the way the generate-credits/generate-api hover shades
   elsewhere in this file required. */
.btn-danger { background: #e74c3c; color: #000; }
.btn-danger:hover { background: #ff6152; color: #000; }

.btn-headrush {
  background: #1a3a2a;
  color: #22aa77;
  border-color: #22aa77;
  text-align: center;
  justify-content: center;
}
.btn-headrush:hover { background: #22aa77; color: #fff; }
.btn-headrush:disabled { opacity: 0.35; cursor: not-allowed; background: #1a3a2a; color: #22aa77; }

.info-card-headrush {
  border-color: #22aa7755;
}

.hr-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.25rem;
}

/* Signal Chain */
.signal-chain-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Fixed-width icon so the hint below can start under "Signal" on every platform */
.signal-chain-icon { display: inline-block; width: 1.15rem; }

.signal-chain-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: -0.6rem 0 1rem;
  padding-left: 1.15rem;
}

.signal-chain {
  display: flex;
  align-items: center;
  gap: 0;
  padding-top: 6px;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.signal-chain::-webkit-scrollbar { height: 4px; }
.signal-chain::-webkit-scrollbar-track { background: transparent; }
.signal-chain::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chain-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s;
}

.chain-block:hover { transform: translateY(-3px); }
.chain-block.active .block-card { border-color: white; }

.block-card {
  width: 90px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.4rem;
  text-align: center;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.block-card:hover {
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 4px 12px rgba(0,0,0,0.4);
}

.block-cat-bar {
  height: 3px;
  border-radius: 2px;
  margin-bottom: 0.5rem;
}

.block-icon {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
  display: block;
}

.block-name {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
  word-break: break-word;
}

/* IN/OUT ends of the chain: toned down by colour, not opacity, so the
   small labels keep AA contrast */
.block-card-terminal .block-name { color: var(--text-muted); }
.block-card-terminal .block-icon { opacity: 0.6; }
.block-cat-label {
  font-size: 0.55rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  /* NAM blocks show their capture name here — long ones end in "…" (full name on hover) */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chain-arrow {
  color: var(--border);
  font-size: 0.9rem;
  padding: 0 2px;
  flex-shrink: 0;
  align-self: center;
  margin-top: -8px;
}

/* Doubled amp/cab — one node on the pedal: A over B, mode toggle below */
.chain-double {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 6px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.block-double-tag {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
}

.double-mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.double-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.6rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}

/* Community preview: the doubled pair's mode, read-only */
.double-mode-static {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
}

.double-mode-btn + .double-mode-btn { border-left: 1px solid var(--border); }
.double-mode-btn.active { background: var(--accent); color: #000; }
.double-mode-btn:focus-visible { outline: 2px solid var(--accent2); outline-offset: -2px; }

/* Block detail panel */
.block-detail {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: all 0.2s;
}

.block-detail-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.block-detail-cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.block-detail-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.block-detail-based {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: auto;
}

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

.block-reason {
  grid-column: 1 / -1;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border-left: 3px solid var(--accent2);
  border-radius: 4px;
}

.param-item label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.param-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.param-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.param-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Editable parameters (rig view block detail) */
.param-item output.param-value { display: block; }
.param-value-text { font-size: 0.78rem; font-weight: 500; word-break: break-all; }

.param-slider {
  width: 100%;
  margin: 0.45rem 0 0;
  cursor: pointer;
}

.param-toggle,
.param-select,
.param-number {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
}

.param-toggle { min-width: 4.5rem; cursor: pointer; color: var(--text-muted); }
.param-toggle.on { color: var(--text); }
.param-select { width: 100%; cursor: pointer; }
.param-number { width: 100%; }
.param-toggle:focus-visible,
.param-select:focus-visible,
.param-number:focus-visible,
.param-slider:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* Drag to reorder (signal chain) */
.chain-block[data-index] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
/* Picked-up block: a floating copy follows the pointer… */
.drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  transform: rotate(-3deg) scale(1.06);
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.6));
  opacity: 0.55;
}
.drag-ghost .block-card { border-color: var(--accent); }
/* …while its spot in the chain shows an empty placeholder */
.drag-placeholder { opacity: 0.25; }
.drag-placeholder .block-card { border-style: dashed; }
body.chain-dragging, body.chain-dragging * { cursor: grabbing !important; }

/* Drop target = the gap between blocks, not a block's edge */
.chain-arrow { transition: color 0.12s, background 0.12s, padding 0.12s; border-radius: 3px; }
.chain-arrow.drop-gap {
  color: #000;
  background: var(--accent);
  padding: 1.6rem 6px;
  margin-top: 0;
}
.chain-block:focus-visible .block-card { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* Info cards */
.info-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.info-card-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.info-card-body {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.5;
}

/* Modify rig */
.modify-rig {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}
.modify-rig-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.modify-rig-row {
  display: flex;
  gap: 0.6rem;
}
.modify-rig-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
}
.modify-rig-row input:focus { outline: none; border-color: var(--accent); }
.modify-rig-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.6rem 0 0;
  line-height: 1.5;
}

/* Tone feedback ("How does it sound?") — shown after Download/Send.
   .rig-feedback-head/-close are also the Modify box's header and × */
.rig-feedback {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 1.5rem;
}
.rig-feedback-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.rig-feedback-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  padding: 0 0.2rem;
  cursor: pointer;
  margin-top: -0.2rem;
}
.rig-feedback-close:hover { color: var(--text); }
.rig-feedback-ratings,
.rig-feedback-problems,
.rig-feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.rig-feedback-ratings .btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent2);
}
.rig-feedback-details { margin-top: 0.4rem; }
.rig-feedback-details .modify-rig-hint { margin-bottom: 0.6rem; }
.rig-feedback-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}
.rig-feedback-chip:hover { border-color: var(--accent); }
.rig-feedback-chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.rig-feedback-details input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0.75rem 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
}
.rig-feedback-details input:focus { outline: none; border-color: var(--accent); }
.rig-feedback-actions { justify-content: flex-end; align-items: center; }
.rig-feedback-note {
  flex: 1 1 12rem;
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.rig-feedback-buttons {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
}
.rig-feedback-or {
  align-self: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
#rigFeedbackSend,
#rigFeedbackFix { flex-direction: column; gap: 0.15rem; line-height: 1.2; }
.rig-feedback .done-msg { text-align: left; margin-top: 0.25rem; }

.modify-loading-state {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}
.modify-loading-state.active { display: flex; }
.modify-loading-state #modifyLoadingStageText { font-weight: 600; color: var(--text); }
.modify-loading-state #modifyLoadingPhraseText { font-size: 0.78rem; }

.done-msg {
  display: none;
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
}
.done-msg.active { display: block; }

/* Error */
#errorState {
  display: none;
  background: rgba(231,76,60,0.08);
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  color: #e74c3c;
  font-size: 0.9rem;
  text-align: left;
  margin-top: 1rem;
}
.error-retry-hint {
  color: #ffffff;
  font-weight: 600;
}

/* Loading state — progress bar */
#loadingState {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}
#loadingState.active { display: flex; }

.loading-progress-track {
  width: 220px;
  max-width: 60vw;
  height: 8px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
  margin-bottom: 0.4rem;
}
/* Width is driven by JS (showLoading()/hideLoading() in app.js) as a plain
   determinate transition — generation time varies, so this is a fixed
   32s estimate rather than tracking real progress, but it still gives a
   genuine sense of how much longer to expect instead of an indeterminate
   loop that never resolves into "nearly done". */
.loading-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}

#loadingStageText {
  color: var(--text);
  font-weight: 600;
}
#loadingPhraseText {
  color: var(--text-muted);
}

/* Prompt Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: hidden;
}

.modal-overlay.open { display: flex; }

/* Can be opened from within the Settings modal ("Buy credits" button) as
   well as standalone (insufficient-credits check) — needs to stack above
   another already-open .modal-overlay rather than relying on DOM order. */
#buyCreditsModal { z-index: 210; }
/* Always wins — can appear on top of the Buy Credits modal itself (Stripe
   redirected back while it happened to still be open) or standalone. */
#purchaseConfirmedModal { z-index: 220; }

/* ── Buy Credits modal — balance card, pack picker, trust row ────────────── */
.credits-balance-card {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}
.credits-balance-icon { font-size: 1.6rem; line-height: 1; }
.credits-balance-label { display: block; font-size: 0.75rem; color: var(--text-muted); }
.credits-balance-amount { display: block; font-size: 1.05rem; font-weight: 700; color: var(--text); }

.credits-pack-list { display: flex; flex-direction: column; gap: 0.5rem; }
.credits-pack-option { display: block; cursor: pointer; }
.credits-pack-option input { position: absolute; opacity: 0; pointer-events: none; }
.credits-pack-card {
  display: flex; align-items: center; gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.credits-pack-option input:checked + .credits-pack-card {
  border-color: var(--accent);
  background: rgba(224, 90, 0, 0.08);
}
.credits-pack-option input:focus-visible + .credits-pack-card { outline: 2px solid var(--accent2); outline-offset: 1px; }
.credits-pack-icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.credits-pack-info { display: flex; flex-direction: column; min-width: 0; }
.credits-pack-title { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.credits-pack-desc { font-size: 0.75rem; color: var(--text-muted); }
.credits-pack-price { margin-left: auto; font-size: 0.95rem; font-weight: 700; color: var(--text); flex-shrink: 0; }

.credits-trust-row {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0.6rem 1rem;
  margin-top: 0.85rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Purchase Confirmed modal ─────────────────────────────────────────── */
.credits-confirm-icon {
  width: 52px; height: 52px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--green);
  color: #06210f;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 700;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  position: relative;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: 16px 16px 0 0;
    max-width: 100%;
    max-height: 90dvh;
    padding: 1.25rem;
  }
}

.modal-close-x {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  transition: all 0.15s;
}
.modal-close-x:hover { color: var(--text); border-color: var(--accent); }

.modal h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-right: 2rem;
}
.modal h3 em { color: var(--accent2); font-style: normal; }
#accountModalTitle { color: var(--accent); }

.modal-divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

/* Settings button */
.settings-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  width: 48px;
  height: auto;
  color: var(--text-muted);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.settings-btn:hover { color: var(--text); border-color: var(--accent); background: var(--surface2); }

/* Settings modal */
.settings-group { margin-top: 1.25rem; }
.settings-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.settings-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  box-sizing: border-box;
  font-family: inherit;
}
.settings-input:focus { outline: none; border-color: var(--accent); }
.settings-hint {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0.4rem 0 0;
  line-height: 1.5;
}
.settings-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.9rem;
  color: var(--text);
}
.settings-checkbox-label input[type="checkbox"] { width: 16px; height: 16px; }
.settings-checkbox-label input[type="checkbox"]:disabled { cursor: not-allowed; opacity: 0.5; }

.nam-variant-picker {
  grid-column: 1 / -1;
  padding: 0.6rem 0.75rem;
  background: var(--surface2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.nam-variant-picker label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.nam-current {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.nam-variant-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 160px;
  overflow-y: auto;
}
.nam-variant-row {
  text-align: left;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-family: inherit;
}
.nam-variant-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent2);
  margin-right: 0.4rem;
}
.nam-variant-row:hover { border-color: var(--accent); color: var(--text); }
.nam-variant-row.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--surface);
  font-weight: 600;
}
/* Settings → Your pedal: a segmented choice */
.pedal-model-toggle {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.pedal-model-option { position: relative; cursor: pointer; }
.pedal-model-option input { position: absolute; opacity: 0; pointer-events: none; }
.pedal-model-option span {
  display: block;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}
.pedal-model-option + .pedal-model-option span { border-left: 1.5px solid var(--border); }
.pedal-model-option input:checked + span { background: var(--accent); color: #000; }
.pedal-model-option input:focus-visible + span { outline: 2px solid var(--accent2); outline-offset: -2px; }

/* "Use NAM A2" sits under the selected mode's card (moved there by updateApiGroupVisibility) */
.mode-toggle > #namGroup { margin: 0.25rem 0 0.5rem 1rem; }

.mode-toggle { display: flex; flex-direction: column; gap: 0.5rem; }
.mode-option { display: flex; cursor: pointer; }
.mode-option input[type="radio"] { display: none; }
.mode-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s;
}
.mode-option input:checked + .mode-card { border-color: var(--accent); }
.mode-title { font-size: 0.9rem; font-weight: 600; }
.mode-desc  { font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
/* Per-mode key/model fields (or, for credits, the buy panel) — collapsed to
   just title+desc until that mode is actually selected, so the settings
   list stays scannable instead of showing four API keys' worth of fields
   at once. .credits-balance-line sits outside .mode-expand (a direct
   child of .mode-card, like every other mode's .mode-desc) specifically
   so the balance stays visible even collapsed; #creditsBalanceRow (the
   buy button) lives inside .mode-expand instead. */
.mode-expand { display: none; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.mode-option input:checked + .mode-card .mode-expand { display: flex; }
#creditsBalanceRow { font-size: 0.82rem; }
.credits-balance-line { color: var(--text); font-weight: 700; }

/* ── Homepage ─────────────────────────────────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: 0 0 2.5rem;
}
.news-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(224,90,0,0.12);
  border: 1px solid var(--accent);
  color: var(--accent2);
  border-radius: 20px;
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: background 0.15s, border-color 0.15s;
}
.news-badge:hover { background: rgba(224,90,0,0.22); }
.news-badge:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.news-date {
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.home-hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0 0 0.75rem;
}
.home-hero h1 span { color: var(--accent); }
.home-hero p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin: 0;
}
.home-hero p.home-hero-sub {
  max-width: 600px;
  margin: 0.5rem auto 0;
}

.home-section { margin-bottom: 3rem; }
.home-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.home-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.tool-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.tool-card:hover { border-color: var(--accent); background: var(--surface2); }
.tool-icon { font-size: 1.75rem; flex-shrink: 0; line-height: 1; }
.tool-name { font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.tool-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; }


/* Players card on index.html (testimonials.js): stats, quotes, Quick start
   in a 2x2 grid; the 1px gap over the border colour draws the dividers. */
.pl-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.pl-box {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1.75rem;
  background: radial-gradient(120% 120% at 0% 0%, rgba(224, 90, 0, 0.12), transparent 60%), var(--surface);
}
.pl-box[hidden] { display: none; }
.pl-box.pl-wide { grid-column: 1 / -1; }
.pl-label { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); }
.pl-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.pl-value { margin: 0; font-size: 3.2rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; background: linear-gradient(90deg, var(--accent), #ffb347); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pl-caption { margin: auto 0 0; font-size: 0.8rem; line-height: 1.55; color: var(--text-muted); }
.pl-caption strong { color: var(--text); font-weight: 600; }

.tm-quote { margin: 0; font-size: 1.05rem; line-height: 1.6; color: var(--text); }
.tm-who { margin-top: auto; font-size: 0.8rem; font-weight: 600; color: var(--accent2); }
.tm-nav { display: flex; align-items: center; gap: 0.75rem; }
.tm-nav[hidden] { display: none; }
.tm-btn { width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.tm-btn:hover { border-color: var(--accent); }
.tm-btn:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.tm-count { font-size: 0.75rem; color: var(--text-muted); min-width: 3.5em; text-align: center; font-variant-numeric: tabular-nums; }

.qs-intro { margin: 0; }
.qs-songs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.pl-wide .qs-songs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qs-song { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.55rem 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface2); color: var(--text); text-decoration: none; min-width: 0; transition: border-color 0.15s; }
.qs-song:hover { border-color: var(--accent); }
.qs-song:focus-visible, .qs-any:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.qs-title { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qs-artist { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qs-any { font-size: 0.8rem; font-weight: 600; color: var(--accent2); text-decoration: none; }
.qs-any:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .pl-card { grid-template-columns: minmax(0, 1fr); }
  .pl-box { padding: 1.25rem 1rem; }
  .pl-value { font-size: 2.5rem; }
  .pl-wide .qs-songs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* stats.html — local-only dashboard. Stat tiles reuse .pl-box/.pl-stat/
   .pl-value/.pl-caption as-is (same look as the homepage's Players card,
   just in grids of their own instead of the fixed 2x2); .st-* here is only
   the dashboard-specific extras: section spacing, bar lists, a sparkline,
   and the ranked list for top shared rigs. */
.st-section { margin-bottom: 2.5rem; }
.st-grid-1, .st-grid-2, .st-grid-3, .st-grid-4 {
  display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; margin-bottom: 1rem;
}
.st-grid-1 { grid-template-columns: minmax(0, 1fr); }
.st-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.st-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.st-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.st-grid-1 .pl-box, .st-grid-2 .pl-box, .st-grid-3 .pl-box, .st-grid-4 .pl-box { padding: 1.4rem 1.5rem; }
.st-value { font-size: 2.1rem; }
.st-empty { color: var(--text-muted); font-size: 0.85rem; margin: 0; }

.st-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.4rem 1.5rem;
}
.st-panel-title { margin: 0 0 0.2rem; font-size: 0.85rem; font-weight: 700; }
.st-panel-sub { margin: 0 0 1rem; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

.st-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.st-bar-row { display: grid; grid-template-columns: 9rem 1fr 3.2rem; align-items: center; gap: 0.6rem; }
.st-bar-label { font-size: 0.78rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-bar-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.st-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #ffb347); border-radius: 4px; }
.st-bar-count { font-size: 0.75rem; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.st-bars-2 .st-bar-row { grid-template-columns: 9rem 1fr 3.2rem 3.2rem 3.2rem; }
.st-bar-head .st-bar-count { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.st-ranked { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.st-ranked li { display: grid; grid-template-columns: 1fr auto; column-gap: 0.75rem; row-gap: 0.1rem; }
.st-ranked-name { font-size: 0.85rem; font-weight: 600; grid-column: 1; }
.st-ranked-meta { font-size: 0.72rem; color: var(--text-muted); grid-column: 1; }
.st-ranked-count { font-size: 0.8rem; font-weight: 700; color: var(--accent2); grid-column: 2; grid-row: 1 / 3; align-self: center; white-space: nowrap; }

.st-spark { display: flex; align-items: flex-end; gap: 2px; height: 48px; margin: 0.2rem 0 0; }
.st-spark-bar { flex: 1; min-width: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0.85; }

@media (max-width: 800px) {
  .st-grid-3, .st-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .st-grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .st-grid-3, .st-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .st-bar-row { grid-template-columns: 6rem 1fr 2.6rem; }
  .st-bars-2 .st-bar-row { grid-template-columns: 6rem 1fr 2.6rem 2.6rem 2.6rem; }
}

.links-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.ext-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.ext-link:hover { border-color: var(--accent); background: var(--surface2); }
.ext-link-title { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.ext-link-desc  { font-size: 0.75rem; color: var(--text-muted); }

/* Devices modal */
.modal-devices { max-width: 860px; }
.devices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}
.device-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.device-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: contain;
  background: #1a1a2a;
  padding: 0.75rem;
  box-sizing: border-box;
}
.device-info { padding: 0.9rem; display: flex; flex-direction: column; flex: 1; }
.device-name {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.3rem;
  color: var(--text);
}
.device-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}
.device-specs {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.device-specs li {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-left: 0.9rem;
  position: relative;
}
.device-specs li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--accent);
}
.device-link {
  font-size: 0.78rem;
  color: var(--accent2);
  text-decoration: none;
  font-weight: 600;
}
.device-link:hover { text-decoration: underline; }

/* JSON export view */
.json-view {
  display: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #a8d8a8;
  white-space: pre;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 1rem;
  line-height: 1.6;
}

/* ── Saved rigs / Community ──────────────────────────────────────────────── */
#savedSection, #communitySection {
  max-width: 800px;
  margin: 0 auto 3rem;
  display: none;
}

.saved-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.saved-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}
.saved-header .spacer { flex: 1; }

.community-sort {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.community-sort .sort-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
}
.community-sort .sort-btn.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.community-shared-by {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.community-signin-prompt {
  max-width: 480px;
  margin: 1.5rem auto 2.5rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.community-signin-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.community-signin-prompt h3 { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--text); }
.community-signin-prompt .settings-hint { margin-bottom: 1rem; }
.community-signin-prompt .btn { margin-top: 0.5rem; }

.community-like-btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.9rem;
  width: 100%;
  justify-content: center;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.community-like-btn.liked { background: var(--accent); color: #000; border-color: var(--accent); }
.saved-note {
  font-size: 0.75rem;
  color: #fff;
  margin: 0;
  opacity: 1;
}

.saved-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s;
}
.saved-card:hover { border-color: var(--accent); }

.saved-card-main { flex: 1; min-width: 0; }

.saved-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.saved-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.saved-card-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.saved-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
}
.saved-card-actions .btn {
  font-size: 0.78rem;
  padding: 0.35rem 0.9rem;
  white-space: nowrap;
  width: 100%;
  justify-content: center;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.6;
  text-align: center;
  padding: 1.75rem 1.5rem;
}
.site-footer p { margin: 0; }
/* Underlined so links don't rely on colour alone (WCAG 1.4.1) */
.site-footer a { color: var(--accent2); text-decoration: underline; text-underline-offset: 2px; }
.site-footer a:hover { color: var(--text); }
.site-footer .footer-fine {
  font-size: 0.72rem;
  margin-top: 0.4rem;
}

/* App-style page: flex column so header + lib-layout + footer stack full-height */
body.app-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .info-cards { grid-template-columns: 1fr 1fr; }
  .devices-grid { grid-template-columns: 1fr; }
  .links-row { grid-template-columns: 1fr 1fr; }
  .home-tools { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .links-row { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  header {
    padding: 0 1rem;
    gap: 0.75rem;
  }
  .header-note { display: none; }
  .nav-toggle { display: flex; align-items: center; }
  .logo-img { height: 22px; }
  .logo-sub { font-size: 0.6rem; }
  .account-btn.signed-in .account-btn-name { font-size: 0; }
  .account-btn.signed-in .account-btn-name::after { content: "Account"; font-size: 0.8rem; }
  .header-nav {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 99;
    gap: 0.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 0.5rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    max-height: 0;
    overflow: hidden;
    padding: 0;
    border-width: 0;
    pointer-events: none;
    transition: max-height 0.25s ease, padding 0.25s ease;
  }
  .header-nav.open {
    max-height: 420px;
    padding: 0.5rem;
    border-width: 1px;
    pointer-events: auto;
  }
  .nav-link {
    border-radius: 8px;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    width: 100%;
  }
  .nav-link-mobile-only { display: flex; align-items: center; }
  /* nav.js moves .bmc-link (146px, non-shrinking widget) into headerNav as
     the last item below this breakpoint — style it to match the stacked
     nav-link rows instead of the desktop pill-row appearance. */
  .header-nav .bmc-link {
    width: 100%;
    margin: 0.25rem 0 0;
    display: flex;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .header-note { display: none; }
  .logo-icon { width: 32px; height: 32px; font-size: 16px; }
  .logo-text { font-size: 1rem; }
  main { padding: 1.5rem 1rem; }

  /* Home */
  .home-hero { padding: 0 0 1.5rem; }
  .home-hero h1 { font-size: 1.7rem; }
  .home-hero p { font-size: 0.9rem; }
  .home-tools { grid-template-columns: 1fr; }
  .links-row { grid-template-columns: 1fr 1fr; }

  /* Rig generator */
  .search-hero { padding: 0 0 1.5rem; }
  .search-hero h1 { font-size: 1.7rem; }
  .search-hero p { font-size: 0.9rem; }
  .search-box { flex-direction: column; }
  .search-actions { width: 100%; }
  .search-actions #generateBtn { flex: 1; justify-content: center; }
  .rig-header { flex-direction: column; }
  .rig-subheader { flex-direction: column; }
  .rig-description-col, .rig-description { max-width: none; }
  .rig-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .rig-actions .btn { flex: 1 1 auto; }
  .info-cards { grid-template-columns: 1fr; }

  /* Community — sort buttons wrap under the "Shared rigs" heading instead
     of squeezing onto the same row, staying right-aligned (via .spacer)
     rather than also going full-width themselves. */
  #communitySection .saved-header { flex-wrap: wrap; }
  #communitySection .saved-header h2 { flex-basis: 100%; }
  .block-card { width: 76px; }

  /* Modals */
  .modal { width: 100%; }

  /* Block grid — 2 columns on mobile */
  .block-grid { grid-template-columns: repeat(2, 1fr); }

  .site-footer { padding: 1.5rem 1rem; }
}

/* ── Feedback-modal ─────────────────────────────────────────────────────────── */

.fb-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}

.fb-modal {
  background: var(--surface, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 12px;
  padding: 2rem;
  width: min(480px, 100%);
  box-sizing: border-box;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

@media (max-width: 520px) {
  .fb-modal { padding: 1.25rem; }
}

.fb-modal h3 {
  margin: 0 0 .4rem;
  font-size: 1.1rem;
  color: var(--text, #e0e0e0);
}

.fb-desc {
  margin: 0 0 1.25rem;
  font-size: .85rem;
  color: var(--text-muted, #888);
}

.fb-close {
  position: absolute; top: 1rem; right: 1rem;
  background: var(--surface2); border: 1px solid var(--border); cursor: pointer;
  color: var(--text-muted, #888); font-size: 0.8rem;
  padding: 0.3rem 0.6rem; border-radius: 6px;
  transition: all 0.15s;
}
.fb-close:hover { color: var(--text, #e0e0e0); border-color: var(--accent); }

.fb-field { margin-bottom: 1rem; }

.fb-field label {
  display: block;
  font-size: .8rem;
  color: var(--text-muted, #888);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.fb-required { color: #e07020; }

.fb-module-name {
  font-weight: 600;
  color: var(--text, #e0e0e0) !important;
  margin-bottom: .25rem !important;
}

.fb-field input,
.fb-field textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg, #12121f);
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  padding: .55rem .75rem;
  font-size: .9rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color .15s;
}

.fb-field input:focus,
.fb-field textarea:focus {
  outline: none;
  border-color: #22aa77;
}

.fb-actions {
  display: flex; justify-content: flex-end; gap: .75rem;
  margin-top: 1.25rem;
}

.fb-status {
  padding: .6rem .85rem;
  border-radius: 6px;
  font-size: .85rem;
  margin-bottom: .75rem;
}
.fb-status-ok    { background: rgba(34,170,119,.15); color: #22aa77; border: 1px solid rgba(34,170,119,.3); }
.fb-status-error { background: rgba(220, 50, 50,.15); color: #e05555; border: 1px solid rgba(220,50,50,.3); }

.fb-trigger-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .8rem;
  color: var(--text-muted, #888);
  background: none;
  border: 1px solid var(--border, #333);
  border-radius: 6px;
  padding: .35rem .7rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.fb-trigger-btn:hover { color: var(--text, #e0e0e0); border-color: #555; }

/* ── Help panel ─────────────────────────────────────────────────────────────── */
.bmc-link {
  flex-shrink: 0;
  line-height: 0;
}
.bmc-btn {
  height: 30px !important;
  min-width: 145px !important;
  padding: 0px 12px !important;
  border-radius: 15px !important;
  font-size: 20px !important;
}
/* The widget's own script injects a same-specificity `.bmc-btn { ... !important }`
   rule into a <style> tag added after style.css loads — on a tie, source
   order wins, so its colors clobber a plain `.bmc-btn` override here no
   matter what. `.bmc-link .bmc-btn` (two classes) has higher specificity
   and wins outright regardless of injection order. */
.bmc-link .bmc-btn { background-color: var(--surface2) !important; color: var(--text-muted) !important; border: 1px solid var(--border) !important; }
.bmc-link .bmc-btn:hover { color: var(--text) !important; border-color: #555 !important; }

.help-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.help-btn:hover { color: var(--text); border-color: #555; background: var(--surface); }
.help-btn-label { display: none; }

/* Moved into the mobile hamburger dropdown (see nav.js) — restyle from the
   round desktop icon button into a full-width stacked menu row matching
   .nav-link, with the label shown instead of just "?". */
.header-nav .help-btn {
  width: 100%;
  height: auto;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 400;
  justify-content: flex-start;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
}
.header-nav .help-btn:hover { color: var(--text); background: var(--surface); }
.header-nav .help-btn-label { display: inline; }

.header-pedal-status {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.header-pedal-status:hover { color: var(--text); border-color: #555; background: var(--surface); }
.header-pedal-status.connected { border-color: var(--green); color: var(--green); box-shadow: inset 0 0 8px rgba(46,204,113,0.45); }
.header-pedal-status.disconnected { border-color: var(--red); color: var(--red); box-shadow: inset 0 0 8px rgba(231,76,60,0.45); }
.header-pedal-status.unreachable { border-color: #e8a838; color: #e8a838; box-shadow: inset 0 0 8px rgba(232,168,56,0.45); }

.account-btn {
  min-height: 30px;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #000;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  max-width: 220px; /* wide enough for a typical email without truncating */
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
}
.account-btn:hover { background: var(--accent2); border-color: var(--accent2); color: #000; }
.account-btn-icon { font-size: 1rem; line-height: 1; align-self: stretch; display: flex; align-items: center; }
/* Two lines when credits mode's balance is shown (app.js's
   updateAccountBtnBalance), just the email otherwise (account.js's
   updateAccountUI) — .account-btn-icon stretches to match either height. */
.account-btn-text { display: flex; flex-direction: column; justify-content: center; gap: 0.05rem; line-height: 1.2; min-width: 0; }
.account-btn-name { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-btn-credits { font-size: 0.68rem; font-weight: 500; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.help-overlay {
  position: fixed; inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.help-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.help-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.help-overlay.open .help-panel { transform: translateX(0); }

.help-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-panel-header h2 { font-size: 1rem; font-weight: 700; }

.help-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.help-close:hover { color: var(--text); border-color: var(--accent); }

.help-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  line-height: 1.6;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.help-contact {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.help-contact-icon {
  flex-shrink: 0;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-contact-icon svg {
  width: 60%;
  height: 60%;
}
.help-body h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent2);
  margin: 1.25rem 0 0.5rem;
}
.help-body h3:first-child { margin-top: 0; }
.help-body p { margin-bottom: 0.6rem; }
.help-body ol, .help-body ul { padding-left: 1.25rem; margin-bottom: 0.6rem; }
.help-body li { margin-bottom: 0.35rem; }
.help-body strong { color: var(--text); font-weight: 600; }
.help-body a, .help-ext-link {
  color: var(--accent2);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,160,50,0.35);
  transition: color 0.15s, border-color 0.15s;
}
.help-body a:hover, .help-ext-link:hover {
  color: var(--text);
  border-color: var(--text);
}
.help-body .help-tag {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.78rem;
  font-family: monospace;
  color: var(--text);
}

/* ── Cookie consent ─────────────────────────────────────────────────────────── */
/* Step aside while a dialog/help panel is open — otherwise a first-time
   visitor's banner (z-index 2000) covers the dialog's bottom buttons,
   e.g. Settings → Save. It's back as soon as the dialog closes. */
body:has(.modal-overlay.open) .cookie-banner,
body:has(.help-overlay.open) .cookie-banner,
body:has(.fb-overlay[style*="flex"]) .cookie-banner { display: none; }
.cookie-banner {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: min(600px, calc(100vw - 2rem));
  width: 100%;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.cookie-banner-hide {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
}
.cookie-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.cookie-banner-text strong {
  color: var(--text);
  font-size: 0.88rem;
}
.cookie-banner-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.cookie-btn-accept,
.cookie-btn-decline {
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.cookie-btn-accept {
  background: var(--accent);
  border: 1px solid transparent;
  color: #000;
}
.cookie-btn-accept:hover { background: var(--accent2); }
.cookie-btn-decline {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.cookie-btn-decline:hover { color: var(--text); border-color: var(--accent); }

.cookie-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.cookie-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: min(420px, 100%);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.cookie-modal h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
}
.cookie-modal p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
}
.cookie-option {
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}
.cookie-option label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.cookie-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

@media (max-width: 520px) {
  .cookie-banner { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .cookie-banner-actions { align-self: flex-end; }
}

/* Cookie modal sections & toggle */
.cookie-section {
  border-top: 1px solid var(--border);
  padding: 1rem 0;
}
.cookie-section p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.cookie-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.cookie-section-header strong {
  font-size: 0.9rem;
  color: var(--text);
}
.cookie-always-on {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Toggle switch */
.cookie-toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}
.cookie-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.cookie-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s;
}
.cookie-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.cookie-toggle input:checked + .cookie-toggle-track { background: var(--accent); }
.cookie-toggle input:checked + .cookie-toggle-track::after { transform: translateX(16px); }

/* ── Focus-visible — WCAG 2.4.7, 2.4.11 ────────────────────────────────────
   Suppress browser focus ring for mouse/touch; keep it for keyboard nav.      */
:focus:not(:focus-visible) {
  outline: none;
}
:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
  border-radius: 3px;
}
/* Inputs use border-color as focus indicator — also add outline for keyboard */
#searchInput:focus-visible,
.settings-input:focus-visible,
.fb-field input:focus-visible,
.fb-field textarea:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 0;
}

/* ── Reduced motion — WCAG 2.3.3 ────────────────────────────────────────────
   Disable animations for users who prefer reduced motion.                     */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .loading-progress-fill { transition: none !important; }
}

/* ── Tone direction on rig.html (tone-direction.js) ───────────────────────── */
.td { margin: 0.9rem 0 0; text-align: left; }
.td-bar {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.55rem 0.9rem; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.td-bar:hover { border-color: var(--accent); background: var(--surface2); }
.td-bar.open, .td-bar.open:hover { border-color: var(--accent); border-bottom-width: 0; padding-bottom: calc(0.55rem + 1px); border-radius: 12px 12px 0 0; background: var(--surface); }
.td-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.75rem; text-align: left;
  background: none; border: none; color: var(--text); font: inherit; cursor: pointer; padding: 0.1rem 0;
}
.td-toggle:focus-visible { outline: 2px solid var(--accent2); outline-offset: 3px; border-radius: 6px; }
.td-clear {
  flex-shrink: 0; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
  color: var(--text); font: inherit; font-size: 0.78rem; font-weight: 600; padding: 0.25rem 0.75rem; cursor: pointer;
}
.td-clear:hover:not(:disabled) { border-color: var(--text-muted); }
.td-clear:disabled { opacity: 0.4; cursor: default; }
.td-clear:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.td-toggle-icon { font-size: 1.3rem; line-height: 1; }
.td-toggle-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.td-toggle-title { font-size: 0.92rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.td-toggle-sub { font-size: 0.78rem; color: var(--text-muted); }
.td-toggle-sub.td-set { color: var(--accent2); font-weight: 600; }
.td-toggle-action { flex-shrink: 0; font-size: 0.8rem; font-weight: 600; color: var(--accent2); border: 1px solid var(--accent); border-radius: 20px; padding: 0.25rem 0.7rem; white-space: nowrap; }
.td-optional { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; border: 1px solid var(--border); border-radius: 20px; padding: 0 0.45rem; }
.td-optional { font-weight: 600; color: var(--text-muted); }
.td-chevron { display: inline-block; transition: transform 0.15s; }
.td-bar.open .td-chevron { transform: rotate(180deg); }
.td-body { background: var(--surface); border: 1px solid var(--accent); border-top: none; border-radius: 0 0 14px 14px; padding: 0 1.25rem 1.1rem; }
.td-body[hidden] { display: none; }
/* .search-hero p (1.05rem, margin-bottom 2rem) would win over a plain .td-sub */
.search-hero .td-sub { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 1rem; line-height: 1.5; }
.td-dials { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.td-dial { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.td-knob { position: relative; width: 108px; max-width: 100%; aspect-ratio: 1; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.td-knob svg { width: 100%; height: 100%; display: block; }
.td-knob-track { fill: none; stroke: #3a3a42; stroke-width: 11; stroke-linecap: round; }
.td-knob-value { fill: none; stroke-width: 11; stroke-linecap: round; }
.td-knob-face { fill: #141417; stroke: #2a2a30; stroke-width: 1; }
.td-knob-needle { stroke-width: 3; stroke-linecap: round; }
.td-dial-auto .td-knob-needle { stroke: #555; }
.td-knob-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; padding-top: 0.8rem; }
.td-knob-label { font-size: 0.55rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.td-knob-word { font-size: 0.8rem; font-weight: 700; line-height: 1.15; max-width: 60px; }
.td-dial-auto .td-knob-word { color: var(--text-muted); font-weight: 600; }
.td-dial-range { font-size: 0.78rem; font-weight: 600; margin-top: 0.3rem; }
.td-dial-row { display: flex; align-items: center; gap: 0.4rem; width: 100%; margin-top: 0.5rem; }
.td-slider { flex: 1; min-width: 0; width: 100%; accent-color: var(--td-color); }
.td-slider-auto { accent-color: #555; opacity: 0.6; }
.td-onoff { min-width: 2.6rem; background: none; border: 1px solid var(--border); border-radius: 20px; color: var(--text-muted); font: inherit; font-size: 0.68rem; font-weight: 700; padding: 0.15rem 0.5rem; cursor: pointer; }
.td-onoff:hover { color: var(--text); border-color: var(--text-muted); }
.td-onoff.on { background: var(--accent); border-color: var(--accent); color: #000; }
.td-onoff:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.td-head { display: flex; align-items: baseline; gap: 0.75rem; margin: 1.1rem 0 0.5rem; }
.td-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); }
.td-current { font-size: 0.9rem; font-weight: 600; }
.td-styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 0.45rem; }
.td-style { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font: inherit; text-align: left; padding: 0.5rem 0.65rem; cursor: pointer; display: flex; flex-direction: column; gap: 0.1rem; }
.td-style:hover { border-color: var(--text-muted); }
.td-style:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.td-style.active { border-color: var(--accent2); background: #3a2416; }
.td-style.active .td-style-name { color: var(--accent2); }
.td-style-name { font-size: 0.85rem; font-weight: 600; }
.td-style-tag { font-size: 0.7rem; color: var(--text-muted); }
.td-era .td-dial-row { margin-top: 0; }
.td-era-ticks { display: flex; justify-content: space-between; margin: 0.3rem 3.4rem 0 0.5rem; font-size: 0.66rem; color: var(--text-muted); }
.td-era-ticks span { width: 0; display: flex; justify-content: center; white-space: nowrap; }
@media (max-width: 520px) {
  /* td-bar: icon+title+subtitle, "All off" and "Show ▾" all crammed into one
     row got too tight for a phone screen — wrap onto two rows instead: the
     toggle (icon/title/subtitle) takes the full first row, "All off" and
     "Show ▾" move to a second row together, right-aligned. */
  .td-bar { flex-wrap: wrap; row-gap: 0.5rem; padding: 0.6rem 0.8rem; }
  .td-toggle { flex-basis: 100%; }
  .td-clear { margin-left: auto; }
  .td-body { padding: 0 1rem 1rem; }
  .td-dials { gap: 0.35rem; }
  .td-dial-range { font-size: 0.68rem; }
  .td-knob-word { font-size: 0.7rem; max-width: 52px; }
  .td-dial-row { flex-direction: column; gap: 0.3rem; }
  .td-era .td-dial-row { flex-direction: row; }
  .td-styles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Modify this rig: the three wheels (tone-direction.js) */
.td-mod { margin-top: 0.75rem; }
.td-dials-mod .td-knob { width: 92px; }

/* stats.html: logo-only header, Sign in in #statsGate */
header.st-header { justify-content: center; }
.st-signin { margin-left: 0.4rem; padding: 0.35rem 0.9rem; border-radius: 8px; border: 1px solid var(--accent); background: transparent; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
.st-signin:hover { background: var(--accent); color: #fff; }
