/* PenguinEHIS wiki. Colours are tokens; dark mode follows the system unless the reader picks one. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --line: #ddd8cc;
  --text: #1f2328;
  --muted: #5d636b;
  --accent: #b3261e;        /* red alloy */
  --accent-soft: #fbe9e7;
  --link: #9c1f18;
  --blue: #1d5fb8;          /* blue alloy */
  --code-bg: #f1eee6;
  --slot: #8b8b8b;
  --slot-edge-dark: #373737;
  --slot-edge-light: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
  --note: #1d5fb8;
  --tip: #1f7a3a;
  --warning: #9a6700;
  --radius: 10px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --surface: #1b1e23; --surface-2: #23272e; --line: #31363e; --text: #e6e3dc;
    --muted: #9aa1aa; --accent: #ef5a4f; --accent-soft: #3a1d1b; --link: #ff8a80; --blue: #7aa8ff;
    --code-bg: #20242a; --slot: #3a3d42; --slot-edge-dark: #101113; --slot-edge-light: #5a5e65;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --note: #7aa8ff; --tip: #5fcf83; --warning: #e3b341;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --surface: #1b1e23; --surface-2: #23272e; --line: #31363e; --text: #e6e3dc;
  --muted: #9aa1aa; --accent: #ef5a4f; --accent-soft: #3a1d1b; --link: #ff8a80; --blue: #7aa8ff;
  --code-bg: #20242a; --slot: #3a3d42; --slot-edge-dark: #101113; --slot-edge-light: #5a5e65;
  --shadow: 0 1px 2px rgb(0 0 0 / .4); --note: #7aa8ff; --tip: #5fcf83; --warning: #e3b341;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--sans); -webkit-text-size-adjust: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
