/* forever.marni.ac: one stylesheet (design section 5.2).
 * Dark first; light is a warm paper theme; the game tooltip card stays dark in both.
 * Token blocks are parsed by the contrast test in tests/pages.rs: keep one declaration per line. */

@layer reset, tokens, base, layout, components, tooltip, utilities;

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/inter-latin.194fdc7f41.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/jetbrains-mono-latin.a549945038.woff2") format("woff2");
}

/* ------------------------------------------------------------------ reset */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-height: 100dvh; }
  img, svg { display: block; max-width: 100%; }
  input, button, select, textarea { font: inherit; color: inherit; }
  table { border-collapse: collapse; }
  ol[class], ul[class] { list-style: none; padding: 0; }
  :where(button) { cursor: pointer; }
}

/* ------------------------------------------------------------------ tokens */
@layer tokens {
  /* theme: dark */
  :root {
    color-scheme: dark;
    --bg: #0c0e13;
    --surface: #13161e;
    --surface-2: #1a1e29;
    --border: #262b39;
    --border-strong: #353b4d;
    --text: #e7e9ef;
    --text-muted: #9aa2b4;
    --accent: #d8b35f;
    --link: #8db7ff;
    --focus: #f0cf7a;
    --danger: #ff7a7a;
    --warning: #f2b45a;
    --success: #6fd38a;
    --q-poor: #9aa2b4;
    --q-common: #e7e9ef;
    --q-uncommon: #3ddc3d;
    --q-rare: #3d9bff;
    --q-epic: #b87bff;
    --q-legendary: #ff9a3d;
    --q-artifact: #e6cc80;
    --q-heirloom: #2ed3ff;
    --school-physical: #e8d27a;
    --school-holy: #ffe680;
    --school-fire: #ff8a3d;
    --school-nature: #5fd35f;
    --school-frost: #7fd9ff;
    --school-shadow: #9c8cff;
    --school-arcane: #ff8cf0;
    --rank-orange: #ff9a52;
    --rank-yellow: #f5e050;
    --rank-green: #5fd35f;
    --rank-grey: #9aa2b4;
    --class-warrior: #c69b6d;
    --class-paladin: #f48cba;
    --class-hunter: #aad372;
    --class-rogue: #fff468;
    --class-priest: #f2f3f7;
    --class-shaman: #3d9bff;
    --class-mage: #3fc7eb;
    --class-warlock: #9a9bf2;
    --class-druid: #ff7c0a;
    --header-bg: #0c0e13d9;
    --shadow: 0 8px 24px #0008;
    --shadow-soft: 0 1px 0 #ffffff08 inset, 0 1px 2px #0006;
    --glow: #d8b35f1f;
  }

  /* theme: light (system preference) */
  @media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
      color-scheme: light;
      --bg: #f6f4ee;
      --surface: #ffffff;
      --surface-2: #efece3;
      --border: #ddd8ca;
      --border-strong: #c9c2ae;
      --text: #1b1c21;
      --text-muted: #5b6070;
      --accent: #7f5e0e;
      --link: #2350b8;
      --focus: #8e6a12;
      --danger: #b42318;
      --warning: #8a5300;
      --success: #1d7a3a;
      --q-poor: #5b6070;
      --q-common: #1b1c21;
      --q-uncommon: #17761a;
      --q-rare: #0a5bb8;
      --q-epic: #7a2fc0;
      --q-legendary: #a64d00;
      --q-artifact: #7d6420;
      --q-heirloom: #00708c;
      --school-physical: #7a6512;
      --school-holy: #786300;
      --school-fire: #b4470a;
      --school-nature: #237a23;
      --school-frost: #0b6d94;
      --school-shadow: #5a45c9;
      --school-arcane: #a3249a;
      --rank-orange: #b04a00;
      --rank-yellow: #766300;
      --rank-green: #237a23;
      --rank-grey: #5b6070;
      --class-warrior: #865a2c;
      --class-paladin: #a8336f;
      --class-hunter: #3f6e12;
      --class-rogue: #6e6000;
      --class-priest: #4b5060;
      --class-shaman: #0a5bb8;
      --class-mage: #08708c;
      --class-warlock: #5347c0;
      --class-druid: #a84700;
      --header-bg: #f6f4eed9;
      --shadow: 0 8px 24px #3a321f24;
      --shadow-soft: 0 1px 2px #3a321f14;
      --glow: #8e6a1214;
    }
  }

  /* theme: light (forced) */
  :root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f4ee;
    --surface: #ffffff;
    --surface-2: #efece3;
    --border: #ddd8ca;
    --border-strong: #c9c2ae;
    --text: #1b1c21;
    --text-muted: #5b6070;
    --accent: #7f5e0e;
    --link: #2350b8;
    --focus: #8e6a12;
    --danger: #b42318;
    --warning: #8a5300;
    --success: #1d7a3a;
    --q-poor: #5b6070;
    --q-common: #1b1c21;
    --q-uncommon: #17761a;
    --q-rare: #0a5bb8;
    --q-epic: #7a2fc0;
    --q-legendary: #a64d00;
    --q-artifact: #7d6420;
    --q-heirloom: #00708c;
    --school-physical: #7a6512;
    --school-holy: #786300;
    --school-fire: #b4470a;
    --school-nature: #237a23;
    --school-frost: #0b6d94;
    --school-shadow: #5a45c9;
    --school-arcane: #a3249a;
    --rank-orange: #b04a00;
    --rank-yellow: #766300;
    --rank-green: #237a23;
    --rank-grey: #5b6070;
    --class-warrior: #865a2c;
    --class-paladin: #a8336f;
    --class-hunter: #3f6e12;
    --class-rogue: #6e6000;
    --class-priest: #4b5060;
    --class-shaman: #0a5bb8;
    --class-mage: #08708c;
    --class-warlock: #5347c0;
    --class-druid: #a84700;
    --header-bg: #f6f4eed9;
    --shadow: 0 8px 24px #3a321f24;
    --shadow-soft: 0 1px 2px #3a321f14;
    --glow: #8e6a1214;
  }

  /* tooltip card: dark in both themes, brightened quality colours */
  :root {
    --tt-bg: #0a1024;
    --tt-bg-2: #070b1a;
    --tt-border: #4a5372;
    --tt-normal: #ffffff;
    --tt-muted: #9d9d9d;
    --tt-spell: #1eff00;
    --tt-description: #ffd100;
    --tt-flavor: #ffd100;
    --tt-set-name: #ffd100;
    --tt-set-item: #9d9d9d;
    --tt-set-bonus: #9d9d9d;
    --tt-requirement: #ffffff;
    --tt-warning: #ff4d4d;
    --tt-link: #8db7ff;
    --tt-q-poor: #9d9d9d;
    --tt-q-common: #ffffff;
    --tt-q-uncommon: #1eff00;
    --tt-q-rare: #3d9bff;
    --tt-q-epic: #b87bff;
    --tt-q-legendary: #ff8000;
    --tt-q-artifact: #e6cc80;
    --tt-q-heirloom: #00ccff;
  }

  :root {
    --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --s7: 48px;
    --radius: 8px;
    --radius-sm: 6px;
    --header-h: 60px;
    --page-w: 1440px;
    --gutter: 24px;
    --ease: cubic-bezier(.2, .7, .2, 1);
  }
}

