/* ==========================================================================
   PalworldBreeding.gg — Design System
   "Field Dossier": survival-research aesthetic. Dark-first, warm-paper light.
   Zero dependencies. Every colour is a token; nothing is hard-coded downstream.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — light palette defined on bare :root (the default),
      then re-declared for system-dark and for the explicit toggle.
   -------------------------------------------------------------------------- */
:root {
  /* Surfaces */
  --bg:            #f4f1ea;
  --bg-deep:       #ece7dc;
  --surface:       #ffffff;
  --surface-2:     #faf8f3;
  --surface-3:     #f0ece2;
  --surface-glass: rgba(255, 255, 255, .78);
  --overlay:       rgba(24, 20, 14, .55);

  /* Lines */
  --line:          #ddd5c6;
  --line-strong:   #c4b9a4;
  --line-faint:    #e9e3d7;

  /* Text */
  --text:          #191d21;
  --text-2:        #4a545e;
  --text-3:        #77828e;
  --text-inv:      #f6f4ef;

  /* Brand */
  --accent:        #c2700a;
  --accent-2:      #e0902a;
  --accent-ink:    #ffffff;
  --accent-soft:   rgba(194, 112, 10, .10);
  --accent-line:   rgba(194, 112, 10, .32);

  --teal:          #0d7d78;
  --teal-soft:     rgba(13, 125, 120, .10);

  /* Semantic */
  --good:          #147a45;
  --warn:          #a86a00;
  --bad:           #b4232c;
  --good-soft:     rgba(20, 122, 69, .10);
  --warn-soft:     rgba(168, 106, 0, .10);
  --bad-soft:      rgba(180, 35, 44, .10);

  /* Elemental identity — the spine of the whole visual language.
     Two ramps: -ink (text/icon on light bg) and -vib (fills, on dark bg). */
  --el-neutral:    #7d7466;  --el-neutral-vib: #cbbfa8;
  --el-fire:       #cf4415;  --el-fire-vib:    #ff7a45;
  --el-water:      #1667b8;  --el-water-vib:   #4aa8f0;
  --el-grass:      #2f7d32;  --el-grass-vib:   #63c065;
  --el-electric:   #a37800;  --el-electric-vib:#f5cf3d;
  --el-ice:        #0f7f92;  --el-ice-vib:     #63d6e8;
  --el-ground:     #8a5a2b;  --el-ground-vib:  #c98f52;
  --el-dark:       #5b3fa8;  --el-dark-vib:    #9b7bf0;
  --el-dragon:     #a52d94;  --el-dragon-vib:  #e065d2;

  /* Rarity */
  --rar-common:    #8b9199;
  --rar-rare:      #2b7fd4;
  --rar-epic:      #8b5cf6;
  --rar-legend:    #e0902a;

  /* Type / rhythm */
  --font-display: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --step--2: clamp(.69rem, .67rem + .1vw, .75rem);
  --step--1: clamp(.81rem, .78rem + .15vw, .875rem);
  --step-0:  clamp(.94rem, .91rem + .18vw, 1rem);
  --step-1:  clamp(1.13rem, 1.06rem + .32vw, 1.25rem);
  --step-2:  clamp(1.35rem, 1.24rem + .55vw, 1.6rem);
  --step-3:  clamp(1.62rem, 1.44rem + .9vw, 2.05rem);
  --step-4:  clamp(1.94rem, 1.65rem + 1.45vw, 2.6rem);
  --step-5:  clamp(2.33rem, 1.86rem + 2.35vw, 3.4rem);

  /* Space */
  --sp-1: .25rem;  --sp-2: .5rem;   --sp-3: .75rem;  --sp-4: 1rem;
  --sp-5: 1.5rem;  --sp-6: 2rem;    --sp-7: 3rem;    --sp-8: 4rem;  --sp-9: 6rem;

  /* Form */
  --r-sm: 4px;  --r-md: 8px;  --r-lg: 14px;  --r-xl: 22px;  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(24, 20, 14, .06), 0 1px 3px rgba(24, 20, 14, .05);
  --shadow-2: 0 2px 4px rgba(24, 20, 14, .05), 0 8px 20px -6px rgba(24, 20, 14, .12);
  --shadow-3: 0 4px 8px rgba(24, 20, 14, .06), 0 24px 48px -12px rgba(24, 20, 14, .20);
  --ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);

  --wrap: 1240px;
  --wrap-wide: 1560px;
  --wrap-read: 74ch;

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

  /* Decorative texture — a faint topographic grid, drawn in CSS only */
  --grid-line: rgba(24, 20, 14, .045);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0b1014;
    --bg-deep:       #070b0e;
    --surface:       #121a20;
    --surface-2:     #16202a;
    --surface-3:     #1d2933;
    --surface-glass: rgba(18, 26, 32, .82);
    --overlay:       rgba(3, 6, 8, .68);

    --line:          #253440;
    --line-strong:   #35485a;
    --line-faint:    #1b2732;

    --text:          #e8eef3;
    --text-2:        #a8b8c6;
    --text-3:        #74889a;
    --text-inv:      #0b1014;

    --accent:        #ffb020;
    --accent-2:      #ffc85a;
    --accent-ink:    #1a1204;
    --accent-soft:   rgba(255, 176, 32, .13);
    --accent-line:   rgba(255, 176, 32, .38);

    --teal:          #2dd4bf;
    --teal-soft:     rgba(45, 212, 191, .13);

    --good:          #46d68a;
    --warn:          #ffc043;
    --bad:           #ff6b6b;
    --good-soft:     rgba(70, 214, 138, .13);
    --warn-soft:     rgba(255, 192, 67, .13);
    --bad-soft:      rgba(255, 107, 107, .13);

    --el-neutral:    #cbbfa8;
    --el-fire:       #ff7a45;
    --el-water:      #4aa8f0;
    --el-grass:      #63c065;
    --el-electric:   #f5cf3d;
    --el-ice:        #63d6e8;
    --el-ground:     #c98f52;
    --el-dark:       #9b7bf0;
    --el-dragon:     #e065d2;

    --rar-common:    #8b9199;
    --rar-rare:      #4aa8f0;
    --rar-epic:      #9b7bf0;
    --rar-legend:    #ffb020;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 8px 24px -6px rgba(0, 0, 0, .55);
    --shadow-3: 0 4px 10px rgba(0, 0, 0, .35), 0 28px 60px -14px rgba(0, 0, 0, .7);
    --ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);

    --grid-line: rgba(140, 190, 230, .05);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:            #0b1014;
  --bg-deep:       #070b0e;
  --surface:       #121a20;
  --surface-2:     #16202a;
  --surface-3:     #1d2933;
  --surface-glass: rgba(18, 26, 32, .82);
  --overlay:       rgba(3, 6, 8, .68);

  --line:          #253440;
  --line-strong:   #35485a;
  --line-faint:    #1b2732;

  --text:          #e8eef3;
  --text-2:        #a8b8c6;
  --text-3:        #74889a;
  --text-inv:      #0b1014;

  --accent:        #ffb020;
  --accent-2:      #ffc85a;
  --accent-ink:    #1a1204;
  --accent-soft:   rgba(255, 176, 32, .13);
  --accent-line:   rgba(255, 176, 32, .38);

  --teal:          #2dd4bf;
  --teal-soft:     rgba(45, 212, 191, .13);

  --good:          #46d68a;
  --warn:          #ffc043;
  --bad:           #ff6b6b;
  --good-soft:     rgba(70, 214, 138, .13);
  --warn-soft:     rgba(255, 192, 67, .13);
  --bad-soft:      rgba(255, 107, 107, .13);

  --el-neutral:    #cbbfa8;
  --el-fire:       #ff7a45;
  --el-water:      #4aa8f0;
  --el-grass:      #63c065;
  --el-electric:   #f5cf3d;
  --el-ice:        #63d6e8;
  --el-ground:     #c98f52;
  --el-dark:       #9b7bf0;
  --el-dragon:     #e065d2;

  --rar-common:    #8b9199;
  --rar-rare:      #4aa8f0;
  --rar-epic:      #9b7bf0;
  --rar-legend:    #ffb020;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, .3), 0 8px 24px -6px rgba(0, 0, 0, .55);
  --shadow-3: 0 4px 10px rgba(0, 0, 0, .35), 0 28px 60px -14px rgba(0, 0, 0, .7);
  --ring: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);

  --grid-line: rgba(140, 190, 230, .05);
  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  font-feature-settings: 'kern' 1, 'liga' 1, 'cv05' 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Faint survey-grid backdrop. Pure CSS, no image request. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 20%, transparent 78%);
}

