/* DO NOT EDIT — generated by build_static.js from src/style.css */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 1 — Layout Variables
 * Theme colors live in colors.css.
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
:root {
  --sidebar-w:    270px;
  --radius:       6px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 2 — Reset & Base
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  display: flex;
}

::-webkit-scrollbar            { width: 5px; height: 5px; }
::-webkit-scrollbar-track      { background: transparent; }
::-webkit-scrollbar-thumb      { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: var(--border-light); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 3 — App Shell
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#app { display: flex; width: 100%; height: 100%; overflow: hidden; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 4 — Sidebar
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 12px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Header row: logo + mobile close button */
.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  transition: opacity 0.15s;
  flex: 0 0 auto;
}
.sidebar-logo:hover { opacity: 0.8; }
.sidebar-logo img {
  display: block;
  width: 190px;
  max-width: 100%;
  height: auto;
}

/* Close button — shown only on mobile */
.sidebar-close {
  display: none;
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: color 0.1s;
  flex-shrink: 0;
}
.sidebar-close:hover { color: var(--text); }

/* Search row: input + collapse-all button side by side */
.search-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

#search {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
#search:focus         { border-color: var(--accent); }
#search::placeholder  { color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
}

/* Sidebar footer: theme toggle + language select — mobile only (desktop uses topbar) */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: none;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 5 — Navigation Tree
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.tree-list, .tree-children { list-style: none; }

/* Children hidden by default; shown when the parent is .expanded */
.tree-children { display: none; }
.tree-item.expanded > .tree-children {
  display: block;
  animation: treeSlideIn 0.13s ease-out;
}
@keyframes treeSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Each row = flex container for [link] + [toggle button] */
.tree-row {
  display: flex;
  align-items: stretch;
  border-right: 2px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.tree-row:hover                    { background: var(--surface2); }
.tree-item.active > .tree-row      { background: var(--surface2); border-right-color: var(--accent); }

/* Nav link — takes remaining width, depth indented via inline padding-left */
.tree-row > a {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 4px 5px 0;  /* left padding set inline from JS */
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  min-width: 0;
}
.tree-row > a:hover           { color: var(--text-dim); }
.tree-item.active > .tree-row > a { color: var(--accent); font-weight: 600; }

/* Item icon */
.tree-icon { width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; image-rendering: pixelated; }

/* Expand / collapse toggle — CSS triangle chevron */
.tree-toggle {
  flex-shrink: 0;
  width: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 0;
  transition: color 0.1s;
}
.tree-toggle:hover { color: var(--text-dim); }
/* CSS triangle arrow */
.tree-toggle::before {
  content: '';
  width: 0; height: 0;
  border: solid transparent;
  border-width: 4px 0 4px 6px;
  border-left-color: currentColor;
  transition: transform 0.15s;
}
.tree-item.expanded > .tree-row .tree-toggle::before { transform: rotate(90deg); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 6 — Sidebar Search Results
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#search-results         { display: none; flex-direction: column; gap: 2px; padding: 6px; }
#search-results.visible { display: flex; }

.search-result {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  background: var(--surface2);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text-dim);
  font-size: 12px;
  border: 1px solid transparent;
  transition: border-color 0.1s, color 0.1s;
}
.search-result:hover         { border-color: var(--accent); color: var(--text); }
.search-result img           { width: 20px; height: 20px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0; }
.search-result .sr-title     { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .sr-id        { font-size: 10px; color: var(--text-muted); font-family: monospace; flex-shrink: 0; }
.search-empty                { color: var(--text-muted); font-size: 12px; padding: 8px; text-align: center; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 7 — Main Panel (breadcrumb + scrollable content)
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#main-panel { flex: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; }

/* Topbar: shown on desktop with theme/lang at right; restructured for mobile burger */
#topbar {
  display: flex;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  min-height: 38px;
}

/* Search button in topbar — hidden on desktop */
.search-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  flex-shrink: 0;
}
.search-btn:hover { color: var(--accent); }

/* Collapse-all button — inside sidebar header, hidden on mobile */
.collapse-all-btn {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.collapse-all-btn:hover { color: var(--accent); background: var(--surface2); }
/* Top arrow points down, bottom arrow points up — compress/collapse icon */
.collapse-all-btn::before,
.collapse-all-btn::after {
  content: '';
  width: 0; height: 0;
  border: solid transparent;
}
.collapse-all-btn::before {
  border-width: 5px 4px 0 4px;
  border-top-color: currentColor;
}
.collapse-all-btn::after {
  border-width: 0 4px 5px 4px;
  border-bottom-color: currentColor;
}

/* Hamburger button — hidden on desktop */
.burger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 0;
  border-radius: var(--radius);
  transition: color 0.15s;
  flex-shrink: 0;
  gap: 0;
}
.burger-btn:hover { color: var(--accent); }
.burger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
  margin: 3px 0;
}

