/* The site frame: palette tokens, header, menu, footer, downloads list.
   Every colour is a token below; a new colour is always a new token (ARCHITECTURE.md §8).
   Light is the default; cold and warm are the dark palettes, chosen with the palette switch (I2c:
   data-theme on <html>). Without a choice an OS in dark mode gets cold (the media block repeats the
   cold tokens; a test keeps them equal). */
:root {
  color-scheme: light;
  --bg: #f7f7f4; --card: #ffffff; --text: #1d2327; --muted: #5f6b73; --line: #dcdcd4;
  --accent: #1f5fa8; --accent-hover: #174a85; --on-accent: #ffffff; --link: #1f5fa8;
  --code-bg: #f1f2ee; --row-alt: #f9f9f6; --head-bg: #f0f1ec;
  --note: #3b82f6; --tip: #16a34a; --warning: #d97706; --quote: #7c3aed;
  --shadow: rgba(0, 0, 0, .12);
  --accent-soft: #e7f0fa; --ok: #16a34a; --danger: #b42318; --lock: #8a6d1f;
  --draft: #8a3fb8;   /* I13: the drafts' ✎ mark and "vázlat" pill (the owner only) */
  --bar: #1f5fa8; --bar-weak: #b9cbe3; --backdrop: rgba(0, 0, 0, .45);   /* I1: the statistics charts, the popup's backdrop */
  --bg-edge: #e6e7df; --bg-art: #8fa3b8;   /* I10: the background's vignette edge, its flowing lines */
  --yin: var(--accent); --yang: var(--card);   /* the icon: yin the dark half, yang the light one */
  --yt-bg: #1d2327; --yt-text: #ffffff;   /* the YouTube facade stays dark in every palette */
  --page: #ffffff; --page-line: #cfcfc6;   /* I5: the paper behind a PDF thumbnail, its border */
  --yt-scrim: rgba(0, 0, 0, .6); --yt-play: rgba(0, 0, 0, .55);   /* I9: the gradient under the label, the play button */
}
:root[data-theme="cold"] {
  color-scheme: dark;
  --bg: #1d2330; --card: #262e3d; --text: #e4e8ef; --muted: #9aa5b5; --line: #364154;
  --accent: #7fb3f0; --accent-hover: #a3c9f5; --on-accent: #1d2330; --link: #8fbdf3;
  --code-bg: #303a4c; --row-alt: #2b3445; --head-bg: #303a4c;
  --note: #7fb0f5; --tip: #5cc58a; --warning: #e8b04a; --quote: #b69cf5;
  --shadow: rgba(0, 0, 0, .45);
  --accent-soft: #24344d; --ok: #5cc58a; --danger: #f08a80; --lock: #e8c66a;
  --draft: #c9a0f0;
  --bar: #7fb3f0; --bar-weak: #3d5270; --backdrop: rgba(0, 0, 0, .6);
  --bg-edge: #141924; --bg-art: #6d83a3;
  --yin: var(--card); --yang: var(--accent);
  --page: #e9ebee; --page-line: #4a5568;
}
:root[data-theme="warm"] {
  color-scheme: dark;
  --bg: #24201d; --card: #2f2a26; --text: #ece6df; --muted: #a89e93; --line: #463f38;
  --accent: #e0a95a; --accent-hover: #ecbf7c; --on-accent: #24201d; --link: #e9b872;
  --code-bg: #3a332d; --row-alt: #342e29; --head-bg: #3a332d;
  --note: #8fb3e8; --tip: #8fcf8f; --warning: #f0a060; --quote: #c9a6e8;
  --shadow: rgba(0, 0, 0, .45);
  --accent-soft: #3e3226; --ok: #8fcf8f; --danger: #f0947a; --lock: #f0c070;
  --draft: #dcaee6;
  --bar: #e0a95a; --bar-weak: #5e4a33; --backdrop: rgba(0, 0, 0, .6);
  --bg-edge: #1a1714; --bg-art: #8a7658;
  --yin: var(--card); --yang: var(--accent);
  --page: #ece6df; --page-line: #5a5047;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #1d2330; --card: #262e3d; --text: #e4e8ef; --muted: #9aa5b5; --line: #364154;
    --accent: #7fb3f0; --accent-hover: #a3c9f5; --on-accent: #1d2330; --link: #8fbdf3;
    --code-bg: #303a4c; --row-alt: #2b3445; --head-bg: #303a4c;
    --note: #7fb0f5; --tip: #5cc58a; --warning: #e8b04a; --quote: #b69cf5;
    --shadow: rgba(0, 0, 0, .45);
    --accent-soft: #24344d; --ok: #5cc58a; --danger: #f08a80; --lock: #e8c66a;
    --draft: #c9a0f0;
    --bar: #7fb3f0; --bar-weak: #3d5270; --backdrop: rgba(0, 0, 0, .6);
    --bg-edge: #141924; --bg-art: #6d83a3;
    --yin: var(--card); --yang: var(--accent);
    --page: #e9ebee; --page-line: #4a5568;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
       background: var(--bg); color: var(--text); font-size: 1rem; line-height: 1.6;
       font-family: 'Helvetica Neue', Helvetica, 'Arial Nova', 'Segoe UI', Arial, sans-serif, 'Segoe UI Emoji', 'Noto Emoji'; }