img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
img { background-color: var(--surface-3); }

input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.015em;
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
h5 { font-size: var(--step-0); }

p, li { text-wrap: pretty; }

a { color: var(--accent); text-decoration-color: var(--accent-line); text-underline-offset: .18em; }
a:hover { text-decoration-color: currentColor; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

code, kbd, samp, pre { font-family: var(--font-mono); font-size: .9em; }
code {
  background: var(--surface-3);
  border: 1px solid var(--line-faint);
  padding: .1em .38em;
  border-radius: var(--r-sm);
}
kbd {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: .08em .42em;
  font-size: .82em;
  color: var(--text-2);
  white-space: nowrap;
}

hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-6) 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 3px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* --------------------------------------------------------------------------
   3. Layout primitives
   -------------------------------------------------------------------------- */
.wrap  { width: min(100% - 2rem, var(--wrap)); margin-inline: auto; }
.wrap-wide { width: min(100% - 2rem, var(--wrap-wide)); margin-inline: auto; }
.wrap-read { width: min(100% - 2rem, var(--wrap-read)); margin-inline: auto; }
@media (max-width: 560px) { .wrap, .wrap-wide, .wrap-read { width: min(100% - 1.5rem, var(--wrap)); } }

.stack > * + * { margin-top: var(--flow, var(--sp-4)); }
.section { padding-block: var(--sp-8); }
.section-tight { padding-block: var(--sp-6); }

