/* ============================================================
   DUAL BUILD ARMORY
   Elemental game-tool styling for the 5-Dual build finder, with
   dark + light themes (see the LIGHT THEME block below).
   Element identity flows through one scoped token (--ec, set from
   data-el) across chips, tags, must-rows and card hover.
   ============================================================ */

/* ---- design tokens — DARK theme is the :root default ----
   Light theme overrides these under [data-theme="light"] and, in
   auto mode, under @media (prefers-color-scheme: light). Anything
   theme-dependent must be a token here so both themes stay in sync. */
:root {
  color-scheme: dark;

  --bg:       #07090f;
  --bg-1:     #0c0e1a;
  --panel:    #101320;
  --panel-2:  #151826;
  --panel-3:  #1b1f30;
  --line:     #222638;
  --line-2:   #191d2e;

  --ink:      #eef0fb;
  --ink-2:    #b2bbd4;
  --ink-3:    #6e7894;
  --ink-4:    #424a62;

  /* gold accent (text / borders / focus) — must read on the panel bg */
  --gold:     #f4c24a;
  --gold-2:   #c99a30;
  --gold-glow: rgba(244, 194, 74, .2);
  /* gold CTA (button backgrounds) — stays vivid; dark text sits on it */
  --gold-cta-1: #f4c24a;
  --gold-cta-2: #c99a30;
  --on-gold:    #1a1200;

  /* semantic surfaces / effects (were hardcoded; tokenized for theming) */
  /* appbar = status bar: one solid color, also fed to <meta theme-color>
     (JS keeps it synced) so the two surfaces are seamless */
  --statusbar:    #07090f;
  --scrim:        rgba(4, 5, 9, .68);
  --shadow-card:  0 16px 36px -12px rgba(0, 0, 0, .75);
  --shadow-sheet: 0 -20px 50px rgba(0, 0, 0, .55);
  --shadow-cta:   0 6px 22px -6px rgba(244, 194, 74, .35);
  --overlay-soft:   rgba(255, 255, 255, .06);
  --overlay-soft-2: rgba(255, 255, 255, .12);

  /* elemental palette */
  --c-fire:   #ff6b3d;
  --c-ice:    #5ed3ff;
  --c-volt:   #f5e04a;
  --c-toxin:  #7ee85c;
  --c-shade:  #b07aff;
  --c-light:  #ffe680;
  --c-blade:  #ff5583;
  --c-none:   #6b748f;

  --sidebar-w: 268px;
  --topbar-h:  52px;

  --r:      14px;
  --r-sm:   9px;
  --r-pill: 999px;

  --ease:   cubic-bezier(.22, 1, .36, 1);
  --ease-2: cubic-bezier(.16, 1, .3,  1);

  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

/* ---- element color helpers (referenced by data-el attr) ---- */
[data-el="fire"]  { --ec: var(--c-fire);  }
[data-el="ice"]   { --ec: var(--c-ice);   }
[data-el="volt"]  { --ec: var(--c-volt);  }
[data-el="toxin"] { --ec: var(--c-toxin); }
[data-el="shade"] { --ec: var(--c-shade); }
[data-el="light"] { --ec: var(--c-light); }
[data-el="blade"] { --ec: var(--c-blade); }
[data-el="none"]  { --ec: var(--c-none);  }

/* ============================================================
   LIGHT THEME
   Two entry points, identical token values:
   1. explicit  -> :root[data-theme="light"]
   2. auto mode -> @media (prefers-color-scheme: light) on
      :root[data-theme="auto"] (the default when nothing is stored)
   Elemental hues are darkened/saturated so they keep contrast on
   the light surfaces.
   ============================================================ */
:root[data-theme="light"] {
  color-scheme: light;

  --bg:       #f5f6fb;
  --bg-1:     #eceef6;
  --panel:    #ffffff;
  --panel-2:  #f4f5fb;
  --panel-3:  #e9ebf4;
  --line:     #d6dae8;
  --line-2:   #e5e8f1;

  --ink:      #14182a;
  --ink-2:    #424c66;
  --ink-3:    #6b7592;
  --ink-4:    #98a1ba;

  --gold:     #9a6a05;
  --gold-2:   #7c5404;
  --gold-glow: rgba(154, 106, 5, .18);
  --gold-cta-1: #f3bf3f;
  --gold-cta-2: #e0a418;
  --on-gold:    #2a1d00;

  --statusbar:    #fdfdfe;
  --scrim:        rgba(22, 26, 42, .42);
  --shadow-card:  0 16px 36px -14px rgba(28, 38, 74, .26);
  --shadow-sheet: 0 -20px 50px rgba(28, 38, 74, .2);
  --shadow-cta:   0 6px 22px -6px rgba(176, 125, 18, .4);
  --overlay-soft:   rgba(22, 26, 42, .06);
  --overlay-soft-2: rgba(22, 26, 42, .12);

  --c-fire:   #e0491b;
  --c-ice:    #1488c4;
  --c-volt:   #9a7a00;
  --c-toxin:  #2f9a22;
  --c-shade:  #7b3fd6;
  --c-light:  #b8870a;
  --c-blade:  #d62a5a;
  --c-none:   #69728c;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;

    --bg:       #f5f6fb;
    --bg-1:     #eceef6;
    --panel:    #ffffff;
    --panel-2:  #f4f5fb;
    --panel-3:  #e9ebf4;
    --line:     #d6dae8;
    --line-2:   #e5e8f1;

    --ink:      #14182a;
    --ink-2:    #424c66;
    --ink-3:    #6b7592;
    --ink-4:    #98a1ba;

    --gold:     #9a6a05;
    --gold-2:   #7c5404;
    --gold-glow: rgba(154, 106, 5, .18);
    --gold-cta-1: #f3bf3f;
    --gold-cta-2: #e0a418;
    --on-gold:    #2a1d00;

    --statusbar:    #fdfdfe;
    --scrim:        rgba(22, 26, 42, .42);
    --shadow-card:  0 16px 36px -14px rgba(28, 38, 74, .26);
    --shadow-sheet: 0 -20px 50px rgba(28, 38, 74, .2);
    --shadow-cta:   0 6px 22px -6px rgba(176, 125, 18, .4);
    --overlay-soft:   rgba(22, 26, 42, .06);
    --overlay-soft-2: rgba(22, 26, 42, .12);

    --c-fire:   #e0491b;
    --c-ice:    #1488c4;
    --c-volt:   #9a7a00;
    --c-toxin:  #2f9a22;
    --c-shade:  #7b3fd6;
    --c-light:  #b8870a;
    --c-blade:  #d62a5a;
    --c-none:   #69728c;
  }
}

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 5px; }
::selection { background: var(--gold-glow); color: var(--ink); }

