/* ==========================================================================
   PRISM — a SearXNG theme
   One query. Many sources.
   --------------------------------------------------------------------------
   Visual system: "precision index". Dark ink + neutral greys, with spectral
   colour reserved exclusively for source identification (1px rules / dots).
   ========================================================================== */

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #0b0e14;
  --surface: #121721;
  --surface-2: #171d2a;
  --surface-3: #1d2432;
  --line: #242c3b;
  --line-strong: #333e52;
  --glass: rgba(11, 14, 20, .82);

  /* type */
  --text: #e8edf6;
  --text-2: #a3aec1;
  --text-3: #6e7a8e;
  --link: #e8edf6;
  --accent: #8aa0ff;
  --accent-soft: rgba(138, 160, 255, .13);
  --accent-ring: rgba(138, 160, 255, .4);
  --ok: #7ddc9a;
  --warn: #f5c26b;
  --err: #ff8a8a;

  /* spectrum — source identity only */
  --s1: #4dd8e8;
  --s2: #7c8cff;
  --s3: #a78bfa;
  --s4: #f0a6c8;
  --s5: #f5c26b;
  --s6: #7ddc9a;

  /* type scale */
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
             "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas,
               "Liberation Mono", "Courier New", monospace;
  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-lg: 18px;
  --fs-xl: 30px;
  --lh-tight: 1.35;
  --lh-body: 1.65;

  /* 4px spacing grid */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px; --sp-16: 64px;

  /* radii */
  --r-sm: 8px; --r-md: 12px; --r-lg: 14px; --r-xl: 20px; --r-pill: 999px;

  /* motion */
  --t-fast: 120ms;
  --t-mid: 180ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* layout */
  --rail-w: 248px;
  --content-max: 880px;
  --bar-h: 116px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .28);
  --shadow-2: 0 14px 40px rgba(0, 0, 0, .38);
  /* raised surface: contact + mid + ambient, plus a lit top edge */
  --shadow-raised:
    0 1px 2px rgba(0, 0, 0, .38),
    0 6px 16px rgba(0, 0, 0, .26),
    0 22px 48px rgba(0, 0, 0, .30),
    inset 0 1px 0 rgba(255, 255, 255, .055);
}

html.theme-light {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --surface-3: #e8ecf2;
  --line: #e1e5ec;
  --line-strong: #cbd2dd;
  --glass: rgba(246, 247, 249, .86);
  --text: #141a24;
  --text-2: #4e5868;
  --text-3: #7a8494;
  --link: #141a24;
  --accent: #4a5bd0;
  --accent-soft: rgba(74, 91, 208, .09);
  --accent-ring: rgba(74, 91, 208, .32);
  --s1: #0f9aa8; --s2: #4a5bd0; --s3: #7c52c9;
  --s4: #c05c92; --s5: #b8801f; --s6: #2f9160;
  --ok: #2f9160; --warn: #b8801f; --err: #c94b4b;
  --shadow-1: 0 1px 2px rgba(20, 26, 36, .07);
  --shadow-2: 0 14px 40px rgba(20, 26, 36, .12);
  --shadow-raised:
    0 1px 2px rgba(20, 26, 36, .05),
    0 8px 20px rgba(20, 26, 36, .07),
    0 24px 52px rgba(20, 26, 36, .10),
    inset 0 1px 0 rgba(255, 255, 255, .9);
}

html.theme-black {
  --bg: #000000;
  --surface: #05070b;
  --surface-2: #0a0d13;
  --surface-3: #10141c;
  --line: #191e28;
  --glass: rgba(0, 0, 0, .9);
}

@media (prefers-color-scheme: light) {
  html.theme-auto {
    color-scheme: light;
    --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f6; --surface-3: #e8ecf2;
    --line: #e1e5ec; --line-strong: #cbd2dd; --glass: rgba(246, 247, 249, .86);
    --text: #141a24; --text-2: #4e5868; --text-3: #7a8494; --link: #141a24;
    --accent: #4a5bd0; --accent-soft: rgba(74, 91, 208, .09); --accent-ring: rgba(74, 91, 208, .32);
    --s1: #0f9aa8; --s2: #4a5bd0; --s3: #7c52c9; --s4: #c05c92; --s5: #b8801f; --s6: #2f9160;
    --ok: #2f9160; --warn: #b8801f; --err: #c94b4b;
    --shadow-1: 0 1px 2px rgba(20, 26, 36, .07);
    --shadow-2: 0 14px 40px rgba(20, 26, 36, .12);
    --shadow-raised:
      0 1px 2px rgba(20, 26, 36, .05),
      0 8px 20px rgba(20, 26, 36, .07),
      0 24px 52px rgba(20, 26, 36, .10),
      inset 0 1px 0 rgba(255, 255, 255, .9);
  }
}

/* --------------------------------------------------------------------------
   Reset / base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-base)/var(--lh-body) var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
p { margin: 0; }
ul { margin: 0; padding: 0; }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font: 500 var(--fs-xs)/1.5 var(--font-mono);
  text-align: center;
  color: var(--text-2);
}
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.pi-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -.25em; }
.pi-icon--sm { width: 15px; height: 15px; stroke-width: 1.8; }
.pi-icon--lg { width: 22px; height: 22px; stroke-width: 1.5; }
.pi-mark-svg { width: 100%; height: 100%; color: var(--text); display: block; }

/* JS/no-JS visibility (contract kept from the stock theme) */
html.no-js .hide_if_nojs { display: none !important; }
html.js .show_if_nojs { display: none !important; }
.invisible { display: none !important; }
.hidden { display: none !important; }
.break { clear: both; }

/* --------------------------------------------------------------------------
   Shell: spectrum rule, top nav, footer
   -------------------------------------------------------------------------- */
.pi-spectrum {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 90;
  background: linear-gradient(90deg, var(--s1), var(--s2) 20%, var(--s3) 40%, var(--s4) 60%, var(--s5) 80%, var(--s6));
  opacity: .9;
}
.pi-topnav {
  display: flex; align-items: center; gap: var(--sp-1);
  max-width: 1440px; margin: 0 auto;
  padding: var(--sp-4) var(--sp-6) 0;
}
.pi-topnav__flex { flex: 1; }
.pi-topnav a, .pi-topnav__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--text-3);
  font-size: var(--fs-sm); transition: color var(--t-fast), background var(--t-fast);
}
.pi-topnav a:hover, .pi-topnav__btn:hover { color: var(--text); background: var(--surface-2); }
.pi-topnav a .pi-icon { width: 15px; height: 15px; }
.pi-topnav__btn { font: 600 var(--fs-sm)/1 var(--font-mono); min-width: 30px; justify-content: center; }

