/* ==========================================================================
   filters.css · the discovery panel
   Namespaced under .fpanel-wrap / .f* so nothing here collides with the
   legacy .filters / .filter-grid / .chip rules in style.css.
   Tokens only (--bg, --panel, --border, --text, --muted, --accent, --gold,
   --danger, --r, --gap); both themes fall out of style.css automatically.
   ========================================================================== */

.fpanel-wrap {
  --f-hit: 38px;                      /* minimum comfortable tap target */
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 var(--gap);
}

/* ------------------------------------------------- the "Filters (N)" bar -- */
.fbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.fbar .fpresets { flex: 1 1 auto; min-width: 0; }

.fdlg-open {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}
.fdlg-open-icon { opacity: .7; }

/* ------------------------------------------------------------- presets -- */
.fpresets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fpreset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.fpreset:hover { border-color: var(--muted); text-decoration: none; }
.fpreset-icon { font-size: .95rem; line-height: 1; }

.fpreset.is-on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  color: var(--text);
}
.fpreset.is-on::after {
  content: "×";
  margin-left: 2px;
  opacity: .65;
  font-weight: 700;
}

/* --------------------------------------------------------------- chips -- */
.fchips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.fchip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2, var(--panel));
  color: var(--text);
  font-size: .8rem;
  line-height: 1.3;
  text-decoration: none;
  overflow: hidden;
}
.fchip:hover { border-color: var(--muted); text-decoration: none; }

.fchip-key {
  color: var(--muted);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.fchip-val { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.fchip-x { color: var(--muted); font-weight: 700; }
.fchip:hover .fchip-x { color: var(--danger); }

/* "not cracked" must never be able to read as "cracked". */
.fchip-not {
  color: var(--danger);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.fchip-neg {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 10%, var(--panel));
}
.fchip-neg .fchip-val {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--danger) 70%, transparent);
  text-decoration-thickness: 2px;
  opacity: .85;
}

/* Soft preferences: wanted, not required. */
.fchip-soft {
  border-style: dashed;
  border-color: color-mix(in srgb, var(--gold) 45%, var(--border));
}
.fchip-soft .fchip-not { color: var(--gold); }

.fchip-clear {
  border-style: dashed;
  background: none;
  color: var(--muted);
}
.fchip-clear:hover { color: var(--danger); border-color: var(--danger); }

/* -------------------------------------------------------------- dialog --
   Two panes: a category rail on the left, that category's controls on the
   right. Without JavaScript the <dialog> is simply never opened and the same
   form is served as a page, so none of this is load-bearing.                */
.fdlg {
  width: min(980px, 94vw);
  max-width: 94vw;
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 12px);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.fdlg::backdrop { background: rgba(0, 0, 0, .6); }
html[data-theme="light"] .fdlg::backdrop { background: rgba(16, 32, 48, .35); }

.fdlg-form {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  min-height: 0;
}

.fdlg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev, var(--panel));
}
.fdlg-title { margin: 0; font-size: 1.05rem; }
.fdlg-game { color: var(--muted); font-size: .82rem; font-weight: 400; }

.fdlg-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 5px);
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.fdlg-close:hover { color: var(--text); border-color: var(--muted); }

.fdlg-chips {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.fdlg-chips .fchips { margin: 0; }

.fdlg-body {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
}

/* left rail */
.fdlg-cats {
  flex: 0 0 210px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
  background: var(--bg-elev, var(--panel));
  overflow-y: auto;
}
.fdlg-cat {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--f-hit);
  padding: 8px 10px;
  border-radius: var(--r-sm, 5px);
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
}
.fdlg-cat:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); text-decoration: none; }
.fdlg-cat.is-active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--text); }
.fdlg-cat-label { flex: 1 1 auto; min-width: 0; }
/* Marks a category that also carries the selected game's own filters. */
.fdlg-cat-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan, var(--accent));
}
.fdlg-cat.is-exclude { color: var(--danger); margin-top: auto; }