/* ---- native-app feel ----
   Remove the usual "web page" tells: tap flash, long-press callout menus,
   the double-tap-zoom delay, overscroll bounce / pull-to-refresh, and image
   drag. Text selection is left ON in a normal browser tab; it's only killed
   when the app runs installed (html.standalone), where selecting UI labels
   or getting a caret feels broken rather than native. */
* { -webkit-tap-highlight-color: transparent; }
html { overscroll-behavior: none; }
body { -webkit-touch-callout: none; touch-action: manipulation; }
img, svg { -webkit-user-drag: none; user-select: none; }

html.standalone, html.standalone body {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* inputs must stay selectable/editable even in standalone */
html.standalone input, html.standalone textarea {
  user-select: text; -webkit-user-select: text;
}

/* slim, themed scrollbars instead of the chunky default (a strong web tell) */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 50;
  /* extend the bar up into the notch / status-bar inset (0 on most devices)
     so its color fills that strip too — seamless on notched phones. */
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  /* solid, identical to the <meta theme-color> status bar (--statusbar) so the
     two surfaces read as one — no seam. (Opaque, so no backdrop-filter.) */
  background: var(--statusbar);
  border-bottom: 1px solid var(--line-2);
}
.topbar-inner {
  height: var(--topbar-h);
  max-width: 1500px; margin: 0 auto;
  /* respect side insets in landscape on notched devices */
  padding: 0 calc(16px + env(safe-area-inset-right, 0px))
           0 calc(16px + env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 10px;
}
.brand-mark {
  color: var(--gold); display: grid; place-items: center; flex: none;
  margin-right: auto; /* pushes controls to the right (title removed) */
  filter: drop-shadow(0 0 8px rgba(244,194,74,.3));
}
.topbar-status {
  font-family: var(--mono);
  font-size: .78rem; font-weight: 700;
  color: var(--ink-2);
  height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap;
  transition: color .25s;
}
/* filter active: status goes gold */
.topbar-status[data-active] {
  color: var(--gold);
}
.lang-btn {
  flex: none; height: 36px; min-width: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
  border-radius: var(--r-pill);
  font-size: .8rem; font-weight: 800; letter-spacing: .04em;
  transition: border-color .2s, color .2s, background .2s;
}
.lang-btn:hover { color: var(--ink); border-color: var(--gold-2); background: var(--panel-3); }

/* theme toggle — cycles auto → light → dark; icon reflects the chosen mode */
.theme-btn {
  flex: none; width: 38px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
  border-radius: var(--r-pill);
  transition: border-color .2s, color .2s, background .2s;
}
.theme-btn:hover { color: var(--ink); border-color: var(--gold-2); background: var(--panel-3); }
.theme-ico { display: none; }
:root[data-theme="auto"]  .theme-ico-auto  { display: block; }
:root[data-theme="light"] .theme-ico-light { display: block; }
:root[data-theme="dark"]  .theme-ico-dark  { display: block; }
/* fallback if no mode attr is set yet (pre-JS): show the auto glyph */
:root:not([data-theme]) .theme-ico-auto { display: block; }

/* mobile picker button — hidden on desktop */
.open-picker-mobile {
  display: none;
  align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2);
  border-radius: var(--r-pill);
  font-size: .84rem; font-weight: 700;
  flex: none;
  transition: border-color .2s, color .2s;
}
.open-picker-mobile:hover { border-color: var(--gold-2); color: var(--ink); }
.sel-badge {
  display: grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--gold-cta-1); color: var(--on-gold);
  font-size: .68rem; font-weight: 900;
  border-radius: var(--r-pill);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
  display: flex;
  max-width: 1500px; margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h));
  min-height: calc(100dvh - var(--topbar-h));
}