.pi-footer {
  display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4);
  max-width: 1440px; margin: var(--sp-16) auto 0;
  padding: var(--sp-5) var(--sp-6);
  border-top: 1px solid var(--line);
  color: var(--text-3); font-size: var(--fs-xs);
}
.pi-footer a { color: var(--text-2); }
.pi-footer__badge { font: 600 10px/1 var(--font-mono); letter-spacing: .24em; color: var(--text-3); }

.pi-brand { display: inline-flex; align-items: center; gap: 10px; flex: none; }
.pi-brand:hover { color: var(--text); }
.pi-brand__mark { width: 30px; height: 30px; flex: none; }
.pi-brand__name { font: 600 var(--fs-base)/1 var(--font-ui); letter-spacing: -.02em; white-space: nowrap; }
.pi-brand--page { margin: var(--sp-6) auto 0; width: min(100% - 48px, 1000px); }

/* --------------------------------------------------------------------------
   Home page — "Spectrum Console"
   Search first on every viewport: the query console owns the full-width top
   row. Brand copy and the refraction diagram sit below it as supporting
   context. Spectral colour is the only chromatic accent.
   -------------------------------------------------------------------------- */
.pi-home { position: relative; min-height: calc(100vh - 170px); padding: var(--sp-8) var(--sp-6) var(--sp-6); }
.pi-home::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .32;
  -webkit-mask-image: radial-gradient(ellipse 74% 64% at 44% 40%, #000 8%, transparent 100%);
  mask-image: radial-gradient(ellipse 74% 64% at 44% 40%, #000 8%, transparent 100%);
}
.pi-home::after {
  content: ""; position: absolute; left: 6%; top: -22%;
  /* 94% + left 6% keeps the glow inside the viewport on narrow screens */
  width: min(620px, 94%); height: 620px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 68%);
}
.pi-home__inner { position: relative; z-index: 1; width: min(100%, 1180px); margin: 0 auto; }
.pi-home__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "console console"
    "intro   optics";
  align-items: center;
  gap: var(--sp-8) clamp(32px, 6vw, 88px);
  padding: var(--sp-8) 0 var(--sp-12);
}

/* --- supporting copy ----------------------------------------------------- */
.pi-hero { grid-area: intro; min-width: 0; }
.pi-hero__optics { grid-area: optics; min-width: 0; }
.pi-hero__eyebrow {
  display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-6);
  color: var(--text-3); font: 500 var(--fs-xs)/1.4 var(--font-mono);
  letter-spacing: .18em; text-transform: uppercase;
}
.pi-hero__dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--s1); box-shadow: 0 0 0 4px var(--accent-soft); }
.pi-hero__slash { color: var(--line-strong); }
.pi-hero__rev {
  margin-left: auto; padding: 2px 9px; border: 1px solid var(--line);
  border-radius: var(--r-pill); letter-spacing: .12em;
}
.pi-hero__title { font-size: clamp(36px, 4.4vw, 58px); line-height: 1.04; letter-spacing: -.05em; font-weight: 600; }
.pi-hero__title em {
  display: block; font-style: normal;
  background: linear-gradient(97deg, var(--s1), var(--s2) 20%, var(--s3) 40%, var(--s4) 60%, var(--s5) 80%, var(--s6));
  -webkit-background-clip: text; background-clip: text;
  color: transparent; -webkit-text-fill-color: transparent;
}
.pi-hero__lede { max-width: 46ch; margin-top: var(--sp-6); color: var(--text-2); line-height: 1.7; }
.pi-hero__figure { max-width: 460px; margin: 0 0 0 auto; }

.pi-beam { display: block; width: 100%; height: auto; overflow: visible; }
.pi-beam__grid line { stroke: var(--line); stroke-width: 1; opacity: .65; }
.pi-beam__axis { stroke: var(--line-strong) !important; stroke-dasharray: 3 6; opacity: .9 !important; }
.pi-beam__prism { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.4; stroke-linejoin: round; }
.pi-beam__prism-edge { fill: none; stroke: var(--line-strong); stroke-width: 1; opacity: .45; }
.pi-beam__in-glow { stroke: var(--text-2); stroke-width: 9; opacity: .08; stroke-linecap: round; }
.pi-beam__in { stroke: var(--text-2); stroke-width: 1.6; stroke-linecap: round; }
.pi-beam__node { fill: var(--bg); stroke: var(--text-2); stroke-width: 1.4; }
.pi-beam__ray, .pi-beam__glow, .pi-beam__cap { fill: none; stroke-linecap: round; }
.pi-beam__ray { stroke-width: 1.7; stroke-dasharray: 420; stroke-dashoffset: 420; animation: pi-beam-draw 900ms var(--ease) forwards; }
.pi-beam__glow { stroke-width: 9; opacity: .12; }
.pi-beam__cap { stroke-width: 1; opacity: .55; }
.pi-beam__ray--1 { stroke: var(--s1); animation-delay: 60ms; }
.pi-beam__ray--2 { stroke: var(--s2); animation-delay: 120ms; }
.pi-beam__ray--3 { stroke: var(--s3); animation-delay: 180ms; }
.pi-beam__ray--4 { stroke: var(--s4); animation-delay: 240ms; }
.pi-beam__ray--5 { stroke: var(--s5); animation-delay: 300ms; }
.pi-beam__ray--6 { stroke: var(--s6); animation-delay: 360ms; }
@keyframes pi-beam-draw { to { stroke-dashoffset: 0; } }

/* Continuous dispersion: the six rays stay fully drawn, only a short light
   packet travels along each one. Long cycles + small amplitude keep the
   query console the dominant element; no layout-affecting properties move. */