a:focus-visible, .nav-toggle:focus-visible + .hamburger { outline: 2px solid var(--accent); outline-offset: 2px; }

/* I10: the background behind everything (base.html .bg-art, a fixed layer): a vignette (--bg in the
   middle, --bg-edge at the screen's edges) and six flowing lines (the taiji's S-curve, stretched) in
   each margin beside the page card, the two sides mirrored; they drift slowly up and down */
.bg-art { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
          background: radial-gradient(ellipse 75% 70% at 50% 42%, var(--bg) 45%, var(--bg-edge) 100%); }
.bg-art svg { position: absolute; top: -2.5rem; width: max(1.5rem, calc((100% - 70rem) / 2)); height: calc(100% + 5rem);
              opacity: .26; animation: bg-drift 14s ease-in-out infinite alternate; }
.bg-art .bg-l { left: 0; }
.bg-art .bg-r { right: 0; }
.bg-art path { fill: none; stroke: var(--bg-art); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
@keyframes bg-drift { from { transform: translateY(0); } to { transform: translateY(-2.25rem); } }

/* I10: the header icon D (the ink-wash taiji in an ensō, inline SVG in base.html), in --accent; the
   taiji's dark half (yin) and light half (yang) are --yin / --yang, so yang stays the light one in
   every palette (the other half is the header's --card, so only one of the two washes shows). On
   the landing page (.morph) it is drawn once: 1 the ensō as one brush stroke (a mask reveals it),
   2 the S-line splits it, 3 the yin rises as ink wash while the S-line fades, 4 the two seeds */
.logo { width: 2.75rem; height: 2.75rem; flex: none; }
.logo-ink { fill: var(--accent); }
.logo-line { fill: none; stroke: var(--accent); }
.logo-yin { fill: var(--yin); }
.logo-yang { fill: var(--yang); }
.logo-wash-yin { stop-color: var(--yin); }
.logo-wash-yang { stop-color: var(--yang); }
.logo .m-brush { stroke-dasharray: 100; }
.logo .m-s { stroke-dasharray: 100; opacity: 0; }
.logo.morph .m-brush { animation: logo-draw 1.3s cubic-bezier(.5, 0, .3, 1) both; }
.logo.morph .m-s { animation: logo-draw .8s ease-in-out 1.4s both, logo-sline 1.1s ease 2.3s both; }
.logo.morph .m-yin { animation: logo-fade 1.1s ease 2.3s both; }
.logo.morph .m-dot { animation: logo-fade .5s ease 3.1s both; }
@keyframes logo-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes logo-sline { from { opacity: 1; } to { opacity: 0; } }
@keyframes logo-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .logo.morph :is(.m-brush, .m-s, .m-yin, .m-dot), .bg-art svg { animation: none; }
}