.row { display: flex; align-items: center; gap: var(--sp-3); }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.spacer { flex: 1 1 auto; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; top: -100%; left: var(--sp-4); z-index: 200;
  background: var(--accent); color: var(--accent-ink);
  padding: var(--sp-2) var(--sp-4); border-radius: 0 0 var(--r-md) var(--r-md);
  font-weight: 600;
}
.skip-link:focus { top: 0; }

/* Wide content must scroll inside itself, never the page */
.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

/* --------------------------------------------------------------------------
   4. Type helpers
   -------------------------------------------------------------------------- */
.eyebrow {
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex; align-items: center; gap: var(--sp-2);
}
.eyebrow::before {
  content: ''; width: 1.6rem; height: 2px; background: currentColor; opacity: .55; border-radius: 2px;
}
.lede { font-size: var(--step-1); color: var(--text-2); line-height: 1.55; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: var(--step--1); }
.tiny { font-size: var(--step--2); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.upper { text-transform: uppercase; letter-spacing: .08em; }

.section-head { margin-bottom: var(--sp-5); }
.section-head h2 { margin-top: var(--sp-2); }
.section-head p { margin-top: var(--sp-2); color: var(--text-2); max-width: 62ch; }

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-line: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: .58em 1.1em;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-line);
  border-radius: var(--r-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
  transition: background .16s var(--ease), border-color .16s var(--ease), transform .12s var(--ease), color .16s var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-line: var(--accent);
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { --btn-bg: var(--accent-2); --btn-line: var(--accent-2); }

.btn-ghost { --btn-bg: transparent; --btn-line: transparent; color: var(--text-2); }
.btn-ghost:hover { --btn-bg: var(--surface-3); color: var(--text); border-color: var(--line); }

.btn-outline { --btn-bg: transparent; --btn-line: var(--accent-line); --btn-fg: var(--accent); }
.btn-outline:hover { --btn-bg: var(--accent-soft); --btn-line: var(--accent); }

.btn-sm { padding: .38em .8em; font-size: var(--step--2); }
.btn-lg { padding: .72em 1.5em; font-size: var(--step-0); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

.btn-icon { padding: .5em; aspect-ratio: 1; }

/* --------------------------------------------------------------------------
   6. Surfaces: cards, panels
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative;
}
.card-flush { padding: 0; overflow: hidden; }
.card-2 { background: var(--surface-2); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3 { font-size: var(--step-0); letter-spacing: .02em; }
.panel-body { padding: var(--sp-4); }

/* Interactive card that reveals an accent rail on hover */
.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
  overflow: hidden;
}
.card-link::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
  transform: scaleY(0); transform-origin: 50% 0;
  transition: transform .22s var(--ease-out);
}
.card-link:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.card-link:hover::after { transform: scaleY(1); }