.pi-beam__flow, .pi-beam__spark { fill: none; stroke-linecap: round; }
.pi-beam__flow {
  stroke: var(--text-2); stroke-width: 2.6; opacity: .7;
  stroke-dasharray: 30 190;
  animation: pi-beam-travel-in 4.2s linear infinite;
}
.pi-beam__spark {
  stroke-width: 3.2; opacity: .95;
  stroke-dasharray: 22 404;
  animation: pi-beam-travel 6.4s linear infinite;
}
/* negative delays spread the packets across the rays from the first frame */
.pi-beam__spark--1 { stroke: var(--s1); animation-delay: 0s; }
.pi-beam__spark--2 { stroke: var(--s2); animation-delay: -1.05s; }
.pi-beam__spark--3 { stroke: var(--s3); animation-delay: -2.1s; }
.pi-beam__spark--4 { stroke: var(--s4); animation-delay: -3.15s; }
.pi-beam__spark--5 { stroke: var(--s5); animation-delay: -4.2s; }
.pi-beam__spark--6 { stroke: var(--s6); animation-delay: -5.25s; }
.pi-beam__node { animation: pi-beam-node 2.8s ease-in-out infinite; }
.pi-beam__cap { animation: pi-beam-cap 6.4s ease-in-out infinite; }
@keyframes pi-beam-travel { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -426; } }
@keyframes pi-beam-travel-in { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -220; } }
@keyframes pi-beam-node { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
@keyframes pi-beam-cap { 0%, 100% { opacity: .45; } 45% { opacity: 1; } }

.pi-hero__legend { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-3) var(--sp-5); margin-top: var(--sp-4); }
.pi-hero__legend-label { color: var(--text-3); font: 500 var(--fs-xs)/1.4 var(--font-mono); letter-spacing: .14em; }
.pi-hero__legend-label i { margin: 0 6px; color: var(--line-strong); font-style: normal; }
.pi-hero__bands { display: inline-flex; gap: 4px; }
.pi-hero__bands i {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 24px; padding: 0 5px;
  border: 1px solid var(--line); border-top: 2px solid var(--b);
  border-radius: 5px; background: var(--surface);
  color: var(--text-3); font: 500 9px/1 var(--font-mono); font-style: normal;
}
.pi-hero__band--1 { --b: var(--s1); } .pi-hero__band--2 { --b: var(--s2); }
.pi-hero__band--3 { --b: var(--s3); } .pi-hero__band--4 { --b: var(--s4); }
.pi-hero__band--5 { --b: var(--s5); } .pi-hero__band--6 { --b: var(--s6); }

/* --- query console ------------------------------------------------------- */
/* the card is lifted off the page by elevation alone; the spectrum rule
   belongs to the page chrome, not to a second decorative stripe here */
.pi-console {
  grid-area: console; justify-self: center;
  position: relative; min-width: 0; width: min(100%, 880px);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-raised);
}
/* one continuous input surface: no title bar, no divider, no fake counter */
.pi-console__body { padding: var(--sp-8) var(--sp-5) var(--sp-3); }
.pi-console__samples { display: none; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-5); }
html.js .pi-console__samples { display: flex; }
.pi-console__samples-label { margin-right: 4px; color: var(--text-3); font: 500 10px/1 var(--font-mono); letter-spacing: .16em; }
.pi-console__samples button {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs);
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.pi-console__samples button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
/* real shortcut hints stay, but as quiet body copy rather than a status bar */
.pi-console__foot {
  display: flex; flex-wrap: wrap; gap: var(--sp-4);
  padding: 0 var(--sp-5) var(--sp-5);
  color: var(--text-3); font-size: var(--fs-xs);
}
.pi-console__foot span { display: inline-flex; align-items: center; gap: 6px; }

.pi-search__pip { display: inline-block; width: 2px; height: 18px; margin-right: 10px; border-radius: 2px; background: linear-gradient(var(--s1), var(--s6)); vertical-align: middle; }

/* --- home status strip --------------------------------------------------- */
.pi-home__status {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-4);
  padding: var(--sp-4) 0 0; border-top: 1px solid var(--line);
  color: var(--text-3); font-size: var(--fs-xs);
}
.pi-home__status-mark { margin-right: 8px; color: var(--text-2); font: 600 10px/1 var(--font-mono); letter-spacing: .24em; }
.pi-home__status a { color: var(--text-2); }
.pi-home__status-keys { display: flex; align-items: center; gap: 5px; }
.pi-home__status-keys span { margin-left: 8px; }
body.index_endpoint .pi-footer { display: none; }
body.index_endpoint .pi-topnav { padding-top: var(--sp-5); }

/* --------------------------------------------------------------------------
   Search command bar
   -------------------------------------------------------------------------- */
.pi-search { position: relative; }
.pi-search--home { margin-top: 0; }
.pi-search--bar {
  position: sticky; top: 0; z-index: 60;
  padding: var(--sp-3) var(--sp-6) var(--sp-2);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.pi-search__row { display: flex; align-items: center; gap: var(--sp-5); max-width: 1440px; margin: 0 auto; }
.pi-search__field {
  position: relative; display: flex; align-items: center;
  flex: 1; min-width: 0; height: 48px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.pi-search--home .pi-search__field { height: 62px; border-radius: var(--r-md); background: var(--surface-2); border-color: var(--line); }
.pi-search__field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pi-search__glyph { display: flex; align-items: center; padding-left: var(--sp-4); color: var(--text-3); }
.pi-search__field:focus-within .pi-search__glyph { color: var(--accent); }
.pi-search__field > input#q {
  flex: 1; min-width: 0; height: 100%; padding: 0 var(--sp-3);
  border: 0; outline: 0; background: transparent;
  font-size: var(--fs-base); color: var(--text);
}
.pi-search--home .pi-search__field > input#q { font-size: var(--fs-lg); }
.pi-search__field > input#q::placeholder { color: var(--text-3); }
.pi-search__field > button {
  display: grid; place-items: center;
  height: 34px; min-width: 34px; margin-right: var(--sp-2);
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.pi-search__field > button:hover { background: var(--surface-3); color: var(--text); }
.pi-search__field > #send_search { background: var(--accent-soft); color: var(--accent); }
.pi-search__field > #send_search:hover { background: var(--accent); color: #fff; }
.pi-search__field > #clear_search.empty { visibility: hidden; }
.pi-search__field > #clear_search > span { display: grid; place-items: center; }

.pi-search__progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; overflow: hidden; opacity: 0; transition: opacity var(--t-fast); }
.pi-search.is-loading .pi-search__progress { opacity: 1; }
.pi-search__progress::after {
  content: ""; position: absolute; width: 32%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--s1), var(--s3), transparent);
  animation: pi-progress 1.1s var(--ease) infinite;
}
@keyframes pi-progress { from { transform: translateX(-100%); } to { transform: translateX(420%); } }

