:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --line: #e1e4ea;
  --text: #1b1f27;
  --muted: #5e6675;
  --accent: #d6452f;
  --accent-2: #2f6fd6;
  --good: #1f9d55;
  --bad: #d63c3c;
  --warn: #c98a00;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141a; --panel: #1a1d25; --panel-2: #222632; --line: #2c313d; --text: #e8eaf0; --muted: #9aa2b2;
    --accent: #ff6a52; --accent-2: #6aa5ff; --good: #3ccf7e; --bad: #ff6b6b; --warn: #f0b429;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12141a; --panel: #1a1d25; --panel-2: #222632; --line: #2c313d; --text: #e8eaf0; --muted: #9aa2b2;
  --accent: #ff6a52; --accent-2: #6aa5ff; --good: #3ccf7e; --bad: #ff6b6b; --warn: #f0b429;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* the hidden attribute must win over any display rule (e.g. .acct-menu { display: grid }) */
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { image-rendering: auto; }
h1, h2, h3, h4 { line-height: 1.2; margin: 1.2em 0 .5em; }
h1 { font-size: 1.7rem; margin-top: .2em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); white-space: nowrap; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.search { position: relative; flex: 1; max-width: 680px; }
.search input { width: 100%; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); outline: none; }
.search input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 25%, transparent); }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; max-height: min(70vh, 640px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.results .group { padding: 8px 10px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.results a.r { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; color: var(--text); }
.results a.r:hover, .results a.r.sel { background: var(--panel-2); text-decoration: none; }
.results a.r img { width: 32px; height: 32px; object-fit: contain; flex: none; }
.results a.r .ph { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 6px; background: var(--panel-2); font-size: .8rem; color: var(--muted); }
.results .rt { display: flex; flex-direction: column; min-width: 0; }
.results .rt b { font-weight: 600; }
.results .rt span { color: var(--muted); font-size: .85em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .empty { padding: 14px; color: var(--muted); }
.results .hint { padding: 6px 10px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); margin-top: 4px; }
.icon-btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
.menu-btn { display: none; }
.run-pill { white-space: nowrap; font-size: .85rem; padding: 5px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.run-pill b { color: var(--accent); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 54px); }
.sidebar { position: sticky; top: 54px; height: calc(100vh - 54px); overflow: auto; border-right: 1px solid var(--line); background: var(--panel); padding: 12px; }
main { padding: 20px 28px 80px; max-width: 1280px; width: 100%; outline: none; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.nav .sec { margin: 14px 10px 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.nav details summary { list-style: none; cursor: pointer; }
.nav details summary::-webkit-details-marker { display: none; }
.settings { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.settings label { display: grid; gap: 2px; font-size: .78rem; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { flex: 1; border: 0; background: none; padding: 4px 6px; cursor: pointer; font-size: .82rem; color: var(--text); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 28; left: 0; top: 54px; width: 280px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.menu-open .sidebar { transform: none; }
  .menu-btn { display: inline-block; }
  .brand span { display: none; }
  main { padding: 16px 16px 80px; }
  .run-pill { display: none; }
}

/* ---------- common bits ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.accent { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); border-color: transparent; }
.badge.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); border-color: transparent; }
.badge.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); border-color: transparent; }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); border-color: transparent; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--text); }
.btn:hover { border-color: var(--accent-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { padding: 2px 8px; font-size: .82rem; }
input.inp, select.inp { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: .85rem; }
.chip.on { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }

/* types */
.type { display: inline-block; min-width: 64px; text-align: center; padding: 1px 8px; border-radius: 6px; font-size: .74rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.35); }
.type.sm { min-width: 0; padding: 0 6px; font-size: .68rem; }
.t-Normal{background:#9fa19f}.t-Fire{background:#e62829}.t-Water{background:#2980ef}.t-Electric{background:#f5c000}.t-Grass{background:#3fa129}.t-Ice{background:#3dcef3}.t-Fighting{background:#ff8000}.t-Poison{background:#9141cb}.t-Ground{background:#915121}.t-Flying{background:#81b9ef}.t-Psychic{background:#ef4179}.t-Bug{background:#91a119}.t-Rock{background:#afa981}.t-Ghost{background:#704170}.t-Dragon{background:#5060e1}.t-Dark{background:#624d4e}.t-Steel{background:#60a1b8}.t-Fairy{background:#ef70ef}
.cat { display: inline-block; font-size: .7rem; font-weight: 700; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.cat.Physical { color: #e0663a; } .cat.Special { color: #4f86e6; } .cat.Status { color: var(--muted); }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
/* headers sit inside horizontally-scrolling wrappers, so they must not be offset (top:54px pushed them over the first rows) */
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tbl th.sort { cursor: pointer; user-select: none; }
.tbl th.sort:hover { color: var(--text); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
.tbl td.eff { color: var(--muted); font-size: .85rem; max-width: 460px; }
.tbl-wrap { overflow-x: auto; }
.mon-cell { display: flex; align-items: center; gap: 8px; }
.mon-cell img { width: 40px; height: 40px; object-fit: contain; }

/* dex grid */
.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.dex-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-align: center; position: relative; }
.dex-card:hover { border-color: var(--accent-2); text-decoration: none; }
.dex-card img { width: 64px; height: 64px; object-fit: contain; }
.dex-card .num { position: absolute; top: 6px; left: 8px; font-size: .72rem; color: var(--muted); }
.dex-card .bst { font-size: .75rem; color: var(--muted); }
.dex-card.dupe { opacity: .45; }
.dex-card .tag { position: absolute; top: 6px; right: 6px; }

/* pokemon page */
.mon-head { display: grid; grid-template-columns: 160px 1fr; gap: 20px; align-items: center; }
.mon-head .art { width: 160px; height: 160px; display: grid; place-items: center; background: var(--panel-2); border-radius: 16px; }
.mon-head .art img { max-width: 140px; max-height: 140px; }
@media (max-width: 600px) { .mon-head { grid-template-columns: 1fr; } .mon-head .art { margin: 0 auto; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.stat-row { display: grid; grid-template-columns: 44px 44px 1fr 60px; gap: 8px; align-items: center; font-size: .9rem; }
.stat-row .bar { height: 10px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.stat-row .bar i { display: block; height: 100%; border-radius: 6px; }
.stat-row .diff { font-size: .8rem; }
.up { color: var(--good); } .down { color: var(--bad); }
.def-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.def-grid .d { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 2px 4px 2px 2px; border-radius: 8px; background: var(--panel-2); font-size: .8rem; font-weight: 700; }
.mult-4 { color: var(--bad); } .mult-2 { color: color-mix(in srgb, var(--bad) 75%, var(--text)); } .mult-05 { color: var(--good); } .mult-025 { color: var(--good); } .mult-0 { color: var(--accent-2); }
.evo { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.evo .stage { display: flex; flex-direction: column; gap: 8px; }
.evo a.e { display: flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 10px; color: var(--text); font-size: .85rem; }
.evo a.e:hover { background: var(--panel-2); text-decoration: none; }
.evo a.e.cur { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.evo a.e img { width: 56px; height: 56px; object-fit: contain; }
.evo .arrow { color: var(--muted); font-size: .78rem; text-align: center; max-width: 140px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 16px 0 10px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.under-cap td { }
.over-cap td:first-child { color: var(--muted); }
.cap-line td { border-top: 2px dashed var(--accent); }

/* encounters */
.enc-method { margin-bottom: 14px; }
.enc-method h4 { margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }
.enc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.enc { display: grid; grid-template-columns: 48px 1fr; gap: 2px 8px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); position: relative; }
.enc:hover { border-color: var(--accent-2); text-decoration: none; }
.enc img { width: 48px; height: 48px; object-fit: contain; grid-row: span 2; }
.enc .nm { font-weight: 600; line-height: 1.15; }
.enc .meta { font-size: .78rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; }
.enc .pct { font-weight: 700; color: var(--text); }
.enc.dupe { opacity: .4; }
.enc.dupe::after { content: "dupe"; position: absolute; top: 4px; right: 6px; font-size: .65rem; font-weight: 700; color: var(--bad); text-transform: uppercase; }
.enc.caught { border-color: var(--good); }
.mini-mons { display: flex; flex-wrap: wrap; gap: 2px; }
.mini-mons img { width: 32px; height: 32px; object-fit: contain; }
.mini-mons img.dupe { opacity: .25; filter: grayscale(1); }

/* route guide */
.split { margin-bottom: 22px; }
.split-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.split-head h2 { margin: 0; }
.slot { display: grid; grid-template-columns: 28px minmax(160px, 260px) 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.slot:last-child { border-bottom: 0; }
.slot .st { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .75rem; }
.slot.s-alive .st, .slot.s-team .st { background: var(--good); border-color: var(--good); color: #fff; }
.slot.s-dead .st { background: var(--bad); border-color: var(--bad); color: #fff; }
.slot.s-failed .st, .slot.s-skipped .st { background: var(--muted); border-color: var(--muted); color: #fff; }
.slot .caught { display: flex; align-items: center; gap: 6px; }
.slot .caught img { width: 36px; height: 36px; object-fit: contain; }
.milestone { padding: 6px 12px; font-size: .82rem; color: var(--warn); font-weight: 600; background: color-mix(in srgb, var(--warn) 8%, transparent); }
@media (max-width: 700px) { .slot { grid-template-columns: 28px 1fr; } .slot > :nth-child(3), .slot > :nth-child(4) { grid-column: 2; } }

/* trainers */
.trainer { padding: 12px 14px; }
.trainer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.trainer-head img.tr { width: 56px; height: 56px; object-fit: contain; }
.trainer-head h3 { margin: 0; font-size: 1.05rem; }
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.tm { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--panel-2); }
.tm-top { display: grid; grid-template-columns: 52px 1fr; gap: 0 8px; align-items: center; }
.tm-top img { width: 52px; height: 52px; object-fit: contain; grid-row: span 3; }
.tm-top .nm { font-weight: 700; color: var(--text); }
.tm .ab, .tm .it { font-size: .8rem; color: var(--muted); }
.tm .it b, .tm .ab b { color: var(--text); font-weight: 600; }
.tm .moves { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-top: 6px; }
.mv { display: flex; align-items: center; gap: 4px; font-size: .78rem; padding: 2px 6px 2px 2px; border-radius: 6px; background: var(--panel); border-left: 4px solid var(--line); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.mv:hover { text-decoration: none; filter: brightness(1.08); }
.mv .pw { margin-left: auto; color: var(--muted); font-size: .7rem; }
.bl-Normal{border-left-color:#9fa19f}.bl-Fire{border-left-color:#e62829}.bl-Water{border-left-color:#2980ef}.bl-Electric{border-left-color:#f5c000}.bl-Grass{border-left-color:#3fa129}.bl-Ice{border-left-color:#3dcef3}.bl-Fighting{border-left-color:#ff8000}.bl-Poison{border-left-color:#9141cb}.bl-Ground{border-left-color:#915121}.bl-Flying{border-left-color:#81b9ef}.bl-Psychic{border-left-color:#ef4179}.bl-Bug{border-left-color:#91a119}.bl-Rock{border-left-color:#afa981}.bl-Ghost{border-left-color:#704170}.bl-Dragon{border-left-color:#5060e1}.bl-Dark{border-left-color:#624d4e}.bl-Steel{border-left-color:#60a1b8}.bl-Fairy{border-left-color:#ef70ef}
.notes { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent-2) 8%, transparent); font-size: .88rem; }
.notes p { margin: 2px 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 16px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.toc a { font-size: .82rem; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }

/* caps */
.cap-row { display: grid; grid-template-columns: 24px 48px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.cap-row img { width: 44px; height: 44px; object-fit: contain; }
.cap-row .lv { font-size: 1.2rem; font-weight: 800; color: var(--accent); min-width: 48px; text-align: right; }
.cap-row.done { opacity: .5; }
.cap-row.next { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.cap-row input { width: 18px; height: 18px; }

/* prose pages */
.prose { line-height: 1.6; }
.prose table { border-collapse: collapse; margin: 10px 0; font-size: .9rem; display: block; overflow-x: auto; max-width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 4px 8px; vertical-align: middle; }
.prose th { background: var(--panel-2); }
.prose img { max-width: 100%; vertical-align: middle; }
.prose code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.prose pre { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow-x: auto; }
.prose .admonition { border-left: 4px solid var(--accent-2); background: color-mix(in srgb, var(--accent-2) 7%, transparent); padding: 6px 14px; border-radius: 6px; margin: 12px 0; }
.prose .admonition-title { font-weight: 700; margin: 4px 0; text-transform: capitalize; }
.prose .tabset { border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; }
.prose .tabset > .tabs { margin: 0; padding: 0 8px; }
.prose .tabset > .tab { padding: 4px 14px; }
.prose details.legend { margin: 8px 0; }
.prose h2, .prose h3 { scroll-margin-top: 70px; }
.prose h1 { display: none; }
mark { background: color-mix(in srgb, var(--warn) 40%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* tooltip */
.tip { position: fixed; z-index: 50; max-width: 340px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; font-size: .85rem; pointer-events: none; }
.tip h5 { margin: 0 0 4px; font-size: .95rem; }
.tip .row { gap: 6px; margin-bottom: 4px; }

/* run tracker */
.party { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pmon { display: flex; flex-direction: column; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); text-align: center; position: relative; }
.pmon img { width: 64px; height: 64px; object-fit: contain; }
.pmon .nick { font-weight: 700; }
.pmon.dead { opacity: .5; filter: grayscale(.8); }
.matrix { border-collapse: collapse; font-size: .8rem; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 3px 5px; text-align: center; min-width: 30px; }
.matrix td.x4 { background: color-mix(in srgb, var(--bad) 55%, transparent); font-weight: 800; }
.matrix td.x2 { background: color-mix(in srgb, var(--bad) 25%, transparent); }
.matrix td.x05 { background: color-mix(in srgb, var(--good) 22%, transparent); }
.matrix td.x025 { background: color-mix(in srgb, var(--good) 40%, transparent); }
.matrix td.x0 { background: color-mix(in srgb, var(--accent-2) 35%, transparent); }
.matrix td.sum-bad { color: var(--bad); font-weight: 800; }
.matrix td.sum-good { color: var(--good); font-weight: 800; }
dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 18px; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .field { display: grid; gap: 4px; margin-bottom: 12px; }
dialog .field > span { font-size: .8rem; color: var(--muted); }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; max-height: 220px; overflow: auto; }
.suggest button { display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 2px 8px 2px 2px; cursor: pointer; font-size: .82rem; }
.suggest button img { width: 32px; height: 32px; object-fit: contain; }
.suggest button.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.suggest button.dupe { opacity: .45; }
.loading { padding: 40px; color: var(--muted); }
.kbd { font-family: var(--mono); font-size: .75rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
.home-hero { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stat-big { font-size: 2rem; font-weight: 800; }

/* ---------- drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 41; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .2s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-close { position: absolute; top: 10px; right: 12px; }
.drawer-body { overflow: auto; padding: 18px 18px 40px; }
.drawer-body h2 { margin: 0 40px 6px 0; }
.drawer-body .dex-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.drawer-body .dex-card img { width: 48px; height: 48px; }
button.ab-btn { border: 1px dashed var(--line); background: none; color: var(--accent-2); padding: 1px 6px; border-radius: 6px; cursor: pointer; font-size: .82rem; text-align: left; }
button.ab-btn:hover { border-style: solid; border-color: var(--accent-2); }
button.ab-btn .ha { color: var(--muted); font-size: .72rem; }

/* ---------- comparer ---------- */
.cmp td.st { text-align: right; font-variant-numeric: tabular-nums; position: relative; min-width: 46px; }
.cmp td.st span.v { position: relative; z-index: 1; }
.cmp td.st i { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; border-radius: 2px; opacity: .8; }
.cmp td.best { font-weight: 800; color: var(--accent); }
.cmp tr.dupe td { opacity: .45; }
.cmp tr.picked td { background: color-mix(in srgb, var(--good) 10%, transparent); }
.cmp .abil { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.cmp .how { font-size: .78rem; color: var(--muted); max-width: 220px; }
.cmp .evo-to { font-size: .75rem; color: var(--muted); }
.cmp thead th { white-space: nowrap; vertical-align: bottom; }
@media (max-width: 700px) {
  .cmp th:nth-last-child(2), .cmp td.how { display: none; }
  .cmp .mon-cell img { width: 32px; height: 32px; }
  .cmp td, .cmp th { padding: 5px 5px; }
  .tbl th { top: 0; }
}
.mini-mons a.pick { border-radius: 8px; line-height: 0; }
.mini-mons a.pick:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); outline: 1px solid var(--accent); }
.mini-mons a.pick:hover img { transform: scale(1.12); }
.mini-mons a.pick.chosen { background: color-mix(in srgb, var(--good) 22%, transparent); outline: 1px solid var(--good); }

/* ---------- maps ---------- */
.map-box { --m-g: #43b14d; --m-d: #1f6e35; --m-w: #4189ec; --m-s: #e2c37a; }
.map-tabs { margin-top: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .8rem; color: var(--muted); margin: 6px 0 10px; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.map-legend .mk { width: 14px; height: 14px; display: inline-grid; }
.map-legend label { display: inline-flex; gap: 4px; align-items: center; }
.map-scroll { overflow: auto; max-height: 78vh; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.map-wrap { position: relative; margin: 0 auto; }
.map-canvas, .map-hl { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.map-hl { pointer-events: none; }
.map-markers { position: absolute; inset: 0; pointer-events: none; }
.mk { position: absolute; pointer-events: auto; border-radius: 50%; border: 2px solid #fff; padding: 0; cursor: pointer; display: grid; place-items: center; font-size: 11px; font-weight: 900; line-height: 1; color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.mk.tr { background: #e0362c; }
.mk.tr.nowiki { background: #9a5a55; }
.mk.tr.boss { background: #f5b301; color: #3a2a00; border-color: #3a2a00; }
.mk.it { background: radial-gradient(circle at 50% 50%, #fff 0 22%, #222 23% 30%, transparent 31%), linear-gradient(#e33 0 46%, #222 46% 54%, #fff 54%); border-color: #222; }
.mk.it.tm { background: linear-gradient(135deg, #8b5cf6, #3b82f6); border-color: #fff; }
.mk.it.hid { opacity: .75; border-style: dashed; border-color: #f5b301; background: rgba(245,179,1,.35); }
.mk.wp { border-radius: 3px; background: #a855f7; border-width: 1px; }
.mk:hover { transform: scale(1.3); z-index: 2; }
.mk.pulse { animation: pulse 1.2s ease-in-out 4; z-index: 3; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(245,179,1,.9); } 50% { box-shadow: 0 0 0 10px rgba(245,179,1,0); } }
.map-hint { margin: 8px 0 0; }
.map-view { margin-top: -4px; }
.map-view input[type=range] { width: 110px; vertical-align: middle; }
.map-legend .zoom { margin-left: auto; }
.map-legend .zoom button { min-width: 34px; font-weight: 700; }

/* ---------- account ---------- */
.account { position: relative; }
.acct-btn { position: relative; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); padding: 0; overflow: visible; background: var(--panel-2); cursor: pointer; display: grid; place-items: center; font-weight: 700; color: var(--text); }
.acct-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.acct-btn .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel); background: var(--muted); }
.acct-btn .dot.saved { background: var(--good); }
.acct-btn .dot.saving { background: var(--warn); }
.acct-btn .dot.error { background: var(--bad); }
.acct-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 240px; display: grid; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
/* sign-in pill matches the search box + theme button (same height, radius and surface) */
.account { display: flex; align-items: center; }
.signin-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.signin-btn:hover { border-color: var(--accent-2); }
.signin-btn svg { flex: none; }
#themeBtn { height: 40px; width: 40px; padding: 0; border-radius: 999px; display: grid; place-items: center; }
.acct-btn { width: 40px; height: 40px; }
.search input { height: 40px; padding: 0 16px; }
@media (max-width: 600px) { .signin-btn span { display: none; } .signin-btn { padding: 0 9px; } }
/* top bar: brand left, search centred, account + theme right */
.topbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 680px) minmax(0, 1fr); gap: 16px; }
.tb-left { display: flex; align-items: center; gap: 10px; justify-self: start; min-width: 0; }
.tb-right { display: flex; align-items: center; gap: 10px; justify-self: end; }
.topbar .search { max-width: none; width: 100%; }
@media (max-width: 900px) {
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
}

/* community votes */
.vote-btn { display: inline-flex; align-items: center; gap: 5px; min-width: 52px; justify-content: center; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); cursor: pointer; font-size: .82rem; }
.vote-btn b { color: var(--text); }
.vote-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.vote-btn.top { border-color: var(--warn); }
.vote-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.vote-btn.on b { color: #fff; }
.vote-btn:disabled { opacity: .6; cursor: progress; }
/* game settings as a compact dropdown */
.settings { padding: 0; display: block; }
.settings details > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; padding: 8px 12px; border-radius: var(--radius); }
.settings details > summary::-webkit-details-marker { display: none; }
.settings details > summary .muted { grid-column: 1; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.settings details > summary b { grid-column: 1; font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings details > summary .chev { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); transition: transform .15s; }
.settings details[open] > summary .chev { transform: rotate(180deg); }
.settings details > summary:hover { background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.settings-body { display: grid; gap: 8px; padding: 4px 10px 10px; }
.settings-body label { display: grid; gap: 2px; font-size: .78rem; color: var(--muted); }
/* one shared top-bar height so the sticky sidebar always fits exactly below it */
:root { --tb: 56px; }
.topbar { height: var(--tb); padding-top: 0; padding-bottom: 0; align-items: center; box-sizing: border-box; }
.layout { min-height: calc(100vh - var(--tb)); }
.sidebar { top: var(--tb); height: calc(100vh - var(--tb)); }
@media (max-width: 900px) { .sidebar { top: var(--tb); height: calc(100dvh - var(--tb)); } }
.settings details > summary b { white-space: normal; overflow: visible; line-height: 1.25; }

/* ---------- comparer layout ---------- */
.cmp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 4px; }
.cmp-head h1 { margin: 0; font-size: 1.6rem; }
.cmp-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-btn { max-width: 300px; }
.nav-btn .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nav-btn .dir { flex: none; }
.cmp-tools { align-items: center; }
.seg button { white-space: nowrap; }
.cmp { table-layout: auto; }
.cmp th, .cmp td { vertical-align: middle; }
.cmp th.num, .cmp td.num { text-align: center; }
.cmp td.st { width: 48px; position: static; }
.cmp td.st .v { display: block; font-variant-numeric: tabular-nums; font-size: .95rem; position: static; }
.cmp td.st .bar { display: block; width: 34px; height: 4px; margin: 4px auto 0; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.cmp td.st .bar i { position: static; display: block; height: 100%; border-radius: 2px; opacity: 1; }
.cmp td.bst .v { font-weight: 700; }
.cmp td.best .v { color: var(--accent); font-weight: 800; }
.cmp .abil { flex-direction: row; flex-wrap: wrap; gap: 4px; max-width: 230px; }
.cmp .mon-cell { white-space: nowrap; }
.cmp td.how { min-width: 180px; }
.cmp tbody tr { height: 64px; }
.btn { white-space: nowrap; }