/* right pane */
.fdlg-panes {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 16px 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.fcat { padding-top: 12px; scroll-margin-top: 12px; }
.fcat + .fcat { border-top: 1px solid var(--border-soft, var(--border)); margin-top: 8px; }
.fcat-title {
  margin: 0 0 4px;
  font-size: .95rem;
}
.fcat-exclude .fcat-title { color: var(--danger); }

/* The selected game's own layer, inside a category. */
.fblock + .fblock { margin-top: 14px; }
.fblock-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  color: var(--cyan, var(--accent));
  font-family: var(--font, inherit);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.fblock-label::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

/* With JS the owner may add .is-tabs to switch panes instead of scrolling. */
.fdlg.is-tabs .fcat { display: none; }
.fdlg.is-tabs .fcat.is-active { display: block; }
.fdlg.is-tabs .fcat + .fcat { border-top: 0; margin-top: 0; }

.fdlg-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev, var(--panel));
}
.fdlg-foot .btn-ghost { margin-right: auto; }
.fdlg-submit { min-width: 180px; }

/* The count on the apply button is live, so it needs to say when it is stale
   and when it is about to hand you an empty page. */
.fdlg-count { font-variant-numeric: tabular-nums; }
[data-fcount-btn] { transition: opacity .12s ease, background-color .12s ease; }
[data-fcount-btn].is-counting { opacity: .72; }
[data-fcount-btn].is-empty-result {
  background: var(--danger);
  border-color: var(--danger);
}
@media (prefers-reduced-motion: reduce) {
  [data-fcount-btn] { transition: none; }
}

/* --------------------------------------------------------------- panel -- */
.fpanel {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
  overflow: hidden;
}

.fpanel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev, var(--panel));
}
.fpanel-title {
  margin: 0;
  font-size: .95rem;
  letter-spacing: .3px;
}
.fpanel-n {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink, var(--bg));
  font-size: .7rem;
  font-weight: 700;
}
.fpanel-reset {
  margin-left: auto;
  color: var(--muted);
  font-size: .8rem;
}

/* -------------------------------------------------------------- groups -- */
.fgroup { border-bottom: 1px solid var(--border-soft, var(--border)); }
.fgroup:last-of-type { border-bottom: 0; }

.fgroup > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--f-hit);
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }

.fgroup-label { font-weight: 700; font-size: .88rem; }
.fgroup-n {
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--accent);
  font-size: .7rem;
  font-weight: 700;
}
.fgroup-mark {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .15s ease;
}
.fgroup[open] > summary .fgroup-mark { transform: rotate(225deg) translate(-2px, -2px); }

.fgroup-body { padding: 4px 14px 16px; }
.fgroup-help {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .78rem;
}

/* -------------------------------------------------------------- fields -- */
.ffields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px var(--gap);
}

.ffield { min-width: 0; }
.ffield-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: .8rem;
  font-weight: 600;
}
.ffield.is-active > .ffield-label { color: var(--accent); }
.ffield select,
.ffield input[type="search"],
.ffield input[type="text"] { width: 100%; }

.ffield-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.35;
}

/* "players said so, the owner did not" */
.fvoted {
  padding: 1px 6px;
  border: 1px solid color-mix(in srgb, var(--gold) 50%, var(--border));
  border-radius: 999px;
  color: var(--gold);
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ---------------------------------------------------- option checkboxes -- */
.fopts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fopt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 5px);
  background: var(--bg-elev, var(--bg));
  font-size: .8rem;
  line-height: 1.2;
  cursor: pointer;
}
.fopt:hover { border-color: var(--muted); }
.fopt input { margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
.fopt-label { min-width: 0; }

.fopt.is-on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elev, var(--bg)));
}
.fopt.is-empty { opacity: .45; }

.fopts-exclude .fopt input { accent-color: var(--danger); }
.fopts-exclude .fopt.is-on {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--bg-elev, var(--bg)));
}