/* --------------------------------------------------------------------------
   7. Chips, tags, badges, element pills
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .22em .62em;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--step--2);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--text-2);
}
.chip-accent { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.chip-good { border-color: color-mix(in srgb, var(--good) 40%, transparent); background: var(--good-soft); color: var(--good); }
.chip-bad  { border-color: color-mix(in srgb, var(--bad) 40%, transparent);  background: var(--bad-soft);  color: var(--bad); }
.chip-warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); color: var(--warn); }

/* Element pill — colour driven by [data-el] so markup stays semantic */
.el {
  display: inline-flex; align-items: center; gap: .38em;
  padding: .2em .6em .2em .45em;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: .03em;
  line-height: 1.55;
  white-space: nowrap;
  color: var(--el, var(--text-2));
  background: color-mix(in srgb, var(--el, var(--text-3)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--el, var(--text-3)) 38%, transparent);
}
.el::before {
  content: ''; width: .6em; height: .6em; border-radius: 50%;
  background: currentColor; flex: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--el, var(--text-3)) 22%, transparent);
}
.el-solid { color: var(--text-inv); background: var(--el); border-color: var(--el); }
.el-dot { padding: 0; width: .7em; height: .7em; border-radius: 50%; background: var(--el); border: 0; }
.el-dot::before { display: none; }

[data-el="Neutral"]  { --el: var(--el-neutral); }
[data-el="Fire"]     { --el: var(--el-fire); }
[data-el="Water"]    { --el: var(--el-water); }
[data-el="Grass"]    { --el: var(--el-grass); }
[data-el="Electric"] { --el: var(--el-electric); }
[data-el="Ice"]      { --el: var(--el-ice); }
[data-el="Ground"]   { --el: var(--el-ground); }
[data-el="Dark"]     { --el: var(--el-dark); }
[data-el="Dragon"]   { --el: var(--el-dragon); }

.rarity-common  { --rar: var(--rar-common); }
.rarity-rare    { --rar: var(--rar-rare); }
.rarity-epic    { --rar: var(--rar-epic); }
.rarity-legend  { --rar: var(--rar-legend); }

/* --------------------------------------------------------------------------
   8. Forms
   -------------------------------------------------------------------------- */