/* autocomplete: keep .autocomplete / .autocomplete ul contract */
.autocomplete { display: none; position: absolute; z-index: 70; top: calc(100% + 8px); left: 0; right: 0; }
.autocomplete.open { display: block; }
.autocomplete ul {
  list-style: none; margin: 0; padding: var(--sp-2);
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.autocomplete li { padding: 8px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); cursor: pointer; }
.autocomplete li:hover, .autocomplete li.active { background: var(--accent-soft); color: var(--accent); }
.autocomplete li.no-item-found { color: var(--text-3); cursor: default; }

/* categories as tabs */
.pi-tabs { max-width: 1440px; margin: var(--sp-2) auto 0; }
.pi-tabs__scroll { display: flex; align-items: center; gap: var(--sp-1); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pi-tabs__scroll::-webkit-scrollbar { display: none; }
.pi-tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 5px 11px; border: 1px solid transparent; border-radius: var(--r-pill);
  background: transparent; color: var(--text-3);
  font-size: var(--fs-sm); white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.pi-tab:hover { background: var(--surface-2); color: var(--text); }
.pi-tab.is-active, .pi-tab.selected { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-ring); }
.pi-tab > input[type="checkbox"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pi-tab__icon { display: flex; }
.pi-tab__icon .pi-icon { width: 14px; height: 14px; }
.pi-tab__key { font: 500 10px/1 var(--font-mono); opacity: .5; }
.pi-tabs__hint { margin-left: auto; color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }

/* filters */
.pi-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); max-width: 1440px; margin: var(--sp-2) auto 0; }
.pi-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 10px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-xs);
}
.pi-filter:hover { border-color: var(--line-strong); }
.pi-filter__icon { display: flex; }
.pi-filter__icon .pi-icon { width: 14px; height: 14px; }
.pi-filter__label { opacity: .7; }
.pi-filter select {
  max-width: 190px; padding: 3px 22px 3px 2px; border: 0; outline: 0;
  background: transparent; color: var(--text); font-size: var(--fs-xs); cursor: pointer;
  appearance: none;
  background-image: url("../img/select-dark.svg");
  background-repeat: no-repeat; background-position: right 4px center; background-size: 10px;
}
html.theme-light .pi-filter select { background-image: url("../img/select-light.svg"); }
@media (prefers-color-scheme: light) {
  html.theme-auto .pi-filter select { background-image: url("../img/select-light.svg"); }
}
.pi-filter select option { background: var(--surface-2); color: var(--text); }
.pi-filters__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.pi-chip-filter {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 10px; border: 1px solid var(--accent-ring); border-radius: var(--r-pill);
  background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xs);
}
.pi-chip-filter button { border: 0; background: transparent; color: inherit; padding: 0 3px; line-height: 1; }

/* --------------------------------------------------------------------------
   Results layout: rail + main
   -------------------------------------------------------------------------- */
.pi-results {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr);
  gap: var(--sp-8); align-items: start;
  max-width: 1440px; margin: var(--sp-6) auto 0; padding: 0 var(--sp-6);
}
.pi-results > #pagination { grid-column: 2; }
.pi-rail { min-width: 0; }
.pi-rail__sticky { position: sticky; top: calc(var(--bar-h) + var(--sp-4)); display: grid; gap: var(--sp-3); }
.pi-rail__head { display: flex; align-items: baseline; gap: var(--sp-2); padding: 0 var(--sp-2) var(--sp-2); border-bottom: 1px solid var(--line); }
.pi-rail__count { font: 600 var(--fs-xl)/1 var(--font-mono); letter-spacing: -.04em; }
.pi-rail__label { color: var(--text-3); font-size: var(--fs-xs); }
.pi-rail__tools { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--sp-1); }

.pi-tool {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-3); font-size: var(--fs-xs);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.pi-tool:hover, .pi-tool.is-active { color: var(--accent); border-color: var(--accent-ring); background: var(--accent-soft); }
.pi-tool .pi-icon { width: 13px; height: 13px; }
.pi-tool--switch { cursor: pointer; }
.pi-tool--switch input { accent-color: var(--accent); margin: 0; }

/* collapsible panels */
.pi-panel { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.pi-panel__title {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-3); cursor: pointer; list-style: none;
  color: var(--text-2); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
}
.pi-panel__title::-webkit-details-marker { display: none; }
.pi-panel__title::before { content: ""; width: 5px; height: 5px; border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3); transform: rotate(-45deg); transition: transform var(--t-fast); }
.pi-panel[open] > .pi-panel__title::before { transform: rotate(45deg); }
.pi-panel__num { margin-left: auto; font: 500 var(--fs-xs)/1 var(--font-mono); color: var(--text-3); }
.pi-panel__body { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-top: 1px solid var(--line); }

.pi-facets { display: grid; gap: 2px; max-height: 320px; overflow-y: auto; }
.pi-facet {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); font-size: var(--fs-sm); text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.pi-facet:hover { background: var(--surface-2); }
.pi-facet.is-active { background: var(--accent-soft); color: var(--accent); }
.pi-facet__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-facet__n { font: 500 var(--fs-xs)/1 var(--font-mono); color: var(--text-3); }
.pi-engine__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--s2); flex: none; }
.pi-facet:nth-child(6n+2) .pi-engine__dot { background: var(--s1); }
.pi-facet:nth-child(6n+3) .pi-engine__dot { background: var(--s2); }
.pi-facet:nth-child(6n+4) .pi-engine__dot { background: var(--s3); }
.pi-facet:nth-child(6n+5) .pi-engine__dot { background: var(--s4); }
.pi-facet:nth-child(6n+6) .pi-engine__dot { background: var(--s5); }
.pi-facet:nth-child(6n+7) .pi-engine__dot { background: var(--s6); }