/* Sidebar backdrop overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  backdrop-filter: blur(1px);
  animation: backdropFadeIn 0.2s ease;
}
.sidebar-backdrop.visible { display: block; }
@keyframes backdropFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#lang-select,
#lang-select-mobile {
  min-width: 88px;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
}

#lang-select:focus,
#lang-select-mobile:focus { outline: none; border-color: var(--accent); }

#breadcrumb {
  padding: 7px 24px 7px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
}
#breadcrumb a        { color: var(--text-muted); text-decoration: none; }
#breadcrumb a:hover  { color: var(--accent); }
.bc-trail            { display: inline-flex; align-items: center; min-width: 0; overflow: hidden; }
.bc-sep              { margin: 0 6px; opacity: 0.4; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  min-width: 78px;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.theme-toggle-icon {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset -4px -3px 0 var(--accent-contrast);
  flex-shrink: 0;
}
:root[data-theme="light"] .theme-toggle-icon {
  box-shadow: 0 0 0 3px rgba(154, 98, 22, 0.18);
}

#page { flex: 1; overflow-y: auto; padding: 24px; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 8 — Item Card
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 24px;
  overflow: hidden;
}

/* Large side image — floated right, mirrors in-game bookForm.sideTexture */
.item-side-img {
  float: right;
  width: 264px; height: 264px;
  object-fit: contain;
  margin: 0 0 12px 20px;
  image-rendering: pixelated;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px;
}

.item-title   { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.item-id      { display: inline-block; font-size: 11px; color: var(--text-muted); font-family: monospace; margin-bottom: 14px; background: var(--surface2); padding: 1px 6px; border-radius: 4px; }
.item-desc    { color: var(--text-dim); margin-bottom: 14px; }
.item-desc p  { margin-bottom: 6px; line-height: 1.7; }
.item-desc p:last-child { margin-bottom: 0; }
.item-desc a  { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 2px; }
.item-desc a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 9 — wikiInfo Badges & Rows
 * To add a new wikiInfo field: add a badge-* class here, then render
 * it in app.js renderWikiInfo(). See AGENTS.md for full guide.
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.wiki-info {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px; margin-top: 4px;
}

.info-row   { display: flex; align-items: center; flex-wrap: wrap; column-gap: 8px; row-gap: 6px; }
.info-label { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.info-values{ font-size: 13px; color: var(--text-dim); }

/* Badge base */
.badge {
  display: inline-flex; align-items: center; gap: 0.25em;
  padding: 2px 9px;
  border-radius: 3px;
  font-size: 12px; font-weight: 500;
  border: 1px solid transparent;
  line-height: 1.5;
  text-decoration: none;
}

/* Badge colour variants — token values live in colors.css */
.badge-hostile  { background: var(--badge-hostile-bg); color: var(--badge-hostile-text); border-color: var(--badge-hostile-border); }
.badge-neutral  { background: var(--badge-neutral-bg); color: var(--badge-neutral-text); border-color: var(--badge-neutral-border); }
.badge-friendly { background: var(--badge-friendly-bg); color: var(--badge-friendly-text); border-color: var(--badge-friendly-border); }
.badge-biome    { background: var(--badge-biome-bg); color: var(--badge-biome-text); border-color: var(--badge-biome-border); }
.badge-recipe   { background: var(--badge-recipe-bg); color: var(--badge-recipe-text); border-color: var(--badge-recipe-border); }
.badge-recipe a { color: inherit; text-decoration: none; }
.badge-recipe a:hover { text-decoration: underline; }
.badge-market   { background: var(--badge-market-bg); color: var(--badge-market-text); border-color: var(--badge-market-border); }
.badge-quest    { background: var(--badge-quest-bg); color: var(--badge-quest-text); border-color: var(--badge-quest-border); }
.badge-prop     { background: var(--badge-prop-bg); color: var(--badge-prop-text); border-color: var(--badge-prop-border); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 10 — Recipes
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.recipes-section { margin: 8px 0 24px; }

.recipes-section h2 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.recipes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.recipe-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 258px;
}

.recipe-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

.recipe-output-name {
  color: var(--text);
  font-weight: 700;
}
.recipe-output-name a {
  color: inherit;
  text-decoration: none;
}
.recipe-output-name a:hover {
  text-decoration: underline;
}

.recipe-station {
  color: var(--text-muted);
  font-weight: 500;
}
.recipe-station a {
  color: inherit;
  text-decoration: none;
}
.recipe-station a:hover {
  text-decoration: underline;
}

.recipe-output-name + .recipe-station::before {
  content: '-';
  margin-right: 6px;
}

.recipe-ui {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recipe-ui--linear { flex-wrap: wrap; }

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 2px;
}

.recipe-slot {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-dim);
  text-decoration: none;
  overflow: hidden;
}

.recipe-slot--large {
  width: 52px;
  height: 52px;
}

.recipe-slot:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.recipe-slot img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}