/* ---- SIDEBAR ---- */
.sidebar {
  flex: none; width: var(--sidebar-w);
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
  border-right: 1px solid var(--line-2);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-1) 100%);
  transition: border-color .3s, box-shadow .3s;
}

/* filter-active sidebar signal */
.sidebar[data-active] {
  border-right-color: rgba(244,194,74,.22);
  box-shadow: 4px 0 28px -8px rgba(244,194,74,.1);
}
.sidebar[data-active] .sidebar-title {
  color: var(--gold);
}

.sidebar-inner {
  padding: 16px 14px 40px;
  display: flex; flex-direction: column; gap: 0;
}
.sidebar-head { margin-bottom: 12px; }
.sidebar-title-row {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 10px;
}
.sidebar-title {
  font-size: .88rem; font-weight: 800; color: var(--ink);
  transition: color .3s;
}
.sidebar-sub { font-size: .7rem; color: var(--ink-4); }

/* selected tags */
.selbar-area {
  display: flex; align-items: flex-start; gap: 6px;
  flex-wrap: wrap; margin-bottom: 8px;
}
.seltags-row {
  display: flex; flex-wrap: wrap; gap: 5px;
  flex: 1 1 auto; min-width: 0;
}

/* cap message */
.cap-msg {
  margin: 0 0 8px;
  font-size: .73rem; font-weight: 600;
  color: var(--gold);
  background: rgba(244,194,74,.1);
  border-radius: 8px; padding: 6px 10px;
  border: 1px solid rgba(244,194,74,.2);
}
.cap-msg.flash { animation: shake .38s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-4px); }
  40%     { transform: translateX(4px); }
  60%     { transform: translateX(-3px); }
  80%     { transform: translateX(3px); }
}