/* sidebar content */
.pi-suggestions form, .pi-download form, .pi-corrections form { display: inline-block; margin: 2px 4px 2px 0; }
.pi-suggestions input[type="submit"], .pi-download input[type="submit"], .pi-corrections input[type="submit"],
.pi-infobox .relatedTopics input[type="submit"], #copy_url {
  padding: 4px 9px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-xs);
}
.pi-suggestions input[type="submit"]:hover, .pi-download input[type="submit"]:hover,
.pi-corrections input[type="submit"]:hover, #copy_url:hover { border-color: var(--accent-ring); color: var(--accent); }
.pi-engine-stats { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.pi-engine-stats td { padding: 4px 2px; vertical-align: middle; }
.pi-engine-stats .engine-name a { color: var(--text-2); }
.pi-engine-stats .response-error { color: var(--err); text-align: right; }
.response-time { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.bar-chart-value { font-family: var(--font-mono); color: var(--text-3); }
.bar-chart-graph { width: 52px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bar-chart-bar { height: 100%; width: 50%; background: linear-gradient(90deg, var(--s1), var(--s3)); border-radius: 2px; }
.selectable_url pre { margin: var(--sp-2) 0 0; padding: var(--sp-2); border-radius: var(--r-sm); background: var(--surface-2); overflow-x: auto; font: 400 var(--fs-xs)/1.6 var(--font-mono); color: var(--text-2); }
.pi-infobox { font-size: var(--fs-sm); }
.pi-infobox h2 { font-size: var(--fs-base); margin-bottom: var(--sp-2); }
.pi-infobox img { border-radius: var(--r-sm); }
.pi-infobox .attributes dl { display: flex; gap: 6px; margin: 3px 0; }
.pi-infobox .attributes dt { color: var(--text-3); }
.pi-infobox .urls ul { list-style: none; margin-top: var(--sp-2); }
.pi-infobox .relatedTopics h3 { font-size: var(--fs-sm); margin: var(--sp-2) 0 4px; }
.pi-answers { grid-column: 1 / -1; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pi-section__title { margin-bottom: var(--sp-3); color: var(--text-2); font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; }
.pi-answer { font-size: var(--fs-sm); }
.pi-corrections { margin-bottom: var(--sp-4); }
.pi-corrections__list { display: flex; flex-wrap: wrap; gap: 6px; }

/* --------------------------------------------------------------------------
   Result cards
   -------------------------------------------------------------------------- */
.pi-main { min-width: 0; max-width: var(--content-max); }
.pi-urls { display: grid; gap: var(--sp-3); }
.pi-urls.is-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pi-group { display: contents; }
.pi-card {
  position: relative; min-width: 0;
  padding: var(--sp-5);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  animation: pi-in var(--t-mid) var(--ease) both;
  animation-delay: calc(min(var(--i, 0), 8) * 22ms);
}
@keyframes pi-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.pi-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.pi-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pi-card__meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pi-card__num { font: 500 var(--fs-xs)/1 var(--font-mono); color: var(--text-3); letter-spacing: .04em; }
.pi-card__favicon { width: 14px; height: 14px; border-radius: 3px; }
.pi-card__host { font: 400 var(--fs-xs)/1.4 var(--font-mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-card__spacer { flex: 1; }
.pi-card__thumb { flex: none; }
.pi-card__thumb img { width: 56px; height: 42px; object-fit: cover; border-radius: var(--r-sm); }
.pi-card__title { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.015em; }
.pi-card__title a { display: inline-block; background-image: linear-gradient(var(--accent), var(--accent)); background-size: 0 1px; background-repeat: no-repeat; background-position: 0 100%; transition: background-size var(--t-fast), color var(--t-fast); }
.pi-card__title a:hover { color: var(--accent); background-size: 100% 1px; }
.pi-card__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pi-chip { padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--text-3); font-size: var(--fs-xs); }
.pi-chip--time { font-family: var(--font-mono); }
.pi-chip .highlight, .pi-card__content .highlight { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 2px; }
.pi-card__content {
  margin-top: 10px; color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh-body);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.pi-card__content--empty { color: var(--text-3); font-style: italic; }
.pi-card__foot { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.pi-card__engines { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.pi-engine { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--r-pill); color: var(--text-3); font: 400 var(--fs-xs)/1.5 var(--font-mono); }
.pi-engine:nth-child(6n+1) .pi-engine__dot { background: var(--s1); }
.pi-engine:nth-child(6n+2) .pi-engine__dot { background: var(--s2); }
.pi-engine:nth-child(6n+3) .pi-engine__dot { background: var(--s3); }
.pi-engine:nth-child(6n+4) .pi-engine__dot { background: var(--s4); }
.pi-engine:nth-child(6n+5) .pi-engine__dot { background: var(--s5); }
.pi-engine:nth-child(6n+6) .pi-engine__dot { background: var(--s6); }
.pi-card__cache { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-size: var(--fs-xs); }
.pi-card__cache a { color: var(--text-3); }
.pi-card__cache a:hover { color: var(--accent); }
.pi-extra { margin-top: 10px; color: var(--text-2); font-size: var(--fs-sm); }
.pi-links { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); }
.pi-links a { color: var(--accent); font-size: var(--fs-sm); }
.pi-attrs { display: grid; gap: 4px; margin-top: var(--sp-3); font-size: var(--fs-sm); }
.pi-attrs > div { display: flex; gap: 8px; }
.pi-attrs > div > span:first-child { min-width: 100px; color: var(--text-3); }
.pi-meta-table { width: 100%; margin-top: var(--sp-3); border-collapse: collapse; font-size: var(--fs-xs); }
.pi-meta-table th, .pi-meta-table td { padding: 5px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.pi-meta-table th { color: var(--text-3); font-weight: 500; }
.pi-kv { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.pi-kv caption { text-align: left; padding-bottom: var(--sp-2); color: var(--text-2); }
.pi-kv th, .pi-kv td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.pi-kv .col-key { color: var(--text-3); font-weight: 500; }
.pi-kv tr.odd { background: var(--surface-2); }
.pi-codelines { margin-top: var(--sp-3); padding: var(--sp-3); border-radius: var(--r-sm); background: var(--surface-2); overflow-x: auto; font: 400 var(--fs-xs)/1.7 var(--font-mono); }
.pi-bigvalue { margin-top: var(--sp-2); font: 600 var(--fs-lg)/1 var(--font-mono); color: var(--accent); }
.pi-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: var(--sp-2); color: var(--text-3); font-size: var(--fs-xs); }
.pi-stats .badge { padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface-2); }
.pi-file-thumb img { max-height: 64px; border-radius: var(--r-sm); margin-top: var(--sp-2); }
.pi-media-toggle { margin-top: var(--sp-2); }
.pi-media-toggle a { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-size: var(--fs-sm); }
.embedded-content, .embedded-video, .audio-control { margin-top: var(--sp-3); }
.embedded-content iframe, .embedded-video iframe { width: 100%; min-height: 320px; border: 0; border-radius: var(--r-sm); }
audio { width: 100%; }
.pi-host-fold { border: 1px dashed var(--line-strong); border-radius: var(--r-md); padding: var(--sp-2); }
.pi-host-fold > summary { cursor: pointer; color: var(--text-2); font: 400 var(--fs-xs)/1.6 var(--font-mono); }
.pi-host-fold > .pi-card { margin-top: var(--sp-2); animation: none; }

/* images: grid tiles (never shown as text cards) */
.pi-tile {
  position: relative; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden;
  animation: pi-in var(--t-mid) var(--ease) both;
  animation-delay: calc(min(var(--i, 0), 8) * 22ms);
}
.pi-tile__link { display: block; }
.pi-tile__link .image_thumbnail { display: block; width: 100%; height: 190px; object-fit: cover; background: var(--surface-2); }
.pi-tile__link .image_resolution { position: absolute; top: 10px; left: 10px; padding: 2px 7px; border-radius: var(--r-pill); background: rgba(0,0,0,.6); color: #fff; font: 400 10px/1.6 var(--font-mono); }
.pi-tile__link .title { display: block; padding: 10px 12px 0; color: var(--text); font-size: var(--fs-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pi-tile__link .source { display: block; padding: 0 12px 12px; color: var(--text-3); font: 400 var(--fs-xs)/1.8 var(--font-mono); }
.only_template_images .pi-urls, .pi-urls:has(.pi-tile:first-child) { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.pi-tile .detail { display: none; }
#image-viewer { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.9); }

/* --------------------------------------------------------------------------
   States: loading / empty / error / pagination / back-to-top
   -------------------------------------------------------------------------- */
.pi-skeleton { padding: var(--sp-5); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.pi-skeleton__line { height: 10px; border-radius: 5px; background: var(--surface-3); margin-bottom: 10px; animation: pi-pulse 1.2s var(--ease) infinite alternate; }
.pi-skeleton__line:nth-child(1) { width: 28%; } .pi-skeleton__line:nth-child(2) { width: 72%; height: 16px; }
.pi-skeleton__line:nth-child(3) { width: 92%; } .pi-skeleton__line:nth-child(4) { width: 60%; }
@keyframes pi-pulse { from { opacity: .35; } to { opacity: .85; } }

.pi-empty { padding: var(--sp-16) var(--sp-6); border: 1px dashed var(--line-strong); border-radius: var(--r-xl); text-align: center; background: var(--surface); }
.pi-empty__mark { width: 56px; height: 56px; margin: 0 auto var(--sp-5); opacity: .5; }
.pi-empty__title { font-size: var(--fs-xl); letter-spacing: -.03em; }
.pi-empty__query { margin-top: var(--sp-2); font: 400 var(--fs-sm)/1.6 var(--font-mono); color: var(--accent); word-break: break-all; }
.pi-empty__desc { margin-top: var(--sp-5); color: var(--text-2); font-size: var(--fs-sm); }
.pi-empty__list { list-style: none; margin: var(--sp-3) auto 0; max-width: 460px; text-align: left; color: var(--text-3); font-size: var(--fs-sm); }
.pi-empty__list li { padding: 5px 0 5px 18px; position: relative; }
.pi-empty__list li::before { content: ""; position: absolute; left: 2px; top: 13px; width: 5px; height: 5px; border-radius: 50%; background: var(--s2); }
.pi-empty__list a { color: var(--accent); }

.dialog-error, .pi-alert { position: relative; margin: var(--sp-4) auto; max-width: min(100% - 48px, 1000px); padding: var(--sp-3) var(--sp-5); border: 1px solid var(--err); border-radius: var(--r-md); background: rgba(255, 138, 138, .08); color: var(--err); font-size: var(--fs-sm); }
.pi-alert ul { list-style: none; }
.pi-alert__close { position: absolute; right: 10px; top: 6px; border: 0; background: transparent; color: inherit; font-size: 20px; line-height: 1; }
.loader { height: 28px; margin: var(--sp-4) auto; border-radius: var(--r-pill); background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: pi-shimmer 1.2s linear infinite; }
@keyframes pi-shimmer { to { background-position: -200% 0; } }
.error_loading_next_page { color: var(--err); }

#pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-8); }
#pagination form { margin: 0; }
#pagination button, #pagination input[type="submit"], #pagination .page_number_current {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-sm);
}
#pagination button:hover, #pagination input[type="submit"]:hover { border-color: var(--accent-ring); color: var(--accent); }
#pagination .page_number_current { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); }
.numbered_pagination { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.numbered_pagination input[type="submit"], .numbered_pagination .page_number_current { min-width: 36px; justify-content: center; padding: 7px 8px; font-family: var(--font-mono); }
#backToTop { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 50; }
#backToTop a { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-1); opacity: 0; pointer-events: none; transition: opacity var(--t-fast); }
#backToTop.is-visible a { opacity: 1; pointer-events: auto; }

/* help / toast */
.pi-help { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.pi-help[hidden] { display: none; }
.pi-help__panel { width: min(100% - 40px, 480px); padding: var(--sp-6); border: 1px solid var(--line-strong); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-2); }
.pi-help__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.pi-help__head h2 { font-size: var(--fs-lg); }
.pi-help__head button { border: 0; background: transparent; color: var(--text-3); font-size: 22px; line-height: 1; }
.pi-help__list { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.pi-help__list dt { padding: 7px 0 2px; }
.pi-help__list dd { margin: 0 0 7px; padding-bottom: 7px; border-bottom: 1px solid var(--line); color: var(--text-3); font-size: var(--fs-sm); }
.pi-help__note { margin-top: var(--sp-3); color: var(--text-3); font-size: var(--fs-xs); }
.pi-toast { position: fixed; left: 50%; bottom: var(--sp-8); transform: translateX(-50%); z-index: 120; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); box-shadow: var(--shadow-2); }
.pi-toast[hidden] { display: none; }

/* shared baseline for results + long-tail pages (scoped rules below override) */
table td, table th { border-bottom: 1px solid var(--line); padding: 6px 8px; font-size: var(--fs-xs); }
.center { text-align: center; }

/* --------------------------------------------------------------------------
   Long-tail functional pages (preferences / info / stats) — stock markup,
   restyled with PRISM tokens so the whole instance stays coherent.
   -------------------------------------------------------------------------- */
/* `page_with_header` is a class ON <main>, not on a wrapper element */
main.page_with_header > h1, main.page_with_header .info-page, main.page_with_header .center {
  max-width: 1000px; margin: var(--sp-6) auto; padding: 0 var(--sp-6);
}
main.page_with_header > h1 { font-size: var(--fs-xl); letter-spacing: -.03em; color: var(--text); }
main.page_with_header .pi-brand--page {
  display: flex; width: min(100%, 1000px);
  margin: var(--sp-6) auto 0; padding: 0 var(--sp-6);
  color: var(--text-2); font-size: var(--fs-sm);
}
main.page_with_header form#search_form { max-width: 1000px; margin: 0 auto; padding: 0 var(--sp-6) var(--sp-12); }
/* keep the utility nav on the same 1000px column as the title and the form */
main.page_with_header .pi-topnav { max-width: 1000px; }

/* preference cards — tighter rhythm so a long list of settings stays scannable */
main.page_with_header fieldset { margin: 0 0 var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
main.page_with_header legend { padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: 600; }
main.page_with_header fieldset .value { margin: var(--sp-2) 0 var(--sp-1); }
main.page_with_header fieldset .description { color: var(--text-3); font-size: var(--fs-xs); }
main.page_with_header fieldset select, main.page_with_header fieldset input[type="text"], main.page_with_header fieldset input[type="url"], main.page_with_header fieldset input[type="number"] {
  max-width: 100%; padding: 6px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm);
}
main.page_with_header .checkbox-onoff { appearance: none; position: relative; width: 38px; height: 22px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--line-strong); transition: background var(--t-fast); cursor: pointer; vertical-align: middle; }
main.page_with_header .checkbox-onoff::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform var(--t-fast), background var(--t-fast); }
main.page_with_header .checkbox-onoff:checked { background: var(--accent-soft); border-color: var(--accent); }
main.page_with_header .checkbox-onoff:checked::after { transform: translateX(16px); background: var(--accent); }
main.page_with_header .reversed-checkbox { flex: none; }

/* Tabs: the stock template interleaves input / label / section. Flex `order`
   pulls EVERY label into the top row and EVERY section below it. The `>`
   combinator keeps the 200+ inner labels (category chips, engine rows) free
   of tab styling — applying tab styles to them was the original misalignment. */
main.page_with_header div.tabs { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; margin-bottom: var(--sp-8); }
main.page_with_header div.tabs > input[type="radio"] { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
main.page_with_header div.tabs > label {
  order: 0; display: inline-flex; align-items: center; cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
main.page_with_header div.tabs > label:hover { border-color: var(--line-strong); color: var(--text); }
main.page_with_header div.tabs > input[type="radio"]:checked + label { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
main.page_with_header div.tabs > section { order: 1; display: none; width: 100%; }
main.page_with_header div.tabs > input[type="radio"]:checked + label + section { display: block; }

/* group headings (both the standalone div and the table row variants) */
main.page_with_header div.pref-group { margin: var(--sp-5) 0 var(--sp-2); color: var(--text-2); font: 600 var(--fs-xs)/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; }
main.page_with_header tr.pref-group th { padding: 9px 10px; background: var(--surface-3); color: var(--text-2); font: 600 var(--fs-xs)/1.4 var(--font-mono); letter-spacing: .08em; text-align: left; }

/* engine table + controls */
main.page_with_header #toggle-all-engines-container { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: var(--sp-3) 0; }
main.page_with_header .button, main.page_with_header input[type="submit"] {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm);
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
main.page_with_header .button:hover, main.page_with_header input[type="submit"]:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
main.page_with_header .scrollx { max-width: 100%; margin-bottom: var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-md); }
main.page_with_header table { border-collapse: collapse; }
main.page_with_header table td, main.page_with_header table th { position: relative; border-bottom: 1px solid var(--line); padding: 8px 10px; font-size: var(--fs-xs); text-align: left; vertical-align: middle; }
main.page_with_header table th { color: var(--text-2); font-weight: 600; white-space: nowrap; }
main.page_with_header table.table_engines { width: 100%; min-width: 720px; }
main.page_with_header table.striped tbody tr:nth-child(even) { background: var(--surface-2); }
main.page_with_header th.checkbox-col, main.page_with_header td.checkbox-col { width: 64px; text-align: center; }
main.page_with_header th.name, main.page_with_header td.name { min-width: 150px; }
main.page_with_header th.shortcut, main.page_with_header td.shortcut, main.page_with_header .column-reliability { white-space: nowrap; }
main.page_with_header .bang { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); font: 500 var(--fs-xs)/1.5 var(--font-mono); }
main.page_with_header .right { float: right; margin-left: var(--sp-2); color: var(--text-3); }

/* engine tooltips: stock markup puts 200+ of these inline; hide until hover */
main.page_with_header .engine-tooltip {
  display: none; position: absolute; z-index: 80;
  left: 0; top: calc(100% + 4px); width: 280px;
  padding: var(--sp-3); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface-2); box-shadow: var(--shadow-2);
  color: var(--text-2); font-size: var(--fs-xs); font-weight: 400; white-space: normal;
}
main.page_with_header .engine-tooltip p { margin: 0 0 5px; }
main.page_with_header .engine-tooltip a { color: var(--accent); }
main.page_with_header .engine-description { color: var(--text); }
main.page_with_header th:hover > .engine-tooltip, main.page_with_header td:hover > .engine-tooltip { display: block; }

/* reliability / response-time bars */
main.page_with_header .stacked-bar-chart { position: relative; display: inline-block; vertical-align: middle; width: 100px; height: 8px; margin-left: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
main.page_with_header .stacked-bar-chart > div, main.page_with_header .stacked-bar-chart > span { position: absolute; top: 0; bottom: 0; left: 0; }
main.page_with_header .stacked-bar-chart-median { background: var(--s2); }
main.page_with_header .stacked-bar-chart-rate80 { background: var(--s3); }
main.page_with_header .stacked-bar-chart-rate95 { background: var(--s4); }
main.page_with_header .stacked-bar-chart-rate100 { background: var(--s1); }
main.page_with_header .stacked-bar-chart-value { color: var(--text-2); font: 500 var(--fs-xs)/1 var(--font-mono); }
main.page_with_header .bar0 { width: 0%; } .bar4 { width: 4%; } .bar7 { width: 7%; } .bar11 { width: 11%; }
main.page_with_header .bar14 { width: 14%; } .bar18 { width: 18%; } .bar21 { width: 21%; } .bar25 { width: 25%; }
main.page_with_header .bar29 { width: 29%; } .bar32 { width: 32%; } .bar36 { width: 36%; } .bar39 { width: 39%; }
main.page_with_header .bar46 { width: 46%; } .bar50 { width: 50%; } .bar61 { width: 61%; } .bar64 { width: 64%; }
main.page_with_header .bar79 { width: 79%; } .bar82 { width: 82%; } .bar100 { width: 100%; }

/* small state helpers */
main.page_with_header .danger { color: var(--err); }
main.page_with_header .success { color: var(--ok); }
main.page_with_header .warning { color: var(--warn); }
main.page_with_header .text-left { text-align: left; }
main.page_with_header .text-muted, main.page_with_header .small_font { color: var(--text-3); }
main.page_with_header .small_font { font-size: var(--fs-xs); }
main.page_with_header .lead { color: var(--text-2); font-size: var(--fs-lg); }
main.page_with_header .alert, main.page_with_header .alert-info, main.page_with_header .fade.in { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm); }
main.page_with_header .preferences_back { display: inline-block; margin: var(--sp-4) 0; color: var(--accent); }

main.page_with_header .info-page { color: var(--text-2); font-size: var(--fs-sm); }
main.page_with_header .info-page h1, main.page_with_header .info-page h2, main.page_with_header .info-page h3 { color: var(--text); margin: var(--sp-5) 0 var(--sp-2); }
main.page_with_header .info-page a { color: var(--accent); }
main.page_with_header .info-page ul { list-style: disc; padding-left: var(--sp-6); }
/* info.html puts <ul class="tabs"> at content top level, NOT inside .info-page */
main.page_with_header ul.tabs {
  display: flex; flex-wrap: wrap; gap: 6px; list-style: none;
  max-width: 1000px; margin: var(--sp-5) auto var(--sp-4); padding: 0 var(--sp-6);
}
main.page_with_header ul.tabs li { margin: 0; }
main.page_with_header ul.tabs a {
  display: inline-block; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-sm);
}
main.page_with_header ul.tabs a:hover { border-color: var(--accent); color: var(--accent); }
main.page_with_header > table.engine-stats, main.page_with_header .stats-table { width: 100%; max-width: 1000px; margin: var(--sp-4) auto; }
main.page_with_header .center { text-align: center; }

/* --------------------------------------------------------------------------
   Responsive: 480 / 768 / 1024 / 1440
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  :root { --rail-w: 100%; }
  .pi-results { grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); }
  .pi-results > #pagination { grid-column: 1; }
  .pi-rail__sticky { position: static; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
  .pi-rail__head { grid-column: 1 / -1; }
  .pi-rail__tools { grid-column: 1 / -1; }
  .pi-rail__section { min-width: 0; }
  .pi-urls.is-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pi-search__row { flex-wrap: wrap; }
  .pi-brand { width: 100%; }
  .pi-brand__name { font-size: var(--fs-sm); }
  main.page_with_header .scrollx { overflow-x: auto; }
  /* one column, but the console still owns the first row */
  .pi-home { min-height: auto; }
  .pi-home__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "console" "intro" "optics";
    gap: var(--sp-6); padding: var(--sp-4) 0 var(--sp-10);
  }
  .pi-console { width: min(100%, 620px); }
  .pi-hero__eyebrow { margin-bottom: var(--sp-3); }
  .pi-hero__title { font-size: clamp(32px, 6vw, 48px); }
  .pi-hero__lede { max-width: 62ch; margin-top: var(--sp-4); font-size: var(--fs-sm); }
  .pi-hero__optics { display: flex; flex-direction: column; align-items: center; }
  .pi-hero__figure { max-width: 380px; margin: 0 auto; }
  .pi-hero__legend { justify-content: center; }
  :root { --bar-h: 176px; }
}
@media (max-width: 767px) {
  .pi-search--bar { padding: var(--sp-2) var(--sp-4) var(--sp-1); }
  .pi-filters { gap: 6px; }
  .pi-filter__label { display: none; }
  .pi-filter select { max-width: 130px; }
  .pi-filters__chips { margin-left: 0; width: 100%; }
  .pi-results { padding: 0 var(--sp-4); }
  .pi-urls.is-grid { grid-template-columns: minmax(0, 1fr); }
  .pi-urls:has(.pi-tile:first-child), .only_template_images .pi-urls { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .pi-card { padding: var(--sp-4); }
  .pi-card__title { font-size: var(--fs-base); }
  .pi-home { padding: var(--sp-5) var(--sp-4) var(--sp-6); }
  .pi-home__grid { gap: var(--sp-5); padding: 0 0 var(--sp-8); }
  .pi-hero__eyebrow { margin-bottom: var(--sp-3); letter-spacing: .12em; }
  .pi-hero__title { font-size: clamp(30px, 9vw, 44px); }
  .pi-hero__lede { font-size: var(--fs-sm); }
  .pi-hero__figure { max-width: 280px; margin: 0 auto; }
  .pi-search--home .pi-search__field > input#q { font-size: 16px; }
  .pi-console__body, .pi-console__foot { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .pi-console__body { padding-top: var(--sp-5); padding-bottom: var(--sp-2); }
  .pi-home__status { flex-direction: column; align-items: flex-start; }
  .pi-topnav { padding: var(--sp-3) var(--sp-4) 0; }
  .pi-footer { flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-12); padding: var(--sp-4); }
  #pagination .numbered_pagination { order: 3; width: 100%; }
  :root { --bar-h: 208px; }
}
@media (max-width: 479px) {
  .pi-tabs__hint { display: none; }
  .pi-tab__key { display: none; }
  .pi-search__field { height: 44px; }
  .pi-search--home .pi-search__field { height: 50px; }
  .pi-hero__rev { display: none; }
  .pi-hero__legend-label { letter-spacing: .08em; }
  .pi-console__foot { gap: var(--sp-3); }
  .pi-home__status-keys { flex-wrap: wrap; }
  .pi-brand__mark { width: 24px; height: 24px; }
  .pi-card__thumb { display: none; }
  .pi-tile__link .image_thumbnail { height: 140px; }
  #backToTop { right: var(--sp-4); bottom: var(--sp-4); }
}
@media (min-width: 1441px) {
  :root { --rail-w: 272px; --content-max: 940px; }
  .pi-results { gap: var(--sp-12); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  /* the drawn rays stay complete; remove only the travelling packets */
  .pi-beam__flow, .pi-beam__spark { display: none; }
  .pi-beam__node, .pi-beam__cap { animation: none; }
}