/* Header and menu (one submenu level) */
.site-header { position: sticky; top: 0; z-index: 100; display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem;
               padding: .6rem 1.5rem; background: var(--card); border-bottom: 2px solid var(--accent); }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: bold; font-size: 1.3rem; color: var(--accent);
         text-decoration: none; }
.menu, .submenu { list-style: none; margin: 0; padding: 0; }
.menu { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.menu > li { position: relative; }
.menu a, .menu-label { display: inline-block; padding: .25rem 0; color: var(--text); text-decoration: none; }
.menu a:hover, .menu a:focus { color: var(--accent); }
.menu li.active > a, .menu li.active > .menu-label { color: var(--accent); border-bottom: 2px solid var(--accent); }
.submenu { display: none; position: absolute; top: 100%; left: 0; z-index: 10; min-width: 11rem; padding: .4rem .8rem;
           background: var(--card); border: 1px solid var(--line); box-shadow: 0 4px 12px var(--shadow); }
.menu > li:hover > .submenu, .menu > li:focus-within > .submenu { display: block; }
.submenu li.active > a { color: var(--accent); font-weight: bold; border: 0; }
/* I2b: members-only entries (shown to members only) */
.menu .lock { color: var(--lock); font-size: .75em; }
.menu .draft { color: var(--draft); font-size: .85em; }

/* Hamburger (CSS-only, no JS): shown below 48rem */
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.hamburger { display: none; cursor: pointer; padding: .5rem; margin-left: auto; }
.hamburger span { display: block; width: 1.6rem; height: 3px; margin: 4px 0; border-radius: 2px; background: var(--accent);
                  transition: transform .2s, opacity .2s; }

.content { flex: 1 0 auto; width: calc(100% - 3rem); max-width: 70rem; margin: 1.5rem auto; padding: 1.6rem 2rem;
            background: var(--card); border-radius: 10px; box-shadow: 0 1px 4px var(--shadow); }   /* I10: the page card */

.site-footer { position: sticky; bottom: 0; z-index: 100; flex-shrink: 0; margin-top: 1rem; padding: .5rem;
               background: var(--card); border-top: 2px solid var(--accent); color: var(--muted); font-size: .9rem; text-align: center; }
/* footer.md (the owner's) first, then the fixed items (date, Adatkezelés) on the same line, " · " between */
.site-footer .footer-inner { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: .2rem .5rem;
                             max-width: 60rem; margin: 0 auto; }
.footer-inner > * + *::before { content: "·"; margin-right: .5rem; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--link); }

/* Account menu (I2a), as in TableTennis: a <details> at the header's right (menu.js closes it on a
   click elsewhere or Esc) */
.account { display: flex; align-items: center; margin-left: auto; white-space: nowrap; font-size: .85rem; }
.account form { margin: 0; }
.accountmenu { position: relative; }
.accountmenu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .3rem; padding: .3rem .55rem;
                       border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-weight: 600; }
.accountmenu summary::-webkit-details-marker { display: none; }
.accountmenu summary:hover, .accountmenu[open] summary { background: var(--row-alt); }
.accountmenu summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.accountmenu .caret { font-size: .65rem; color: var(--muted); }
.accountmenu .who { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.accountpanel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 17rem; max-width: calc(100vw - 2rem);
                padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px var(--shadow); }
.accountpanel .acc-head { padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; white-space: normal; overflow-wrap: anywhere; }
.accountpanel form { margin: 0; }
.accountpanel a, .accountpanel button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: 6px;
                                         color: var(--text); background: none; border: 0; font: inherit; font-size: .875rem; text-align: left;
                                         text-decoration: none; cursor: pointer; }