/* ---- CHIPS ---- */
.chips-list { display: flex; flex-direction: column; gap: 16px; }
.chip-group { }
.chip-group-label {
  font-size: .62rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-4); margin-bottom: 7px;
  display: flex; align-items: center; gap: 6px;
}
.chip-group-label::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(90deg, var(--line-2), transparent);
}
/* subtle count badge next to slot group label */
.chip-group-count {
  font-size: .6rem; font-weight: 700; letter-spacing: 0;
  color: var(--ink-4);
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  padding: 0 5px; line-height: 16px;
  margin-right: 2px;
  flex: none;
}
.chip-grid { display: flex; flex-wrap: wrap; gap: 5px; }

/* chip with always-visible element dot */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 11px 0 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-3);
  font-size: .82rem; font-weight: 600;
  transition: border-color .15s, color .15s, background .15s, transform .1s, box-shadow .18s;
}
/* the always-on element dot */
.chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ec, var(--c-none));
  flex: none;
  opacity: .7;
  transition: opacity .15s, box-shadow .15s;
}
.chip:hover .chip-dot { opacity: 1; box-shadow: 0 0 6px var(--ec, var(--c-none)); }
.chip:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ec, var(--c-none)) 40%, var(--line)); }
.chip:active { transform: scale(.95); }

/* selected state */
.chip.chip-sel {
  color: var(--ec, var(--c-none));
  border-color: color-mix(in srgb, var(--ec, var(--c-none)) 55%, transparent);
  background: color-mix(in srgb, var(--ec, var(--c-none)) 12%, var(--panel));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ec, var(--c-none)) 35%, transparent),
              0 0 14px -4px color-mix(in srgb, var(--ec, var(--c-none)) 40%, transparent);
}
.chip.chip-sel .chip-dot { opacity: 1; box-shadow: 0 0 8px var(--ec, var(--c-none)); }
.chip.chip-dim { opacity: .3; pointer-events: none; }

/* ---- RESULTS AREA ---- */
.results-area {
  flex: 1 1 auto; min-width: 0;
  padding: 20px 18px 80px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-content: start;
  gap: 14px;
}

/* ============================================================
   BUILD CARD
   ============================================================ */
.build-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  position: relative;
  isolation: isolate;
  display: flex; flex-direction: column;
  transition: border-color .22s, transform .22s, box-shadow .22s;
}
/* hover border: perceptible base tint; cards with a must-have row carry data-el
   so --ec resolves to that element's color and echoes it on the border. */
.build-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: color-mix(in srgb, var(--ink-3) 55%, var(--line));
}
/* elemental echo: when card carries a must-have element (data-el set in JS) */
.build-card[data-el]:hover {
  border-color: color-mix(in srgb, var(--ec) 25%, var(--line));
}

/* ---- card rows ---- */
.card-rows {
  display: flex; flex-direction: column; flex: 1;
  /* clip the element strips (and must-row glow) to the card's rounded shape */
  overflow: hidden;
  border-radius: calc(var(--r) - 1px);
}

.card-row {
  display: grid;
  /* left: slot label; right: content block */
  grid-template-columns: 46px 1fr;
  column-gap: 10px;
  padding: 8px 12px 8px 0;
  padding-left: 0;
  position: relative;
}
.card-row + .card-row { border-top: 1px solid var(--line-2); }

/* element left strip — 3px colored bar */
.card-row::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ec, var(--c-none));
  opacity: .55;
  border-radius: 0 0 0 0;
  transition: opacity .2s, width .2s;
}
.card-row:hover::before { opacity: .9; }

