/* factorio-blueprints: direction A of the design, "factory panel". Dark only, as in the design. */
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/titillium-web-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/titillium-web-600-latin.woff2) format('woff2'); }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 700; font-display: swap; src: url(fonts/titillium-web-700-latin.woff2) format('woff2'); }
@font-face { font-family: 'Titillium Web'; font-style: normal; font-weight: 900; font-display: swap; src: url(fonts/titillium-web-900-latin.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400 600; font-display: swap; src: url(fonts/jetbrains-mono-latin.woff2) format('woff2'); }

:root {
  --bg: #171614; --bar: #1f1d1b; --panel: #242220; --inset: #121110; --ghost: #1c1b19;
  --chip: #2e2b28; --pressed: #3a3631;
  --line: #3d3935; --line-soft: #34302c; --line-chip: #4a4540; --line-strong: #6b645b; --dash: #5a544c;
  --text: #efe9df; --text-2: #d9d1c4; --text-3: #c9c0b2; --muted: #b5ab9c; --muted-2: #9d9486; --icon-muted: #8c8376;
  --accent: #f2a531; --accent-hover: #ffc766; --accent-ink: #1a1400;
  --ok: #8fd07c; --ok-bg: #1d2a1a; --ok-line: #3f5f35; --warn: #e9c53f; --warn-bg: #2a2614; --warn-line: #5f5530;
  --error: #f08a74;
  --radius: 6px; --gutter: 48px; --maxw: 1280px;
  --bevel: inset 0 1px 0 rgba(255, 255, 255, 0.05), inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  --sans: 'Titillium Web', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 16px; scroll-padding-bottom: var(--consent-h, 0px); }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.5; padding-bottom: var(--consent-h, 0px); }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.1; }
h1 { font-size: 52px; font-weight: 900; }
h2 { font-size: 30px; font-weight: 900; }
h3, .h3 { font-size: 20px; font-weight: 700; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--inset); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.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 { position: absolute; left: 16px; top: -60px; z-index: 10; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 4px; font-weight: 700; text-decoration: none; }
.skip:focus { top: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.accent { color: var(--accent); font-weight: 600; }
.icon { flex-shrink: 0; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 0 18px; border-radius: 4px; border: 1px solid var(--line-chip); background: var(--chip); color: var(--text); font-weight: 700; font-size: 16px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--pressed); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--chip); color: var(--accent-hover); }
.btn-lg { min-height: 52px; font-size: 17px; padding: 0 22px; }
.btn[data-state="done"] { border-color: var(--ok-line); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 4px; border: 1px solid var(--line-chip); background: var(--chip); color: var(--text); padding: 0; }
.btn-icon:hover { background: var(--pressed); }
.btn-icon[aria-pressed="true"] { background: var(--pressed); border-color: var(--line-strong); }
.btn-icon[data-state="done"] { color: var(--ok); border-color: var(--ok-line); }
.btn[data-state="error"], .btn-icon[data-state="error"] { color: var(--error); border-color: var(--error); }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--consent-h, 0px)); transform: translateX(-50%); z-index: 20; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: var(--radius); background: var(--pressed); border: 1px solid var(--ok-line); color: var(--text); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.toast-error { border-color: var(--error); }
.consent { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 19; width: calc(100% - 32px); max-width: 780px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; display: flex; align-items: center; flex-wrap: wrap; gap: 14px 24px; padding: 16px 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line-strong); box-shadow: var(--bevel), 0 8px 24px rgba(0, 0, 0, 0.45); color: var(--text-2); font-size: 15px; line-height: 1.5; }
.consent-body { flex: 1 1 340px; }
.consent-title { margin-bottom: 2px; font-size: 17px; font-weight: 900; color: var(--text); }
.consent-actions { display: flex; gap: 10px; flex: 0 0 auto; }
.consent-actions .btn { min-width: 120px; }
@media (max-height: 520px) { .consent { position: static; transform: none; width: auto; max-width: none; max-height: none; margin: 16px; } }  /* landscape phones and 400% zoom: in the flow, never over the page */
/* without JavaScript nothing can be copied and the viewer cannot draw: show only what works (downloads, lists) */
html:not(.js) [data-copy], html:not(.js) .tabs, html:not(.js) .variants, html:not(.js) .matrix-controls,
html:not(.js) .matrix-axes, html:not(.js) .legend, html:not(.js) .selected, html:not(.js) .filters,
html:not(.js) .cat-chips, html:not(.js) .toolbar .select-label, html:not(.js) .view-toggle,
html:not(.js) .matrix-hint, html:not(.js) .toolbar .search-field { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 9px; border-radius: 3px; background: var(--chip); border: 1px solid var(--line-chip); font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; text-decoration: none; }
a.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip-ok { color: var(--ok); }
.arrow-link, .more { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; text-decoration: none; }
.more { font-size: 15px; font-weight: 600; padding-top: 6px; }
.source { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 3px; border: 1px dashed var(--line-strong); font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; white-space: nowrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bevel); padding: 20px 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.panel-head h2 { font-size: 24px; }
.panel-head h3 { font-size: 20px; font-weight: 900; }
.search-field { flex-grow: 1; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; background: var(--inset); border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); }
.search-field:focus-within { border-color: var(--accent); }
.search-field input { flex-grow: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font-size: 17px; outline: none; padding: 12px 0; }
.search-field input::placeholder { color: var(--muted-2); opacity: 1; }
select { min-height: 44px; padding: 0 12px; background: var(--chip); color: var(--text); border: 1px solid var(--line-chip); border-radius: 4px; font-size: 15px; }

