:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --border: #dfe2ea;
  --text: #1f2430;
  --text-2: #5a6172;
  --text-3: #8a90a0;
  --accent: #d6322f;
  --accent-soft: #fde8e7;
  --link: #2458c6;
  --shadow: 0 1px 2px rgba(20, 24, 40, .06), 0 4px 16px rgba(20, 24, 40, .06);
  --radius: 12px;
  --header-bg: #1f2430;
  --header-text: #ffffff;
  --bar: #4d8ff0;
  --bar-plus: #e0544f;
  --bar-minus: #4f9fd8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b1f29;
    --surface-2: #232835;
    --border: #2e3444;
    --text: #e8eaf0;
    --text-2: #aab0bf;
    --text-3: #7a8193;
    --accent: #ff5a52;
    --accent-soft: #3a1f22;
    --link: #7fa7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --header-bg: #0c0e13;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }

/* ---------- header ---------- */
.site-header { background: var(--header-bg); color: var(--header-text); position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.header-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 4px; }
.main-nav a { color: rgba(255,255,255,.75); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.main-nav a:hover { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.main-nav a.active { color: #fff; background: rgba(255,255,255,.14); }
.search { margin-left: auto; flex: 0 1 280px; }
.search input { width: 100%; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: #fff; border-radius: 8px; padding: 7px 12px; font: inherit; outline: none; }
.search input::placeholder { color: rgba(255,255,255,.55); }
.search input:focus { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.14); }
@media (max-width: 720px) {
  .header-inner { gap: 8px 12px; }
  .search { flex: 1 1 100%; order: 3; }
  .main-nav { margin-left: auto; }
  .main-nav a { padding: 6px 8px; font-size: .92rem; }
}
@media (max-width: 420px) { .brand-title { display: none; } }

/* ---------- layout ---------- */
.page { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; flex: 1; }
.site-footer { text-align: center; color: var(--text-3); font-size: .85rem; padding: 20px 16px 28px; }
.loading, .empty { color: var(--text-2); padding: 48px 0; text-align: center; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; color: var(--text-2); }
.crumbs { font-size: .9rem; color: var(--text-3); margin-bottom: 8px; }
.crumbs a { color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.02rem; margin-bottom: 12px; }
.muted { color: var(--text-2); }
.small { font-size: .86rem; }

/* ---------- home ---------- */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: 2.2rem; }
.hero p { color: var(--text-2); font-size: 1.05rem; margin: 0 0 24px; max-width: 640px; }
.section-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 32px; }
.section-card { padding: 20px; display: block; color: inherit; transition: transform .12s ease, border-color .12s ease; }
.section-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.section-card .count { font-size: 2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.section-card .label { font-weight: 700; margin: 6px 0 4px; font-size: 1.05rem; }
.section-card p { margin: 0; color: var(--text-2); font-size: .92rem; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search], .toolbar select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; outline: none;
}
.toolbar input[type=search] { flex: 1 1 220px; max-width: 340px; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--link); }
.type-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.type-filter button { cursor: pointer; opacity: .45; border: 0; }
.type-filter button.on, .type-filter button:hover { opacity: 1; }
.result-count { color: var(--text-3); font-size: .88rem; margin-left: auto; }