/* ---------------------------------------------------------- option counts -- */
.fcount {
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--muted);
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.fopt.is-on .fcount { color: var(--text); }
.fcount.is-zero { opacity: .5; text-decoration: line-through; }

/* ---------------------------------------------------- grouped checkboxes --
   A per-game vocabulary shown with no game selected is filed under a heading
   per game instead of one alphabetical soup. Long ones scroll in place so a
   single filter cannot own the whole pane.                                   */
.fmulti { min-width: 0; }
.fmulti.is-long {
  max-height: 232px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 5px);
  background: color-mix(in srgb, var(--text) 3%, transparent);
  overscroll-behavior: contain;
}
.fopts-group + .fopts-group { margin-top: 10px; }
.fopts-group-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
/* A filter with a lot of options gets the full row rather than one grid cell. */
.ffield-wide { grid-column: 1 / -1; }

/* ------------------------------------------------------ numeric ranges -- */
.frange {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.frange-n {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.frange-sep, .frange-unit {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .76rem;
  white-space: nowrap;
}
/* The rating filter's unit is a star, so it should look like the review stars
   and not like the word "players" set in grey 12px. */
.frange-stars {
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: 1px;
  text-shadow: 0 0 6px color-mix(in srgb, var(--gold) 35%, transparent);
}

/* ------------------------------------------------- two-handle range slider --
   Two <input type="range"> stacked on one track. The inputs themselves are
   transparent and click-through; only their thumbs take pointer events, so the
   handle you grab is the one you are over. Hidden until app.js wires them -
   they carry no name and drive the number boxes, which are what submits.      */
.frange-slider {
  position: relative;
  height: 26px;
  margin: 10px 2px 0;
}
.frange-slider[hidden] { display: none; }

.frange-track {
  position: absolute;
  top: 11px;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 16%, transparent);
}
.frange-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--lo, 0%);
  right: calc(100% - var(--hi, 100%));
  border-radius: 999px;
  background: var(--accent);
}

.frange-h {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 26px;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.frange-h:focus { outline: none; }
.frange-h::-webkit-slider-runnable-track { height: 26px; background: transparent; border: 0; }
.frange-h::-moz-range-track { height: 26px; background: transparent; border: 0; }

.frange-h::-webkit-slider-thumb {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  cursor: grab;
}
.frange-h::-moz-range-thumb {
  pointer-events: auto;
  width: 18px;
  height: 18px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  cursor: grab;
}
.frange-h:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.frange-h:focus-visible::-moz-range-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Whichever handle app.js says is on top wins the overlap. */
.frange-h-lo { z-index: 2; }
.frange-h-hi { z-index: 3; }
.frange-slider.is-lo-top .frange-h-lo { z-index: 4; }

/* ------------------------------------------------------------- versions -- */
.ffield input.fversion { width: 100%; font-variant-numeric: tabular-nums; }
.ffield .fspan input.fversion-n {
  width: 7.5em;
  padding: 3px 6px;
  text-align: center;
}

/* ------------------------------------------------------- busy-when block --
   Was a paragraph with number boxes wedged into the prose. It read well in the
   source and broke in the browser: 5.5em boxes on a 0.82rem line wrapped at a
   different point at every width, and the <fieldset>'s <legend> hung off the
   rounded top-left corner with a hole punched through the border behind it.
   Two labelled rows on a grid instead · same inputs, same names, holds shape. */
.fhours-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

.fhours {
  margin: 0;
  padding: 9px 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 5px);
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.fhours-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.fhours-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  font-size: .66rem;
  line-height: 1;
}