/* ------------------------------------------------------------------ base */
@layer base {
  html { scroll-padding-top: calc(var(--header-h) + var(--s4)); }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    font-feature-settings: "cv05", "cv08", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  h1, h2, h3, h4 { font-weight: 650; letter-spacing: -0.01em; line-height: 1.2; text-wrap: balance; }
  h1 { font-size: clamp(24px, 2.4vw + 12px, 32px); }
  h2 { font-size: 19px; }
  h3 { font-size: 15.5px; }
  p { text-wrap: pretty; }
  a { color: var(--link); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
  a:hover { text-decoration: underline; }
  code, kbd, samp, .mono { font-family: var(--font-mono); font-size: 0.9em; }
  kbd {
    display: inline-block; min-width: 1.6em; padding: 0 6px; text-align: center;
    border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px;
    background: var(--surface-2); color: var(--text); font-size: 12px; line-height: 1.6;
  }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
  ::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
  hr { border: 0; border-top: 1px solid var(--border); }
  table { font-variant-numeric: tabular-nums; }
  summary { cursor: pointer; }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
}

/* ------------------------------------------------------------------ layout */
@layer layout {
  .skip-link {
    position: absolute; left: var(--s4); top: -100px; z-index: 100;
    padding: var(--s2) var(--s3); border-radius: var(--radius-sm);
    background: var(--accent); color: var(--bg); font-weight: 600;
  }
  .skip-link:focus { top: var(--s2); }

  .wrap { width: 100%; max-width: var(--page-w); margin-inline: auto; padding-inline: var(--gutter); }

  .site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--header-bg);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--border);
  }
  .site-header .wrap {
    display: flex; align-items: center; gap: var(--s4);
    min-height: var(--header-h);
  }
  .wordmark {
    display: inline-flex; align-items: baseline; gap: 3px; flex: none;
    color: var(--text); font-weight: 700; font-size: 18px; letter-spacing: -0.02em;
  }
  .wordmark:hover { text-decoration: none; }
  .wordmark .mark {
    align-self: center; width: 22px; height: 22px; margin-right: 6px; flex: none;
  }
  .wordmark small { color: var(--accent); font-weight: 600; font-size: 12px; letter-spacing: 0; }

  .site-nav { display: flex; gap: 2px; margin-left: auto; }
  .site-nav a {
    padding: 6px 10px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-weight: 500; font-size: 14px; white-space: nowrap;
  }
  .site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
  .site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

  .nav-menu { display: none; margin-left: auto; position: relative; }
  .nav-menu > summary {
    list-style: none; display: grid; place-items: center; width: 38px; height: 38px;
    border-radius: var(--radius-sm); border: 1px solid var(--border); color: var(--text);
  }
  .nav-menu > summary::-webkit-details-marker { display: none; }
  .nav-menu[open] > summary { background: var(--surface-2); }
  .nav-menu .menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: min(280px, calc(100vw - 32px));
    padding: var(--s2); border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow);
    display: grid; gap: 2px;
  }
  .nav-menu .menu-panel a { padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); }
  .nav-menu .menu-panel a:hover { background: var(--surface-2); text-decoration: none; }
  .nav-menu .menu-panel .theme-control { margin: var(--s2) 10px 4px; }

  main { display: block; padding-block: var(--s5) var(--s7); }

  .site-footer {
    border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 13px;
    padding-block: var(--s5) var(--s6);
  }
  .site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; }
  .site-footer a { color: var(--text-muted); text-decoration: underline; text-decoration-color: var(--border-strong); }
  .site-footer a:hover { color: var(--text); }
  .site-footer .disclaimer { margin-left: auto; }

  /* search pages: sidebar + results */
  .search-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--s5); align-items: start; }
  .search-layout > .filters { position: sticky; top: calc(var(--header-h) + var(--s4)); max-height: calc(100dvh - var(--header-h) - var(--s5)); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 4px; }

  /* detail pages */
  .detail-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr) 200px; gap: var(--s5) var(--s6); align-items: start; margin-top: var(--s5); }
  .detail-aside { display: grid; gap: var(--s4); position: sticky; top: calc(var(--header-h) + var(--s4)); }
  .detail-main { display: grid; gap: var(--s6); min-width: 0; }
  .toc { position: sticky; top: calc(var(--header-h) + var(--s4)); font-size: 13px; }

  @media (max-width: 1360px) {
    .detail-grid { grid-template-columns: 360px minmax(0, 1fr); }
    .toc { display: none; }
  }
  @media (max-width: 1099px) {
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
    .detail-aside { position: static; }
  }
  @media (max-width: 1180px) {
    .site-nav a { padding: 6px 7px; font-size: 13.5px; }
  }
  @media (max-width: 1060px) {
    .site-nav { display: none; }
    .nav-menu { display: block; }
  }
  @media (max-width: 959px) {
    .search-layout { grid-template-columns: minmax(0, 1fr); }
    .search-layout > .filters { position: static; max-height: none; overflow: visible; padding-right: 0; }
  }
  @media (max-width: 640px) {
    :root { --gutter: 16px; --header-h: 56px; }
    .site-header .wrap { gap: var(--s2); }
    main { padding-block: var(--s4) var(--s6); }
    .wordmark small { display: none; }
    .site-footer .disclaimer { margin-left: 0; }
  }
}