.recipe-slot--large img {
  width: 40px;
  height: 40px;
}

.recipe-slot-text {
  padding: 2px;
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
}

.recipe-count {
  position: absolute;
  right: 3px;
  bottom: 0;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 1px var(--bg), 1px 0 1px var(--bg);
}

.recipe-arrow {
  width: 34px;
  height: 18px;
  position: relative;
  flex-shrink: 0;
}
.recipe-arrow::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 4px;
  background: var(--border-light);
}
.recipe-arrow::after {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 12px solid var(--border-light);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 11 — Children Grid
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.children-section { margin-top: 8px; }

.children-section h2 {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(130px, calc((100% + 8px) / 7 - 8px)), 1fr));
  gap: 8px;
}

.child-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-dim);
  font-size: 12px; text-align: center; line-height: 1.3;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.child-card:hover { border-color: var(--accent); background: var(--surface2); color: var(--text); }

.child-icon             { width: 44px; height: 44px; object-fit: contain; image-rendering: pixelated; flex-shrink: 0; }
.child-icon-placeholder { width: 44px; height: 44px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; flex-shrink: 0; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 12 — Empty / Error States
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.state-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 50vh; color: var(--text-muted); text-align: center; gap: 8px;
}
.state-empty strong { font-size: 16px; color: var(--text-dim); }
.state-empty code   { font-family: monospace; font-size: 12px; color: var(--text-muted); background: var(--surface2); padding: 2px 8px; border-radius: 3px; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 * SECTION 13 — Responsive & Print
 * ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ── Mobile (≤ 768px) ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: min(300px, 85vw); }

  body { overflow: auto; }

  /* Topbar on mobile: hide desktop controls, show burger + search */
  #topbar { display: flex; justify-content: space-between; min-height: 48px; padding: 0 12px; }
  .top-controls { display: none; }

  /* Burger + search buttons: visible on mobile */
  .burger-btn  { display: flex; }
  .search-btn  { display: flex; }

  /* Collapse-all button: hidden on mobile (sidebar tree not persistent) */
  .collapse-all-btn { display: none; }

  /* Sidebar footer: visible on mobile inside burger menu */
  .sidebar-footer { display: flex; }

  /* Sidebar: off-screen by default, slides in as overlay */
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: none;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.35);
  }

  /* Close button: visible on mobile */
  .sidebar-close { display: flex; align-items: center; justify-content: center; }

  /* Logo in header row: left-aligned, takes remaining space */
  .sidebar-header-row {
    justify-content: flex-start;
  }
  .sidebar-logo {
    flex: 1;
  }

  /* Item side image: smaller on mobile */
  .item-side-img { width: 160px; height: 160px; }

  /* Page padding: tighter on mobile */
  #page { padding: 16px; }

  /* Children grid: fewer columns */
  .children-grid {
    grid-template-columns: repeat(auto-fill, minmax(max(90px, calc((100% + 8px) / 4 - 8px)), 1fr));
  }

  /* Recipe cards: allow full width on small screens */
  .recipe-card { min-width: 0; width: 100%; }
  .recipes-list { flex-direction: column; }
}

/* ── Small mobile (≤ 480px) ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .item-side-img { width: 120px; height: 120px; }
  .item-title    { font-size: 17px; }
  #page          { padding: 12px; }
  .item-card     { padding: 14px 14px; }
}

@media print {
  #sidebar { display: none; }
  #topbar  { display: none; }
  body, #main-panel { overflow: visible; height: auto; }
  #page { overflow: visible; }
  .child-card { break-inside: avoid; }
}