.fhours-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px 10px;
}
.fhours-word {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.fhours-pair {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}
.fhours-and, .fhours-oclock {
  color: var(--muted);
  font-size: .76rem;
  white-space: nowrap;
}
.ffield .fhours-n {
  width: 4.6em;
  min-width: 0;
  margin: 0;
  padding: 4px 6px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
/* Whose clock the hours are read on. Never decorative · a window read as UTC
   by somebody in Berlin is a two-hour lie, so this line is always present. */
.fhours-tz {
  margin: 9px 0 0;
  padding-top: 7px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35;
}
.fhours-tz strong { color: var(--text); font-weight: 700; }
.fhours-tz.is-yours strong { color: var(--accent); }
.fhours-add, .fhours-drop {
  margin-top: 8px;
  padding: 5px 11px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
}
.fhours-add:hover { color: var(--accent); border-color: var(--accent); }
.fhours-drop { margin: 6px 0 0; border-style: solid; }
.fhours-drop:hover { color: var(--danger); border-color: var(--danger); }

/* --------------------------------------------------------- time spans -- */
.fspan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  font-size: .8rem;
  color: var(--muted);
}
/* Beats the `.ffield input[type="text"] { width: 100% }` rule above, which
   would otherwise stretch each box onto its own line and break the sentence. */
.ffield .fspan input.fsince {
  width: 6em;
  padding: 3px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.fspan-word { white-space: nowrap; }
.fspan-word-2 { color: color-mix(in srgb, var(--muted) 80%, transparent); }

/* --------------------------------------------- plugin-reported columns -- */
.fsparse {
  padding: 1px 6px;
  border: 1px solid color-mix(in srgb, var(--cyan, var(--accent)) 50%, var(--border));
  border-radius: 999px;
  color: var(--cyan, var(--accent));
  font-size: .62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: help;
}
.fsparse-note { font-style: italic; }

/* -------------------------------------------------------- game first -- */
.fgames {
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.fpanel-wrap > .fgames {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
}
.fgames-head {
  margin: 0 0 8px;
  font-size: .84rem;
  font-weight: 700;
}
.fgames-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink, var(--bg));
  font-size: .68rem;
}
.fgames-note {
  margin-left: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 400;
}
.fgames-row { display: flex; flex-wrap: wrap; gap: 5px; }
.fgame {
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.fgame:hover { border-color: var(--muted); color: var(--text); text-decoration: none; }
.fgame.is-on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--text);
}
/* While the panel is being re-fetched for a different game. */
.fdlg.is-busy .fdlg-panes, .fdlg.is-busy .fgames-row { opacity: .5; pointer-events: none; }
.fdlg.is-busy { cursor: progress; }

/* ----------------------------------------------------- durations & text -- */
.fsince { width: 100%; }
.ffield-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .7rem;
}
.fnot { margin-top: 8px; }
.fnot-label {
  display: block;
  margin-bottom: 3px;
  color: var(--danger);
  font-size: .72rem;
  font-weight: 600;
}
.fnot-input {
  width: 100%;
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
}

/* ------------------------------------------------------------- exclude -- */
.fgroup-exclude > summary .fgroup-label { color: var(--danger); }
.fgroup-exclude .ffield { margin-top: 10px; max-width: 320px; }

.fex-head {
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.fex-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px;
  align-items: start;
}
.fex {
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 5px);
  background: var(--bg-elev, var(--bg));
}
.fex[open] { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.fex-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: .8rem;
}
.fex-summary::-webkit-details-marker { display: none; }
.fex-summary:hover { color: var(--danger); }
.fex-label { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.fex[open] > .fex-summary .fgroup-mark { transform: rotate(225deg) translate(-2px, -2px); }
.fex-body { padding: 0 10px 10px; }
.fex-body .fmulti.is-long { max-height: 190px; }

/* -------------------------------------------------- active filter banner --
   The one thing the results page never said: "you are looking at a subset".  */
.factive {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--accent) 7%, var(--panel));
}
.factive-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.factive-n {
  flex: 0 0 auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink, var(--bg));
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
}
.factive-text {
  flex: 1 1 220px;
  min-width: 0;
  margin: 0;
  font-size: .84rem;
  line-height: 1.35;
}
.factive-reset {
  flex: 0 0 auto;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--danger);
  font-size: .76rem;
  font-weight: 700;
  text-decoration: none;
}
.factive-reset:hover { border-color: var(--danger); text-decoration: none; }
.factive-hide {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: var(--r-sm, 5px);
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.factive-hide:hover { color: var(--text); border-color: var(--border); }
.factive[hidden] { display: none; }

/* What is left once the banner is dismissed: a way to bring it back. */
.factive-peek {
  align-self: flex-start;
  padding: 4px 10px;
  border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--border));
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
}