/* must-have row: glowing strip + tinted background */
.card-row-must {
  background: color-mix(in srgb, var(--ec, var(--c-none)) 9%, transparent);
}
.card-row-must::before {
  opacity: 1;
  width: 4px;
  box-shadow: 0 0 14px 1px var(--ec, var(--c-none));
}

/* slot label — left column */
.cr-slot {
  align-self: start;
  padding: 2px 0 0 8px;
  font-size: .6rem; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-4);
  text-align: center;
  line-height: 1.2;
}
.card-row-must .cr-slot {
  color: color-mix(in srgb, var(--ec, var(--c-none)) 65%, var(--ink-3));
}

/* right column — two-line vertical block */
.cr-content {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
  padding: 2px 0;
}

/* line 1 — dual name HEADLINE */
.cr-dual-line {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px;
}
.cr-dual-name {
  font-size: .96rem; font-weight: 800;
  color: var(--ink);
  letter-spacing: .005em; line-height: 1.2;
}
.card-row-must .cr-dual-name {
  color: color-mix(in srgb, var(--ec, var(--c-none)) 45%, var(--ink));
  text-shadow: 0 0 20px color-mix(in srgb, var(--ec, var(--c-none)) 35%, transparent);
}

/* strategy name CAPTION — sits inline beside the dual name (same baseline) */
.cr-strat {
  font-size: .72rem; font-weight: 600;
  color: var(--ink-4);
  letter-spacing: .01em;
  line-height: 1;
  white-space: nowrap;
}
.card-row-must .cr-strat {
  color: color-mix(in srgb, var(--ec, var(--c-none)) 55%, var(--ink-4));
}

/* line 3 — description, shown in full */
.cr-desc {
  display: block;
  margin-top: 2px;
  font-size: .74rem; line-height: 1.45;
  color: var(--ink-4);
  transition: color .15s;
}
.card-row:hover .cr-desc { color: var(--ink-3); }

/* confidence badge */
.badge {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 17px; padding: 0 5px;
  font-size: .62rem; font-weight: 900;
  letter-spacing: .04em; border-radius: 5px;
  transform: translateY(-1px);
}
.badge-H { background: rgba(126,232,92,.14); color: var(--c-toxin); border: 1px solid rgba(126,232,92,.35); }
.badge-G { background: rgba(244,194,74,.14); color: var(--gold);    border: 1px solid rgba(244,194,74,.35); }
.badge-Q { background: rgba(176,122,255,.14);color: var(--c-shade); border: 1px solid rgba(176,122,255,.35); }

/* ============================================================
   SELECTED TAGS
   ============================================================ */
.seltag {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 8px 0 10px;
  border: 1px solid color-mix(in srgb, var(--ec, var(--c-none)) 50%, var(--line));
  background: color-mix(in srgb, var(--ec, var(--c-none)) 10%, var(--panel-2));
  color: var(--ec, var(--c-none));
  border-radius: var(--r-pill);
  font-size: .8rem; font-weight: 700;
  animation: tagIn .22s var(--ease-2);
  transition: transform .1s;
}
.seltag:active { transform: scale(.94); }
.tag-name { pointer-events: none; color: var(--ec, var(--c-none)); }
.tag-x {
  font-size: .64rem; color: var(--ink-4);
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--overlay-soft);
  pointer-events: none;
}
.seltag:hover .tag-x { color: var(--ink); background: var(--overlay-soft-2); }
@keyframes tagIn { from { opacity: 0; transform: scale(.86); } }

.clear-btn-sm {
  flex: none; height: 30px; padding: 0 10px;
  border: 1px solid transparent; background: transparent; color: var(--ink-4);
  border-radius: var(--r-pill); font-size: .75rem; font-weight: 700;
  transition: color .15s, background .15s;
}
.clear-btn-sm:hover { color: var(--c-blade); background: rgba(255,85,131,.08); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  grid-column: 1 / -1;
  text-align: center; padding: 80px 20px;
  color: var(--ink-3);
}
.empty-ico { color: var(--ink-4); margin-bottom: 18px; }
.empty-title { margin: 0; font-size: 1.02rem; font-weight: 800; color: var(--ink-2); }
.empty-sub { margin: 8px auto 0; font-size: .85rem; max-width: 36ch; line-height: 1.55; }

