/* Radiology Assistant offline reader */
:root {
  --fs: 17px;
  --page-w: 1280px;
  --gutter: 24px;
  --bg: #f6f4ef;
  --paper: #ffffff;
  --ink: #1d2433;
  --muted: #5d6677;
  --line: #e2ded4;
  --accent: #1b5fae;
  --accent-soft: #e6eefa;
  --vi: #0f6b4f;
  --vi-bg: #eef7f2;
  --cap: #3e5f99;
  --bar: rgba(246, 244, 239, .92);
  --label-bg: rgba(255, 248, 196, .93);
  --label-ink: #111;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
:root[data-theme="dark"] {
  --bg: #111418;
  --paper: #1a1f26;
  --ink: #e4e7ec;
  --muted: #98a1b0;
  --line: #2b323c;
  --accent: #7eaaff;
  --accent-soft: #1f2b40;
  --vi: #7fd8b3;
  --vi-bg: #16261f;
  --cap: #8fb3ff;
  --bar: rgba(17, 20, 24, .92);
  --label-bg: rgba(20, 24, 30, .88);
  --label-ink: #ffe98a;
  --shadow: none;
}
* { box-sizing: border-box; }
body.article { --page-w: 1480px; }
html { scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: var(--fs)/1.65 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; height: auto; display: block; }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
button { font: inherit; }

/* ---------- language modes ---------- */
.ra-vi { display: block; color: var(--vi); }
.ra-src + .ra-vi { margin-top: .2em; }
p .ra-vi, li .ra-vi, td .ra-vi, .ra-text > .ra-vi, .ra-intro > .ra-vi {
  background: var(--vi-bg); border-left: 3px solid var(--vi); padding: .25em .6em; border-radius: 0 6px 6px 0;
}
h1 .ra-vi, h2 .ra-vi, h3 .ra-vi, h4 .ra-vi { font-size: .78em; font-weight: 600; }
.toc .ra-vi, .card .ra-vi, .chip .ra-vi, .crumbs .ra-vi, .pn .ra-vi, .changes .ra-vi { font-size: .88em; }
.crumbs .ra-vi, .chip .ra-vi { display: inline; margin-left: .3em; }
.crumbs .ra-vi::before, .chip .ra-vi::before { content: "· "; }
[data-lang="en"] .ra-vi { display: none !important; }
[data-lang="vi"] .ra-src { display: none !important; }
[data-lang="vi"] .ra-vi { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; font-weight: inherit; }
[data-lang="vi"] .ra-review, [data-lang="bi"] .ra-review { text-decoration: underline dotted var(--muted); }
[data-lang="vi"] .ra-review::before, [data-lang="bi"] .ra-review::before {
  content: 'Cần đối chiếu'; color: var(--muted); font-size: .73em; font-weight: 600; margin-right: .45em;
}
[data-lang="vi"] .crumbs .ra-vi::before, [data-lang="vi"] .chip .ra-vi::before { content: ""; }
[data-lang="vi"] .crumbs .ra-vi, [data-lang="vi"] .chip .ra-vi { margin: 0; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 8px max(var(--gutter), calc((100% - var(--page-w)) / 2 + var(--gutter))); background: var(--bar); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.home { font-weight: 800; font-size: 18px; color: var(--ink); letter-spacing: -.02em; white-space: nowrap; }
.home img { display: block; height: 26px; width: auto; }
:root[data-theme="dark"] .home img { filter: invert(1); }
.home:hover { text-decoration: none; }
.crumbs { color: var(--muted); font-size: 14px; line-height: 1.5; }
.art-head .crumbs { margin-bottom: 12px; }
.home-main > .crumbs { margin-bottom: 6px; }

/* category menu */
.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); white-space: nowrap; user-select: none;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; color: var(--muted); }
.menu[open] summary, .menu summary:hover { border-color: var(--accent); }
/* one panel, two columns: categories on the left, sub-groups of the highlighted one on the right */
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50; width: 660px; padding: 6px 386px 6px 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgba(0,0,0,.18);
}
.menu-sub {
  display: none; position: absolute; top: 0; right: 0; bottom: 0; width: 380px; padding: 6px; overflow: auto;
  border-left: 1px solid var(--line); background: var(--bg); border-radius: 0 14px 14px 0;
}
.menu-item.on > .menu-sub, .menu-item:focus-within > .menu-sub { display: block; }
.menu-panel a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border-radius: 8px; color: var(--ink); line-height: 1.3;
}
.menu-panel a:hover, .menu-item.on > a { background: var(--accent-soft); text-decoration: none; }
.menu-sub a:hover { background: var(--paper); }
.menu-panel .ml { display: flex; flex-direction: column; min-width: 0; }
.menu-panel .ml .ra-src { font-weight: 550; }
.menu-panel .ml .ra-vi { display: block; margin: 1px 0 0; padding: 0; background: none; border: 0; font-size: 12.5px; color: var(--vi); }
[data-lang="vi"] .menu-panel .ml .ra-vi { font-size: inherit; color: inherit; margin: 0; }
.menu-panel a > b {
  flex: none; min-width: 28px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--bg); border-radius: 999px; padding: 1px 7px;
}
.menu-sub a > b { background: var(--paper); }
.menu-item.on > a > b { color: var(--accent); background: var(--paper); }
.menu-panel .menu-head {
  height: 48px; margin-bottom: 4px; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0;
  font-weight: 700; color: var(--accent);
}
.menu-panel .menu-head small { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }

/* search results drop-down on article and category pages */
.search-pop {
  position: absolute; z-index: 45; top: calc(100% + 6px); left: 0; right: 0;
  max-height: calc(100vh - 80px); overflow: auto; background: var(--bg); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.2); font-size: 15px;
}
.search-pop[hidden] { display: none; }
.tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.tools button {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 8px;
  padding: 4px 9px; cursor: pointer; line-height: 1.3;
}
.tools button:hover { border-color: var(--accent); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 8px 0 0 8px; }
.seg button:last-child { border-radius: 0 8px 8px 0; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.toc-toggle { display: none; }

/* ---------- article layout ---------- */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 32px; max-width: var(--page-w); margin: 0 auto; padding: 24px var(--gutter) 64px; }
.toc {
  position: sticky; top: 70px; align-self: start; max-height: calc(100vh - 90px); overflow: auto;
  font-size: 14px; line-height: 1.4; padding-right: 6px;
}
.toc-title { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc ul ul { padding-left: 12px; margin: 4px 0 8px; border-left: 1px solid var(--line); }
.toc li { margin: 3px 0; }
.toc a { color: var(--ink); display: block; padding: 3px 8px; border-radius: 6px; }
.toc a.toc-h2 { font-weight: 650; }
.toc a:hover { background: var(--accent-soft); text-decoration: none; }
.toc a.active { background: var(--accent-soft); color: var(--accent); }

.content { min-width: 0; }
.art-head { text-align: center; margin: 8px auto 28px; max-width: 900px; }
.art-head h1 { font-size: 2.1em; line-height: 1.2; margin: 0 0 .3em; letter-spacing: -.01em; }
.subtitle { font-weight: 600; margin: 0; }
.authors { margin: .4em 0 0; font-weight: 600; }
.affil { margin: .2em 0; font-style: italic; color: var(--muted); font-size: .9em; }
.pubdate { color: var(--muted); font-size: .88em; margin: .4em 0; }
.srcline { display: none; }

.ra-intro, .ra-text, .ra-refs { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 18px 22px; box-shadow: var(--shadow); }
.ra-intro { max-width: 900px; margin: 0 auto 32px; }
.ra-chapter { margin: 0 0 40px; }
.ra-chapter > h2 {
  font-size: 1.55em; line-height: 1.25; margin: 48px 0 18px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); color: var(--accent);
}
.ra-block { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; margin: 0 0 26px; align-items: start; }
.ra-block > .ra-media:only-child, .ra-block > .ra-text:only-child { grid-column: 1 / -1; }
.ra-media { position: sticky; top: 72px; }
.ra-media > * + * { margin-top: 12px; }
.ra-media img { border-radius: 8px; cursor: zoom-in; background: #000; }
.ra-media .ra-image-original { display: inline-block; margin-top: 4px; font-size: 13px; }
.ra-media .ra-table-reference { display: block; margin-top: 4px; font-size: 13px; }
.ra-figure-companion { display: block; }
.ra-stack .ra-figure-companion { margin-top: .55em; }
.content .ra-illustration-crop { aspect-ratio: var(--ra-crop-ratio); overflow: hidden; }
[data-lang="en"] .content .ra-illustration-crop { aspect-ratio: auto; overflow: visible; }
.lb-labels .ra-figure-companion { padding: 4px 0; color: inherit; }
[data-lang="en"] .ra-media .ra-image-original,
[data-lang="en"] .ra-media .ra-table-reference,
[data-lang="en"] .ra-figure-companion { display: none; }
.ra-caption { display: block; font-style: normal; font-size: .86em; line-height: 1.4; color: var(--cap); margin-top: 6px; }
.ra-text h3 { margin: 0 0 .5em; font-size: 1.15em; color: var(--accent); }
.ra-text p { margin: 0 0 .8em; }
.ra-text ul, .ra-text ol, .ra-intro ul { padding-left: 1.3em; margin: 0 0 .8em; }
.ra-text li { margin: .2em 0; }
.ra-text table { border-collapse: collapse; width: 100%; font-size: .9em; margin: .5em 0 1em; }
.ra-text td, .ra-text th { border: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
.ra-refs { margin-top: 48px; font-size: .85em; }
.ra-refs h2 { margin-top: 0; font-size: 1.2em; }
.ra-refs li { margin-bottom: .6em; }
.ra-refs p { margin: .2em 0; }
/* a citation with a title line keeps title, authors and journal in one run of text */
.ra-refs li > p { display: inline; margin: 0; }
.ra-refs br { display: none; }
[data-lang="vi"] .ra-refs li > .ra-vi, [data-lang="en"] .ra-refs li > .ra-src { display: inline; }

/* Image text and location markers */
.ocr-wrap { position: relative; }
.ocr-wrap img { width: 100%; }
.ra-positioned-figure { container-type: inline-size; }
.ra-positioned-figure > img { display: block; }
.ra-positioned-labels { position: absolute; inset: 0; pointer-events: none; }
.ra-positioned-labels span {
  position: absolute; display: flex; align-items: center; padding-left: .55cqw;
  box-sizing: border-box; line-height: 1.14; white-space: pre-line; font-weight: 500;
}
.ra-positioned-labels .ra-positioned-center { justify-content: center; padding: 0 .55cqw; text-align: center; }
.ra-positioned-labels .ra-positioned-top { align-items: flex-start; padding: .65cqw .55cqw 0; }
[data-lang="en"] .ra-positioned-labels { display: none; }
.ocr-lab {
  display: none; position: absolute; background: var(--label-bg); color: var(--label-ink); border-radius: 50%;
  min-width: 1.3em; padding: 0 .2em; text-align: center; font-size: 12px; font-weight: 700; pointer-events: none;
  transform: translate(-65%, -50%);
}
.ocr-expanded .ocr-lab { display: block; }
.ocr-text, .ra-image-description { font-size: 13px; margin: .3em 0 .6em; }
.ocr-text summary, .ra-image-description summary { cursor: pointer; }
.ocr-text ol { padding-left: 1.55em; margin: .4em 0; }
.ocr-source { display: block; opacity: .78; }
[data-lang="en"] .ocr-lab, [data-lang="en"] .ocr-text, [data-lang="vi"] .ocr-source { display: none; }
.lb-labels { max-height: 22vh; overflow: auto; padding: 0 24px; color: #e4edff; }
.ocr-hint { display: none; }

/* image stack viewer */
.ra-stack { position: relative; user-select: none; touch-action: none; }
.ra-stack .bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.ra-stack input[type=range] { flex: 1; accent-color: var(--accent); }
.ra-stack .bar button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 6px; cursor: pointer; padding: 0 8px; }

/* online-only embeds */
.ra-embed { border: 1px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; background: var(--paper); }
.ra-embed iframe { width: 100%; aspect-ratio: 16/9; border: 0; border-radius: 8px; }

/* lightbox */
.lb { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.94); display: flex; flex-direction: column; }
.lb[hidden] { display: none; }
.lb-stage { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: grab; }
.lb-stage.drag { cursor: grabbing; }
.lb-inner { position: relative; transform-origin: center center; }
.lb-inner img { max-width: 94vw; max-height: 84vh; width: auto; }
.lb-inner.ocr-wrap { width: auto; }
.lb-bar { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 10px; color: #ccd; font-size: 14px; }
.lb-bar button { background: #222a; color: #fff; border: 1px solid #555; border-radius: 8px; padding: 4px 12px; cursor: pointer; }
.lb-cap { color: #cdd8ee; text-align: center; padding: 0 16px 12px; font-size: 14px; max-height: 18vh; overflow: auto; }

.prevnext { display: flex; gap: 16px; margin-top: 40px; }
.pn { flex: 1; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 12px 16px; color: var(--ink); }
.pn small { display: block; color: var(--muted); }
.pn.next { text-align: right; }
.pn:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- index ---------- */
.search-box { flex: 1; max-width: 640px; position: relative; }
.search-box input {
  width: 100%; font: inherit; font-size: 15px; padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
}
.search-box input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.home-main { max-width: var(--page-w); margin: 0 auto; padding: 24px var(--gutter) 64px; }
.hero h1 { margin: 8px 0 4px; font-size: 2em; letter-spacing: -.02em; }
.hero h1 small { font-size: .5em; color: var(--muted); font-weight: 500; }
.hero p { color: var(--muted); margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.chip { border: 1px solid var(--line); background: var(--paper); padding: 4px 12px; border-radius: 999px; color: var(--ink); font-size: 15px; }
.chip b { color: var(--accent); font-weight: 700; margin-left: 4px; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: .85em; background: var(--paper); }

/* home: category tiles */
.cat-grid { list-style: none; margin: 4px 0 32px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cat {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px 20px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: 14px;
  box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
.cat:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); }
.cat-name { font-size: 1.25em; font-weight: 750; letter-spacing: -.01em; line-height: 1.25; }
[data-lang="bi"] .cat-name .ra-vi { font-size: .72em; font-weight: 600; background: none; border: 0; padding: 0; }
.cat-n { color: var(--accent); font-size: 13px; font-weight: 650; }
.cat-subs { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.cat-subs > span { background: var(--accent-soft); border-radius: 6px; padding: 1px 7px; }
[data-lang="bi"] .cat-subs .ra-vi { display: none; }
.changes-panel summary { cursor: pointer; list-style-position: inside; }
.changes-panel summary h2 { display: inline; }
.changes-panel[open] summary { margin-bottom: 10px; }

/* category page */
.cat-head h1 { margin: 4px 0 12px; font-size: 2em; letter-spacing: -.02em; line-height: 1.2; }
.cat-head h1 small { font-size: .45em; color: var(--muted); font-weight: 500; }
.cat-head h1 .ra-vi { display: inline; margin-left: .35em; }
[data-lang="bi"] .cat-head h1 .ra-vi { font-size: .6em; font-weight: 600; }
[data-lang="bi"] .cat-head h1 .ra-vi::before { content: "· "; }
.category .sub h2 { font-size: 1.2em; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin: 30px 0 12px; scroll-margin-top: 70px; }
.category .sub h2 .ra-vi { display: inline; margin-left: .4em; }
[data-lang="bi"] .category .sub h2 .ra-vi { font-size: .8em; }
[data-lang="bi"] .category .sub h2 .ra-vi::before { content: "· "; }
.cat-others { margin: 48px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 30px; align-items: start; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.panel h2, .results h2 { margin: 0 0 10px; font-size: 1.1em; }
h2 small { font-weight: 400; color: var(--muted); font-size: .75em; }
.changes { list-style: none; margin: 0; padding: 0; font-size: 14px; max-height: 420px; overflow: auto; }
.changes > li { margin-bottom: 10px; }
.changes ul { list-style: none; padding-left: 8px; margin: 4px 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 0 6px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; }
.badge.new { background: #d9f5e3; color: #116b3a; }
.badge.upd { background: #fff1c9; color: #7a5600; }
.badge.gone { background: #f6d9d9; color: #8a1d1d; }
.sec { margin: 34px 0; scroll-margin-top: 70px; }
.sec > h2 { font-size: 1.5em; border-bottom: 2px solid var(--accent); padding-bottom: 6px; color: var(--accent); }
.sub h3 { font-size: 1em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; scroll-margin-top: 70px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.cards.compact { grid-template-columns: 1fr; gap: 6px; }
.card a {
  display: block; height: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; color: var(--ink); font-size: 15px; line-height: 1.35;
}
.cards.compact .card a { padding: 7px 12px; }
.card a:hover { border-color: var(--accent); text-decoration: none; box-shadow: var(--shadow); }
.card .ct { font-weight: 650; display: block; }
.card .cm { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.card.read .ct::after { content: " ✓ đã đọc"; color: var(--vi); font-size: 12px; font-weight: 600; }
.results { margin-bottom: 30px; }
.hit-snip { display: block; font-size: 12.5px; color: var(--muted); margin-top: 4px; }
mark { background: #ffe58a; color: #000; border-radius: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; position: fixed; top: 52px; left: 0; right: 0; bottom: 0; max-height: none; z-index: 40; background: var(--bg); padding: 16px 20px; }
  .toc.open { display: block; }
  .toc-toggle { display: inline-block; }
}
/* ---------- footer ---------- */
.site-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px;
  padding: 18px max(var(--gutter), calc((100% - var(--page-w)) / 2 + var(--gutter))) 28px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.site-foot .heart { display: inline-block; vertical-align: -2px; color: #e0245e; }

@media (max-width: 820px) {
  :root { --fs: 16px; }
  .ra-block { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .ra-media { position: static; }
  :root { --gutter: 16px; }
  .layout, .home-main { padding-top: 16px; padding-bottom: 48px; }
  .two { grid-template-columns: 1fr; }
  .topbar { gap: 8px; flex-wrap: wrap; }
  .home img { height: 22px; }
  .site-foot { padding-top: 16px; padding-bottom: 24px; }
  .search-box { order: 10; flex-basis: 100%; max-width: none; }
  /* no room for the second column: categories only, each opens its page */
  .menu-sub, .menu-item.on > .menu-sub, .menu-item:focus-within > .menu-sub { display: none; }
  .menu-panel { width: min(320px, calc(100vw - 24px)); padding: 6px; max-height: 70vh; overflow: auto; }
  .search-pop { max-height: calc(100vh - 116px); }
  .toc { top: 96px; }
  .cat-head h1 { font-size: 1.6em; }
  .tools button { padding: 3px 7px; }
  .art-head h1 { font-size: 1.6em; }
  .prevnext { flex-direction: column; }
}
@media (max-width: 600px) {
  /* row 1: logo + tools; row 2: category menu + search */
  .topbar { gap: 6px; padding-top: 6px; padding-bottom: 6px; }
  .topbar::after { content: ""; order: 8; flex-basis: 100%; height: 0; }
  .home { flex: 0 1 auto; min-width: 0; }
  .home img { height: auto; max-height: 20px; max-width: 100%; }
  .tools { flex: none; }
  .menu { order: 9; flex: none; position: static; }
  .menu summary { display: flex; align-items: center; height: 34px; padding: 0 10px; font-size: 14px; border-radius: 10px; }
  .search-box { order: 10; flex: 1 1 0; min-width: 0; }
  .search-box input { height: 34px; padding: 4px 10px; font-size: 15px; }
  /* category panel spans the bar under row 2 */
  .menu-panel { left: var(--gutter); right: var(--gutter); width: auto; max-height: calc(100vh - 110px); }
  .menu-panel a { padding: 9px 10px; }
  .menu-panel .menu-head { height: 42px; }
  .tools { gap: 4px; }
  .tools button { padding: 3px 7px; }
  .seg button:not(.on) { display: none; }
  .seg button.on { border-radius: 8px; margin: 0; }
}
@media print {
  .topbar, .site-foot, .toc, .prevnext, .ocr-lab, .ra-stack .bar, .search-pop, .crumbs { display: none !important; }
  .layout { display: block; padding: 0; }
  .ra-media { position: static; }
  .ra-block { break-inside: avoid; }
}