.accountpanel a:hover, .accountpanel button:hover { background: var(--row-alt); }
.accountpanel a.active { color: var(--accent); font-weight: 600; }
.accountpanel a small.acc-count { margin-left: auto; padding-left: 8px; }
.accountpanel .acc-sep { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.acc-last { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.accountpanel .acc-last > form:first-child button { width: auto; }
/* I2b: Nézet (tag / látogató); the summary shows "látogató" while it is on */
.accountpanel .acc-view { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 10px 4px; }
.viewpick { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.accountpanel .viewpick button { width: auto; padding: 3px 10px; border-radius: 0; font-size: .8rem; }
.accountpanel .viewpick button + button { border-left: 1px solid var(--line); }
.accountpanel .viewpick button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.accountmenu .view-pill { color: var(--lock); border-color: var(--lock); }
/* I2c: the palette switch (A / light / cold / warm): in the account menu's last row, next to
   Kilépés, and in the visitors' footer; the look of the Nézet buttons */
.themes { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.themes button { width: 2rem; height: 1.8rem; padding: 0; border: 0; border-radius: 0; background: none; color: var(--text);
                 font: inherit; font-size: .9rem; line-height: 1; cursor: pointer; justify-content: center; }
.themes button + button { border-left: 1px solid var(--line); }
.themes button:hover { background: var(--row-alt); }
.themes button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.accountpanel .themes button { width: 2rem; padding: 0; border-radius: 0; }
.site-footer .themes { vertical-align: middle; }
.site-footer .themes button { width: 1.8rem; height: 1.5rem; font-size: .8rem; }

/* Account pages: login, Eszközeim, Belépés másik eszközön, Admin */
.box { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: .9rem 1rem; margin-bottom: 1rem; }
.acc-page .box h1 { margin-top: 0; font-size: 1.4rem; }
.acc-page .box h2 { margin-top: 0; display: flex; align-items: center; gap: .5rem; border: 0; font-size: 1.1rem; }
.box-narrow { max-width: 28rem; margin: 1rem auto; }
.cnt { color: var(--muted); font-weight: normal; font-size: .85rem; }
.muted { color: var(--muted); font-size: .88rem; }
.center { text-align: center; }
.btn { display: inline-block; padding: .4rem .9rem; border: 1px solid var(--accent); border-radius: 4px; background: var(--accent);
       color: var(--on-accent); font: inherit; font-size: .92rem; line-height: 1.4; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--accent-hover); }
.btn-ghost { background: none; color: var(--accent); border-color: var(--line); }
.btn-danger { background: none; color: var(--danger); border-color: var(--line); }
.btn-ghost:hover, .btn-danger:hover { background: var(--row-alt); }
.btn-sm { padding: .15rem .55rem; font-size: .8rem; }
/* a link styled as a button inside the page text (.markdown-body a would colour and underline it) */
.acc-page a.btn { color: var(--on-accent); text-decoration: none; }
.acc-page a.btn:hover { color: var(--on-accent); }
.acc-page a.btn-ghost, .acc-page a.btn-ghost:hover { color: var(--accent); }
.btn-link { border: 0; padding: 0; background: none; color: var(--danger); font: inherit; text-decoration: underline; cursor: pointer; }
.pill { display: inline-block; padding: 0 .45rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
        font-size: .72rem; font-weight: normal; vertical-align: middle; }
.pill-ok { color: var(--ok); border-color: var(--ok); }
.pill-lock { color: var(--lock); border-color: var(--lock); }
.pill-draft { color: var(--draft); border-color: var(--draft); }
.members-note { margin: -.4rem 0 1rem; }
.notice { padding: .5rem .8rem; border-left: 4px solid var(--ok); background: var(--row-alt); border-radius: 4px; }
.notice-bad { border-left-color: var(--danger); }
.field { min-width: 0; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 4px; background: var(--bg);
         color: var(--text); font: inherit; font-size: .9rem; }
.dev { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; padding: .6rem .8rem; background: var(--card);
       border: 1px solid var(--line); border-radius: 6px; }
.dev form { margin: 0; }
.dev-ic { font-size: 1.4rem; }
.dev-t { flex: 1; min-width: 0; }
.dev-t b { display: block; }
.dev-t span { font-size: .82rem; color: var(--muted); }
.qr { display: flex; justify-content: center; margin: .6rem 0; }
.qr svg { width: 12rem; height: auto; max-width: 100%; border-radius: 4px; }
/* I2c: the admin tabs (admin.js); a full-width bar, the tabs share it and wrap on a narrow screen */
.tabbar { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 1rem; border-bottom: 1px solid var(--line); }
.tabbar a { flex: 1 1 auto; margin-bottom: -1px; padding: .35rem .9rem; border: 1px solid var(--line); border-bottom: 0;
            border-radius: 6px 6px 0 0; color: var(--text); text-align: center; text-decoration: none; }
.tabbar a.on { background: var(--card); color: var(--accent); font-weight: bold; border-bottom: 1px solid var(--card); }
.tabbar, .tabpanel { max-width: 48rem; }
.acc-page .box form { margin: .5rem 0 0; }
.kv { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; margin: .2rem 0 .6rem; }
.kv b { font-size: 1.1rem; }
.acc-page .box p { margin: .3rem 0; }
.acc-page .box p.warn-line { color: var(--danger); font-size: .88rem; overflow-wrap: anywhere; }
.acc-page ul.facts { margin: 0; padding: 0; list-style: none; font-size: .9rem; overflow-wrap: anywhere; }
.acc-page ul.facts li { margin: .15rem 0; }
.ok { color: var(--ok); }
.bad { color: var(--danger); }
/* I3: the Országszűrés card: a term / value list (stacked on phones), the mode pill, the IP tester */
.acc-page dl.facts-dl { display: grid; grid-template-columns: auto 1fr; gap: .15rem .8rem; margin: .2rem 0 .6rem;
                        font-size: .9rem; overflow-wrap: anywhere; }
.acc-page dl.facts-dl dt { color: var(--muted); }
.acc-page dl.facts-dl dd { margin: 0; }
@media (max-width: 40rem) {
  .acc-page dl.facts-dl { grid-template-columns: 1fr; gap: 0; }
  .acc-page dl.facts-dl dd { margin-bottom: .3rem; }
}
.pill-mode { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); font-weight: bold; font-size: .8rem; }
.ip-form label { display: block; }
.ip-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.ip-row .field { flex: 0 1 13rem; }
.acc-page .box p.ip-res { margin: .5rem 0; padding: .4rem .6rem; border-left: 3px solid var(--accent); background: var(--row-alt);
                          font-size: .88rem; overflow-wrap: anywhere; }
.acc-page table.members { display: table; width: 100%; border-collapse: collapse; font-size: .9rem; }
.acc-page .members th, .acc-page .members td { padding: .4rem; border: 0; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.acc-page .members th { border-top: 0; color: var(--muted); font-weight: normal; font-size: .8rem; }
.members td.act { text-align: right; }
.members td.act form, .members td.act details { display: inline-block; margin: 0 0 .2rem; }
.acc-page .members tr.new-row td { background: var(--row-alt); }
.new-member { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; }
.devs summary { color: var(--muted); font-size: .82rem; cursor: pointer; }
.dev-line { margin: 0; padding-left: .8rem; color: var(--muted); font-size: .82rem; }
.confirm[open] form { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; justify-content: flex-end; margin-top: .3rem; }
.confirm summary { list-style: none; }
.confirm summary::-webkit-details-marker { display: none; }

/* I1: the statistics popup (a <dialog>, full screen on phones) and its content (stats.html; the
   no-JS page stats_page.html). Charts are SVG: bars <rect class="b|w">, table bars svg.hb. */
dialog.stats-dlg { width: min(62rem, calc(100% - 2rem)); max-width: none; max-height: calc(100% - 2rem); padding: 0;
                   background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
                   box-shadow: 0 8px 30px var(--shadow); }
dialog.stats-dlg[open] { display: flex; flex-direction: column; }
dialog.stats-dlg::backdrop { background: var(--backdrop); }
.dlg-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.acc-page .dlg-head h1, .acc-page .dlg-head h2 { margin: 0; padding: 0; border: 0; font-size: 1.15rem; }
.stats-page .dlg-head { padding: 0 0 .7rem; margin-bottom: 1rem; }
.stats-page .dlg-head .btn { margin-left: auto; }
.close { margin-left: auto; width: 2.4rem; height: 2.4rem; border: 1px solid var(--line); border-radius: 4px; background: none;
         color: var(--text); font-size: 1.2rem; cursor: pointer; }
.close:hover { background: var(--row-alt); }
.dlg-body { overflow: auto; padding: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.seg a, .seg button { border: 0; background: none; color: var(--text); padding: .3rem .7rem; font: inherit; font-size: .9rem;
                      text-align: center; text-decoration: none; cursor: pointer; }
.seg a + a, .seg button + button { border-left: 1px solid var(--line); }
.seg a.on, .seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: bold; }
.seg.sm { margin-bottom: .4rem; }
.seg.sm button { padding: .15rem .6rem; font-size: .8rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.tile { border: 1px solid var(--line); border-radius: 6px; padding: .5rem .7rem; background: var(--row-alt); }
.tile b { display: block; font-size: 1.45rem; line-height: 1.2; }
.tile span { display: block; color: var(--muted); font-size: .8rem; }
.tile .delta { font-size: .75rem; }
.delta.up::before { content: "▲ "; }
.delta.down::before { content: "▼ "; }
.stats-dlg .grid, .stats-page .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stats-dlg .box, .stats-page .box { min-width: 0; margin: 0; padding: .6rem .8rem; }
.stats-dlg .box.wide, .stats-page .box.wide { grid-column: 1 / -1; }
.stats-dlg .box h3, .stats-page .box h3 { margin: 0 0 .4rem; font-size: .95rem; }
.stats-dlg .box h3 small, .stats-page .box h3 small { color: var(--muted); font-weight: normal; }
.stats-dlg .box h4, .stats-page .box h4 { margin: .4rem 0 .2rem; font-size: .85rem; }
.stats-dlg .dlg-body p, .stats-page .stats-body p { margin: .3rem 0; }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart rect.b { fill: var(--bar); }
svg.chart rect.w { fill: var(--bar-weak); }
svg.chart text { fill: var(--muted); font-size: 20px; }
svg.chart line { stroke: var(--line); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; margin-right: .3rem; vertical-align: -1px; border-radius: 2px; }
.legend i.b { background: var(--bar); }
.legend i.w { background: var(--bar-weak); }
.acc-page table.top, .stats-dlg table.top { display: table; width: 100%; border-collapse: collapse; font-size: .88rem; }
table.top td { padding: .2rem .3rem; border: 0; border-top: 1px solid var(--line); vertical-align: middle; }
table.top tr:first-child td { border-top: 0; }
table.top td.n { text-align: right; white-space: nowrap; width: 1%; font-variant-numeric: tabular-nums; }
table.top td.name { overflow-wrap: anywhere; }
table.top td.bar { width: 28%; }
table.top tr.drill td { background: var(--row-alt); }
table.top.susip { margin-top: .5rem; font-size: .8rem; }
svg.hb { display: block; width: 100%; height: .55rem; }
svg.hb rect { fill: var(--bar); }
.note { font-size: .8rem; color: var(--muted); margin: .8rem 0 0; }

@media (max-width: 48rem) {
  .site-header { gap: .5rem; padding: .5rem 1rem; }
  .logo { width: 2.3rem; height: 2.3rem; }
  .bg-art svg { width: .5rem; }
  /* B6: a three-column bar: the brand left, the menu button in the middle of the screen (it moves aside
     only when a side has no room, never overlapping), the account menu right; the open menu below */
  .site-header { display: grid; grid-template-columns: 1fr auto 1fr; }
  .brand { grid-area: 1 / 1; justify-self: start; }
  .hamburger { grid-area: 1 / 2; }
  .account { grid-area: 1 / 3; justify-self: end; margin-left: 0; }
  .site-header nav { grid-area: 2 / 1 / 3 / -1; }
  .accountmenu summary { padding: .3rem .45rem; }
  .accountmenu .who { max-width: 4.5rem; }
  .members thead { display: none; }
  .acc-page .members tr { display: block; padding: .4rem 0; border-top: 1px solid var(--line); }
  .acc-page .members td { display: block; padding: .1rem 0; border: 0; }
  .members td.act { text-align: left; padding-top: .3rem; }
  .hamburger { display: block; }
  .site-header nav { display: none; flex-basis: 100%; }
  .nav-toggle:checked ~ nav { display: block; }
  .nav-toggle:checked + .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle:checked + .hamburger span:nth-child(2) { opacity: 0; }
  .nav-toggle:checked + .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .menu { flex-direction: column; gap: 0; }
  .menu > li { border-top: 1px solid var(--line); }
  .menu a, .menu-label { display: block; padding: .6rem 0; }
  .submenu { display: block; position: static; min-width: 0; padding: 0 0 .4rem 1rem; border: 0; box-shadow: none; }
  .content { width: calc(100% - 1rem); margin: .75rem auto; padding: 1rem; border-radius: 8px; }
  .d-only { display: none; }   /* desktop only: the phone footer stays one line */
  dialog.stats-dlg { width: 100%; height: 100%; max-height: none; margin: 0; border: 0; border-radius: 0; }
  .stats-dlg .seg, .stats-page .seg { order: 3; width: 100%; }
  .stats-dlg .seg a, .stats-page .seg a { flex: 1; }
  .stats-dlg .grid, .stats-page .grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  table.top td.bar { width: 22%; }
  .footer-themes::before { display: none; }   /* the switch wraps to its own line: no "·" before it */
}
/* B6: the narrowest phones (320 px) keep the brand, the button and the account menu with its view pill on one line */
@media (max-width: 22rem) {
  .site-header { padding-inline: .75rem; }
  .accountmenu summary { padding-inline: .3rem; }
}

/* Downloads list (::: downloads and the downloads page) */
.page-title { margin-top: 2rem; }
.dl-section h2 { border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.dl-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr)); }
.dl-item { display: flex; gap: .9rem; min-width: 0; padding: .8rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.dl-item.card { flex-direction: column; align-items: flex-start; }
.dl-item.row { grid-column: 1 / -1; flex-direction: row; align-items: center; }
.dl-info { min-width: 0; overflow-wrap: anywhere; }
.dl-thumb { flex-shrink: 0; width: 96px; height: 96px; object-fit: cover; background: var(--code-bg); border-radius: 4px; }
/* I5: the thumbnail links to the download (no second tab stop); a PDF page or a cover keeps its shape on paper */
.dl-thumb-link { position: relative; flex-shrink: 0; display: block; line-height: 0; }
.dl-thumb.doc { width: auto; height: 96px; max-width: 96px; object-fit: contain; background: var(--page);
                border: 1px solid var(--page-line); border-radius: 2px; box-shadow: 0 1px 4px var(--shadow); }
.dl-item.card .dl-thumb.doc { height: 120px; max-width: 120px; }
.dl-badge { position: absolute; left: -4px; bottom: 6px; padding: 0 .3rem; border-radius: 3px; background: var(--accent);
            color: var(--on-accent); font: bold .66rem/1.35 system-ui, sans-serif; letter-spacing: .03em; }
.dl-title { display: block; font-weight: bold; color: var(--link); }
.dl-desc { margin: .2rem 0; color: var(--muted); }
.dl-meta { font-size: .8rem; color: var(--muted); }