.field { display: grid; gap: var(--sp-2); }
.label {
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.input, .select, .textarea {
  width: 100%;
  padding: .58em .8em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.input:hover, .select:hover { border-color: var(--line-strong); }
.input::placeholder { color: var(--text-3); }
.select {
  appearance: none;
  padding-right: 2.2em;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.05em) 55%, calc(100% - .68em) 55%;
  background-size: .37em .37em, .37em .37em;
  background-repeat: no-repeat;
}
.input-search { padding-left: 2.35em; }

/* Segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
}
.seg button {
  border: 0; background: transparent; color: var(--text-2);
  padding: .34em .8em; border-radius: 5px;
  font-family: var(--font-display); font-size: var(--step--2); font-weight: 600;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button.is-on {
  background: var(--accent); color: var(--accent-ink);
}

/* Toggle-chip filter (checkbox styled as chip) */
.tog { position: relative; display: inline-flex; }
.tog input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tog span {
  display: inline-flex; align-items: center; gap: .38em;
  padding: .3em .7em;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: var(--step--2); font-weight: 600; color: var(--text-2);
  transition: all .15s var(--ease);
  user-select: none;
}
.tog input:hover + span { border-color: var(--line-strong); color: var(--text); }
.tog input:checked + span {
  background: color-mix(in srgb, var(--el, var(--accent)) 16%, transparent);
  border-color: color-mix(in srgb, var(--el, var(--accent)) 55%, transparent);
  color: var(--el, var(--accent));
}
.tog input:focus-visible + span { box-shadow: var(--ring); }

/* --------------------------------------------------------------------------
   9. Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.table-wrap > .scroll-x { max-width: 100%; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}
table.data th, table.data td {
  padding: .62rem .85rem;
  text-align: left;
  border-bottom: 1px solid var(--line-faint);
  vertical-align: middle;
}
table.data thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th[aria-sort] { cursor: pointer; user-select: none; }
table.data th[aria-sort]:hover { color: var(--text); }
table.data th[aria-sort]::after { content: '↕'; opacity: .35; margin-left: .4em; }
table.data th[aria-sort="ascending"]::after  { content: '↑'; opacity: 1; color: var(--accent); }
table.data th[aria-sort="descending"]::after { content: '↓'; opacity: 1; color: var(--accent); }
table.data tr.is-alt { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   10. Stat bars / meters
   -------------------------------------------------------------------------- */
.meter {
  --pct: 0%;
  --meter-color: var(--accent);
  position: relative;
  height: 7px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.meter::after {
  content: ''; position: absolute; inset: 0 auto 0 0;
  width: var(--pct);
  background: var(--meter-color);
  border-radius: inherit;
  transition: width .5s var(--ease-out);
}
.statline { display: grid; grid-template-columns: 6.5rem 1fr 3rem; gap: var(--sp-3); align-items: center; }
.statline .label { text-transform: none; letter-spacing: .02em; font-size: var(--step--1); color: var(--text-2); }
.statline .val { text-align: right; font-family: var(--font-mono); font-size: var(--step--1); }

/* Work-suitability tick row */
.work-row { display: flex; align-items: center; gap: var(--sp-3); }
.pips { display: inline-flex; gap: 3px; }
.pip { width: 9px; height: 9px; border-radius: 2px; background: var(--surface-3); border: 1px solid var(--line); }
.pip.on { background: var(--accent); border-color: var(--accent); }

/* --------------------------------------------------------------------------
   11. Header / navigation
   -------------------------------------------------------------------------- */
.hdr {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface-glass);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.hdr-inner { display: flex; align-items: center; gap: var(--sp-4); height: 60px; }

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  letter-spacing: -.02em; color: var(--text); text-decoration: none;
  flex: none;
}
.brand-mark {
  width: 30px; height: 30px; flex: none;
  border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--teal)));
  color: var(--accent-ink);
  font-size: 15px; font-weight: 800;
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.brand b { color: var(--accent); font-weight: 700; }

.nav { display: flex; align-items: center; gap: 2px; }
.nav a {
  padding: .45em .72em; border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none;
  font-family: var(--font-display); font-weight: 600; font-size: var(--step--1);
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.hdr-tools { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.search-trigger {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  min-width: 15rem;
  padding: .4em .5em .4em .75em;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--text-3);
  font-size: var(--step--1); text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--text-2); }
.search-trigger kbd { margin-left: auto; }

.nav-toggle { display: none; }

@media (max-width: 1080px) {
  .search-trigger { min-width: 0; }
  .search-trigger span { display: none; }
  .search-trigger kbd { display: none; }
}
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; inset: 60px 0 auto 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: var(--sp-2);
    max-height: calc(100dvh - 60px); overflow-y: auto;
    transform: translateY(-6px); opacity: 0; pointer-events: none;
    transition: opacity .18s var(--ease), transform .18s var(--ease);
    box-shadow: var(--shadow-3);
  }
  .nav.is-open { transform: none; opacity: 1; pointer-events: auto; }
  .nav a { padding: .7em .9em; font-size: var(--step-0); }
}

/* --------------------------------------------------------------------------
   12. Command palette / search overlay
   -------------------------------------------------------------------------- */