/* ---------- test badges ---------- */
.test { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.test-dot { width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.test-in-game { color: var(--ok); }
.test-simulation { color: var(--warn); }
.test-untested { color: var(--muted-2); }
.test-big { font-size: 17px; }
.test-banner { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); background: var(--chip); border: 1px solid var(--line-chip); font-size: 15px; color: var(--text-3); }
.test-banner-in-game { background: var(--ok-bg); border-color: var(--ok-line); }
.test-banner-simulation { background: var(--warn-bg); border-color: var(--warn-line); }
.test-banner a { font-weight: 600; }

/* ---------- header / footer ---------- */
.topbar { background: var(--bar); border-bottom: 1px solid var(--line); }
.topbar-inner { min-height: 72px; display: flex; align-items: center; gap: 36px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 20px; }
.brand:hover { color: var(--text); }
.menu { display: flex; align-items: center; gap: 36px; flex-grow: 1; }
.nav { display: flex; gap: 26px; font-size: 16px; font-weight: 600; }
.nav a { color: var(--text-3); text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"], .nav a.is-active { color: var(--text); border-bottom-color: var(--accent); }
.brand span, .nav a { white-space: nowrap; }
.top-search .search-field-sm { min-height: 40px; width: 220px; padding: 0 12px; }
.top-search .search-field-sm input { font-size: 15px; padding: 8px 0; }
.news-titles { display: flex; flex-wrap: wrap; gap: 0 6px; font-weight: 700; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.lang { display: flex; border: 1px solid var(--line-chip); border-radius: 4px; overflow: hidden; }
.lang a { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 36px; padding: 0 10px; color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; }
.lang a + a { border-left: 1px solid var(--line-chip); }
.lang a:hover { color: var(--text); background: var(--chip); }
.lang a[aria-current="true"] { background: var(--pressed); color: var(--text); font-weight: 700; }
.gh { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 15px; }
.menu-btn { display: none; margin-left: auto; background: transparent; border-color: transparent; }
.footer { margin-top: 64px; border-top: 1px solid var(--line); background: var(--bar); color: var(--muted); font-size: 15px; line-height: 1.6; }
.footer-inner { padding-top: 32px; padding-bottom: 32px; display: flex; justify-content: space-between; align-items: flex-start; gap: 24px 48px; flex-wrap: wrap; }
.footer-text { display: flex; flex-direction: column; gap: 4px; max-width: 640px; }
.footer-text strong { color: var(--text); }
.footer-links { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; text-align: right; }
.footer-links a, .link-btn { font-weight: 600; text-decoration: none; }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent); text-align: inherit; }
.link-btn:hover { color: var(--accent-hover); }

/* ---------- sections ---------- */
.section { padding-top: 56px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head { padding-top: 36px; padding-bottom: 24px; display: flex; flex-direction: column; gap: 14px; }
.page-head h1 { font-size: 44px; line-height: 1.05; }
.lead { font-size: 18px; line-height: 1.55; color: var(--text-3); max-width: 820px; }

/* ---------- home ---------- */
.hero { padding-top: 64px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 32px 24px; align-items: start; }
.hero-main { grid-column: span 8; display: flex; flex-direction: column; gap: 22px; }
.hero-title { font-size: 58px; line-height: 1.02; font-weight: 900; max-width: 760px; }
.search-form { display: flex; gap: 10px; max-width: 760px; }
.search-form .search-field { min-height: 56px; }
.search-form .search-field input { font-size: 18px; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 15px; color: var(--muted); }
.news { grid-column: span 4; display: flex; flex-direction: column; gap: 4px; }
.news .panel-head h2 { font-size: 20px; }
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; }
.news-list li + li { border-top: 1px solid var(--line); }
.news-title { color: var(--text); font-weight: 700; text-decoration: none; }
.news-subject { color: var(--text-3); font-size: 15px; text-decoration: none; }
.news-subject:hover, .news-title:hover { text-decoration: underline; }
.cat-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.cat { height: 100%; min-height: 112px; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bevel); color: var(--text); text-decoration: none; }
.cat:hover { border-color: var(--line-strong); color: var(--text); }
.cat-icon { color: var(--accent); }
.cat-name { font-size: 16px; font-weight: 700; line-height: 1.2; }
.cat-count { margin-top: auto; font-size: 13px; color: var(--muted); }
.cat-empty { background: var(--ghost); border-style: dashed; border-color: var(--dash); box-shadow: none; }
.cat-empty .cat-icon { color: var(--icon-muted); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps li div { display: flex; flex-direction: column; gap: 2px; }
.steps strong { font-size: 18px; }
.steps span:not(.step-num) { font-size: 15px; line-height: 1.5; color: var(--text-3); }
.step-num { width: 34px; height: 34px; flex-shrink: 0; border-radius: 4px; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.import { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px 24px; }
.import h2 { grid-column: span 3; }
.import .steps { grid-column: span 9; }
.seal-grid { margin-top: 18px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.seal { display: flex; flex-direction: column; gap: 8px; }
.seal p { font-size: 15px; line-height: 1.55; color: var(--text-3); }

/* ---------- cards ---------- */
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.card { position: relative; display: flex; flex-direction: column; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bevel); }
.card:hover { border-color: var(--line-strong); }
.card-media { height: 190px; background: var(--inset); border-bottom: 1px solid var(--line); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex-grow: 1; }
.card-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.card-title { font-size: 22px; font-weight: 900; line-height: 1.15; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a::after { content: ''; position: absolute; inset: 0; }
.card-title a:focus-visible { outline: none; }
.card:has(.card-title a:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.card-summary { font-size: 15px; line-height: 1.5; color: var(--text-3); }
.card-facts { color: var(--muted); }
.card-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-actions { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.card-date { font-size: 13px; color: var(--muted-2); white-space: nowrap; }
.card-ghost { background: var(--ghost); border-style: dashed; border-color: var(--dash); box-shadow: none; }
.card-ghost .card-title { color: var(--text-2); }
.card-ghost-icon { color: var(--icon-muted); }

/* ---------- catalog ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar .search-field { min-width: 260px; }
.select-label { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.select-label select { min-height: 52px; }
.view-toggle { display: flex; gap: 4px; }
.view-toggle .btn-icon { width: 52px; height: 52px; }
.cat-chips { display: none; }
.catalog { display: flex; gap: 28px; align-items: flex-start; }
.filters { width: 260px; flex-shrink: 0; position: sticky; top: 16px; }
.filters-toggle { display: none; }
.filters-body { display: flex; flex-direction: column; gap: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--bevel); padding: 18px; }
.fgroup { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fgroup legend { font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; padding: 0; }
.fbtn { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--text); text-align: left; font-size: 15px; }
.fbtn:hover { background: var(--chip); }
.fbtn[aria-pressed="true"] { background: var(--pressed); border-color: var(--accent); }
.fbtn[data-zero] { color: var(--muted-2); }
.fcount { font-size: 13px; color: var(--muted); font-weight: 600; }
.fchips { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--line-chip); background: transparent; color: var(--text-2); font-size: 14px; font-weight: 600; white-space: nowrap; }
.fchip:hover { border-color: var(--line-strong); }
.fchip[aria-pressed="true"] { background: var(--pressed); border-color: var(--accent); color: var(--text); }
.results { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.results-head { display: flex; justify-content: space-between; align-items: center; min-height: 44px; font-size: 16px; color: var(--text-3); }
.results-count strong { color: var(--text); }
/* next to the filters there is room for two readable cards, not three */
.card-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card-grid-2 .card-media { height: 170px; }
.card-grid-2 .card-title { font-size: 20px; }
.card-grid[data-view="list"] { grid-template-columns: 1fr; gap: 10px; }
.card-grid[data-view="list"] .card { flex-direction: row; align-items: center; gap: 18px; padding: 12px 16px; }
.card-grid[data-view="list"] .card-media { width: 120px; height: 90px; border: 1px solid var(--line); border-radius: 4px; flex-shrink: 0; }
.card-grid[data-view="list"] .card-body { padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 18px; row-gap: 4px; align-items: center; }
.card-grid[data-view="list"] .card-meta { grid-column: 1; order: 2; justify-content: flex-start; gap: 12px; }
.card-grid[data-view="list"] .card-title { grid-column: 1; order: 1; font-size: 19px; }
.card-grid[data-view="list"] .card-summary { grid-column: 1; order: 3; }
.card-grid[data-view="list"] .chips { grid-column: 1; order: 4; }
.card-grid[data-view="list"] .card-facts { grid-column: 2; grid-row: 1; text-align: right; }
.card-grid[data-view="list"] .card-foot { grid-column: 2; grid-row: 2 / span 3; border: 0; padding: 0; flex-direction: column; align-items: flex-end; }
.empty { background: var(--ghost); border: 1px dashed var(--dash); border-radius: var(--radius); padding: 40px; text-align: center; font-size: 17px; color: var(--text-3); }

/* ---------- blueprint page ---------- */
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb [aria-current] { color: var(--text); }
.bp-head { flex-direction: row; justify-content: space-between; align-items: flex-end; gap: 32px 40px; }
.bp-head-main { display: flex; flex-direction: column; gap: 12px; max-width: 800px; min-width: 0; }
.bp-head h1 { font-size: 52px; line-height: 1.02; }
.bp-actions { display: flex; flex-direction: column; gap: 10px; min-width: 260px; }
.bp-actions .btn { white-space: normal; text-align: center; }
.gallery { margin: 0; padding: 10px; display: flex; flex-direction: column; gap: 12px; }
.gallery-main { display: block; border-radius: 3px; overflow: hidden; background: var(--inset); }
.gallery-main img { width: 100%; max-height: 640px; object-fit: contain; }
.gallery-caption { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; padding: 2px 4px; font-size: 15px; }
.gallery-caption a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { display: block; border: 1px solid var(--line-chip); border-radius: 3px; overflow: hidden; }
.thumb img { width: 110px; height: 82px; object-fit: cover; }
.thumb[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.stats { margin-top: 12px; padding: 10px 0 0; }
.stats > .source { margin-left: auto; margin-right: 14px; display: flex; width: fit-content; }
.stats-grid { margin: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats-grid div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 4px; padding: 16px 20px 18px; }
.stats-grid div + div { border-left: 1px solid var(--line); }
.stats-grid dd { margin: 0; font-size: 28px; font-weight: 900; line-height: 1; color: var(--accent); }
.stats-grid dt { font-size: 15px; color: var(--text-3); }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; }
.rows li + li { border-top: 1px solid var(--line); }
.row-name { font-weight: 700; }
.row-value { font-size: 15px; color: var(--text-3); text-align: right; }
.rows-tight li { padding: 6px 0; font-size: 15px; }
.rows-tight li + li { border-top-color: var(--line-soft); }
.rows-tight .row-name { font-weight: 400; color: var(--text-2); }
/* A game icon in front of a name: build.py packs the sprite, the page's <style> sets its image and grid, --x and --y pick the cell. */
.ic { --s: 28px; flex: none; width: var(--s); height: var(--s); background-repeat: no-repeat; background-size: calc(var(--s) * var(--ic-cols)) calc(var(--s) * var(--ic-rows)); background-position: calc(var(--s) * var(--x) * -1) calc(var(--s) * var(--y) * -1); }
.ic.ic-none { background: none; }  /* two classes: wins over the page's <style>, which comes after this file */
.rows-tight .ic { --s: 24px; }
.rows-icons li { padding-top: 8px; padding-bottom: 8px; }
.rows-icons.rows-tight li { padding-top: 4px; padding-bottom: 4px; }
.rows-icons .row-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rows-title { margin: 14px 0 4px; padding-top: 12px; border-top: 2px solid var(--line-chip); font-size: 15px; font-weight: 700; color: var(--text-2); }
.more-rows { margin-top: 6px; }
.more-rows summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 15px; padding: 8px 0; }
.report { columns: 2; column-gap: 24px; }
.report > .panel { break-inside: avoid; margin-bottom: 24px; display: inline-block; width: 100%; }
.prose { font-size: 16px; line-height: 1.6; color: var(--text-3); }
.prose p, .prose ul, .prose ol, .prose .table-wrap, .prose pre { margin: 0 0 12px; }
.prose > :last-child { margin-bottom: 0; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 4px; }
.prose h4, .prose h3:not(.panel-head h3) { font-size: 17px; font-weight: 700; color: var(--text); margin: 16px 0 8px; }
.prose strong { color: var(--text); }
.privacy > * { max-width: 780px; }
.privacy h2 { margin: 32px 0 10px; font-size: 24px; color: var(--text); }
.privacy > :first-child { margin-top: 0; }
.prose pre { background: var(--inset); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--text-2); }
.prose pre code { background: none; border: 0; padding: 0; }
.table-wrap { overflow-x: auto; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; }
.prose th { text-align: left; font-size: 14px; color: var(--muted); font-weight: 600; padding: 0 12px 8px 0; }
.prose td { padding: 9px 12px 9px 0; border-top: 1px solid var(--line); vertical-align: top; }
.big-section { margin-bottom: 24px; }
.big-section summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; list-style: none; }
.big-section summary::-webkit-details-marker { display: none; }
.big-section summary h3 { font-size: 20px; font-weight: 900; }
.big-section[open] summary { margin-bottom: 12px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; gap: 20px; align-items: baseline; padding: 14px 0; flex-wrap: wrap; }
.history li + li { border-top: 1px solid var(--line); }
.history-subject { flex-grow: 1; font-weight: 700; font-size: 17px; }
.section-last { padding-bottom: 8px; }

/* ---------- book page ---------- */
.book-bar { padding-top: 28px; padding-bottom: 20px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] { min-height: 44px; padding: 0 16px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 700; font-size: 17px; }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs [role="tab"]:hover { color: var(--text); }
.variants { display: flex; gap: 6px; padding: 4px; background: var(--inset); border: 1px solid var(--line); border-radius: var(--radius); }
.variants button { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 4px; border: 1px solid transparent; background: transparent; color: var(--text); font-weight: 600; font-size: 15px; }
.variants button[aria-pressed="true"] { background: var(--pressed); border-color: var(--line-strong); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }
.matrix-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 16px; }
.mode-toggle { display: flex; align-items: center; gap: 6px; }
.mode-toggle .muted { margin-right: 4px; font-size: 15px; }
.mode-toggle button { min-height: 40px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--line); background: transparent; color: var(--text); font-weight: 600; font-size: 15px; }
.mode-toggle button[aria-pressed="true"] { background: var(--pressed); border-color: var(--line-strong); }
.pair-select { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); }
.pair-select label { display: flex; align-items: center; gap: 8px; }
.matrix-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 440px); gap: 24px; align-items: start; }
.matrix-wrap { padding: 18px; display: flex; flex-direction: column; gap: 12px; container-type: inline-size; min-width: 0; }
.matrix-hint { margin-bottom: 2px; }
/* the cells shrink with the panel (container query units) and never grow past the design's 24px */
.matrix-axes { --gap: 4px; --cell: clamp(7px, calc((100cqi - 58px) / var(--size, 24) - var(--gap)), 24px); display: grid; grid-template-columns: 20px auto; grid-template-rows: auto auto; gap: 6px 8px; justify-content: start; }
.axis-x { grid-column: 2; font-size: 14px; }
.axis-y { grid-column: 1; grid-row: 2; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 14px; text-align: right; }
.matrix { grid-column: 2; grid-row: 2; display: grid; gap: var(--gap); grid-template-columns: 22px repeat(var(--size, 24), var(--cell)); align-items: center; }
.matrix .lbl { font-family: var(--mono); font-size: 11px; color: var(--muted-2); text-align: center; }
.matrix .lbl-row { text-align: right; padding-right: 4px; }
.matrix [role="row"] { display: contents; }
.matrix button { width: var(--cell); height: var(--cell); padding: 0; border-radius: 3px; border: 1px solid rgba(0, 0, 0, 0.35); background: var(--c, #333); }
.matrix button:hover { outline: 2px solid var(--text-2); outline-offset: 0; }
.matrix button[aria-selected="true"] { border: 2px solid #fff; box-shadow: 0 0 0 2px var(--bg); }
.matrix button:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.legend { list-style: none; margin: 0; padding: 4px 0 0; display: flex; flex-wrap: wrap; gap: 10px 20px; font-size: 15px; color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 8px; }
.legend .swatch { width: 14px; height: 14px; border-radius: 3px; }
.selected { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.selected-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.selected-head > div { display: flex; flex-direction: column; gap: 4px; }
.selected-head h2 { font-size: 44px; line-height: 1; }
.origin-badge { display: inline-flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 10px; border-radius: 3px; background: var(--chip); border: 1px solid var(--line-chip); font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; flex-shrink: 0; }
.origin-badge::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--c, transparent); flex-shrink: 0; }
.preview { min-height: 300px; max-height: 460px; display: flex; align-items: center; justify-content: center; padding: 12px; background: var(--inset); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.preview svg { width: 100%; height: 100%; max-height: 430px; }
.sel-stats { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sel-stats div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 2px; padding: 12px 14px; background: var(--chip); border-radius: 4px; }
.sel-stats dt { font-size: 13px; color: var(--muted); }
.sel-stats dd { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.2; }
.sel-variants { display: flex; flex-direction: column; gap: 8px; color: var(--accent); }
.sel-variant-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.sel-variant-buttons button { min-height: 36px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--line-chip); background: transparent; color: var(--text); font-weight: 600; }
.sel-variant-buttons button[aria-pressed="true"] { background: var(--pressed); border-color: var(--accent); }
.sel-desc { display: flex; flex-direction: column; gap: 6px; }
.sel-desc h3 { font-size: 14px; color: var(--text-2); }
.sel-desc p { line-height: 1.6; color: var(--text-3); white-space: pre-line; overflow-wrap: anywhere; }
.verif { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; line-height: 1.5; color: var(--ok); }
.sel-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.contents { padding: 0; margin-top: 12px; overflow: hidden; }
.contents-title { display: flex; align-items: center; gap: 10px; padding: 16px 20px; font-size: 20px; }
.contents-list { list-style: none; margin: 0; padding: 0; }
.contents-list li { display: grid; grid-template-columns: 20px 140px minmax(0, 1fr) 150px 44px; align-items: center; gap: 16px; padding: 8px 20px; border-top: 1px solid var(--line-soft); }
.contents-label { font-weight: 700; font-size: 17px; }
.contents-desc { font-size: 15px; color: var(--text-3); }
.about-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.about-grid .h3 { margin-bottom: 8px; }
#panel-about .section:first-of-type { padding-top: 24px; }
.not-found { gap: 28px; padding-top: 64px; }
.nf-block { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.nf-block h2 { font-size: 28px; }

/* ---------- tablet ---------- */
@media (max-width: 1100px) {
  :root { --gutter: 32px; }
  .hero-main, .news { grid-column: span 12; }
  .cat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid-2 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats-grid div:nth-child(3n + 1) { border-left: 0; }
  .stats-grid div:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .matrix-layout { grid-template-columns: 1fr; }
  .selected { position: static; }
  .about-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import h2, .import .steps { grid-column: span 12; }
  .bp-head { flex-direction: column; align-items: stretch; }
  .bp-actions { flex-direction: row; flex-wrap: wrap; min-width: 0; }
  /* the links drop under the text once the footer wraps: align them with it */
  .footer-links { align-items: flex-start; text-align: left; }
}

/* ---------- header: search only where it fits, compact menu below 900px ---------- */
@media (min-width: 901px) and (max-width: 1140px) {
  .top-search { display: none; }
}
@media (max-width: 900px) {
  .js .topbar-inner { min-height: 56px; gap: 10px; flex-wrap: wrap; }
  .js .menu-btn { display: inline-flex; }
  .js .menu { display: none; }
  .js .topbar[data-open] .menu { display: flex; }
  .menu { flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 16px; padding: 8px 0 16px; }
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding-top: 8px; padding-bottom: 8px; }
  .nav { flex-direction: column; gap: 0; }
  .nav a { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
  .nav a[aria-current="page"], .nav a.is-active { border-bottom-color: var(--accent); }
  .topbar-end { margin-left: 0; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
  .top-search { flex-basis: 100%; }
  .top-search .search-field-sm { width: 100%; min-height: 48px; }
  .lang a { min-width: 44px; min-height: 44px; }
}

/* ---------- phone ---------- */
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  .section-head .source { white-space: normal; padding-block: 2px; line-height: 1.3; }
  h1, .page-head h1, .bp-head h1 { font-size: 34px; }
  h2 { font-size: 26px; }
  .hero { padding-top: 32px; }
  .hero-title { font-size: 38px; }
  .search-form { flex-direction: column; }
  .brand { font-size: 18px; }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid, .card-grid-2, .seal-grid, .steps, .two-col, .about-grid { grid-template-columns: 1fr; }
  .toolbar .search-field { min-width: 0; flex-basis: 100%; }
  .view-toggle { display: none; }
  .cat-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 calc(-1 * var(--gutter)); padding-left: var(--gutter); padding-right: var(--gutter); scrollbar-width: none; }
  .cat-chips .fchip { min-height: 40px; }
  .catalog { flex-direction: column; align-items: stretch; gap: 12px; }
  .filters { width: 100%; position: static; }
  .js .filters-toggle { display: inline-flex; }
  .js .filters-body { display: none; margin-top: 10px; }
  .js .filters[data-open] .filters-body { display: flex; }
  .fgroup-cat { display: none; }
  /* compact rows, as in the phone design */
  .card-grid-2 .card, .card-grid .card { flex-direction: row; align-items: center; gap: 12px; padding: 10px; min-height: 84px; }
  .card-grid-2 .card-media, .card-grid .card-media { width: 72px; height: 72px; border: 0; border-radius: 4px; flex-shrink: 0; }
  .card-grid .card-body { padding: 0; gap: 2px; }
  .card-grid .card-summary, .card-grid .card-facts, .card-grid .chips, .card-grid .card-date { display: none; }
  .card-grid .card-title { font-size: 17px; line-height: 1.2; }
  .card-grid .card-meta span + span { display: none; }
  .card-grid .card-foot { border: 0; padding: 0; margin-top: 2px; }
  .card-grid .test { font-size: 13px; }
  .card-grid .card-ghost { display: block; }
  .card-ghost .card-body { gap: 6px; }
  .card-ghost .card-summary { display: block; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid div:nth-child(3n + 1) { border-left: 1px solid var(--line); }
  .stats-grid div:nth-child(2n + 1) { border-left: 0; }
  .stats-grid div:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .stats-grid dd { font-size: 24px; }
  .report { columns: 1; }
  .bp-actions .btn { flex-grow: 1; }
  .gallery-main img { max-height: 70vh; }
  .book-bar { align-items: stretch; }
  .tabs { overflow-x: auto; }
  .tabs [role="tab"] { padding: 0 12px; font-size: 16px; white-space: nowrap; }
  .variants { flex-wrap: wrap; }
  .variants button { flex-grow: 1; justify-content: center; }
  .matrix-axes { --gap: 2px; --cell: clamp(7px, calc((100cqi - 50px) / var(--size, 24) - var(--gap)), 24px); grid-template-columns: 16px auto; }
  /* cells are ~10px wide here: only 1, 4, 8 ... 24 are labelled, in a readable size */
  .matrix .lbl { font-size: 10px; overflow: visible; white-space: nowrap; }
  .matrix .lbl:not([data-major]) { visibility: hidden; }
  /* touch targets of at least 44px (WCAG 2.5.8) */
  a.chip, .breadcrumb a, .test-banner a, .gallery-caption a, .history a, .more, .arrow-link { display: inline-flex; align-items: center; min-height: 44px; }
  .variants button, .mode-toggle button, .fbtn, .fchip, .cat-chips .fchip, .sel-variant-buttons button { min-height: 44px; }
  .big-section summary, .footer-links a, .footer-links .link-btn { display: flex; align-items: center; min-height: 44px; }
  .consent { padding: 14px 16px; }
  .consent-actions { width: 100%; }
  .consent-actions .btn { flex: 1 1 0; min-width: 0; }
  .more-rows summary { padding: 11px 0; }  /* stays display: list-item so the ▸ marker is drawn; 22px text + 22px = 44px */
  .matrix button { border-radius: 2px; }
  .matrix-wrap { padding: 12px; }
  .pair-select { width: 100%; justify-content: space-between; }
  .pair-select select { min-width: 72px; }
  .selected-head h2 { font-size: 36px; }
  .sel-stats { gap: 8px; }
  .sel-stats div { padding: 10px; }
  .sel-stats dd { font-size: 17px; }
  .preview { min-height: 240px; }
  .contents-list li { grid-template-columns: 20px minmax(0, 1fr) 44px; gap: 4px 12px; }
  .contents-desc { grid-column: 2; }
  .contents-list .mono { grid-column: 2; }
  .contents-list .btn-icon { grid-column: 3; grid-row: 1 / span 3; }
}

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