/* -------------------------------------------------------- resume search --
   Offered, never applied. One tap puts the last filter set back; the × forgets
   it. Deliberately quieter than the active-filter banner: that one describes
   what you ARE looking at, this one only offers something you might want.    */
.fresume {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: var(--r);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  overflow: hidden;
}
.fresume-go {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
}
.fresume-go:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); text-decoration: none; }
.fresume-icon { flex: 0 0 auto; color: var(--accent); font-size: 1rem; }
.fresume-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.fresume-label { font-size: .82rem; font-weight: 700; white-space: nowrap; }
.fresume-terms {
  min-width: 0;
  color: var(--muted);
  font-size: .8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fresume-x {
  flex: 0 0 auto;
  width: 34px;
  border: 0;
  border-left: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--border));
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.fresume-x:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* ---------------------------------------------------------- relax hints -- */
.frelax {
  padding: 12px 14px;
  border: 1px dashed color-mix(in srgb, var(--gold) 50%, var(--border));
  border-radius: var(--r);
  background: color-mix(in srgb, var(--gold) 8%, var(--panel));
}
.frelax-head {
  margin: 0 0 8px;
  font-size: .82rem;
  font-weight: 600;
}
.frelax-items { display: flex; flex-wrap: wrap; gap: 6px; }
.frelax-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: .8rem;
  text-decoration: none;
}
.frelax-item:hover { border-color: var(--gold); text-decoration: none; }
.frelax-item strong { color: var(--gold); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- apply -- */
.fapply {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev, var(--panel));
}
.fapply .btn { flex: 0 0 auto; }

/* ---------------------------------------------------------- save search -- */
.fsave {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--panel);
}
.fsave-name { flex: 1 1 220px; min-width: 0; }
.fsave-name span {
  display: block;
  margin-bottom: 4px;
  font-size: .8rem;
  font-weight: 600;
}
.fsave-name input { width: 100%; }
.fsave-notify {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 8px;
  color: var(--muted);
  font-size: .8rem;
}
.fsave-notify input { accent-color: var(--accent); }

/* ---------------------------------------------------------------- mini -- */
.fmini { display: flex; flex-direction: column; gap: 8px; margin-bottom: var(--gap); }

/* ------------------------------------------- sidebar "Browse by type" -----
   Grouped per game when no game is selected, so "Bhop" and "Anime" are not
   loose in a list a Minecraft player is reading.                             */
.tag-groups { display: flex; flex-direction: column; gap: 12px; }
.tag-group-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ------------------------------------------------ saved searches: "Edit" --
   A <details><summary> is a real control and the right markup here · no route,
   no JavaScript, the list stays scannable. It just did not look like anything:
   bare blue-ish text in a row of buttons, so nobody pressed it. Same element,
   dressed as the button it behaves like, with the marker rotating so its state
   is legible before you click.                                                */
.saved-edit > summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm, 5px);
  background: var(--panel-2, var(--panel));
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.saved-edit > summary::-webkit-details-marker { display: none; }
.saved-edit > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-1px, -2px);
  transition: transform .15s ease;
}
.saved-edit[open] > summary::after { transform: rotate(225deg) translate(-2px, -1px); }
.saved-edit > summary:hover { border-color: var(--accent); color: var(--accent); }
.saved-edit > summary:hover::after { border-color: var(--accent); }
.saved-edit > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.saved-edit[open] > summary { border-color: var(--accent); }
.saved-edit[open] { flex: 1 1 100%; }
.saved-edit-form { margin-top: 10px; display: grid; gap: 8px; max-width: 460px; }
.saved-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  .saved-edit > summary::after { transition: none; }
}