.cmdk {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: start center;
  padding: clamp(1rem, 8vh, 6rem) 1rem 1rem;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .16s var(--ease);
}
.cmdk[open], .cmdk.is-open { opacity: 1; pointer-events: auto; }
.cmdk-box {
  width: min(100%, 40rem);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  transform: translateY(-8px) scale(.99);
  transition: transform .2s var(--ease-out);
}
.cmdk.is-open .cmdk-box { transform: none; }
.cmdk-input {
  width: 100%; border: 0; background: transparent;
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--step-1);
  border-bottom: 1px solid var(--line);
}
.cmdk-input:focus { outline: none; box-shadow: none; }
.cmdk-results { max-height: min(52vh, 30rem); overflow-y: auto; padding: var(--sp-2); }
.cmdk-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text); text-decoration: none;
}
.cmdk-item:hover, .cmdk-item.is-active { background: var(--accent-soft); }
.cmdk-item img { width: 30px; height: 30px; border-radius: 6px; flex: none; background: var(--surface-3); }
.cmdk-item .k { font-size: var(--step--1); font-weight: 600; }
.cmdk-item .s { font-size: var(--step--2); color: var(--text-3); }
.cmdk-empty { padding: var(--sp-6); text-align: center; color: var(--text-3); }
.cmdk-foot {
  display: flex; gap: var(--sp-4); padding: var(--sp-2) var(--sp-4);
  border-top: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--step--2); color: var(--text-3);
}
.cmdk-group {
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
  font-size: var(--step--2); font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}

/* --------------------------------------------------------------------------
   13. Pal cards & grids
   -------------------------------------------------------------------------- */
.pal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: var(--sp-3);
}
@media (max-width: 480px) { .pal-grid { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); } }

.pal-card {
  position: relative;
  display: flex; flex-direction: column; gap: .35rem;
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: inherit; text-decoration: none;
  transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
  overflow: hidden;
}
.pal-card::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 50% 12%, color-mix(in srgb, var(--el, var(--accent)) 22%, transparent), transparent 62%);
  opacity: .5;
  transition: opacity .2s var(--ease);
}
.pal-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--el, var(--accent)) 50%, var(--line)); box-shadow: var(--shadow-2); }
.pal-card:hover::before { opacity: .95; }
.pal-card .no {
  position: absolute; top: var(--sp-2); left: var(--sp-3);
  font-family: var(--font-mono); font-size: var(--step--2); color: var(--text-3);
  z-index: 1;
}
.pal-card figure { position: relative; z-index: 1; aspect-ratio: 1; display: grid; place-items: center; }
.pal-card img { width: 84%; height: auto; object-fit: contain; background: transparent; filter: drop-shadow(0 4px 10px rgba(0,0,0,.22)); }
.pal-card .nm {
  position: relative; z-index: 1;
  font-family: var(--font-display); font-weight: 600; font-size: var(--step--1);
  line-height: 1.25; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pal-card .els { position: relative; z-index: 1; display: flex; justify-content: center; gap: 4px; }

/* Compact inline pal reference (used in tables, breeding chains) */
.pal-ref {
  display: inline-flex; align-items: center; gap: .5em;
  color: inherit; text-decoration: none; font-weight: 600;
}
.pal-ref img { width: 26px; height: 26px; border-radius: 6px; flex: none; background: var(--surface-3); }
.pal-ref:hover { color: var(--accent); }
.pal-ref-lg img { width: 40px; height: 40px; border-radius: 9px; }

/* --------------------------------------------------------------------------
   14. Hero
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  padding-block: clamp(2.5rem, 7vw, 5rem) clamp(2rem, 5vw, 3.5rem);
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: -40% -10% auto -10%; height: 130%;
  background:
    radial-gradient(46% 55% at 18% 20%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 70%),
    radial-gradient(40% 50% at 82% 8%, color-mix(in srgb, var(--teal) 22%, transparent), transparent 70%);
  filter: blur(18px);
  opacity: .55;
  pointer-events: none;
}
.hero > * { position: relative; }
.hero h1 { font-size: var(--step-5); }
.hero h1 em { font-style: normal; color: var(--accent); }

/* --------------------------------------------------------------------------
   15. Prose (guides)
   -------------------------------------------------------------------------- */
.prose { max-width: var(--wrap-read); font-size: 1.02rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 {
  margin-top: 2.4em; padding-top: .6em;
  border-top: 1px solid var(--line);
  font-size: var(--step-2);
  scroll-margin-top: 6rem;
}
.prose h3 { margin-top: 1.9em; font-size: var(--step-1); scroll-margin-top: 6rem; }
.prose h4 { margin-top: 1.6em; font-size: var(--step-0); color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: .4em; }
.prose ul > li::marker { color: var(--accent); }
.prose ol > li::marker { color: var(--accent); font-family: var(--font-mono); font-weight: 600; }
.prose strong { font-weight: 650; color: var(--text); }
.prose blockquote {
  border-left: 3px solid var(--accent);
  padding: .2em 0 .2em 1.1em;
  color: var(--text-2);
  font-style: italic;
}
.prose figure { margin-block: var(--sp-5); }
.prose figcaption { margin-top: var(--sp-2); font-size: var(--step--1); color: var(--text-3); text-align: center; }
.prose table { width: 100%; }
.prose .table-wrap { margin-block: var(--sp-5); }
.prose img { border-radius: var(--r-md); border: 1px solid var(--line); }

/* Callouts */
.note {
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--step--1);
}
.note-title { font-family: var(--font-display); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: var(--step--2); }
.note > .ico { font-size: 1.1em; line-height: 1.4; }
.note-tip  { border-left-color: var(--good); }
.note-warn { border-left-color: var(--warn); }
.note-key  { border-left-color: var(--teal); }

/* Table of contents */
.toc { position: sticky; top: 5.5rem; align-self: start; font-size: var(--step--1); }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--line); }
.toc li a {
  display: block; padding: .3em 0 .3em .9em; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-3); text-decoration: none; line-height: 1.4;
}
.toc li a:hover { color: var(--text); }
.toc li a.is-active { color: var(--accent); border-left-color: var(--accent); }
.toc .lvl-3 a { padding-left: 1.8em; font-size: .95em; }