/* ------------------------------------------------------------------ components */
@layer components {
  /* omnibox */
  .omnibox { position: relative; flex: 1 1 340px; max-width: 520px; min-width: 0; }
  .omnibox input {
    width: 100%; height: 38px; padding: 0 64px 0 36px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
  }
  .omnibox input::placeholder { color: var(--text-muted); }
  /* A transparent outline is painted in forced-colors mode, where box-shadow is dropped. */
  .omnibox input:focus { outline: 2px solid transparent; outline-offset: 2px; border-color: var(--accent); box-shadow: 0 0 0 4px var(--glow); }
  .omnibox .search-icon { position: absolute; left: 12px; top: 0; bottom: 0; display: grid; place-items: center; color: var(--text-muted); pointer-events: none; }
  .omnibox .search-icon svg { width: 16px; height: 16px; }
  .omnibox .kbd-hint { position: absolute; right: 9px; top: 0; height: 38px; display: flex; align-items: center; gap: 3px; pointer-events: none; }
  .omnibox .kbd-hint kbd { font-size: 11px; color: var(--text-muted); }
  .omnibox:focus-within .kbd-hint { display: none; }
  .omnibox .listbox {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
    max-height: min(70vh, 560px); overflow: auto;
    padding: 6px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); box-shadow: var(--shadow);
  }
  .omnibox .listbox[hidden] { display: none; }
  .suggest-group { padding: 8px 10px 4px; color: var(--text-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; display: flex; justify-content: space-between; }
  .suggest-option { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: var(--text); cursor: pointer; }
  .suggest-option:hover, .suggest-option[aria-selected="true"] { background: var(--surface-2); text-decoration: none; }
  .suggest-option[aria-selected="true"] { box-shadow: inset 2px 0 0 var(--accent); }
  .suggest-option .sub { margin-left: auto; color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
  .suggest-empty { padding: 12px; color: var(--text-muted); }
  .suggest-all { display: block; padding: 8px 10px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 13px; }

  /* theme control */
  .theme-control { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); flex: none; }
  .theme-control button {
    display: grid; place-items: center; width: 30px; height: 28px; border: 0; border-radius: 7px;
    background: transparent; color: var(--text-muted);
  }
  .theme-control button:hover { color: var(--text); }
  .theme-control button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-soft); }
  .theme-control svg { width: 15px; height: 15px; }
  .no-js .theme-control, .no-js .js-only { display: none !important; }
  html:not(.no-js) .nojs-only { display: none !important; }

  /* icons, game style */
  .icon {
    display: inline-block; flex: none; vertical-align: middle;
    width: 18px; height: 18px; max-width: none; border-radius: 4px;
    border: 1px solid #000c; background: #0a0d14;
    box-shadow: 0 0 0 1px #ffffff14 inset;
    object-fit: cover;
  }
  .icon.i28 { width: 28px; height: 28px; }
  .icon.i36 { width: 36px; height: 36px; border-radius: 5px; }
  .icon.i56 { width: 56px; height: 56px; border-radius: 7px; border-width: 2px; box-shadow: 0 0 0 1px #ffffff1f inset, 0 4px 14px #0007; }
  .icon.placeholder { background: linear-gradient(135deg, #1b2131, #0d1119); }
  .icon.muted { filter: grayscale(1) brightness(.6); }

  /* entity links */
  .elink { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-weight: 500; }
  .elink > span { overflow: hidden; text-overflow: ellipsis; }
  .elink .sub { color: var(--text-muted); font-weight: 400; font-size: .92em; }
  .elink.stub { color: var(--text-muted); font-style: italic; }
  .q-poor { color: var(--q-poor); }
  .q-common { color: var(--q-common); }
  .q-uncommon { color: var(--q-uncommon); }
  .q-rare { color: var(--q-rare); }
  .q-epic { color: var(--q-epic); }
  .q-legendary { color: var(--q-legendary); }
  .q-artifact { color: var(--q-artifact); }
  .q-heirloom { color: var(--q-heirloom); }

  /* chips and badges */
  .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface-2);
    color: var(--text); font-size: 12.5px; font-weight: 500; line-height: 1.6; white-space: nowrap;
  }
  a.chip:hover { border-color: var(--border-strong); text-decoration: none; }
  .chip .x { color: var(--text-muted); font-size: 14px; line-height: 1; }
  a.chip:hover .x { color: var(--danger); }
  .chip.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: color-mix(in srgb, var(--warning) 10%, var(--surface)); color: var(--text); }
  .chip.warn .label { color: var(--warning); font-weight: 600; }
  .chip.school { padding-left: 7px; }
  .chip.school::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--text-muted)); box-shadow: 0 0 6px var(--c, transparent); }
  .chip.school .label { color: var(--c, var(--text)); }
  .s-physical { --c: var(--school-physical); }
  .s-holy { --c: var(--school-holy); }
  .s-fire { --c: var(--school-fire); }
  .s-nature { --c: var(--school-nature); }
  .s-frost { --c: var(--school-frost); }
  .s-shadow { --c: var(--school-shadow); }
  .s-arcane { --c: var(--school-arcane); }
  .badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .01em;
    border: 1px solid var(--border); color: var(--text-muted); background: var(--surface);
  }
  .badge.buff { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
  .badge.debuff { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
  .badge.passive { color: var(--link); border-color: color-mix(in srgb, var(--link) 40%, var(--border)); }
  .badge.gold { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
  .badge.warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
  .badge.missing { color: var(--text-muted); border-style: dashed; }
  /* A badge that explains itself on hover or focus (the aura classification). */
  .tip-wrap { position: relative; display: inline-flex; }
  button.badge { cursor: help; line-height: inherit; }
  .tip-wrap .tip {
    display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 30;
    width: max-content; max-width: min(20rem, 80vw); padding: 6px 10px; border-radius: 6px;
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
    font-size: 13px; font-weight: 400; line-height: 1.4; white-space: normal;
  }
  .tip-wrap:hover .tip, .tip-wrap:focus-within .tip { display: block; }

  .class-tag { display: inline-flex; align-items: center; gap: 5px; color: var(--cc, var(--text)); font-weight: 500; }
  .class-tag::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--cc, var(--text-muted)); }
  .class-icons { display: inline-flex; gap: 3px; flex-wrap: wrap; }
  .cc-warrior { --cc: var(--class-warrior); }
  .cc-paladin { --cc: var(--class-paladin); }
  .cc-hunter { --cc: var(--class-hunter); }
  .cc-rogue { --cc: var(--class-rogue); }
  .cc-priest { --cc: var(--class-priest); }
  .cc-shaman { --cc: var(--class-shaman); }
  .cc-mage { --cc: var(--class-mage); }
  .cc-warlock { --cc: var(--class-warlock); }
  .cc-druid { --cc: var(--class-druid); }
  h1[class*="cc-"] { color: var(--cc); }

  /* buttons and inputs */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-size: 13px; font-weight: 550; white-space: nowrap;
  }
  .btn:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
  .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
  .btn.small { height: 26px; padding: 0 8px; font-size: 12px; }
  .btn svg { width: 14px; height: 14px; }
  .btn.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
  .btn.ghost:hover { color: var(--text); background: var(--surface-2); }
  .field {
    width: 100%; height: 34px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text);
  }
  .field:focus { outline: 2px solid transparent; outline-offset: 2px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
  select.field { padding-right: 28px; }

  /* cards and sections */
  .card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  .card.pad { padding: var(--s4); }
  .section-label { color: var(--text-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-variant: all-small-caps; font-size: 13px; }
  .lede { color: var(--text-muted); font-size: 16px; max-width: 68ch; }
  .muted { color: var(--text-muted); }
  .prose { max-width: 72ch; display: grid; gap: var(--s3); }
  .prose h2 { margin-top: var(--s4); }
  .prose ul { padding-left: 1.2em; display: grid; gap: 4px; }

  /* home */
  .hero { position: relative; padding: clamp(28px, 6vw, 72px) 0 var(--s6); text-align: center; display: grid; justify-items: center; gap: var(--s4); }
  .hero::before {
    content: ""; position: absolute; inset: -40px 0 auto; height: 360px; z-index: -1; pointer-events: none;
    background: radial-gradient(600px 220px at 50% 0%, var(--glow), transparent 70%);
  }
  .hero h1 { font-size: clamp(30px, 4vw + 10px, 52px); letter-spacing: -0.03em; font-weight: 700; }
  .hero h1 .accent { color: var(--accent); }
  .hero .lede { margin-inline: auto; text-align: center; }
  .hero-search { width: min(640px, 100%); max-width: 640px; position: relative; }
  .hero-search input { height: 52px; font-size: 17px; padding-left: 46px; border-radius: 14px; box-shadow: var(--shadow-soft); }
  .hero-search .search-icon { left: 17px; }
  .hero-search .search-icon svg { width: 19px; height: 19px; }
  .hero-search .kbd-hint { height: 52px; right: 14px; }
  .hero-examples { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; color: var(--text-muted); font-size: 13px; }
  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); margin-block: var(--s5) var(--s6); }
  .stat { display: grid; gap: 2px; padding: var(--s4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); transition: border-color .15s var(--ease), transform .15s var(--ease); }
  .stat:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
  .stat .n { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
  .stat .k { color: var(--text-muted); font-size: 13px; }
  .browse { display: grid; gap: var(--s6); }
  .browse-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
  .browse-head a { font-size: 13px; font-weight: 500; }
  .tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--s2); }
  .tile-grid > li { display: grid; }
  .tile-grid > li > .tile { height: 100%; }
  .tile .tile-text { display: grid; min-width: 0; }
  .tile .tile-text .sub { color: var(--text-muted); font-size: 12px; font-weight: 400; }
  .skill-group { display: grid; gap: var(--s3); scroll-margin-top: calc(var(--header-h) + var(--s4)); }
  .skill-group > h2 { font-size: 17px; }
  .skill-group > h2 .count { color: var(--text-muted); font-size: 13px; font-weight: 500; }
  .tile {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
    color: var(--text); font-weight: 550; transition: border-color .15s var(--ease), background .15s var(--ease);
  }
  .tile:hover { border-color: var(--cc, var(--border-strong)); background: var(--surface-2); text-decoration: none; }
  .tile .meta { margin-left: auto; color: var(--text-muted); font-size: 12px; font-weight: 400; }
  .tile.class-tile { border-left: 3px solid var(--cc, var(--border)); }
  .tile.class-tile .name { color: var(--cc, var(--text)); }
  .pill-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .pill { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13.5px; font-weight: 500; }
  .pill:hover { border-color: var(--border-strong); text-decoration: none; background: var(--surface-2); }

  /* page header */
  .page-head { display: grid; gap: var(--s2); margin-bottom: var(--s4); }
  .page-head .crumbs { color: var(--text-muted); font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; }
  .page-head .crumbs a { color: var(--text-muted); }
  .page-head .crumbs a:hover { color: var(--text); }
  .tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: var(--s4); overflow-x: auto; scrollbar-width: none; }
  .tabs a { padding: 8px 14px; color: var(--text-muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
  .tabs a:hover { color: var(--text); text-decoration: none; }
  .tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

  /* filters sidebar */
  .filters-drawer > summary { display: none; }
  .filters, .filters-drawer, .fgroup, .fgroup .body { min-width: 0; }
  .filters form { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .fgroup .body > * { min-width: 0; }
  .filters .q-row { display: grid; gap: 6px; }
  .filters .q-row .in-all { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; }
  .fgroup { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  .fgroup > summary {
    display: flex; align-items: center; gap: 8px; padding: 9px 12px; list-style: none;
    font-weight: 600; font-size: 13.5px;
  }
  .fgroup > summary::-webkit-details-marker { display: none; }
  .fgroup > summary::before {
    content: ""; width: 6px; height: 6px; margin-right: 2px; flex: none;
    border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted);
    transform: rotate(-45deg); transition: transform .15s var(--ease);
  }
  .fgroup[open] > summary::before { transform: rotate(45deg); }
  .fgroup > summary .active-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--bg); font-size: 11px; display: inline-grid; place-items: center; }
  .fgroup .body > .clear { justify-self: end; margin: -2px 0 4px; font-size: 12px; font-weight: 500; }
  .fgroup .body { padding: 0 12px 12px; display: grid; gap: 2px; }
  .fgroup .help { color: var(--text-muted); font-size: 12px; line-height: 1.45; margin-bottom: 6px; }
  .fgroup.advanced { background: transparent; border-style: dashed; }
  .fgroup.advanced > .body { gap: var(--s3); padding-top: 4px; }
  .fgroup.advanced .fgroup { background: var(--surface); }
  .opt {
    display: flex; align-items: center; gap: 8px; padding: 3px 6px; margin-inline: -6px; border-radius: 5px;
    font-size: 13.5px; cursor: pointer; user-select: none;
  }
  .opt:hover { background: var(--surface-2); }
  .opt input { margin: 0; flex: none; width: 15px; height: 15px; }
  .opt .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .opt .n { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
  .opt:has(input:disabled:not(:checked)) { opacity: .45; cursor: default; }
  .opt:has(input:checked) .lbl { font-weight: 600; }
  .opt.cls .lbl { color: var(--cc, inherit); }
  .opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; }
  .opt .n { flex: none; }
  .more-opts > summary { font-size: 12.5px; color: var(--link); padding: 4px 0; list-style: none; }
  .more-opts > summary::-webkit-details-marker { display: none; }
  .more-opts .opt-filter { margin: 6px 0; height: 30px; font-size: 13px; }
  .more-opts .opts-scroll { max-height: 260px; overflow: auto; scrollbar-width: thin; }
  .range { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; }
  .range .field { height: 30px; font-size: 13px; }
  .range .dash { color: var(--text-muted); }
  .presets { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
  .presets button { padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: 12px; }
  .presets button:hover { color: var(--text); border-color: var(--border-strong); }
  .presets button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
  .tri { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
  .tri .lbl { flex: 1; min-width: 0; }
  .seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; flex: none; }
  .seg label { position: relative; padding: 1px 8px; font-size: 11.5px; color: var(--text-muted); cursor: pointer; }
  .seg label + label { border-left: 1px solid var(--border); }
  .seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
  .seg label:has(input:checked) { background: var(--surface-2); color: var(--text); font-weight: 600; }
  .seg label:has(input[value="have"]:checked), .seg label:has(input[value="1"]:checked) { color: var(--success); }
  .seg label:has(input[value="not"]:checked), .seg label:has(input[value="0"]:checked) { color: var(--danger); }
  .seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }
  .flags-list { max-height: 300px; overflow: auto; scrollbar-width: thin; }
  .flags-list .tri { padding-right: 4px; }
  .flags-list .tri .word { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
  .apply-row { display: flex; gap: var(--s2); }

  /* results */
  .results-wrap { position: relative; min-width: 0; }
  #results { display: grid; gap: var(--s3); transition: opacity .2s var(--ease); }
  #results[aria-busy="true"] { opacity: .55; }
  .progress { position: absolute; left: 0; right: 0; top: -10px; height: 2px; overflow: hidden; border-radius: 2px; opacity: 0; transition: opacity .2s; }
  .results-wrap:has(#results[aria-busy="true"]) .progress { opacity: 1; }
  .progress::after { content: ""; position: absolute; inset: 0; width: 35%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: slide 1s var(--ease) infinite; }
  @keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
  .results-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
  .results-head .count { font-size: 15px; font-weight: 600; }
  .results-head .count .n { font-variant-numeric: tabular-nums; }
  .results-head .tools { margin-left: auto; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
  .results-head .sort-select { display: none; height: 32px; width: auto; font-size: 13px; }
  .notice {
    display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); font-size: 13.5px;
  }
  .notice.info { border-color: color-mix(in srgb, var(--link) 35%, var(--border)); }
  .notice.warn { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
  .notice svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--text-muted); }
  .empty { padding: var(--s6) var(--s4); text-align: center; display: grid; gap: var(--s3); justify-items: center; border: 1px dashed var(--border-strong); border-radius: var(--radius); }
  .empty h2 { font-size: 17px; }
  .empty ul { display: grid; gap: 6px; }

  /* position: relative contains absolutely positioned descendants (.sr-only spans), so they are
   * clipped by the scroller instead of widening the page. The local/scroll background pairs draw
   * edge shadows only while there is more table to scroll to. */
  .table-wrap {
    position: relative;
    border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto;
    background:
      linear-gradient(to right, var(--surface) 30%, transparent) left center / 28px 100% no-repeat local,
      linear-gradient(to left, var(--surface) 30%, transparent) right center / 28px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, #0000004d, transparent) left center / 12px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, #0000004d, transparent) right center / 12px 100% no-repeat scroll,
      var(--surface);
  }
  .table-wrap:focus-visible { outline-offset: -2px; }
  .data-table { width: 100%; font-size: 13.5px; }
  .data-table th, .data-table td { padding: 7px 10px; text-align: left; vertical-align: middle; }
  .data-table th, .data-table td.num, .data-table td.id { white-space: nowrap; }
  .data-table th.wrap, .data-table td.num.wrap { white-space: normal; }
  .data-table .cell-badge { display: block; margin-top: 2px; }
  .results-table .data-table th, .results-table .data-table td { padding-inline: 7px; }
  .data-table thead th {
    position: sticky; top: 0; z-index: 1; background: var(--surface);
    color: var(--text-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    border-bottom: 1px solid var(--border);
  }
  .data-table thead th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
  .data-table thead th a:hover { color: var(--text); text-decoration: none; }
  .data-table thead th[aria-sort] { color: var(--text); }
  .data-table thead th[aria-sort="ascending"] a::after { content: "↑"; color: var(--accent); }
  .data-table thead th[aria-sort="descending"] a::after { content: "↓"; color: var(--accent); }
  .data-table tbody tr { border-top: 1px solid var(--border); }
  .data-table tbody tr:first-child { border-top: 0; }
  .data-table tbody tr:hover, .data-table tbody tr.hl { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
  .data-table tbody tr.hl { box-shadow: inset 2px 0 0 var(--accent); }
  @media (forced-colors: active) {
    .data-table tbody tr.hl, .result-card.hl, .suggest-option[aria-selected="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  }
  .data-table td.num, .data-table th.num { text-align: right; }
  .data-table td.name { white-space: normal; min-width: 180px; }
  .data-table td.wrap { white-space: normal; }
  .data-table td.id { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; text-align: right; }
  .data-table tr.partial td { color: var(--text-muted); }
  .data-table .rank-of { color: var(--text-muted); font-size: 12px; }
  .data-table.compact th, .data-table.compact td { padding: 5px 10px; }
  .row-info { display: none; }
  @media (hover: none) {
    .row-info { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 700; }
  }

  .result-list { display: none; }
  .result-card {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  }
  .result-card + .result-card { margin-top: 6px; }
  .result-card .title { font-weight: 600; min-width: 0; }
  .result-card .meta { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--text-muted); font-size: 12.5px; }
  .result-card.hl { border-color: var(--accent); }

  @media (max-width: 640px) {
    .table-wrap.results-table { display: none; }
    .result-list { display: block; }
    .results-head .sort-select { display: inline-block; }
  }

  .pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; margin-top: var(--s2); }
  .pager a, .pager span { min-width: 34px; height: 34px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13.5px; font-variant-numeric: tabular-nums; }
  .pager a:hover { border-color: var(--border-strong); text-decoration: none; }
  .pager [aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 650; }
  .pager .gap { border: 0; background: none; color: var(--text-muted); }
  .pager .disabled { color: var(--text-muted); border-style: dashed; }

  .api-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; color: var(--text-muted); }
  .api-hint code { color: var(--text); overflow-wrap: anywhere; }

  /* detail pages */
  .detail-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2) var(--s4); align-items: center; }
  .detail-head .titles { display: grid; gap: 6px; min-width: 0; }
  .detail-head h1 { overflow-wrap: anywhere; }
  .detail-head .subtitle { color: var(--text-muted); font-size: 15px; }
  .detail-head .badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  .detail-head .id-tools { display: inline-flex; align-items: center; gap: 4px; }
  .detail-head .stub-title { color: var(--text-muted); }
  .facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 16px; padding: var(--s4); font-size: 13.5px; }
  .facts dt { color: var(--text-muted); }
  .facts dd { min-width: 0; overflow-wrap: anywhere; }
  .facts dd .chips { display: inline-flex; }
  /* minmax(0, 1fr): a wide table inside scrolls in its wrapper instead of widening the page. */
  .dsec { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); min-width: 0; }
  .dsec > h2, .dsec > .sec-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .dsec > .sec-head > h2 { display: flex; align-items: center; gap: 10px; }
  .dsec > h2 .count, .dsec > .sec-head .count { color: var(--text-muted); font-size: 13px; font-weight: 500; }
  .dsec > .sec-head .see-all { margin-left: auto; font-size: 13px; font-weight: 500; }
  .dsec > h2 a.anchor, .dsec > .sec-head a.anchor { margin-left: auto; color: var(--text-muted); font-size: 13px; opacity: 0; }
  .dsec:hover > h2 a.anchor, .dsec > h2 a.anchor:focus,
  .dsec:hover > .sec-head a.anchor, .dsec > .sec-head a.anchor:focus { opacity: 1; }
  @media (hover: none) {
    .dsec > h2 a.anchor, .dsec > .sec-head a.anchor { display: none; }
  }
  .dsec h3 { color: var(--text-muted); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
  .kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 20px; font-size: 13.5px; }
  .kv > div { display: grid; gap: 2px; min-width: 0; align-content: start; }
  .kv > div.wide { grid-column: 1 / -1; }
  .kv dt { color: var(--text-muted); font-size: 12px; }
  .kv dd { overflow-wrap: anywhere; }
  .kv dd code { overflow-wrap: break-word; }
  .link-list { display: grid; gap: 6px; }
  .link-list.cols { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
  .link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
  .link-list li .rel { margin-left: auto; min-width: 0; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
  .link-list.mismatches li .rel { white-space: normal; overflow-wrap: anywhere; }
  .link-list.bonuses li { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 4px 10px; }
  .link-list.bonuses .badge { white-space: nowrap; margin-top: 1px; }
  .link-list.bonuses .bonus { display: grid; gap: 1px; min-width: 0; }
  .link-list.bonuses .bonus .sub { color: var(--text-muted); font-size: 12px; }
  .link-list.bonuses .bonus-text.stub { color: var(--text-muted); font-style: italic; }
  .meter-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--text-muted); }
  .meter-legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
  .meter-legend .key:first-child { margin-left: 0; }
  .meter-legend .key.c { background: var(--success); }
  .meter-legend .key.p { background: var(--warning); }
  .meter-legend .key.m { background: var(--border-strong); }
  .problems { display: grid; gap: var(--s2); }
  .problems > div { scroll-margin-top: calc(var(--header-h) + var(--s4)); }
  .problems dd { color: var(--text-muted); }
  .badge.muted-warn { color: var(--text-muted); border-style: dotted; }
  .badge.muted-warn:hover { color: var(--warning); text-decoration: none; }
  .note { display: flex; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
  .note .kind { font-weight: 650; white-space: nowrap; }
  .note.unverified .kind, .note.derived .kind { color: var(--warning); }
  .note.missing .kind { color: var(--text-muted); }
  .note.forever_only .kind { color: var(--accent); }
  .note.info .kind { color: var(--link); }
  .unverified-mark { color: var(--warning); cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
  .toc ol { display: grid; gap: 2px; border-left: 1px solid var(--border); }
  .toc a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--text-muted); }
  .toc a:hover { color: var(--text); text-decoration: none; border-left-color: var(--border-strong); }
  .toc .section-label { display: block; margin-bottom: 8px; }
  .code-block { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
  details.raw > summary, details.more > summary { color: var(--link); font-size: 13.5px; font-weight: 500; }
  details.raw[open] > summary, details.more[open] > summary { margin-bottom: var(--s3); }
  .raw-table td:first-child { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }
  .raw-table td { font-family: var(--font-mono); font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
  .raw-table caption { text-align: left; padding: 8px 10px; font-weight: 600; font-size: 13px; }
  .flag-list { display: flex; flex-wrap: wrap; gap: 6px; }
  .flag-list .chip { font-weight: 450; }
  .flag-list .chip .w { color: var(--text-muted); font-family: var(--font-mono); font-size: 11px; }
  .effects-table td { vertical-align: top; }
  .effect-name { font-weight: 600; }
  .effect-sub { color: var(--text-muted); font-size: 12.5px; }
  /* spell power and attack power coefficients */
  .section-lede { margin: 0 0 var(--s3); max-width: 70ch; }
  .coef-table td { vertical-align: top; }
  .coef-pct { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
  .coef-table .effect-name, .coef-table .badge { white-space: nowrap; }
  .data-table tbody tr.coef-formulas { border-top: 0; }
  .coef-table .coef-formulas td { padding-top: 0; white-space: normal; }
  .formula-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
  code.formula { display: inline-block; max-width: 100%; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 12px; overflow-wrap: anywhere; white-space: normal; }
  /* threat */
  .threat-table { table-layout: fixed; }
  .threat-table th { white-space: normal; }
  .threat-table td { vertical-align: top; overflow-wrap: break-word; }
  .threat-table th:nth-child(1) { width: 32%; }
  .threat-table th:nth-child(2) { width: 24%; }
  .threat-value { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
  .copy-btn[data-copied]::after { content: "Copied"; margin-left: 4px; color: var(--success); }

  .rank-orange { color: var(--rank-orange); }
  .rank-yellow { color: var(--rank-yellow); }
  .rank-green { color: var(--rank-green); }
  .rank-grey { color: var(--rank-grey); }
  .skill-ranks { display: inline-flex; gap: 6px; font-family: var(--font-mono); font-size: 12px; }

  /* talent grid */
  .talent-trees { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: var(--s4); }
  .talent-tree { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: var(--s3); display: grid; gap: var(--s3); }
  .talent-tree h3 { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
  .talent-grid { display: grid; grid-template-columns: repeat(4, 44px); gap: 12px 14px; justify-content: center; }
  .talent { position: relative; width: 44px; height: 44px; }
  .talent a { display: block; }
  .talent .icon { width: 44px; height: 44px; border-radius: 7px; }
  .talent .pts { position: absolute; right: -6px; bottom: -6px; padding: 0 4px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border-strong); font-size: 10.5px; font-weight: 700; color: var(--rank-green); font-family: var(--font-mono); }
  .talent.req::before { content: ""; position: absolute; left: 50%; top: -12px; width: 2px; height: 12px; background: var(--accent); opacity: .6; }

  /* dialog */
  dialog.shortcuts {
    width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  }
  dialog.shortcuts::backdrop { background: #000a; backdrop-filter: blur(2px); }
  dialog.shortcuts .head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  dialog.shortcuts .body { padding: 12px 16px 16px; display: grid; gap: 10px; }
  dialog.shortcuts dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; align-items: center; font-size: 13.5px; }
  dialog.shortcuts dd { color: var(--text-muted); }
  dialog.shortcuts .toggle { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13.5px; }

  /* api docs */
  .api-op { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); padding: var(--s4); }
  .api-op > * { min-width: 0; }
  .api-op .path { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 14px; }
  .api-op .method { padding: 0 7px; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--success) 50%, var(--border)); color: var(--success); font-weight: 700; font-size: 12px; }
  .api-op .params td:first-child { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); }
  .api-op .params td { white-space: normal; }
  .api-nav { display: grid; gap: 2px; font-size: 13px; }
  .api-nav a { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); padding: 2px 0; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .api-nav a:hover { color: var(--text); }
  .api-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s6); align-items: start; }
  .api-layout > nav { position: sticky; top: calc(var(--header-h) + var(--s4)); max-height: calc(100dvh - var(--header-h) - var(--s5)); overflow: auto; scrollbar-width: thin; }
  @media (max-width: 959px) { .api-layout { grid-template-columns: minmax(0, 1fr); } .api-layout > nav { position: static; max-height: none; } }

  /* coverage */
  .meter { display: block; width: 100%; min-width: 120px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
  .meter .c { fill: var(--success); }
  .meter .p { fill: var(--warning); }
  .meter .m { fill: var(--border-strong); }

  /* error */
  .error-page { display: grid; gap: var(--s4); justify-items: start; padding-block: var(--s6); max-width: 640px; }
  .error-page .code { font-size: 64px; font-weight: 750; letter-spacing: -0.04em; color: var(--accent); line-height: 1; }

  @media (max-width: 959px) {
    .filters-drawer > summary { display: inline-flex; margin-bottom: var(--s3); list-style: none; }
    .filters-drawer > summary::-webkit-details-marker { display: none; }
  }
  @media (max-width: 640px) {
    .site-header .wrap > .theme-control { display: none; }
    .omnibox .kbd-hint { display: none; }
    .omnibox input { padding-right: 10px; }
    /* The header omnibox is narrow on phones; its suggestions use the full width. The sticky
     * header's backdrop-filter makes it the containing block, so top is the header's bottom. */
    .site-header .omnibox .listbox {
      position: fixed; left: var(--gutter); right: var(--gutter); top: calc(var(--header-h) - 2px);
      max-height: calc(100dvh - var(--header-h) - 16px);
    }
    .suggest-option .sub { white-space: normal; text-align: right; }
  }
  @media (pointer: coarse) {
    .presets button { min-height: 32px; padding: 4px 10px; }
    .opt { min-height: 32px; }
  }
}