img { max-width: 100%; }
code, kbd, pre { font-family: var(--mono); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 99; background: var(--surface); padding: 6px 10px; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand img { image-rendering: pixelated; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand small { font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: .02em; }
.top-nav { display: flex; gap: 4px; }
.top-nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 500; }
.top-nav a:hover, .top-nav a[aria-current] { color: var(--text); background: var(--surface-2); }
.search { position: relative; margin-left: auto; width: min(360px, 40vw); }
.search input {
  width: 100%; height: 38px; padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search kbd { position: absolute; right: 8px; top: 8px; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.search-results {
  position: absolute; top: 44px; right: 0; width: min(440px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 12px 40px rgb(0 0 0 / .18);
}
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none; }
.search-results a img, .search-results .glyph { width: 28px; height: 28px; flex: none; image-rendering: pixelated; }
.search-results .glyph { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); border-radius: 6px; font-weight: 700; font-size: 13px; }
.search-results li[aria-selected="true"] a, .search-results a:hover { background: var(--surface-2); }
.search-results small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.search-results .none { padding: 10px; color: var(--muted); }
.theme-button, .menu-button { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }
.menu-button { display: none; }
.menu-button span, .menu-button span::before, .menu-button span::after { display: block; width: 16px; height: 2px; background: currentColor; position: relative; content: ""; }
.menu-button span::before { position: absolute; top: -5px; } .menu-button span::after { position: absolute; top: 5px; }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 40px; max-width: 1400px; margin: 0 auto; padding: 0 20px; }
.layout.wide { grid-template-columns: 250px minmax(0, 1fr); }
.home .layout { grid-template-columns: minmax(0, 1fr); max-width: 1180px; }
.home .sidebar { display: none; }
.sidebar { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow: auto; padding: 24px 4px 40px 0; font-size: 14.5px; }
.sidebar details { margin-bottom: 4px; }
.sidebar summary { cursor: pointer; padding: 6px 8px; border-radius: 6px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::after { content: "+"; color: var(--muted); }
.sidebar details[open] summary::after { content: "−"; }
.sidebar summary:hover { background: var(--surface-2); }
.sidebar ul { list-style: none; margin: 2px 0 10px; padding: 0 0 0 10px; border-left: 1px solid var(--line); margin-left: 8px; }
.sidebar li a { display: block; padding: 4px 10px; color: var(--muted); text-decoration: none; border-radius: 6px; line-height: 1.4; }
.sidebar li a:hover { color: var(--text); background: var(--surface-2); }
.sidebar li a[aria-current] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.content { min-width: 0; padding: 28px 0 64px; }
.toc { position: sticky; top: 60px; align-self: start; padding: 32px 0; font-size: 13.5px; max-height: calc(100vh - 60px); overflow: auto; }
.toc p { margin: 0 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 3px 12px; color: var(--muted); text-decoration: none; line-height: 1.4; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.footer { border-top: 1px solid var(--line); padding: 24px 20px 40px; text-align: center; color: var(--muted); font-size: 14px; }
.footer p { margin: 4px 0; }

/* ---------------------------------------------------------------- prose */
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.prose { max-width: 780px; }
.prose h1, .item-title h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
.lede { font-size: 19px; color: var(--muted); margin: 0 0 28px; line-height: 1.55; }
.prose h2 { font-size: 25px; letter-spacing: -.01em; margin: 44px 0 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.prose h3 { font-size: 19px; margin: 30px 0 8px; }
.prose h2, .prose h3 { position: relative; }
.anchor { position: absolute; left: -22px; color: var(--muted); text-decoration: none; opacity: 0; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
.prose p, .prose li { max-width: 74ch; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--muted); }
.prose :not(pre) > code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 4px; padding: .05em .35em; font-size: .88em; }
.prose kbd { font-size: .85em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--surface); }
.prose pre { position: relative; background: #1b1d22; color: #e8e4da; border-radius: var(--radius); padding: 16px 18px; overflow-x: auto; font-size: 14px; line-height: 1.55; }
.prose pre code { background: none; border: 0; padding: 0; }
.prose pre .copy { position: absolute; top: 8px; right: 8px; font: 12px var(--sans); color: #c9c5bb; background: #2c2f36; border: 1px solid #40444c; border-radius: 6px; padding: 2px 8px; cursor: pointer; opacity: 0; }
.prose pre:hover .copy, .prose pre .copy:focus { opacity: 1; }
.prose pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 8px; right: 70px; font: 11px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: #8b877e; }
.prose table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.prose td code { white-space: nowrap; }
.prose blockquote { margin: 20px 0; padding: 12px 16px; border-left: 4px solid var(--line); background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; }
.prose blockquote p { margin: 4px 0; }
.callout-note { border-left-color: var(--note) !important; }
.callout-tip { border-left-color: var(--tip) !important; }
.callout-warning, .callout-caution, .callout-important { border-left-color: var(--warning) !important; }
.callout-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.callout-note .callout-title { color: var(--note); } .callout-tip .callout-title { color: var(--tip); }
.callout-warning .callout-title, .callout-caution .callout-title, .callout-important .callout-title { color: var(--warning); }
.item-link { white-space: nowrap; }
.inline-icon { width: 20px; height: 20px; vertical-align: -4px; margin-right: 3px; image-rendering: pixelated; }
.shot { margin: 22px 0; }
.shot img { display: block; border-radius: var(--radius); border: 1px solid var(--line); }
.shot figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 780px; margin-top: 56px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); font-weight: 600; background: var(--surface); }
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pager .next { text-align: right; }
.page-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; max-width: 780px; }
.page-list a { display: block; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.page-list a:hover { border-color: var(--accent); }
.page-list span { display: block; color: var(--muted); font-size: 14.5px; }
.page-list.compact { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); max-width: none; }
.wiki-section { margin-top: 36px; }
.wiki-section h2 { margin: 0 0 4px; font-size: 22px; }
.wiki-section h2 a { color: var(--text); text-decoration: none; }
.wiki-section > p { margin: 0 0 12px; color: var(--muted); }

/* ---------------------------------------------------------------- items */
.item-head { display: flex; flex-wrap: wrap; gap: 24px 40px; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.item-title { display: flex; gap: 18px; align-items: center; }
.item-icon { width: 64px; height: 64px; image-rendering: pixelated; flex: none; }
.item-meta { margin: 0; color: var(--muted); font-size: 14px; }
.item-meta code { font-size: 13px; }
.block-picture { margin: 0; width: min(300px, 100%); }
.block-picture img { display: block; width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); }
.block-picture figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.item-section { margin-top: 32px; }
.item-section h2 { font-size: 21px; margin: 0 0 14px; }
.guide-links { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.guide-links li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14.5px; }
.guide-links span { color: var(--muted); font-size: 13px; }
.recipes { display: flex; flex-wrap: wrap; gap: 16px; }
.recipe { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; box-shadow: var(--shadow); }
.recipe figcaption { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.recipe figcaption a { color: inherit; }
.recipe-body { display: flex; align-items: center; gap: 12px; }
.recipe-note { margin: 10px 0 0; font-size: 13px; color: var(--muted); max-width: 260px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 48px); gap: 2px; }
.slot {
  position: relative; display: grid; place-items: center; width: 48px; height: 48px; background: var(--slot);
  border: 2px solid; border-color: var(--slot-edge-dark) var(--slot-edge-light) var(--slot-edge-light) var(--slot-edge-dark);
  text-decoration: none; color: var(--text);
}
.slot img { width: 40px; height: 40px; image-rendering: pixelated; }
a.slot:hover { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 1; }
.slot.result { width: 60px; height: 60px; }
.slot .count { position: absolute; right: 2px; bottom: -1px; font: 600 14px var(--mono); color: #fff; text-shadow: 1px 1px 0 #3f3f3f; }
.slot .tag-text { font-size: 9px; line-height: 1.1; text-align: center; word-break: break-all; padding: 2px; }
.icon-missing { display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.arrow { width: 30px; height: 20px; flex: none; background: var(--muted); clip-path: polygon(0 35%, 60% 35%, 60% 0, 100% 50%, 60% 100%, 60% 65%, 0 65%); }
.furnace { display: grid; grid-template-rows: 48px 22px 48px; justify-items: center; gap: 2px; }
.flame { width: 18px; height: 22px; background: linear-gradient(#ffd54a, #e8620c); clip-path: polygon(50% 0, 85% 45%, 100% 100%, 0 100%, 15% 45%); }
.toolrow { display: flex; align-items: center; gap: 8px; }
.plus { font-size: 22px; color: var(--muted); }
.slot.tool { border-style: dashed; }

.melt { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; max-width: 880px; }
.melt summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.melt-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 16px; font-size: 14.5px; }
.item-section > .melt-list { margin: 0; }
.melt-list li { padding: 3px 0; }
.melt-list a { color: var(--text); text-decoration: none; }
.melt-list a:hover { color: var(--link); text-decoration: underline; }
.melt-arrow { color: var(--muted); }

/* ---------------------------------------------------------------- downloads */
.downloads { max-width: 880px; margin-bottom: 8px; }
.download-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); border-top: 4px solid var(--accent); }
.download-head { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: center; justify-content: space-between; }
.download-head h2 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.download-head .eyebrow { margin: 0 0 4px; }
.download-meta { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; }
.download-button { font-size: 16px; padding: 12px 20px; word-break: break-all; }
.download-notes { white-space: pre-wrap; margin: 14px 0 0; }
.download-hash { margin: 12px 0 0; font-size: 13px; color: var(--muted); word-break: break-all; }
.older-title { font-size: 20px; margin: 28px 0 10px; }
.older-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.older-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.older-list .download-notes { margin-top: 6px; font-size: 14px; color: var(--muted); }

/* ---------------------------------------------------------------- catalog */
.catalog-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
#catalog-filter { flex: 1 1 260px; max-width: 420px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.chips { display: flex; gap: 6px; }
.chips button { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.category-links { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.category-links a { font-size: 13.5px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.category-links span { color: var(--muted); }
.catalog-section h2 { font-size: 20px; margin: 30px 0 12px; }
.item-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.item-grid a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; font-size: 14.5px; line-height: 1.3; min-height: 58px; }
.item-grid a:hover { border-color: var(--accent); }
.item-grid img, .item-grid .icon { width: 40px; height: 40px; flex: none; image-rendering: pixelated; }
.item-grid.small { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.item-grid.small a { min-height: 46px; font-size: 13.5px; }
.item-grid.small img { width: 32px; height: 32px; }

/* ---------------------------------------------------------------- home */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; padding: 36px 0 24px; }
.eyebrow { font: 600 13px var(--mono); color: var(--accent); letter-spacing: .04em; margin: 0 0 10px; }
.hero h1 { font-size: clamp(44px, 7vw, 76px); line-height: 1; letter-spacing: -.035em; margin: 0 0 18px; }
.hero .lede { font-size: 19px; max-width: 54ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button { display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button:hover { filter: brightness(1.05); border-color: var(--accent); }
.hero-art { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-art img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 28px; }
.feature { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--text); text-decoration: none; box-shadow: var(--shadow); }
.feature:hover { border-color: var(--accent); }
.feature img { width: 100%; height: 150px; object-fit: cover; display: block; }
.feature div { padding: 14px 16px 16px; }
.feature h3 { margin: 0 0 4px; font-size: 18px; }
.feature p { margin: 0 0 8px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.feature-start { font-size: 13.5px; color: var(--link); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 36px 0 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.facts strong { display: block; font: 600 28px var(--mono); }
.facts span { color: var(--muted); font-size: 14px; }

/* ---------------------------------------------------------------- narrow screens */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .top { gap: 10px; padding: 0 16px; }
  .menu-button { display: grid; }
  .top-nav { display: none; }
  .search { width: auto; flex: 1; }
  .search kbd { display: none; }
  .brand small { display: none; }
  .layout, .layout.wide { grid-template-columns: minmax(0, 1fr); padding: 0 16px; gap: 0; }
  .sidebar { position: fixed; inset: 60px 0 0 0; z-index: 15; max-height: none; background: var(--bg); padding: 16px; display: none; }
  body.nav-open .sidebar { display: block; }
  body.home.nav-open .sidebar { display: block; }
  .hero { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr 1fr; }
  .anchor { display: none; }
}
@media (max-width: 520px) {
  .brand span { display: none; }
  .grid3 { grid-template-columns: repeat(3, 40px); }
  .slot { width: 40px; height: 40px; }
  .slot img { width: 32px; height: 32px; }
  .slot.result { width: 50px; height: 50px; }
  .recipe { padding: 10px; }
  .pager { grid-template-columns: 1fr; }
  .item-grid { grid-template-columns: 1fr 1fr; }
  .item-grid a { font-size: 13.5px; }
}