.guide-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); }
@media (min-width: 1080px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr) 15rem; }
}

/* --------------------------------------------------------------------------
   16. Breadcrumbs, pagination, meta
   -------------------------------------------------------------------------- */
.crumbs { display: flex; flex-wrap: wrap; gap: .4em; font-size: var(--step--2); color: var(--text-3); }
.crumbs a { color: var(--text-3); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs li + li::before { content: '/'; margin-right: .4em; opacity: .5; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: .4em; list-style: none; padding: 0; margin: 0; }

.meta-row { display: flex; flex-wrap: wrap; gap: var(--sp-4); font-size: var(--step--2); color: var(--text-3); }

/* --------------------------------------------------------------------------
   17. Footer
   -------------------------------------------------------------------------- */
.ftr {
  margin-top: var(--sp-9);
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  padding-block: var(--sp-7) var(--sp-5);
  font-size: var(--step--1);
}
.ftr-grid { display: grid; gap: var(--sp-6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.ftr h3 {
  font-size: var(--step--2); letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: var(--sp-3);
}
.ftr ul { list-style: none; padding: 0; display: grid; gap: .45rem; }
.ftr a { color: var(--text-2); text-decoration: none; }
.ftr a:hover { color: var(--accent); }
.ftr-legal {
  margin-top: var(--sp-6); padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
  color: var(--text-3); font-size: var(--step--2);
  display: flex; flex-wrap: wrap; gap: var(--sp-4); justify-content: space-between;
}

/* --------------------------------------------------------------------------
   18. Utility
   -------------------------------------------------------------------------- */
.hidden, [hidden] { display: none !important; }
.mt-0 { margin-top: 0 !important; }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }
.flex-1 { flex: 1 1 auto; min-width: 0; }
.w-full { width: 100%; }
.rel { position: relative; }
.divider { height: 1px; background: var(--line); border: 0; }

.empty-state { padding: var(--sp-8) var(--sp-4); text-align: center; color: var(--text-3); }
.empty-state h3 { color: var(--text-2); margin-bottom: var(--sp-2); }

/* Sticky filter bar used by dex/map/tools */
.filterbar {
  position: sticky; top: 60px; z-index: 40;
  background: var(--surface-glass);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-block: var(--sp-3);
  margin-bottom: var(--sp-5);
}

/* Loading shimmer */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
  border-radius: var(--r-md);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* Print */
@media print {
  .hdr, .ftr, .filterbar, .cmdk, .toc, .btn { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .panel { border: 1px solid #ccc; box-shadow: none; }
}