/* --------------------------------------------------------------- light -- */
html[data-theme="light"] .fchip { background: var(--panel-2); }
html[data-theme="light"] .fopt { background: var(--panel-2); }
html[data-theme="light"] .fcount { background: color-mix(in srgb, var(--text) 8%, transparent); }
html[data-theme="light"] .fgroup > summary:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
html[data-theme="light"] .frelax { background: color-mix(in srgb, var(--gold) 12%, var(--panel)); }
html[data-theme="light"] .fex { background: var(--panel-2); }
html[data-theme="light"] .factive { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }

/* -------------------------------------------------------------- mobile -- */
@media (max-width: 720px) {
  .fpanel-wrap { --f-hit: 44px; }

  /* The dialog becomes a full-screen sheet and the categories a top row. */
  .fdlg {
    width: 100vw;
    max-width: 100vw;
    max-height: 100dvh;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .fdlg-body { flex-direction: column; }
  .fdlg-cats {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 6px;
    padding: 8px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  .fdlg-cats::-webkit-scrollbar { display: none; }
  .fdlg-cat {
    flex: 0 0 auto;
    scroll-snap-align: start;
    border: 1px solid var(--border);
    white-space: nowrap;
  }
  .fdlg-cat.is-exclude { margin-top: 0; }
  .fdlg-panes { padding: 0 12px 12px; }

  .fdlg-foot {
    position: sticky;
    bottom: 0;
    box-shadow: 0 -6px 16px rgba(0, 0, 0, .35);
  }
  .fdlg-submit { flex: 1 1 auto; min-width: 0; }
  html[data-theme="light"] .fdlg-foot { box-shadow: 0 -6px 16px rgba(16, 32, 48, .1); }

  .fbar { flex-wrap: wrap; }
  .fbar .fdlg-open { flex: 1 1 100%; justify-content: center; }

  .fpresets {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .fpresets::-webkit-scrollbar { display: none; }
  .fpreset { scroll-snap-align: start; padding: 9px 14px; }

  .ffields { grid-template-columns: 1fr; }
  .fex-list { grid-template-columns: 1fr; }
  .fgroup > summary { min-height: 44px; }
  .fopt { min-height: 38px; }
  .frange { flex-wrap: wrap; }
  .frange-n { flex: 1 1 100px; }
  /* Fingers are not mouse pointers: the two handles have to be grabbable
     without hitting the other one. */
  .frange-slider, .frange-h { height: 34px; }
  .frange-track { top: 15px; }
  .frange-h::-webkit-slider-runnable-track, .frange-h::-moz-range-track { height: 34px; }
  .frange-h::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: 5px; }
  .frange-h::-moz-range-thumb { width: 24px; height: 24px; }
  .fhours-grid { grid-template-columns: 1fr; gap: 2px; }
  .fhours-word { margin-top: 6px; }
  .fresume-terms { flex-basis: 100%; }
  .fhours-line { line-height: 2.4; }
  .fgames { padding: 10px 12px 12px; }
  .fgames-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .fgames-row::-webkit-scrollbar { display: none; }

  /* The apply bar follows you down a long panel. */
  .fapply {
    position: sticky;
    bottom: 0;
    z-index: 5;
    box-shadow: 0 -6px 16px rgba(0, 0, 0, .35);
  }
  .fapply .btn { flex: 1 1 auto; text-align: center; }

  html[data-theme="light"] .fapply { box-shadow: 0 -6px 16px rgba(16, 32, 48, .1); }

  .fsave { flex-direction: column; align-items: stretch; }
  .fsave .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .fgroup-mark, .fpreset, .fchip { transition: none; }
}

/* Printing a results page should not print the controls. */
@media print {
  .fpanel, .fpresets, .fsave, .frelax, .fdlg, .fbar { display: none !important; }
}