/* ---------- chips ---------- */
.type { display: inline-block; padding: 2px 9px; border-radius: 999px; color: #fff; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; line-height: 1.6; text-shadow: 0 1px 1px rgba(0,0,0,.25); white-space: nowrap; font-family: inherit; }
.types { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cat { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.cat-physical { background: #f3dfd5; color: #b23c14; }
.cat-special { background: #dde3f7; color: #3453b3; }
.cat-status { background: #e6e6e9; color: #555a66; }
@media (prefers-color-scheme: dark) {
  .cat-physical { background: #4a2a20; color: #ffa27c; }
  .cat-special { background: #25305a; color: #a9bbff; }
  .cat-status { background: #34374a; color: #c5c8d6; }
}
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .04em; vertical-align: middle; }
.badge.neutral { background: var(--surface-2); color: var(--text-2); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .84rem; color: var(--text-2); }

/* type colours */
.t-normal { background: #9fa19f; } .t-fire { background: #e62829; } .t-water { background: #2980ef; }
.t-electric { background: #e0b400; } .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; }
.t-stellar { background: linear-gradient(90deg, #40b5a5, #f2c54a, #e57ab4); } .t-unknown { background: #68a090; }

/* ---------- rumble grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.mon-card { display: flex; flex-direction: column; color: inherit; overflow: hidden; transition: transform .12s ease, border-color .12s ease; }
.mon-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.mon-art { background: radial-gradient(circle at 50% 60%, var(--surface-2), var(--surface) 70%); height: 150px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); position: relative; }
.mon-art img { max-width: 80%; max-height: 132px; object-fit: contain; }
.mon-art img.sprite { image-rendering: pixelated; width: 120px; height: 120px; }
.mon-art .placeholder { font-size: 3rem; opacity: .25; }
.mon-art .shiny { position: absolute; top: 8px; right: 10px; }
.mon-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.mon-name { font-weight: 700; font-size: 1.02rem; line-height: 1.25; }
.mon-species { color: var(--text-2); font-size: .86rem; }
.mon-meta { font-size: .84rem; color: var(--text-2); display: grid; gap: 1px; }
.mon-meta b { color: var(--text); font-weight: 600; }

/* ---------- detail layouts ---------- */
.detail { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.detail > * { min-width: 0; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.profile .mon-art { height: 240px; border-radius: var(--radius) var(--radius) 0 0; }
.profile .mon-art img { max-height: 210px; }
.profile .mon-art img.sprite { width: 192px; height: 192px; }
.facts { margin: 0; padding: 14px 20px 18px; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
.facts dt { color: var(--text-3); font-size: .85rem; padding-top: 1px; }
.facts dd { margin: 0; font-weight: 500; }
.facts dd .desc { display: block; font-weight: 400; color: var(--text-2); font-size: .86rem; margin-top: 2px; }

.stat-block { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat .k { font-size: .78rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 1.25rem; font-weight: 700; margin-top: 2px; }
.description { font-size: 1.05rem; margin: 0; }
.mechanics { color: var(--text-2); margin: 10px 0 0; }
.effects { margin: 0; padding-left: 20px; }
.effects li { margin: 3px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none; }
table.list th.sortable { cursor: pointer; }
table.list th.sortable:hover { color: var(--text); }
table.list th .arrow { font-size: .7rem; margin-left: 3px; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr.clickable { cursor: pointer; }
table.list tbody tr.clickable:hover { background: var(--surface-2); }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.list .name { font-weight: 600; white-space: nowrap; }
table.list .desc-cell { color: var(--text-2); font-size: .88rem; min-width: 240px; }
@media (max-width: 720px) {
  table.list .hide-sm { display: none; }
  table.list .desc-cell { min-width: 160px; }
  table.list th, table.list td { padding: 8px 6px; }
  table.list .name { white-space: normal; }
  table.list .name .badge { display: none; }
}

/* stats table */
.stats-table td, .stats-table th { padding: 6px 8px; }
.stats-table .bar-cell { width: 45%; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--bar); }
.nature-plus { color: var(--bar-plus); font-weight: 700; }
.nature-minus { color: var(--bar-minus); font-weight: 700; }

/* export */
.export { position: relative; }
.export pre { margin: 0; background: var(--surface-2); border-radius: 10px; padding: 14px 16px; overflow-x: auto; white-space: pre; }
.copy-btn { position: absolute; top: 8px; right: 8px; font: inherit; font-size: .8rem; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.copy-btn:hover { border-color: var(--link); }
details.source summary { cursor: pointer; font-weight: 600; }
details.source pre { margin: 12px 0 0; background: var(--surface-2); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }

/* users list */
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); color: inherit; }
.user:hover { text-decoration: none; outline: 1px solid var(--accent); }
.user img { width: 44px; height: 44px; object-fit: contain; }
.user img.sprite { image-rendering: pixelated; }
.user span { font-weight: 600; font-size: .92rem; line-height: 1.25; }

/* search results */
.search-group { margin-bottom: 24px; }
.search-group h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.hit { display: flex; gap: 12px; align-items: center; padding: 10px 14px; color: inherit; }
.hit + .hit { border-top: 1px solid var(--border); }
.hit:hover { background: var(--surface-2); text-decoration: none; }
.hit .hit-name { font-weight: 600; }
.hit .hit-desc { color: var(--text-2); font-size: .88rem; }

/* ---------- Minecraft legacy formatting codes (§0-§f, §k-§o) ---------- */
/* Exact in-game colours. Colours that would vanish into the page background get a soft outline
   in that theme, instead of being recoloured, so §f still reads as white and §0 as black. */
.mc-0 { color: #000000; } .mc-1 { color: #0000aa; } .mc-2 { color: #00aa00; } .mc-3 { color: #00aaaa; }
.mc-4 { color: #aa0000; } .mc-5 { color: #aa00aa; } .mc-6 { color: #ffaa00; } .mc-7 { color: #aaaaaa; }
.mc-8 { color: #555555; } .mc-9 { color: #5555ff; } .mc-a { color: #55ff55; } .mc-b { color: #55ffff; }
.mc-c { color: #ff5555; } .mc-d { color: #ff55ff; } .mc-e { color: #ffff55; } .mc-f { color: #ffffff; }
.mc-l { font-weight: 800; }
.mc-o { font-style: italic; }
.mc-n { text-decoration: underline; }
.mc-m { text-decoration: line-through; }
.mc-n.mc-m { text-decoration: underline line-through; }
.mc-k { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
/* light theme: outline the pale colours */
.mc-6, .mc-7, .mc-a, .mc-b, .mc-d, .mc-e, .mc-f {
  text-shadow: 0 0 1px rgba(0, 0, 0, .9), 0 0 2px rgba(0, 0, 0, .55);
}
@media (prefers-color-scheme: dark) {
  .mc-6, .mc-7, .mc-a, .mc-b, .mc-d, .mc-e, .mc-f { text-shadow: none; }
  .mc-0, .mc-1, .mc-8 { text-shadow: 0 0 1px rgba(255, 255, 255, .9), 0 0 3px rgba(255, 255, 255, .45); }
}
/* the header bar is always dark */
.site-header .mc-6, .site-header .mc-7, .site-header .mc-a, .site-header .mc-b,
.site-header .mc-d, .site-header .mc-e, .site-header .mc-f { text-shadow: none; }
.site-header .mc-0, .site-header .mc-1, .site-header .mc-8 { text-shadow: 0 0 1px rgba(255, 255, 255, .9), 0 0 3px rgba(255, 255, 255, .45); }
/* links keep their colour codes, but still show they're links on hover */
a .mc { text-decoration-color: currentColor; }

/* ---------- regional forms ---------- */
.bar.compare { position: relative; }
.bar.compare > span { position: absolute; left: 0; top: 0; }
.bar.compare > span.ghost { background: var(--text-3); opacity: .35; }
.up { color: #2f9e44; font-weight: 700; }
.down { color: var(--bar-plus); font-weight: 700; }
@media (prefers-color-scheme: dark) { .up { color: #69db7c; } }
.evo { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.evo > li { font-weight: 600; }
.evo .how { font-weight: 400; margin: 4px 0 0; padding-left: 20px; color: var(--text-2); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { font: inherit; font-size: .9rem; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs button.on .muted { color: rgba(255,255,255,.8); }

/* ---------- enchanting ---------- */
.ingredients { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.plus { color: var(--text-3); font-weight: 700; }
.item-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px; font-size: .88rem; white-space: nowrap; }
.item-chip img { width: 20px; height: 20px; image-rendering: pixelated; object-fit: cover; object-position: top; }
.badge.moon { background: #ece6ff; color: #6741d9; }
@media (prefers-color-scheme: dark) { .badge.moon { background: #2e2750; color: #b197fc; } }

/* five sections: let the nav scroll sideways rather than wrap on narrow screens */
.main-nav { overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.main-nav a { white-space: nowrap; }
@media (max-width: 720px) { .main-nav { margin-left: 0; flex: 1 1 0; min-width: 0; } }

.notice { margin-bottom: 16px; border-color: var(--accent); background: var(--accent-soft); }
.main-nav a.external .ext { font-size: .8em; opacity: .7; }
/* keep brand, menu and search on one row on desktop: the menu scrolls and the search shrinks before anything wraps */
@media (min-width: 721px) {
  .header-inner { flex-wrap: nowrap; }
  .main-nav { flex: 0 1 auto; min-width: 0; }
  .search { flex: 0 1 260px; min-width: 150px; }
}
@media (min-width: 721px) and (max-width: 1040px) { .brand-title { display: none; } .header-inner { gap: 14px; } }
@media (min-width: 721px) {
  .search { flex: 0 20 260px; }
}
@media (min-width: 721px) and (max-width: 1040px) { .main-nav a { padding: 6px 9px; } }
.badge.mega-badge { background: linear-gradient(90deg, #ffd6e8, #d6e4ff); color: #7a2e8e; }
@media (prefers-color-scheme: dark) { .badge.mega-badge { background: linear-gradient(90deg, #4a2340, #23304a); color: #f0b3ff; } }

/* ---------- crafting ---------- */
.recipes { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.recipe { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.recipe header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.recipe header h2 { font-size: 1.05rem; margin: 0; }
.recipe .badge.status { flex: none; }
.recipe.status-new .badge.status { background: #d3f9d8; color: #2b8a3e; }
.recipe.status-changed .badge.status { background: #fff3bf; color: #946800; }
.recipe.status-removed .badge.status { background: #ffe3e3; color: #c92a2a; }
@media (prefers-color-scheme: dark) {
  .recipe.status-new .badge.status { background: #1f3d27; color: #8ce99a; }
  .recipe.status-changed .badge.status { background: #3d3418; color: #ffd43b; }
  .recipe.status-removed .badge.status { background: #4a1f22; color: #ffa8a8; }
}
.recipe-body { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.craft-grid { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; padding: 6px; background: #8b8b8b; border-radius: 6px; }
.craft-row { display: flex; gap: 4px; padding: 6px; background: #8b8b8b; border-radius: 6px; }
.slot { width: 44px; height: 44px; background: #c6c6c6; box-shadow: inset 2px 2px 0 #373737, inset -2px -2px 0 #fff; display: flex; align-items: center; justify-content: center; position: relative; }
.slot.blank { background: #b4b4b4; }
.slot img { width: 32px; height: 32px; image-rendering: pixelated; object-fit: cover; object-position: top; }
.slot span { font-size: .72rem; font-weight: 800; color: #373737; letter-spacing: .02em; }
.slot .more { position: absolute; top: 1px; right: 3px; font-size: .62rem; font-style: normal; font-weight: 800; color: #373737; }
.slot.result { width: 56px; height: 56px; }
.slot.result img { width: 40px; height: 40px; }
.slot .count { position: absolute; right: 4px; bottom: 2px; color: #fff; font-size: .9rem; text-shadow: 2px 2px 0 #3f3f3f; }
.slot.crossed::after { content: ""; position: absolute; inset: 6px; background: linear-gradient(45deg, transparent 45%, #e03131 45%, #e03131 55%, transparent 55%); }
.arrow { font-size: 1.8rem; color: var(--text-3); }
.recipe-meta { margin: 0; font-size: .88rem; color: var(--text-2); }
.recipe-meta .station { font-weight: 600; color: var(--text); }
.removed-note { margin: 0; color: var(--text-2); flex: 1; min-width: 160px; }
.lore { background: #1d0f1f; border: 2px solid #2c0b5a; border-radius: 6px; padding: 8px 10px; font-size: .86rem; color: #aaa; }
.original summary { cursor: pointer; font-size: .9rem; color: var(--text-2); }
.original .recipe-body { margin-top: 10px; opacity: .85; }
.original .recipe-meta { margin-top: 8px; }

/* ---------- guides ---------- */
[hidden] { display: none !important; }
.guide-category { margin-bottom: 28px; }
.guide-category h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 10px; }
.guide-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.guide-card { display: block; padding: 16px 18px; color: inherit; transition: transform .12s ease, border-color .12s ease; }
.guide-card:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.guide-card-title { font-weight: 700; font-size: 1.02rem; }
.guide-card p { margin: 6px 0 0; color: var(--text-2); font-size: .92rem; }

.guide-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
.guide-layout.no-toc { grid-template-columns: minmax(0, 1fr); max-width: 860px; }
.guide-layout aside { position: sticky; top: 80px; }
@media (max-width: 860px) {
  .guide-layout { grid-template-columns: minmax(0, 1fr); }
  .guide-layout aside { position: static; }
}
.toc { padding: 14px 10px; display: flex; flex-direction: column; }
.toc-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; padding: 0 8px 6px; }
.toc button { font: inherit; font-size: .9rem; text-align: left; background: none; border: 0; color: var(--text-2); padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.toc button:hover { background: var(--surface-2); color: var(--text); }
.toc button.toc-3 { padding-left: 22px; font-size: .86rem; }

.article-body { padding: 24px 28px; font-size: 1.02rem; line-height: 1.65; overflow-wrap: break-word; }
@media (max-width: 600px) { .article-body { padding: 18px 16px; } }
.article-body > :first-child { margin-top: 0; }
.article-body > :last-child { margin-bottom: 0; }
.article-body h2, .article-body h3, .article-body h4 { scroll-margin-top: 80px; margin: 1.6em 0 .5em; }
.article-body h2 { font-size: 1.35rem; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.article-body h3 { font-size: 1.12rem; }
.article-body p, .article-body ul, .article-body ol, .article-body blockquote, .article-body pre, .article-body .g-table { margin: 0 0 1em; }
.article-body ul, .article-body ol { padding-left: 1.4em; }
.article-body li { margin: .25em 0; }
.article-body li > ul, .article-body li > ol { margin: .25em 0 0; }
.article-body blockquote { border-left: 4px solid var(--accent); background: var(--surface-2); padding: 10px 16px; border-radius: 0 8px 8px 0; color: var(--text-2); }
.article-body blockquote > :last-child { margin-bottom: 0; }
.article-body code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.article-body pre { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.article-body pre code { background: none; border: 0; padding: 0; }
.article-body hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }
.article-body .g-table { overflow-x: auto; }
.article-body table { border-collapse: collapse; min-width: 50%; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.article-body th { background: var(--surface-2); }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; cursor: zoom-in; vertical-align: middle; }
.article-body .g-figure { margin: 1.2em 0; }
.article-body .g-figure > img { display: block; margin: 0 auto; }
.article-body .g-gallery-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.article-body .g-gallery-row img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4 / 3; }
.article-body figcaption { text-align: center; color: var(--text-2); font-size: .9rem; font-style: italic; margin-top: 8px; }
.article-body .g-missing { color: var(--text-3); border: 1px dashed var(--border); border-radius: 6px; padding: 2px 8px; font-size: .88rem; }

/* [[tags]] */
.wl { font-weight: 600; white-space: nowrap; }
.wl .type { font-size: .66rem; padding: 1px 7px; vertical-align: 2px; margin-right: 2px; }
.wl-item img { width: 20px; height: 20px; image-rendering: pixelated; object-fit: cover; object-position: top; vertical-align: -4px; margin-right: 4px; cursor: default; border-radius: 0; }
.wl-broken { font-weight: 400; }

.guide-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.guide-nav a { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; color: inherit; font-weight: 600; }
.guide-nav a:hover { text-decoration: none; border-color: var(--accent); }
.guide-nav a.next { text-align: right; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lightbox button { position: absolute; top: 12px; right: 16px; font-size: 2rem; line-height: 1; color: #fff; background: none; border: 0; cursor: pointer; }

/* highlight after following a link to a recipe */
.flash { animation: flash 2s ease; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
tr.flash { animation: flashrow 2s ease; }
@keyframes flashrow { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ---------- tournament replays ---------- */
.badge.live { background: #dcf5e3; color: #1e7b3c; }
.replay-hit .battle-no { flex: 0 0 82px; font-weight: 700; color: var(--text-2); font-size: .9rem; }
.replay-hit .watch { margin-left: auto; color: var(--link); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.notice { padding: 12px 16px; margin-bottom: 16px; border-left: 4px solid #1e7b3c; }
@media (prefers-color-scheme: dark) { .badge.live { background: #17331f; color: #6fd68f; } }
.winner { margin: 6px 0 0; font-size: .95rem; }
.guide-card p.winner { color: var(--text); }
.page-head .winner { font-size: 1.05rem; }
.winner-photo { margin: 4px 0 20px; text-align: center; }
.winner-photo img { max-width: 100%; max-height: 520px; border-radius: var(--radius); box-shadow: var(--shadow); cursor: zoom-in; display: inline-block; }
.badge.cat-champion { background: #fff1d6; color: #9a5b00; }
.badge.cat-vgc { background: #e1ecff; color: #1f4fb0; }
.badge.cat-monotype { background: #dcf3ec; color: #136f55; }
.badge.cat-randomiser { background: #ece6ff; color: #6741d9; }
.badge.cat-pokeskins-rumble { background: #ffe1f2; color: #a8327a; }
@media (prefers-color-scheme: dark) {
  .badge.cat-champion { background: #3a2c10; color: #ffc766; }
  .badge.cat-vgc { background: #182a4a; color: #8fb4ff; }
  .badge.cat-monotype { background: #12332a; color: #6fd6b4; }
  .badge.cat-randomiser { background: #2a2245; color: #b9a6ff; }
  .badge.cat-pokeskins-rumble { background: #3d1a30; color: #ff9fd4; }
}