/* ============================================================
   ERROR
   ============================================================ */
.error-screen {
  display: grid; place-items: center;
  min-height: 100vh; min-height: 100dvh; padding: 20px;
}
.error-box {
  max-width: 440px; text-align: center;
  padding: 36px 28px;
  border: 1px solid var(--c-blade); border-radius: var(--r);
  background: var(--panel);
}
.error-icon {
  width: 48px; height: 48px; margin: 0 auto 14px;
  display: grid; place-items: center;
  border-radius: 50%; background: rgba(255,85,131,.12);
  color: var(--c-blade); font-size: 1.5rem; font-weight: 900;
}
.error-box p { color: var(--ink-2); font-size: .9rem; line-height: 1.65; margin: 0; }
.error-box code {
  font-family: var(--mono); font-size: .8rem;
  background: var(--panel-3); color: var(--gold);
  padding: 1px 6px; border-radius: 5px;
}

/* ============================================================
   MOBILE PICKER SHEET
   ============================================================ */
.picker { position: fixed; inset: 0; z-index: 90; }
.picker[hidden] { display: none; }
.scrim {
  position: absolute; inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn .22s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 90vh; max-height: 90dvh;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel-2), var(--bg-1));
  border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-sheet);
  animation: sheetUp .3s var(--ease-2);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes sheetUp { from { transform: translateY(100%); } }
.sheet:focus { outline: none; }
.sheet-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 16px 18px 10px;
}
.sheet-head-text { margin-right: auto; min-width: 0; }
.sheet-title-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sheet-h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.sheet-sub { margin: 2px 0 0; font-size: .74rem; color: var(--ink-4); }

/* live build count next to the sheet title — plain text, no chrome */
.sheet-status {
  font-size: .82rem; font-weight: 700;
  color: var(--ink-4);
  white-space: nowrap;
  transition: color .25s;
}
.sheet-status[data-active] { color: var(--gold); }
.icon-btn {
  flex: none; width: 38px; height: 38px;
  display: grid; place-items: center;
  border: none; background: none; color: var(--ink-3);
  transition: color .15s;
  margin: -6px -8px 0 0; /* nudge toward the top-right corner */
}
.icon-btn:hover { color: var(--ink); }
.sheet-selbar { padding: 0 18px 10px; }
.sheet-cap { margin: 0 18px 6px; }
.sheet-chips {
  flex: 1 1 auto; overflow-y: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px 18px;
}
/* ============================================================
   RESPONSIVE — column thresholds
   Layout: sidebar = 268px, results fill rest.
   At 1340px total width, results area ≈ 1072px → 3 cols (~343px each) ✓
   At 768–1339px total width → 2 cols
   Below 640px → mobile (no sidebar)
   ============================================================ */

/* tablet: narrow sidebar, 2-col results (default) */
@media (max-width: 900px) {
  :root { --sidebar-w: 220px; }
}

/* mobile: hide sidebar, show mobile trigger */
@media (max-width: 639px) {
  .sidebar { display: none; }
  .open-picker-mobile { display: inline-flex; }
  .layout { display: block; }
  .results-area {
    grid-template-columns: 1fr;
    padding: 14px calc(12px + env(safe-area-inset-right, 0px))
             calc(80px + env(safe-area-inset-bottom, 0px))
             calc(12px + env(safe-area-inset-left, 0px));
    gap: 12px;
  }
}

/* wide desktop → 3 columns, with tighter row padding to reclaim description space */
@media (min-width: 1340px) {
  .results-area { grid-template-columns: repeat(3, 1fr); }

  .card-row {
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .cr-content { gap: 1px; padding: 1px 0; }
  .cr-desc { margin-top: 1px; }
}

/* ============================================================
   REDUCED MOTION — Web Animations also checks at call time
   prefersReducedMotion() in JS; belt-and-suspenders here:
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