/* ------------------------------------------------------------------ tooltip card */
@layer tooltip {
  .tt {
    position: relative;
    max-width: 340px; padding: 10px 12px;
    background: linear-gradient(#0a1024f2, #070b1af2);
    border: 1px solid var(--tt-border); border-radius: 6px;
    box-shadow: 0 0 0 1px #ffffff14 inset, var(--shadow);
    color: var(--tt-normal);
    font: 400 13.5px/1.45 var(--font-ui);
    color-scheme: dark;
    overflow-wrap: anywhere;
  }
  .tt-wrap { position: relative; }
  .tt-wrap.with-icon { padding-left: 52px; }
  .tt-wrap.with-icon > .tt-icon { position: absolute; left: 0; top: 0; width: 44px; height: 44px; border-radius: 6px; border: 1px solid #000; box-shadow: 0 0 0 1px #ffffff1f inset; }
  .tt .ln { display: flex; justify-content: space-between; gap: 16px; }
  .tt .ln .r { flex: none; text-align: right; }
  .tt .ln + .ln { margin-top: 1px; }
  .tt .title { font-size: 15px; font-weight: 600; line-height: 1.35; }
  .tt .normal { color: var(--tt-normal); }
  .tt .muted { color: var(--tt-muted); }
  .tt .spell { color: var(--tt-spell); }
  .tt .description { color: var(--tt-description); }
  .tt .flavor { color: var(--tt-flavor); font-style: italic; }
  .tt .set_name { color: var(--tt-set-name); margin-top: 10px; }
  .tt .set_item { color: var(--tt-set-item); padding-left: 10px; }
  .tt .set_bonus { color: var(--tt-set-bonus); }
  .tt .requirement { color: var(--tt-requirement); }
  .tt .warning { color: var(--tt-warning); }
  .tt .separator { height: 8px; }
  .tt .ln.description, .tt .ln.flavor, .tt .ln.spell { margin-top: 6px; }
  .tt .ln:first-child { margin-top: 0; }
  .tt .tq-poor { color: var(--tt-q-poor); }
  .tt .tq-common { color: var(--tt-q-common); }
  .tt .tq-uncommon { color: var(--tt-q-uncommon); }
  .tt .tq-rare { color: var(--tt-q-rare); }
  .tt .tq-epic { color: var(--tt-q-epic); }
  .tt .tq-legendary { color: var(--tt-q-legendary); }
  .tt .tq-artifact { color: var(--tt-q-artifact); }
  .tt .tq-heirloom { color: var(--tt-q-heirloom); }
  .tt a { color: inherit; text-decoration: underline; text-decoration-color: #ffffff40; }
  .tt a:hover { text-decoration-color: currentColor; }
  .tt .val { font-weight: 600; }
  .tt .unk { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
  .tt .money { display: inline-flex; gap: 6px; font-variant-numeric: tabular-nums; }
  .tt .foot { display: flex; justify-content: flex-end; margin-top: 8px; padding-top: 6px; border-top: 1px solid #ffffff14; }
  .tt .foot .lvl { font-size: 11px; color: var(--tt-muted); border: 1px solid #ffffff24; border-radius: 999px; padding: 0 7px; cursor: help; }
  .money { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; font-variant-numeric: tabular-nums; }
  .coin { display: inline-flex; align-items: center; gap: 3px; }
  .coin::after { content: ""; width: 9px; height: 9px; border-radius: 50%; box-shadow: inset 0 -1px 1px #0006; }
  .coin.g::after { background: radial-gradient(circle at 35% 35%, #ffe58a, #c99a1d); }
  .coin.s::after { background: radial-gradient(circle at 35% 35%, #f2f4f7, #8f98a6); }
  .coin.c::after { background: radial-gradient(circle at 35% 35%, #f0a46c, #9b4f1f); }

  .tt-float {
    position: fixed; z-index: 90; left: 0; top: 0; pointer-events: auto;
    opacity: 0; transform: translateY(4px); transition: opacity .12s var(--ease), transform .12s var(--ease);
  }
  .tt-float.on { opacity: 1; transform: none; }
  .tt-float .tt { width: max-content; max-width: min(340px, calc(100vw - 24px)); background: linear-gradient(#0a1024, #070b1a); }
  .tt-stack { display: grid; gap: var(--s3); justify-items: start; }
  .tt-stack .tt { width: 100%; }
  .tt.loading { color: var(--tt-muted); }
}

/* ------------------------------------------------------------------ utilities */
@layer utilities {
  .sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .hidden { display: none !important; }
  .nowrap { white-space: nowrap; }
  .mt-2 { margin-top: var(--s2); }
  .mt-4 { margin-top: var(--s4); }
  .mt-5 { margin-top: var(--s5); }
  .gap-2 { gap: var(--s2); }
  .stack { display: grid; gap: var(--s3); }
  .row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
  .grow { flex: 1; }
  .small { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
