/* Calcoala — main stylesheet. No framework. Logical properties = automatic RTL. */

/* ---------- Fonts (self-hosted, subset WOFF2 — see src/assets/fonts) ---------- */
@font-face { font-family: "Geist Mono"; src: url(/assets/fonts/geist-mono-latin.565f272e.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Paytone One"; src: url(/assets/fonts/paytone-one-latin.3577b1cb.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(/assets/fonts/rubik-latin.e4494183.woff2) format("woff2"); font-weight: 300 900; font-display: swap;
  unicode-range: U+0000-024F, U+0259, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0300-0304, U+0308, U+0323, U+1E00-1EFF, U+2000-214F, U+2190-21FF, U+2212, U+2215, U+2248, U+2260, U+2264-2265, U+FEFF, U+FFFD; }
@font-face { font-family: "Rubik"; src: url(/assets/fonts/rubik-arabic.dd2f0c98.woff2) format("woff2"); font-weight: 300 900; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200F, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFF; }

/* ---------- Tokens ---------- */
:root {
  /* Brand palette */
  --brand: hsl(101 65% 51%);          /* CTA / main pop colour */
  --brand-dark: hsl(212 15% 17%);     /* dark */
  --brand-mud: hsl(210 9% 35%);       /* mud-dark */
  --brand-mist: hsl(210 29% 90%);     /* accent-bg */
  --brand-paper: hsl(210 16% 98%);    /* off-white bg */

  --bg: var(--brand-paper);
  --surface: #ffffff;
  --surface-2: hsl(210 29% 95.5%);
  --surface-3: var(--brand-mist);
  --border: hsl(210 24% 89%);
  --border-strong: hsl(210 16% 80%);
  --text: var(--brand-dark);
  --text-2: var(--brand-mud);
  --text-3: hsl(210 8% 44%);
  --accent: var(--brand);             /* fills, borders, focus — never small text on white */
  --accent-hover: hsl(101 60% 45%);
  --accent-ink: var(--brand-dark);    /* text on the green */
  --accent-soft: hsl(101 62% 93%);
  --result-bg: hsl(101 35% 96.5%);   /* result boxes: muted tint (stripes added on top) */
  --accent-text: hsl(101 70% 28%);    /* green that passes 4.5:1 on white */
  --ring: hsl(101 65% 51% / .35);
  --warn-soft: #fff6e0;
  --h1-a: hsl(212 16% 16%); --h1-b: hsl(210 10% 27%); --h1-c: hsl(210 8% 38%);
  --h1-stroke: hsl(212 16% 16% / .2);
  --shadow-sm: 0 1px 2px hsl(212 15% 17% / .05);
  --shadow: 0 1px 2px hsl(212 15% 17% / .04), 0 4px 16px hsl(212 15% 17% / .06);
  --shadow-lg: 0 10px 40px hsl(212 15% 17% / .16);
  --content-bg: color-mix(in srgb, #fff 55%, var(--brand-paper));   /* content column: brighter than the page, not pure white */
  --btn-bg: #fff;   /* buttons: white face */
  --badge: oklch(0.6 0.22 25);  /* count bubbles (favourites, history): white on red, 4.6:1 */
  --shadow-btn: 0 0 0 1px rgba(0, 0, 0, .08), 0 8px 2px 0 rgba(0, 0, 0, 0), 0 4px 2px 0 rgba(0, 0, 0, .01), 0 2px 1px 0 rgba(0, 0, 0, .04), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 1px 0 rgba(0, 0, 0, .08);  /* buttons: the ring is the outline */
  --shadow-control: inset 0 -1.5px 0 hsl(212 15% 17% / .06), 0 1px 1px hsl(212 15% 17% / .07), 0 1px 3px -1px hsl(212 15% 17% / .07);  /* controls and cards: weighted bottom edge + 1px lift */
  /* logo + koala badge in every colour, one cached file; --logo-y picks the row (brand green = 0%, set per page in layout.mjs) */
  --sprite: url(/assets/brand/logo-sprite.d4a8a7f2.svg); --logo-y: 0%;
  /* Type scale (rem, so the reader's font size applies). One size + line-height + weight per role. */
  --fs-caption: .8125rem;  /* 13 — meta, footnotes */
  --fs-small: .875rem;     /* 14 — labels, UI text */
  --fs-body: .9375rem;         /* 15 — body */
  --fs-lead: 1.0625rem;     /* 17 — intro paragraph, card titles */
  --fs-h3: 1.1875rem;        /* 19 */
  --fs-h2: 1.4375rem;        /* 23 */
  --fs-h1: clamp(1.5625rem, .75rem + 2vw, 2.4375rem); /* 25 → 39, tool pages */
  --fs-display: clamp(1.8125rem, .85rem + 2.6vw, 2.9375rem); /* 29 → 47, home hero */
  --fw-body: 400; --fw-medium: 500;
  /* Paytone One ships one weight (400, already heavy). Headings stay at 400 so the browser never fakes a bold. */
  --fw-heading: 400; --fw-subheading: 400;
  /* Spacing scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  /* Corner radii, calculated from size: a control gets about a third of its height; a container gets its inner radius
     plus half its padding, so nested corners stay concentric. Plain round arcs, no superellipse. */
  --r-2xs: 6px;   /* ≤ 24px: badges, keycaps, inline code */
  --r-xs: 9px;    /* 28–32px: chips, menu items, small toggles, tooltips */
  --r-sm: 11px;   /* 32–40px: buttons, icon buttons, sidebar rows */
  --r-md: 13px;   /* 40–44px: inputs, selects, swap, back-to-top, menus */
  --r-lg: 15px;   /* 52–56px: big inputs, result boxes, panels, tables */
  --r-xl: 18px;   /* tiles, dialogs */
  --r-card: calc(var(--r-lg) + 6px);  /* converter / calculator card: its inputs' radius + a little, so the corners still nest */
  --radius: var(--r-card); --radius-sm: var(--r-md); --radius-xs: var(--r-xs);
  --header-h: 72px;
  --side-w: 264px; --rail-w: 300px; --gap: 32px;
  --font: "Rubik", sans-serif;   /* self-hosted fonts only: Rubik, Paytone One, Geist Mono */
  --font-display: "Paytone One", var(--font);
  --mono: "Geist Mono", monospace;
  color-scheme: light only;
}
/* Paytone One has no Arabic or CJK glyphs: Arabic headings use Rubik bold; Chinese headings take a real bold from the system CJK font,
   while Paytone keeps its Latin letters (font-synthesis-weight: none on headings stops a faked Paytone bold). */
:lang(ar) { --font: "Rubik", sans-serif; --font-display: var(--font); --fw-heading: 700; --fw-subheading: 600; }
:lang(zh) { --font: "Rubik", sans-serif; --font-display: "Paytone One", var(--font); --fw-heading: 700; --fw-subheading: 600; }
/* Category pages: the accent follows the page's category / calculator hue (body carries --page-hue).
   Same roles as the brand green: a fill, a text shade that passes 4.5:1, a soft background and a focus ring. */
body[style*="--page-hue"] {
  --accent: oklch(0.72 0.17 var(--page-hue)); --accent-hover: oklch(0.62 0.16 var(--page-hue));
  --accent-text: oklch(0.47 0.14 var(--page-hue)); --accent-soft: oklch(0.95 0.045 var(--page-hue)); --result-bg: oklch(0.975 0.02 var(--page-hue));
  --ring: oklch(0.72 0.17 var(--page-hue) / .35);
}
/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--text); overflow-x: clip;
  font: var(--fw-body) var(--fs-body)/1.6 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
img, svg { display: block; }
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--fw-subheading); font-synthesis-weight: none; line-height: 1.2; letter-spacing: 0; text-wrap: balance; margin: 0; }
/* Section headings sit a step back from the H1: text colour at 80%, mixed into the page so it stays solid */
h2, h3 { color: color-mix(in oklab, var(--text) 80%, var(--bg)); }
h2 { font-size: var(--fs-h2); letter-spacing: -0.01em; }
h3 { font-size: var(--fs-h3); line-height: 1.3; }
/* Headline style (brand): Paytone One, 64px, cap-trimmed, wordmark gradient + hairline stroke */
h1 {
  font-size: var(--fs-h1); font-weight: var(--fw-heading); line-height: 1.08; letter-spacing: -0.02em;
  color: var(--h1-b); width: fit-content; max-width: 100%;
  text-box: trim-both cap alphabetic;
  /* the gradient only paints inside the box: pad it past accents/descenders, then cancel the padding out */
  padding-block: .22em .26em; margin-block: -.22em -.26em;
  -webkit-text-stroke: 1px var(--h1-stroke);
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  h1 {
    background: linear-gradient(100deg, var(--h1-a) 0%, var(--h1-b) 55%, var(--h1-c) 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}
/* The gradient H1 paints its letters transparent (background-clip: text). Selected text needs a solid fill or it vanishes under the highlight. */
@media (forced-colors: active) { h1 { background: none; -webkit-text-fill-color: currentColor; -webkit-text-stroke: 0; } }
:lang(ar) :is(h1, h2, h3), :lang(zh) :is(h1, h2, h3) { letter-spacing: 0; }
:lang(ar) h1 { line-height: 1.3; text-box: none; }
:lang(zh) h1 { line-height: 1.2; }
p { margin: 0 0 1em; text-wrap: pretty; }
/* no orphans anywhere: body text never leaves a single word alone on its last line (headings balance instead) */
body { text-wrap: pretty; }
/* short labels (card and tile titles, chips, sidebar links): balance the lines so a two-line label never ends with one word */
:is(.tile-title, .cat-card h3, .cat-card strong, .pager-link, .side-sub a, .crumbs li, .chip, .footer-col a, th, dt, figcaption, label) { text-wrap: balance; }
strong, b { font-weight: var(--fw-medium); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: 6px; }
/* Page text can't be selected or copied (app.js also blocks copy / cut / right-click); form fields stay fully editable.
   No selection colour on the page; inside fields a neutral grey so you can still see what you've selected. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:is(input, textarea, select, [contenteditable]) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
img, svg { -webkit-user-drag: none; }
::selection { background: transparent; }
:is(input, textarea)::selection { background: hsl(212 15% 17% / .14); color: inherit; }
.i { flex: none; }
.i-sm { width: 16px; height: 16px; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--r-xs); }
.skip:focus { top: 12px; }
kbd { font: 12px/1 var(--mono); padding: 3px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-2xs); color: var(--text-3); background: var(--surface); }

/* ---------- Press feedback ---------- */
/* Every button (and button-like control) dips to 90% while pressed; disabled controls never move. */
:where(button, summary, .chip, [role="tab"]) { transition: scale .15s ease-out; }
:is(button, summary, .chip):not(:disabled):active { scale: .9; }

/* ---------- Tooltips ---------- */
/* data-hint is filled by app.js from each icon-only control's label (aria-label), so every language is covered.
   Shown after a short hover delay on mouse devices and immediately on keyboard focus; never on touch taps. */
:where([data-hint]) { position: relative; }
[data-hint]::after {
  content: attr(data-hint); position: absolute; z-index: 90; inset-inline-start: 50%; bottom: calc(100% + 8px);
  translate: -50% 4px; padding: 5px 9px; border-radius: var(--r-xs); background: var(--text); color: var(--bg);
  font: 450 .75rem/1.3 var(--font); letter-spacing: 0; text-transform: none; white-space: nowrap;
  box-shadow: var(--shadow); pointer-events: none; opacity: 0; transition: opacity .12s ease-out, translate .12s ease-out;
}
[dir="rtl"] [data-hint]::after { translate: 50% 4px; }
@media (hover: hover) { [data-hint]:hover::after { opacity: 1; translate: -50% 0; transition-delay: .4s; } [dir="rtl"] [data-hint]:hover::after { translate: 50% 0; } }
[data-hint]:focus-visible::after { opacity: 1; translate: -50% 0; }
[dir="rtl"] [data-hint]:focus-visible::after { translate: 50% 0; }
/* below the control: top bar on phones/tablets, dialog headers */
:is(.search-dialog, .lib-drawer, .sidebar-head) [data-hint]::after { bottom: auto; top: calc(100% + 8px); translate: -50% -4px; }
[dir="rtl"] :is(.search-dialog, .lib-drawer, .sidebar-head) [data-hint]::after { translate: 50% -4px; }
@media (max-width: 1023px) {
  .topbar [data-hint]::after { bottom: auto; top: calc(100% + 8px); translate: -50% -4px; }
  [dir="rtl"] .topbar [data-hint]::after { translate: 50% -4px; }
}
/* beside the control: the desktop icon bar, the sidebar chevrons (kept inside the scrolling sidebar) and back-to-top */
@media (min-width: 1024px) {
  .topbar [data-hint]::after, .topbar [data-hint]:hover::after, .topbar [data-hint]:focus-visible::after { inset-inline-start: calc(100% + 10px); bottom: auto; top: 50%; translate: 0 -50%; }
}
.side-toggle[data-hint]::after, .side-toggle[data-hint]:hover::after, .side-toggle[data-hint]:focus-visible::after,
.to-top[data-hint]::after, .to-top[data-hint]:hover::after, .to-top[data-hint]:focus-visible::after { inset-inline-start: auto; inset-inline-end: calc(100% + 10px); bottom: auto; top: 50%; translate: 0 -50%; }
@media (forced-colors: active) { [data-hint]::after { border: 1px solid CanvasText; } }

/* ---------- Header ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--header-h); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-in { height: 100%; max-width: 1480px; margin: 0 auto; padding-inline: 24px; display: flex; align-items: center; gap: var(--s-4); }
.brand { display: inline-flex; align-items: center; flex: none; border-radius: var(--r-xs); }
.brand-logo { display: block; width: 200px; aspect-ratio: 368 / 104; background: var(--sprite) no-repeat 0 var(--logo-y) / 132.6087% auto; }   /* sprite is 488 wide, the logo cell 368 */.footer-brand .brand-logo { width: 208px; }
.sidebar-head .brand-logo { width: 168px; }
.search-trigger { flex: 1; min-width: 0; max-width: 520px; margin-inline: auto; height: 40px; display: flex; align-items: center; gap: 10px; padding-inline: 12px 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); color: var(--text-3); text-align: start; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, scale .15s ease-out; }
.search-trigger span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-body); }
.search-trigger:hover { border-color: var(--border-strong); }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: var(--r-sm); color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-btn { display: none; }
.lang-menu { position: relative; }
.lang-menu summary { list-style: none; height: 40px; display: flex; align-items: center; gap: 6px; padding-inline: 10px; border-radius: var(--r-sm); color: var(--text-2); cursor: pointer; font-size: var(--fs-small); font-weight: var(--fw-medium); }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu:not(.lang-menu-up) summary:hover { background: var(--surface-2); color: var(--text); }
.lang-menu ul { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 170px; margin: 0; padding: 0; overflow: hidden; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); z-index: 50; }
.lang-menu a { display: block; padding: 10px 16px; border-radius: 0; color: var(--text); text-decoration: none; font-size: .8125rem; }
.lang-menu a:hover { background: var(--surface-2); }
.lang-menu a[aria-current] { color: var(--text); font-weight: var(--fw-medium); background: var(--surface-2); }

/* Desktop: no top bar. A thin full-height icon bar (badge · search · favorites · history … language) sits
   beside the navigation sidebar; both stay put while the content column (page + footer) scrolls. */
@media (min-width: 1024px) {
  :root { --header-h: 0px; --bar-w: 64px; }
  .side-col { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; }
  .topbar { position: static; flex: none; width: var(--bar-w); height: auto; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; border: 0; border-inline-end: 1px solid var(--border); }
  .topbar-in { height: 100%; max-width: none; margin: 0; padding: var(--s-4) 0; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
  .topbar .brand-logo { width: 44px; aspect-ratio: 1; background-position: 100% var(--logo-y); background-size: 469.2308% auto; }
  .topbar .brand { margin-top: 8px; margin-bottom: var(--s-3); }
  .topbar .search-trigger { flex: none; width: 44px; height: 44px; padding: 0; margin: 0; justify-content: center; border-color: transparent; box-shadow: none; background: transparent; color: var(--text-2); border-radius: var(--r-sm); }
  .topbar .search-trigger span, .topbar .search-trigger kbd { display: none; }
  .topbar .search-trigger:hover { background: var(--surface-2); color: var(--text); }
  .topbar .icon-btn { width: 44px; height: 44px; }
  .top-actions { flex: none; flex-direction: column; align-items: center; gap: var(--s-2); }
  /* logo at the top; a faint line runs down to search, favourites, history and language grouped at the bottom */
  .topbar-in::before { content: ""; order: 1; flex: 1; width: 1px; margin-block: var(--s-1) var(--s-3); background: hsl(0 0% 100% / .1); }
  .topbar .search-trigger, .top-actions { order: 2; }
  .topbar .lang-menu summary { flex-direction: column; justify-content: center; gap: 2px; width: 44px; height: auto; min-height: 44px; padding: 4px 0; font-size: .6875rem; }
  .topbar .lang-menu ul { top: auto; bottom: 0; inset-inline-end: auto; inset-inline-start: calc(100% + 10px); }
  .side-col .sidebar { position: static; flex: 1; min-width: 0; min-height: 0; height: auto; max-height: none; overflow: hidden auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; padding: var(--s-6) 20px 0; }
  .side-col .side-nav { flex: none; overflow: visible; min-height: auto; }  /* the whole sidebar scrolls (padding included), so lists run right up to its rounded edge */
  /* full-width app shell: bar + sidebar flush with the window's start edge, ad rail at the end, page centred between */
  body .shell { max-width: none; margin: 0; padding-inline: 0 24px; grid-template-columns: calc(var(--bar-w) + var(--side-w)) minmax(0, 1fr); }
  body.has-ads .shell { grid-template-columns: calc(var(--bar-w) + var(--side-w)) minmax(0, 1fr) calc(var(--rail-w) + var(--gap)); }
  .rail-sticky { top: var(--s-6); }
}
@media (min-width: 1024px) {
  body .shell { column-gap: 0; }
  .content-col { min-height: calc(100vh - 16px); min-height: calc(100dvh - 16px); margin-block: 8px; padding-inline: clamp(32px, 4vw, 64px); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 2px 0 rgba(0, 0, 0, 0), 0 4px 2px 0 rgba(0, 0, 0, .01), 0 2px 1px 0 rgba(0, 0, 0, .04), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 1px 0 rgba(0, 0, 0, .08); }  /* button shadow (its ring is the border); a rounded white card 8px in from the top and bottom; the fixed frame below keeps those edges in view while the page scrolls */
  body.has-ads .rail { padding-inline-start: var(--gap); }  /* the gap lives inside the rail's own column, so the 300px slot keeps its width */
}
/* Desktop icon bar: the H1's dark gradient, light icons */
@media (min-width: 1024px) {
  .side-col { background: linear-gradient(180deg, hsl(212 16% 16%) 0%, hsl(210 10% 24%) 55%, hsl(210 9% 31%) 100%); }
  .topbar { background: transparent; border-inline-end: 0; }
  .side-col .sidebar { background: var(--bg); border-start-start-radius: 14px; border-end-start-radius: 14px; }
  .topbar .icon-btn, .topbar .search-trigger, .topbar .lang-menu summary { color: hsl(210 20% 88% / .78); background: transparent; }
  .topbar .icon-btn:hover, .topbar .search-trigger:hover, .topbar .lang-menu summary:hover, .topbar .lang-menu[open] summary { color: #fff; background: hsl(0 0% 100% / .1); }
  .topbar :focus-visible { outline-color: #fff; }
  .topbar .lib-badge { background: var(--badge); box-shadow: 0 0 0 2px hsl(212 16% 18%); }
}
@media (min-width: 1024px) and (max-width: 1279px) { body.has-ads .shell { grid-template-columns: calc(var(--bar-w) + var(--side-w)) minmax(0, 1fr); } }

/* ---------- Shell: sidebar | main | ad rail ---------- */
.shell { max-width: 1480px; margin: 0 auto; padding-inline: 24px; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.has-ads .shell { grid-template-columns: var(--side-w) minmax(0, 1fr) var(--rail-w); }
.content-col { min-width: 0; background: var(--content-bg); }
.main { min-width: 0; padding-block: var(--s-6) var(--s-8); max-width: 800px; width: 100%; margin-inline: auto; }
.main:focus { outline: none; }

.sidebar { position: sticky; top: var(--header-h); max-height: calc(100vh - var(--header-h)); max-height: calc(100dvh - var(--header-h)); overflow-y: auto; padding-block: var(--s-6) var(--s-7); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.sidebar-head { display: none; }
/* Sidebar: each item carries an OKLCH hue (--hue) → tinted icon tile. Same lightness across hues, so no colour shouts. */
.side-nav { display: grid; align-content: start; }   /* groups stack at the top instead of stretching to fill the sidebar */
.side-group { padding-block: var(--s-4); }
.side-group:first-child { padding-top: 0; }
.side-group:not([hidden]) ~ .side-group:not([hidden]) { border-top: 1px solid var(--border); }
.side-group h2 {
  display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); padding-inline: 10px;
  font-family: var(--font-display); font-weight: var(--fw-subheading); font-size: .875rem; letter-spacing: 0; color: var(--text);
}
.side-group h2 a { color: inherit; text-decoration: none; }
.side-group h2 a:hover { color: var(--accent-text); }
.side-count { margin-inline-start: auto; min-width: 22px; padding: 1px 7px; border-radius: var(--r-2xs); background: var(--surface-3); color: var(--text-2); font: var(--fw-medium) .75rem/1.5 var(--font); text-align: center; }
.side-h-ico { display: inline-grid; place-items: center; color: var(--text-3); }
.side-h-ico.is-star { color: oklch(0.72 0.15 75); }
.side-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }

.side-link { display: flex; align-items: center; gap: var(--s-3); padding: 6px 10px 6px 6px; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--text-2); text-decoration: none; font-size: .875rem; line-height: 1.3; transition: background-color .15s, color .15s, scale .15s ease-out; }
/* Glossy icons: gradient fill (url via --ico-fill, set per item) + 20% inner shadow (filter #ico-fx) */
.ico-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico-g0 { stop-color: oklch(0.5 0.17 var(--hue)); }   /* bottom: darker */
.ico-g1 { stop-color: oklch(0.76 0.15 var(--hue)); }  /* top: lighter */
.side-ico { flex: none; width: 26px; height: 26px; display: grid; place-items: center; }
.side-ico .i { width: 26px; height: 26px; overflow: visible; }
.side-ico path { fill: var(--ico-fill, currentColor); filter: url(#ico-fx); }
.side-ico path[fill="none"] { fill: none; }
.side-ico path[stroke] { stroke: var(--ico-fill, currentColor); }
/* Yellow turns muddy at the shared lightness; lift it */
#ico-g95 .ico-g0 { stop-color: oklch(0.68 0.16 88); }
#ico-g95 .ico-g1 { stop-color: oklch(0.88 0.15 98); }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active { background: var(--surface); color: var(--text); font-weight: var(--fw-medium); }
:root:root .side-link.is-active { box-shadow: var(--shadow-btn); }   /* one clean ring + soft lift (same as buttons) */

/* Category accordion: the whole row is a button; its chevron springs round when it opens */
.side-cat-btn { width: 100%; background: transparent; font-family: inherit; text-align: start; cursor: pointer; }
.side-chev { flex: none; width: 16px; height: 16px; margin-inline-start: auto; color: var(--text-3); transition: rotate .45s cubic-bezier(.34, 1.56, .64, 1); }
.side-cat.is-open > .side-cat-btn .side-chev { rotate: 90deg; }
[dir="rtl"] .side-cat.is-open > .side-cat-btn .side-chev { rotate: -90deg; }
.side-group .side-sub[hidden] { display: none; }

/* A category's pairs: an indented list hung on a thin line in the category colour */
.side-group .side-sub { display: grid; gap: 0; margin: 0; margin-inline-start: 18px; padding-inline-start: var(--s-3); overflow: hidden; border-inline-start: 2px solid oklch(0.88 0.06 var(--hue, 250)); }
.side-sub > li:first-child { margin-top: var(--s-1); }
.side-sub > li:last-child { margin-bottom: var(--s-2); }
.side-all a { color: oklch(0.45 0.13 var(--hue, 250)) !important; font-weight: var(--fw-medium); }
.side-sub a { display: block; padding: 5px 10px; font-size: var(--fs-small); color: var(--text-2); text-decoration: none; border-radius: var(--r-xs); }
.side-sub a:hover { color: var(--text); background: var(--surface-2); }
.side-sub a[aria-current] { color: oklch(0.45 0.13 var(--hue, 250)); font-weight: var(--fw-medium); background: oklch(0.96 0.03 var(--hue, 250)); }

/* The glossy sidebar icons, reused on cards and chips (sizes only; colour and gloss come from .side-ico) */
.card-ico, .card-ico .i { width: 30px; height: 30px; }
.cat-ico, .cat-ico .i { width: 30px; height: 30px; }
.chip-ico, .chip-ico .i { width: 18px; height: 18px; }
.cat-card h3 a:hover { color: oklch(0.45 0.13 var(--hue, 140)); }
/* Sidebar = navigation only; it scrolls on its own. Favorites / Recently used live in the top-bar drawer. */
.sidebar { display: flex; flex-direction: column; }
.side-nav { flex: 1 1 auto; min-height: 0; margin-inline: -4px; padding-inline: 4px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; padding-bottom: var(--s-4); }
/* Favorites / Recently used drawer (opened from the top bar) */
.lib-btn { position: relative; }
.lib-badge { position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px; border-radius: 3px; background: var(--badge); box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }  /* dot: the list has items */ /* same pill as the sidebar counts */
.lib-badge[hidden] { display: none; }
.lib-drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; inset-inline-start: auto; margin: 0; width: min(400px, 92vw); max-width: none; height: 100dvh; max-height: none;
  padding: 0; border: 0; border-inline-start: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  flex-direction: column; overscroll-behavior: contain;
}
.lib-drawer[open] { display: flex; animation: lib-in .22s cubic-bezier(.2, 0, 0, 1); }
[dir="rtl"] .lib-drawer[open] { animation-name: lib-in-rtl; }
@keyframes lib-in { from { translate: 100% 0; } }
@keyframes lib-in-rtl { from { translate: -100% 0; } }
/* closing: the same slide in reverse, with the backdrop fading out */
.lib-drawer.is-closing { animation: lib-out .2s cubic-bezier(.4, 0, 1, 1) forwards; }
[dir="rtl"] .lib-drawer.is-closing { animation-name: lib-out-rtl; }
@keyframes lib-out { to { translate: 100% 0; } }
@keyframes lib-out-rtl { to { translate: -100% 0; } }
.lib-drawer[open]::backdrop { animation: lib-fade .22s ease-out; }
.lib-drawer.is-closing::backdrop { animation: lib-fade .2s ease-in reverse forwards; }
@keyframes lib-fade { from { opacity: 0; } }
.lib-drawer::backdrop { background: #0b0f0d66; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.lib-head { flex: none; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-3) var(--s-4) var(--s-4); border-bottom: 1px solid var(--border); }
.lib-head-ico { flex: none; display: grid; place-items: center; color: var(--text-3); }
.lib-head-ico .i { width: 20px; height: 20px; }
.lib-head-ico.is-star { color: oklch(0.72 0.15 75); }
.lib-title { flex: 1; min-width: 0; margin: 0; font-size: var(--fs-lead); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-count { flex: none; min-width: 24px; padding: 3px 8px; border-radius: var(--r-2xs); background: var(--surface-3); color: var(--text-2); font: var(--fw-medium) .75rem/1.2 var(--font); text-align: center; margin-inline-end: var(--s-1); }
.lib-panel { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-3) var(--s-2) var(--s-5); }
.lib-panel[hidden] { display: none; }
.lib-panel ul { display: grid; gap: 2px; list-style: none; margin: 0; padding: 0; }
.lib-panel a { padding-block: 10px; font-size: var(--fs-body); }
.lib-empty { margin: var(--s-6) var(--s-4); color: var(--text-3); font-size: var(--fs-small); text-align: center; text-wrap: balance; }

/* Favorites & recent (filled by app.js): a colour dot per tool */
.side-personal a { display: flex; align-items: center; gap: var(--s-3); padding: 6px 10px 6px 6px; border-radius: var(--r-xs); color: var(--text-2); text-decoration: none; font-size: var(--fs-small); line-height: 1.3; }
.side-personal a::before { content: ""; flex: none; align-self: flex-start; width: 8px; height: 8px; margin: calc(.65em - 4px) 9px 0; border-radius: 2.5px; background: oklch(0.65 0.14 var(--hue, 250)); }
.side-personal li:not([style]) a::before { background: var(--border-strong); }
.side-personal a:hover { background: var(--surface-2); color: var(--text); }
.side-personal a[aria-current] { color: var(--text); font-weight: var(--fw-medium); }.scrim { display: none; }

.rail { position: relative; height: 100%; padding-top: var(--s-6); }
.rail-sticky { position: sticky; top: calc(var(--header-h) + var(--s-6)); }

/* ---------- Ads ----------
   Real AdSense units use .ad / .ad-*; the "coming soon" placeholder uses neutral .slot / .slot-* names,
   because ad blockers hide anything called .ad-rail, .ad-label, .ad-placeholder… and the notice would never be seen. */
:is(.ad, .slot) { position: relative; display: grid; justify-items: center; gap: 4px; }
:is(.ad-label, .slot-label) { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
:is(.ad-rail, .slot-rail) { min-height: 620px; }
.slot-rail .slot-box { width: 300px; height: 600px; }
:is(.ad-inContent, .slot-inContent) { margin: var(--s-7) 0; min-height: 280px; }
.slot-inContent .slot-box { width: 100%; height: 250px; }
.slot-box { display: grid; place-content: center; justify-items: center; gap: 4px; padding: var(--s-4); text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); color: var(--text-3); font-size: 13px; background: repeating-linear-gradient(45deg, transparent 0 10px, var(--surface-2) 10px 20px); }
.slot-box em { font-size: 11px; font-style: italic; opacity: .8; }
/* "coming soon" box: readable at a glance, with the page-coloured koala badge from the logo sprite */
.slot-box { gap: 6px; padding: var(--s-5); }
.slot-box .slot-koala { width: 56px; aspect-ratio: 1; margin-bottom: 4px; background: var(--sprite) no-repeat 100% var(--logo-y) / 469.2308% auto; }
.slot-box strong { font-size: 15px; font-weight: 500; color: var(--text-2); }
.slot-box span { max-width: 230px; font-size: 13px; line-height: 1.45; color: var(--text-3); text-wrap: balance; }
.slot-box em { margin-top: 2px; }
.slot-inContent .slot-box .slot-koala { width: 44px; }
/* Desktop: ads live only in the rail. In-content units are not requested (display:none). */
@media (min-width: 1280px) { .has-ads :is(.ad-inContent, .slot-inContent) { display: none; } }
/* AdSense marks a slot it couldn't fill (data-ad-status="unfilled"): drop the whole slot, label included, so no blank box remains */
.ad:has(> ins.adsbygoogle[data-ad-status="unfilled"]) { display: none; }
/* the rail ad only sticks when the whole 300×600 unit (plus its label and offset) fits in the window */
@media (max-height: 679px) { .rail-sticky { position: static; } }


/* Share menu (desktop; touch devices use the native share sheet) */
.share { position: relative; }
.share-menu {
  position: absolute; z-index: 30; top: calc(100% + 8px); inset-inline-end: 0; min-width: 210px; padding: 6px;
  display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  font: var(--fw-body) var(--fs-small)/1.3 var(--font); letter-spacing: 0;
}
.share-menu[hidden] { display: none; }
.share-menu a, .share-menu button {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-xs);
  background: none; color: var(--text); text-align: start; text-decoration: none; font: inherit; cursor: pointer;
}
.share-menu a:hover, .share-menu button:hover, .share-menu :focus-visible { background: var(--surface-2); outline: none; }
.share-menu .i { width: 18px; height: 18px; color: var(--text-3); }
.share-menu [data-net="whatsapp"] .i { color: #25d366; }
.share-menu [data-net="facebook"] .i { color: #1877f2; }
.share-menu [data-net="linkedin"] .i { color: #0a66c2; }
.share-menu [data-net="x"] .i { color: var(--text); }
.share-menu button { border-bottom: 1px solid var(--border); border-radius: var(--r-xs) var(--r-xs) 0 0; margin-bottom: 4px; padding-bottom: 11px; }

/* Back to top: appears after scrolling; on desktop with ads it stays in the content column, clear of the ad rail */
.to-top {
  position: fixed; z-index: 45; bottom: 24px; inset-inline-end: 24px; width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-control);
  opacity: 0; visibility: hidden; translate: 0 10px; cursor: pointer;
  transition: opacity .2s ease-out, translate .2s ease-out, visibility .2s, background-color .15s, color .15s, scale .15s ease-out, transform .15s ease-out;
}
.to-top.show { opacity: 1; visibility: visible; translate: 0 calc(-1 * var(--lift, 0px)); }
.to-top:not(:disabled):active { scale: .9; }
.to-top .i { width: 20px; height: 20px; }
@media (min-width: 1280px) {
  .has-ads .to-top { inset-inline-end: calc(24px + var(--rail-w) + var(--gap) - 20px); }   /* button centre on the card's edge */
}
@media (max-width: 640px) { .to-top { bottom: 16px; inset-inline-end: 16px; } }

/* ---------- Breadcrumbs ---------- */
.crumbs ol { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0 0 var(--s-6); padding: 0; font-size: var(--fs-small); color: var(--text-3); }
.crumbs li { display: flex; align-items: center; gap: 4px; }
.crumbs li + li::before { content: "/"; color: var(--border-strong); margin-inline-end: 2px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--accent-text); text-decoration: underline; }
.crumbs [aria-current] { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40ch; }

/* ---------- Tool header ---------- */
.tool-head { margin-bottom: var(--s-6); }
/* Header row: glossy icon · H1 · favourite. The row uses the H1 size so em = H1 em: Paytone caps are .688em tall and the
   trimmed H1 starts at cap height, so "margin-top: .344em - half the element" centres each side item on the first line. */
.tool-title { display: flex; align-items: flex-start; gap: var(--s-4); font-size: var(--fs-h1); }
.tool-title h1 { flex: 0 1 auto; min-width: 0; margin-inline-end: auto; }
.tool-icon { flex: none; width: 1em; height: 1em; margin-top: calc(.344em - .5em); display: grid; place-items: center; color: var(--accent-text); }
.tool-icon .i { width: 100%; height: 100%; overflow: visible; }
.tool-icon[style] path { fill: var(--ico-fill); filter: url(#ico-fx); }
.tool-icon[style] path[fill="none"] { fill: none; }
.tool-icon[style] path[stroke] { stroke: var(--ico-fill); }
.head-actions { flex: none; display: flex; gap: var(--s-2); margin-top: calc(.344em - 17px); }
.head-btn, .fav-btn { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); transition: color .15s, background-color .15s, transform .15s, scale .15s ease-out; }
.head-btn .i, .fav-btn .i { width: 18px; height: 18px; }
:lang(ar) .tool-icon { margin-top: calc(.65em - .5em); }  /* Arabic H1 is not cap-trimmed: centre on its first line box */
:lang(ar) .head-actions { margin-top: calc(.65em - 17px); }
@supports not (text-box: trim-both cap alphabetic) { .tool-title { align-items: center; } .tool-icon, .head-actions { margin-top: 0 !important; } }
.head-btn[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }   /* share menu open */
.head-btn:not(:disabled):active, .fav-btn:not(:disabled):active { transform: scale(.96); }
.fav-btn[aria-pressed="true"] { color: #fff; background: oklch(0.6 0.15 var(--page-hue, 140)); border-color: transparent; background-clip: border-box; }   /* saved: one flat category colour, white star */
.fav-btn[aria-pressed="true"] svg path { fill: currentColor; }
.answer { display: inline-block; margin: var(--s-6) 0 0; padding: 4px 11px; border-radius: var(--r-xs); background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-weight: var(--fw-medium); font-size: var(--fs-small); }
.lead { color: var(--text-2); font-size: 1rem; line-height: 1.55; margin: var(--s-5) 0 0; max-width: 62ch; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-card); box-shadow: var(--shadow-control); }

/* ---------- Converter ---------- */
.converter { padding: 20px; }
.cv-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: var(--s-3); }
.cv-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; }
.cv-label, .field-label { font-size: .75rem; font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
:lang(ar) :is(.cv-label, .field-label), :lang(zh) :is(.cv-label, .field-label) { letter-spacing: 0; font-size: .8125rem; }
/* Dropdowns: one look everywhere — native <select> (keyboard, screen reader and mobile pickers keep working), custom face */
.cv-unit-select, .calc select, .cv-dec select {
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23646d76' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6l6 -6'/%3E%3C/svg%3E");
  appearance: none; -webkit-appearance: none; width: 100%; height: 40px; padding-inline: 14px 40px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface) var(--chev) no-repeat right 12px center / 16px 16px;
  box-shadow: var(--shadow-sm); color: var(--text); font-weight: var(--fw-medium); font-size: .875rem; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background-color .15s, scale .15s ease-out;
}
[dir="rtl"] :is(.cv-unit-select, .calc select, .cv-dec select) { background-position: left 12px center; padding-inline: 40px 14px; }
:is(.cv-unit-select, .calc select, .cv-dec select):hover { border-color: var(--text-3); }
:is(.cv-unit-select, .calc select, .cv-dec select):focus-visible { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 4px var(--ring); }
.cv-dec select { width: auto; min-width: 96px; height: 32px; padding-inline: 12px 34px; background-position: right 10px center; background-size: 14px 14px; }
[dir="rtl"] .cv-dec select { background-position: left 10px center; padding-inline: 34px 12px; }.cv-input { position: relative; display: flex; align-items: center; height: 56px; border: 1.5px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); transition: border-color .15s, box-shadow .15s, scale .15s ease-out; }
.cv-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.cv-num { flex: 1; min-width: 0; height: 100%; padding-inline: 16px 8px; border: 0; background: transparent; font-size: 1.5625rem; font-weight: var(--fw-medium); letter-spacing: -0.01em; outline: none; direction: ltr; text-align: start; }
[dir="rtl"] .cv-num { text-align: right; }
.cv-num:focus-visible { outline: none; }
/* Unit symbol, set off from the number by a short hairline that stops short of the field's edges */
.cv-sym { flex: none; align-self: stretch; display: flex; align-items: center; justify-content: center; min-width: 52px; margin-block: 16px; padding-inline: 14px 16px; border-inline-start: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-body); direction: ltr; }
.cv-num[aria-invalid="true"] { color: #c2410c; }
.cv-swap { width: 40px; height: 40px; margin-bottom: 8px; display: grid; place-items: center; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); text-decoration: none; transition: background .15s, color .15s, scale .15s ease-out; }
.cv-swap .i { transition: rotate .25s cubic-bezier(.3,.7,.4,1.3); }  /* the arrows spin, not the button, so its tooltip stays upright */
.cv-swap:hover .i { rotate: 180deg; }
.cv-result { display: block; margin-top: var(--s-4); padding: 14px 16px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--text); font-size: var(--fs-lead); line-height: 1.45; word-break: break-word; }
.cv-result strong { color: var(--accent-text); font-weight: var(--fw-medium); }
.cv-extra { margin: var(--s-2) 0 0; color: var(--text-2); }
.cv-extra:empty { display: none; }
.cv-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-4); }
.cv-dec { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-small); color: var(--text-3); }
.cv-actions { display: flex; gap: var(--s-2); }
.btn-ghost { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding-inline: 12px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: var(--fs-small); font-weight: var(--fw-medium); transition: background .15s, color .15s, scale .15s ease-out; }
.btn-ghost .i { width: 16px; height: 16px; }
.btn-ghost.is-done { color: var(--accent-text); border-color: var(--accent); }
.reverse-link { margin: var(--s-4) 0 0; font-size: .875rem; }
.reverse-link a { display: inline-flex; align-items: center; gap: 6px; font-weight: var(--fw-medium); text-decoration: none; }
.reverse-link a:hover { text-decoration: underline; }

/* ---------- Prose sections ---------- */
.prose { margin-top: var(--s-7); }
.prose h2, .related h2, .faq h2, .home-section h2 { margin-bottom: var(--s-4); }
.prose > h2:not(:first-child), .prose > section + section { margin-top: var(--s-7); }
.prose h3 { margin: var(--s-5) 0 var(--s-2); }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); }
.prose ul { padding-inline-start: 1.2em; }
.prose table { width: 100%; border-collapse: collapse; margin: var(--s-2) 0 var(--s-4); font-size: .875rem; }
.prose th, .prose td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose thead th { font-size: .75rem; font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
:lang(ar) .prose thead th, :lang(zh) .prose thead th { letter-spacing: 0; text-transform: none; }
/* "Good to know": a sticky note — warm paper, a strip of tape, a hair of tilt */
.callout {
  --note-a: oklch(0.975 0.06 100); --note-b: oklch(0.94 0.085 92); --note-ink: oklch(0.3 0.045 75); --note-head: oklch(0.42 0.09 70);
  --tape: hsl(0 0% 100% / .6);
  position: relative; padding: var(--s-6) var(--s-6) var(--s-5);
  background: linear-gradient(172deg, var(--note-a), var(--note-b));
  border-radius: var(--r-md);
  box-shadow: inset 0 -1.5px 0 hsl(40 50% 25% / .07), 0 1px 1px hsl(40 50% 25% / .08), 0 1px 3px -1px hsl(40 50% 25% / .08);
  rotate: -.6deg; color: var(--note-ink);
}
[dir="rtl"] .callout { rotate: .6deg; }
.callout::before { /* tape */
  content: ""; position: absolute; top: -22px; inset-inline-start: 50%; width: 176px; height: 44px; margin-inline-start: -88px;
  background: var(--tape); border-inline: 1px dashed hsl(40 30% 50% / .18); box-shadow: 0 1px 2px hsl(40 30% 20% / .08);
  rotate: 2.5deg;
}
.callout h2 { position: relative; width: fit-content; font-size: var(--fs-lead); margin-bottom: var(--s-4); padding-bottom: 8px; color: var(--note-head); }
.callout h2::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 6px; background: currentColor; opacity: .45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='6' viewBox='0 0 12 6'%3E%3Cpath d='M0 3 Q3 0 6 3 T12 3' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 12px 6px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='6' viewBox='0 0 12 6'%3E%3Cpath d='M0 3 Q3 0 6 3 T12 3' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 12px 6px; }
.callout p { margin: 0; color: var(--note-ink); line-height: 1.75;
  background: linear-gradient(transparent calc(100% - 1px), hsl(40 55% 35% / .14) 0) 0 0 / 100% 1lh; }   /* ruled paper: a hairline under every text line */.formula code { display: inline-block; padding: 10px 14px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--text); font: 500 .9375rem/1.4 var(--mono); }
.faq-a code { font: 500 .875rem var(--mono); background: var(--surface-3); padding: 2px 6px; border-radius: var(--r-2xs); }
.examples { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-3); }
.examples li { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); }
.examples strong { color: var(--accent-text); font-weight: var(--fw-medium); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); }
.conv-table { margin: 0 !important; }
.conv-table th, .conv-table td { padding: 9px 16px; white-space: nowrap; }
.conv-table tbody tr:nth-child(even) { background: var(--surface-2); }
.conv-table tbody tr:last-child td, .conv-table tbody tr:last-child th { border-bottom: 0; }
.conv-table tbody th { font-weight: var(--fw-body); color: var(--text-2); }
.conv-table td:last-child { color: var(--text); font-weight: var(--fw-medium); }
.accuracy { margin-top: var(--s-6); font-size: var(--fs-caption); color: var(--text-3); }

/* ---------- FAQ ---------- */
.faq { margin-top: var(--s-7); }
.faq details { border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); margin-bottom: var(--s-3); overflow: hidden; }
.faq summary { list-style: none; cursor: pointer; padding: 18px var(--s-5); line-height: 1.4; font-weight: var(--fw-medium); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: ""; flex: none; width: 10px; height: 10px; border-inline-end: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(45deg); transition: transform .2s, scale .15s ease-out; margin-top: -4px; }
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.faq summary:hover::after { border-color: var(--text); }   /* hover darkens the chevron only; the question keeps its colour */
.faq summary:not(:disabled):active { scale: 1; }         /* a full-width row shouldn't shrink on press */
.faq-a { padding: 0 var(--s-5) var(--s-5); color: var(--text-2); line-height: 1.7; }

/* ---------- Tiles, chips, related ---------- */
.related { margin-top: var(--s-7); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s-3); }
.tiles-lg { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-4); }
.tile { display: grid; gap: var(--s-1); align-content: start; padding: 14px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--border-strong); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s, scale .15s ease-out; }
.tile:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); box-shadow: var(--shadow-control); }
.tile-title { font-weight: var(--fw-medium); line-height: 1.35; }
.tile-sub { font-size: var(--fs-small); color: var(--text-3); line-height: 1.4; }
.tile-icon { grid-template-columns: auto 1fr; column-gap: 12px; }
.tile-icon > .side-ico { grid-row: span 2; align-self: start; }
.tile-sub { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }  /* even card heights */
.tile-all { background: transparent; border-style: dashed; place-content: center; text-align: center; justify-items: center; }
.tile-all .tile-title { color: var(--accent-text); }
.post-tile time { font-size: var(--fs-caption); color: var(--text-3); margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; line-height: 1.4; border-radius: var(--r-xs); background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); text-decoration: none; font-size: var(--fs-small); }

/* ---------- Home ---------- */
.hero { text-align: center; padding: var(--s-5) 0 0; }
.hero-mark { position: relative; width: 168px; aspect-ratio: 1; margin: 0 auto var(--s-6); animation: bob 5s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
/* numbers and units float out of the koala's calculator, growing from tiny to large as they fade away */
.hero-mark span { position: absolute; left: 72%; top: 58%; font: 600 13px/1 var(--font); white-space: nowrap; color: oklch(0.62 0.17 135); opacity: 0; pointer-events: none;
  translate: -50% -50%; animation: hero-digit 4.2s cubic-bezier(.25, .6, .35, 1) infinite; }
@keyframes hero-digit {
  0% { opacity: 0; transform: translate(0, 0) scale(.3); }
  15% { opacity: .55; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.9); }
}
.hero-mark span:nth-child(1) { --dx: -50px; --dy: -60px; animation-delay: 0.00s; }
.hero-mark span:nth-child(2) { --dx: -45px; --dy: -82px; animation-delay: 2.08s; }
.hero-mark span:nth-child(3) { --dx: -33px; --dy: -105px; animation-delay: 1.04s; }
.hero-mark span:nth-child(4) { --dx: -13px; --dy: -125px; animation-delay: 3.12s; }
.hero-mark span:nth-child(5) { --dx: 7px; --dy: -78px; animation-delay: 0.52s; }
.hero-mark span:nth-child(6) { --dx: 27px; --dy: -90px; animation-delay: 2.60s; }
.hero-mark span:nth-child(7) { --dx: 52px; --dy: -97px; animation-delay: 1.56s; }
.hero-mark span:nth-child(8) { --dx: 80px; --dy: -97px; animation-delay: 3.64s; }
.hero-mark span:nth-child(9) { --dx: 60px; --dy: -49px; animation-delay: 2.34s; }
.hero-mark span:nth-child(10) { --dx: 83px; --dy: -44px; animation-delay: 0.26s; }
.hero-mark span:nth-child(11) { --dx: 105px; --dy: -32px; animation-delay: 3.38s; }
.hero-mark span:nth-child(12) { --dx: 125px; --dy: -12px; animation-delay: 1.30s; }
.hero-mark span:nth-child(13) { --dx: 78px; --dy: 8px; animation-delay: 2.86s; }
.hero-mark span:nth-child(14) { --dx: 90px; --dy: 28px; animation-delay: 0.78s; }
.hero-mark span:nth-child(15) { --dx: 97px; --dy: 53px; animation-delay: 3.90s; }
.hero-mark span:nth-child(16) { --dx: 97px; --dy: 81px; animation-delay: 1.82s; }
@media (prefers-reduced-motion: reduce) { .hero-mark { animation: none; } .hero-mark span { display: none; } }
@media (max-width: 640px) { .hero-mark { width: 132px; } }
.hero h1 { font-size: var(--fs-display); max-width: 20ch; margin-inline: auto; }
.hero .lead { margin: var(--s-5) auto 0; }
.hero-search { margin: var(--s-6) auto 0; width: 100%; max-width: 560px; height: 52px; display: flex; align-items: center; gap: 12px; padding-inline: 18px 12px; border-radius: var(--r-lg); border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--text-3); font-size: var(--fs-lead); text-align: start; box-shadow: var(--shadow-control); transition: border-color .15s, box-shadow .15s, scale .15s ease-out; }
.hero-search span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-search:hover { border-color: var(--text-3); }
.quick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; list-style: none; padding: 0; margin: var(--s-4) 0 0; }
.quick .chip { direction: ltr; }
.home-section { margin-top: var(--s-8); }
.home-section h2 a { color: inherit; text-decoration: none; }
.home-section h2 a:hover { color: var(--accent-text); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s-4); }
.cat-card { padding: 20px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border-strong); display: flex; flex-direction: column; }
.cat-card h3 { font-size: var(--fs-lead); margin-bottom: var(--s-3); }
.cat-card h3 a { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.cat-card h3 a:hover { color: var(--accent-text); }
.cat-card ul { list-style: none; margin: 0 0 12px; padding: 0; flex: 1; }
.cat-card li a { display: block; padding: 4px 0; font-size: .875rem; color: var(--text-2); text-decoration: none; }
.cat-card li a:hover { color: var(--accent-text); text-decoration: underline; }
.more { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); font-weight: var(--fw-medium); text-decoration: none; }
/* "Why people use Calcoala": no cards; a big green numeral in Paytone One with the step's koala leaning on it, text below */
.why { container-type: inline-size; }
.why-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-7) var(--s-6); margin: 0; padding: 0; list-style: none; }
/* each step scales with its column width (--col, from the section's width): numeral, koala and overlap keep their proportions */
.why-grid > li { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; }   /* art, title, text share rows across the three steps, so the texts always start on one line */
/* number and koala are the same height (--art) and stand on one line: the koala's bottom edge is the digit's baseline */
.why-art { --col: calc((100cqi - 2 * var(--s-6)) / 3); --art: min(150px, var(--col) * .56); display: flex; align-items: flex-end; margin-bottom: var(--s-6); }
/* a Paytone One digit is .70em tall: size the font so the digit is exactly --art, and trim the line box to the digit */
.why-num { font: 400 calc(var(--art) / .7)/1 "Paytone One", sans-serif; color: var(--accent); letter-spacing: -.04em; user-select: none; text-box: trim-both cap alphabetic; }
@supports not (text-box: trim-both cap alphabetic) { .why-num { line-height: .7; } }
.why-art img { position: relative; width: auto; height: var(--art); margin-inline-start: calc(var(--art) * -.16); object-fit: contain; }
.why h2 { margin-bottom: var(--s-7); }   /* room between the section title and the big numbers */
.why-grid h3 { font-size: var(--fs-h3); margin-bottom: var(--s-3); }
/* text measure close to the title width (20em ≈ 300px, or the column when narrower); the copy is written to fill 3 lines at this measure */
.why-grid p { margin: 0; max-width: 20em; color: var(--text-2); font-size: var(--fs-body); line-height: 1.75; text-wrap: pretty; }
/* mid widths (laptops with the ad rail): three columns would be too narrow for the text, so each step becomes a row:
   number + koala on one side, title and text beside it, vertically centred */
@container (max-width: 879px) {
  .why-grid { grid-template-columns: minmax(0, 1fr); row-gap: var(--s-6); }
  .why-grid > li { --art: clamp(96px, 20cqi, 130px); grid-row: auto; grid-template-rows: 1fr auto auto 1fr; grid-template-columns: calc(var(--art) * 1.75) minmax(0, 1fr); column-gap: var(--s-5); }   /* fixed art column: the titles line up */
  .why-art { --art: inherit; grid-row: 1 / -1; margin-bottom: 0; }
  .why-grid h3 { grid-row: 2; grid-column: 2; }
  .why-grid p { grid-row: 3; grid-column: 2; }
}
/* phones: stacked, one step after another */
@container (max-width: 459px) {
  .why-grid > li { display: block; }
  .why-art { --art: min(150px, 100cqi * .56); margin-bottom: var(--s-6); }
}

/* ---------- Calculators ---------- */
.calc { padding: 20px; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-5) var(--s-4); align-items: start; }
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-2); min-width: 0; }
.field-wide { grid-column: 1 / -1; }

.field input, .stepper input, .inline-num { height: 42px; width: 100%; padding-inline: 14px; border: 1.5px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); font-size: 1.125rem; font-weight: var(--fw-medium); direction: ltr; transition: border-color .15s, box-shadow .15s, scale .15s ease-out; }
[dir="rtl"] .field input { text-align: right; }
.field input:focus, .stepper input:focus, .inline-num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.field input[hidden], .field:has(input[hidden]) { display: none; }
.field-inline { display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-2); font-size: var(--fs-small); color: var(--text-3); }
.field-inline input { height: 34px; width: 90px; font-size: 15px; padding-inline: 10px; border: 1.5px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); direction: ltr; }
.field-inline input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip-btn { height: 36px; min-width: 56px; padding-inline: 12px; border-radius: var(--r-sm); border: 1.5px solid var(--border-strong); background: var(--surface); font-size: .875rem; color: var(--text-2); direction: ltr; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: var(--fw-medium); }
.stepper { display: flex; align-items: stretch; gap: var(--s-2); }
.stepper button { flex: none; width: 42px; border-radius: var(--r-md); border: 1.5px solid var(--border-strong); background: var(--surface-2); display: grid; place-items: center; color: var(--text-2); }
.stepper input { text-align: center; }
.check { display: flex; align-items: center; gap: 10px; align-self: end; min-height: 42px; font-size: .875rem; color: var(--text-2); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.segmented { display: flex; padding: 4px; gap: 4px; border-radius: calc(var(--r-sm) + 4px); background: var(--surface-2); border: 1px solid var(--border); height: 42px; }
.segmented label { flex: 1; position: relative; display: grid; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: grid; place-items: center; border-radius: var(--r-sm); font-size: var(--fs-small); color: var(--text-2); padding-inline: 8px; text-align: center; line-height: 1.15; }
.segmented input:checked + span { background: var(--surface); color: var(--text); font-weight: var(--fw-medium); box-shadow: var(--shadow-control); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent-text); }
.results { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-3); margin: var(--s-5) 0 0; }
.res { padding: var(--s-3) var(--s-4); border-radius: var(--r-lg); background: var(--surface-2); min-width: 0; }
.res dt { font-size: var(--fs-caption); color: var(--text-3); }
.res dd { margin: var(--s-1) 0 0; font-size: 1.3125rem; font-weight: var(--fw-medium); direction: ltr; text-align: start; word-break: break-word; }
[dir="rtl"] .res dd { text-align: right; }
.res dd small { display: block; font-size: var(--fs-caption); font-weight: var(--fw-body); color: var(--text-3); }
.res-main { background: var(--accent-soft); }
.res-main dd { color: var(--accent-text); }
.pct-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--s-3) var(--s-4); padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
.pct-row:first-child { padding-top: 0; }
.pct-row:last-child { border-bottom: 0; padding-bottom: 0; }
.pct-q { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); color: var(--text-2); }
.inline-num { width: 110px; height: 40px; font-size: 16px; }
.pct-out { min-width: 130px; padding: 10px 14px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-text); font-size: 1.1875rem; font-weight: var(--fw-medium); text-align: center; direction: ltr; }
.pct-out small { display: block; font-size: .75rem; color: var(--text-2); }
.note { margin: var(--s-4) 0 0; font-size: var(--fs-caption); color: var(--text-3); }
.res[hidden] { display: none; }
/* Currency converter: amount, from, swap, to on one row; stacked on phones */
.fx-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) auto minmax(0, 1fr); gap: var(--s-4); align-items: end; }
.fx-swap { margin: 0 0 1px; }
.fx-rates { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-5); margin: var(--s-3) 0 0; font-size: var(--fs-small); color: var(--text-2); }
.fx-rates:empty { display: none; }
.fx-status { margin-top: var(--s-3); }
#fx-retry { margin-top: var(--s-2); }
#fx-retry[hidden] { display: none; }
.fx-table { margin-top: var(--s-5); }
.fx-table caption { caption-side: top; text-align: start; padding-bottom: var(--s-2); font-weight: var(--fw-medium); color: var(--text-2); font-size: var(--fs-small); }
.fx-table tbody:empty::after { content: '—'; display: block; padding: var(--s-3); color: var(--text-3); }
@media (max-width: 640px) {
  .fx-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .fx-swap { justify-self: center; }
}

/* ---------- Pages & blog ---------- */
.page h1, .post h1 { margin-bottom: calc(var(--s-6) - .26em); }
.page h2, .post h2 { margin-top: var(--s-6); margin-bottom: var(--s-3); }
.post { margin-top: 0; }
.post-meta { color: var(--text-3); font-size: var(--fs-small); }
.post-tools { margin: var(--s-4) 0 var(--s-6); }
.post img { max-width: 100%; height: auto; border-radius: var(--r-lg); }

/* ---------- Footer ---------- */
.footer { max-width: 800px; margin: var(--s-7) auto 0; border-top: 1px solid var(--border); }
/* Grid pages: a wider column so cards have room; reading pages stay at 800px */
.is-wide .main, .is-wide .footer { max-width: 1120px; }
@media (min-width: 1024px) {
  .is-wide .tiles { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-4); }
  .is-wide .tiles-lg { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}
.footer-in { position: relative; isolation: isolate; margin: 0; padding: var(--s-7) 0 var(--s-6); display: grid; grid-template-columns: repeat(3, max-content) 1fr; justify-content: start; gap: var(--s-6) var(--s-7); }  /* empty 4th track keeps the brand row full width */
.footer { position: relative; isolation: isolate; overflow: visible clip; }   /* the footer clips the bottom; the content column clips the side at the rail edge */
.content-col { overflow-x: clip; }
.footer::after { content: ""; position: absolute; z-index: -1; top: 0; inset-inline-end: -380px; width: 760px; aspect-ratio: 1; background: var(--sprite) no-repeat 100% var(--logo-y) / 469.2308% auto; filter: grayscale(1); opacity: .05; pointer-events: none; }  /* huge muted koala pushed far right: half of it is cut off by the ad rail edge, the rest by the page bottom */
.footer { container-type: inline-size; }
@media (max-width: 640px) { .footer::after { width: 360px; top: auto; bottom: -120px; inset-inline-end: -16px; } }
@container (max-width: 600px) { .footer-in { grid-template-columns: 1fr 1fr; gap: var(--s-6); } }
@media (max-width: 640px) { .footer-in { grid-template-columns: 1fr 1fr; justify-content: stretch; } }
.footer-brand { grid-column: 1 / -1; margin-top: var(--s-2); padding-top: var(--s-6); border-top: 1px solid var(--border); display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: var(--s-2) var(--s-6); }
.footer-brand p { margin: 0 !important; max-width: 52ch !important; }
.footer-brand { align-items: center; }
.footer-brand p { color: var(--text-3); font-size: var(--fs-small); margin-top: var(--s-4); max-width: 34ch; }
.footer h2 { font-family: var(--font-display); font-weight: var(--fw-heading); font-size: var(--fs-body); letter-spacing: 0; color: var(--accent-text); margin: 0 0 var(--s-3); }
/* Site links (blog, about, contact, legal) sit under the logo as one wrapping row */
.footer-site { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin-top: var(--s-4) !important; }
.footer-site a { font-weight: var(--fw-medium); color: var(--text) !important; }
.footer-site a:hover { color: var(--accent-text) !important; }
.footer ul { list-style: none; margin: 0; padding: 0; }
.footer li a { display: inline-block; padding: 4px 0; font-size: var(--fs-small); color: var(--text-2); text-decoration: none; }
.footer li a:hover { color: var(--accent-text); text-decoration: underline; }
.footer-bottom { margin: 0; padding: var(--s-4) 0 var(--s-6); display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: var(--s-3) var(--s-6); font-size: var(--fs-caption); color: var(--text-3); border-top: 1px solid var(--border); }
/* copyright + version take the logo's width, so the site links start in line with the description above */
.footer-bottom > span:first-child { flex: none; min-width: 208px; }
@media (max-width: 640px) { .footer .footer-bottom > span:first-child { min-width: 0; } .footer .footer-bottom .footer-site { flex: 1 1 100%; order: 2; } .footer .footer-bottom .lang-menu { order: 3; } }   /* phones: links get their own full-width line */
.footer-bottom .footer-site { margin: 0 !important; flex: 1 1 0; min-width: 0; }   /* long labels wrap inside this column instead of dropping the row */
.footer-bottom .footer-site a { font-size: var(--fs-small); padding: 0; }
.footer-bottom .lang-menu { margin-inline-start: auto; }
.lang-menu-up summary { gap: var(--s-2); height: 32px; padding-inline: 12px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text-2); font-size: var(--fs-small); box-shadow: var(--shadow-control); }
.lang-menu-up summary .i { width: 16px; height: 16px; }
.lang-menu-up .lang-chev { rotate: -90deg; transition: rotate .2s; }
.lang-menu-up[open] .lang-chev { rotate: 90deg; }
.lang-menu-up ul { top: auto; bottom: calc(100% + 6px); }
.footer .lang-menu-up li a { display: block; padding: 10px 16px; font-size: .8125rem; color: var(--text); text-decoration: none; }   /* full-width rows, not the footer's inline links */
.footer .lang-menu-up li a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.footer .lang-menu-up li a[aria-current] { background: var(--surface-2); font-weight: var(--fw-medium); }

/* ---------- Search dialog ---------- */
.search-dialog { width: min(640px, calc(100vw - 24px)); max-height: min(70vh, 620px); margin: 10vh auto auto; padding: 0; border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
.search-dialog[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
.search-dialog::backdrop { background: #0b0f0d80; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.985); } }
.search-box { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4) 0 var(--s-5); border-bottom: 1px solid var(--border); color: var(--text-3); }
.search-box input { flex: 1; min-width: 0; height: 56px; border: 0; background: transparent; font-size: 17px; color: var(--text); outline: none; }
.search-box input::-webkit-search-cancel-button { display: none; }
.kbd-btn { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; font: var(--fw-medium) 11px/1 var(--font); letter-spacing: .04em; color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-2xs); cursor: pointer; }  /* same keycap as the footer hints */
.kbd-btn:hover { color: var(--text); }

/* Results: glossy category icon · name + example · (value) · Enter keycap on the highlighted row */
.search-results { list-style: none; margin: 0; padding: var(--s-2); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 2px; }
.search-results a { display: flex; align-items: center; gap: var(--s-4); min-height: 52px; padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); color: var(--text); text-decoration: none; transition: background-color .12s, scale .15s ease-out; }
.search-results a:hover { background: var(--surface-2); }
.search-results a[aria-selected="true"] { background: var(--surface-2); }
.r-ico { flex: none; width: 30px; height: 30px; display: grid; place-items: center; }
.r-ico .i { width: 30px; height: 30px; overflow: visible; }
.r-ico path { fill: var(--ico-fill, currentColor); filter: url(#ico-fx); }
.r-ico path[fill="none"] { fill: none; }
.r-ico path[stroke] { stroke: var(--ico-fill, currentColor); }
.search-results .r-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.search-results .r-name { font-weight: var(--fw-medium); line-height: 1.3; }
.search-results .r-sub { font-size: var(--fs-caption); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results mark { background: none; color: inherit; font-weight: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.search-results .r-val { flex: none; font-size: var(--fs-caption); font-weight: var(--fw-medium); color: var(--text-2); background: var(--surface-3); padding: 4px 9px; border-radius: var(--r-2xs); direction: ltr; white-space: nowrap; }
.r-go { flex: none; display: grid; place-items: center; width: 30px; height: 26px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-2xs); background: var(--surface); color: var(--text-2); opacity: 0; transition: opacity .12s, scale .15s ease-out; }
.search-results a[aria-selected="true"] .r-go { opacity: 1; }
[dir="rtl"] .r-go svg, [dir="rtl"] .kbd-enter svg { transform: scaleX(-1); }

/* Keyboard hints */
.search-foot { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-caption); color: var(--text-3); }
.search-foot span { display: inline-flex; align-items: center; gap: 6px; }
.search-foot kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; font: var(--fw-medium) 11px/1 var(--font); letter-spacing: .04em; color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-2xs); }
@media (pointer: coarse) { .search-foot, .r-go { display: none; } }
.search-empty { padding: 26px; text-align: center; color: var(--text-3); margin: 0; }

/* ---------- Toast ---------- */
.toast { position: fixed; z-index: 90; inset-inline: 0; bottom: 24px; margin: 0 auto; width: max-content; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--r-md); background: var(--text); color: var(--bg); font-weight: var(--fw-medium); font-size: var(--fs-small); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s, scale .15s ease-out; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

/* ---------- Root language chooser ---------- */
.root-page { display: grid; place-items: center; min-height: 100vh; }
.root-choose { text-align: center; padding: 20px; }
.root-choose ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.root-choose a { display: block; padding: 10px 18px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); text-decoration: none; font-weight: var(--fw-medium); }

/* ---------- Responsive ---------- */
@media (max-width: 1279px) {
  .has-ads .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .rail { display: none; }
}
@media (max-width: 1023px) {
  :root { --header-h: 64px; }
  .shell, .has-ads .shell { grid-template-columns: minmax(0, 1fr); padding-inline: 0; gap: 0; }
  .side-col { display: contents; }
  .content-col { padding-inline: var(--s-4); }
  .topbar-in { padding-inline: 8px 12px; gap: var(--s-2); }
  .topbar .brand-logo { width: 168px; }
  .menu-btn { display: inline-grid; }
  .search-trigger { margin-inline: 6px 0; }
  .search-trigger kbd { display: none; }
  .sidebar {
    position: fixed; z-index: 60; top: 0; bottom: 0; inset-inline-start: 0; width: min(320px, 86vw); max-height: none; height: 100%;
    padding: 0 12px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .25s cubic-bezier(.2,.8,.2,1), scale .15s ease-out; visibility: hidden;
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .menu-open .sidebar { transform: none; visibility: visible; }
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 12px 4px 12px 10px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
  .scrim { position: fixed; inset: 0; z-index: 55; background: #0b0f0d66; }
  .menu-open .scrim { display: block; }
  .sidebar-head { flex: none; }
  .menu-open { overflow: hidden; }
  .main { padding-top: var(--s-5); }
}
@media (max-width: 440px) {
  .topbar .search-trigger { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; margin-inline-start: auto; border-color: transparent; box-shadow: none; background: transparent; }
  .topbar .search-trigger span, .topbar .search-trigger kbd { display: none; }
  .topbar .search-trigger:hover { background: var(--surface-2); }
}
@media (max-width: 520px) { .topbar .brand-logo, :root .topbar .brand-logo { width: 50px; aspect-ratio: 1; background-position: 100% var(--logo-y); background-size: 469.2308% auto; } }
@media (max-width: 640px) {
  .lang-menu summary span { display: none; }
  .converter, .calc { padding: var(--s-4); border-radius: var(--r-xl); }
  :root { --fs-h2: 1.4375rem; --fs-h3: 1.0625rem; --fs-lead: 1rem; }
  .cv-dec select, .cv-unit-select, .calc select, .field-inline input { font-size: 1rem; } /* iOS zooms fields under 16px */
  .cv-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cv-swap { justify-self: center; margin: 0; width: 38px; height: 38px; }
  .cv-swap .i { rotate: 90deg; }
  .cv-swap:hover .i { rotate: 270deg; }
  .cv-input { height: 52px; }
  .cv-num { font-size: 1.375rem; }
  .tool-icon { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { padding: var(--s-3); }
  .tiles .tile-icon { grid-template-columns: 1fr; }                /* two narrow columns: icon above the text */
  .tiles .tile-icon > .side-ico { grid-row: auto; margin-bottom: 4px; }
  .tiles-lg .tile-icon { grid-template-columns: auto 1fr; }
  .tiles-lg .tile-icon > .side-ico { grid-row: span 2; margin-bottom: 0; }
  .tile-sub { font-size: 13px; }
  .tiles-lg { grid-template-columns: 1fr; }
  .crumbs [aria-current] { display: none; }
  .crumbs li:nth-last-child(2)::after { content: ""; }
  .pct-row { flex-direction: column; align-items: stretch; }
  .pct-out { text-align: start; }
  .footer-in { grid-template-columns: 1fr; gap: var(--s-5); }
  .footer-brand { grid-template-columns: 1fr; }
  .footer-bottom { padding-inline-end: 0; }
  .footer-bottom .lang-menu { margin-inline-start: 0; }
  .home-section { margin-top: var(--s-7); }
  .prose, .faq, .related { margin-top: var(--s-6); }
}
@media (max-width: 380px) { .tiles { grid-template-columns: 1fr; } .tiles .tile-icon { grid-template-columns: auto 1fr; } .tiles .tile-icon > .side-ico { grid-row: span 2; margin-bottom: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .topbar, .sidebar, .rail, .ad, .slot, .footer, .cv-tools, .head-actions, .to-top, .search-dialog, .lib-drawer { display: none !important; }
  .shell { display: block; }
}

/* ---------- Interactive surfaces: one firmer shadow ---------- */
:is(.search-trigger, .hero-search, .btn-ghost, .chip, .chip-btn, .tile, .stepper button, .cv-swap, .to-top, .head-btn, .fav-btn,
    .cv-input, .field input, .field-inline input, .inline-num, .cv-unit-select, .calc select, .cv-dec select,
    .segmented input:checked + span) { box-shadow: var(--shadow-control); }
.topbar .search-trigger { box-shadow: none; }                       /* icon-only in the bar / on small phones */
@media (min-width: 441px) and (max-width: 1023px) { .topbar .search-trigger { box-shadow: var(--shadow-control); } }
.cv-input:focus-within, .field input:focus, .stepper input:focus, .inline-num:focus, .field-inline input:focus,
:is(.cv-unit-select, .calc select, .cv-dec select):focus-visible { box-shadow: var(--shadow-control), 0 0 0 4px var(--ring); }
.tile:hover { box-shadow: var(--shadow-control); }

/* ---------- Buttons: off-white face; the shadow's 1px ring replaces the border ---------- */
:is(.head-btn, .fav-btn, .btn-ghost, .cv-swap, .to-top, .lang-menu-up summary, .chip, .chip-btn, .stepper button, .cv-dec select) {
  background-color: var(--btn-bg); border-color: transparent;
}
/* hover: lift 0.8px, no colour change; pressing dips to 90% */
:root :is(.head-btn, .fav-btn, .btn-ghost, .cv-swap, .to-top, .lang-menu-up summary, .chip, .chip-btn, .stepper button, .cv-dec select):not(:disabled):hover:not(:active) { transform: translateY(-.8px); }
:is(.head-btn, .fav-btn, .btn-ghost, .cv-swap, .lang-menu-up summary, .chip, .chip-btn, .stepper button, .cv-dec select) { transition: transform .15s ease-out, scale .15s ease-out, background-color .15s, color .15s; }
:root .cv-dec select:hover { border-color: transparent; }   /* the shared select hover border doesn't apply to this button-style select */
/* the shadow needs to outrank the shared interactive-surface rule above (hover states keep their own backgrounds) */
:root:root :is(.head-btn, .fav-btn, .btn-ghost, .cv-swap, .to-top, .lang-menu-up summary, .chip, .chip-btn, .stepper button, .cv-dec select) { box-shadow: var(--shadow-btn); }
:root:root .cv-dec select:focus-visible { box-shadow: var(--shadow-btn), 0 0 0 4px var(--ring); }
:root:root .fav-btn[aria-pressed="true"] { box-shadow: 0 0 0 1px oklch(0.45 0.13 var(--page-hue, 140) / .5), 0 1px 1px 0 rgba(0, 0, 0, .07); }

/* ---------- Favourite: pop + spark burst when saved ---------- */
.fav-btn .i { transition: transform .5s cubic-bezier(.34, 1.56, .64, 1); }
.fav-btn.pop .i { transform: scale(1.4); }
/* confetti: little paper bits burst out, spin, slow down and drift down a little before fading (about 1.4s) */
.fav-particle { position: absolute; z-index: 1; left: 50%; top: 50%; width: var(--w, 6px); height: var(--h, 6px); translate: -50% -50%; border-radius: 1.5px; background: var(--c); pointer-events: none;
  animation: fav-fly var(--dur, 1.4s) cubic-bezier(.15, .7, .35, 1) forwards; }
@keyframes fav-fly {
  0% { transform: translate(0, 0) rotate(0) scale(.4); opacity: 1; }
  45% { transform: translate(calc(var(--tx) * .9), calc(var(--ty) * .9)) rotate(calc(var(--rot) * .6)) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), calc(var(--ty) + 26px)) rotate(var(--rot)) scale(.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .fav-btn .i { transition: none; } }

/* ---------- Section breaks: a short wiggle centred in the gap between sections (104px on phones up to 152px on desktop; tool pages and the home page) ---------- */
.tool > :is(.prose, .faq, .related):not(.callout), .is-home .home-section { --wig-gap: clamp(48px, 6vw, 72px); position: relative; margin-top: 0; padding-top: calc(var(--wig-gap) * 2 + 8px); }
.tool > :is(.prose, .faq, .related):not(.callout)::before, .is-home .home-section::before {
  content: ""; position: absolute; top: var(--wig-gap); inset-inline-start: 50%; width: 96px; height: 8px; margin-inline-start: -48px;
  background: var(--border-strong);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='8' viewBox='0 0 16 8'%3E%3Cpath d='M0 4 Q4 0 8 4 T16 4' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 16px 8px;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='8' viewBox='0 0 16 8'%3E%3Cpath d='M0 4 Q4 0 8 4 T16 4' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center / 16px 8px;
}

/* ---------- Result boxes: muted tint with faint diagonal stripes ---------- */
.cv-result, .res-main, .pct-out {
  background: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in oklch, var(--accent-text) 6%, transparent) 7px 8px), var(--result-bg);
}

/* A control's tooltip hides while the menu or panel it opened is showing (it would sit on top of it) */
:root :is(.lang-menu[open] > summary, [aria-expanded="true"])[data-hint]::after { opacity: 0; transition-delay: 0s; }

/* ---------- Footer version stamp ---------- */
.footer-version { margin-inline-start: 6px; font-size: 10px; letter-spacing: .03em; color: var(--text-3); opacity: .75; font-variant-numeric: tabular-nums; }

/* ---------- Previous / next ---------- */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-6); }
.pager-link { display: grid; gap: 6px; align-content: start; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--r-lg); background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow-control); transition: transform .15s ease-out, border-color .15s; }
.pager-link:hover { transform: translateY(-1px); border-color: var(--accent); }
.pager-next { grid-column: 2; justify-items: end; text-align: end; }
.pager-dir { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: var(--fw-medium); letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
:lang(ar) .pager-dir, :lang(zh) .pager-dir { letter-spacing: 0; }
.pager-prev .pager-dir .i { rotate: 180deg; }
.pager-next .pager-dir { flex-direction: row-reverse; }
.pager-name { display: inline-flex; align-items: center; gap: 8px; font-weight: var(--fw-medium); line-height: 1.35; }
.pager-next .pager-name { flex-direction: row-reverse; }

/* ---------- Previous / next arrows beside the breadcrumbs ---------- */
.crumb-row { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-6); }
.crumb-row .crumbs { min-width: 0; }
.crumb-row .crumbs ol { margin: 0; }
/* one combo control: a white pill (the button ring + shadow) split by a hairline divider */
.step-nav { flex: none; display: flex; align-items: stretch; height: 28px; border-radius: var(--r-xs); background: #fff; box-shadow: var(--shadow-btn); transition: transform .15s ease-out; }
.step-nav:hover { transform: translateY(-.8px); }
.step-btn { width: 30px; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.step-btn + .step-btn { border-inline-start: 1px solid rgba(0, 0, 0, .08); }
.step-btn .i { width: 14px; height: 14px; transition: scale .15s ease-out; }
.step-back .i { rotate: 180deg; }
.step-btn:not(:disabled):hover { color: var(--text); }
.step-nav .step-btn:not(:disabled):active { scale: 1; }            /* the half doesn't shrink; its arrow dips instead */
.step-btn:not(:disabled):active .i { scale: .8; }
.step-btn:disabled { color: var(--text-3); opacity: .45; cursor: default; }   /* nowhere to go that way */
.crumb-row [data-hint]::after, .crumb-row [data-hint]:hover::after, .crumb-row [data-hint]:focus-visible::after { bottom: auto; top: calc(100% + 8px); inset-inline-start: 0; translate: 0 -4px; }
.crumb-row [data-hint]:hover::after, .crumb-row [data-hint]:focus-visible::after { translate: 0 0; }

/* ---------- Desktop: the white card always shows its rounded top and bottom edges ---------- */
@media (min-width: 1024px) {
  .shell { --frame-end: 24px; }
  body.has-ads .shell { --frame-end: calc(24px + var(--rail-w) + var(--gap)); }
  .shell::before, .shell::after {
    /* 3px wider than the card on each side so the card's soft shadow is covered beside the curves too */
    content: ""; position: fixed; z-index: 30; inset-inline-start: calc(var(--bar-w) + var(--side-w) - 3px); inset-inline-end: calc(var(--frame-end) - 3px); height: 22px; pointer-events: none;
    background:
      linear-gradient(var(--bg), var(--bg)) 0 0 / 100% 8px no-repeat,
      linear-gradient(var(--bg), var(--bg)) 0 8px / 3px 14px no-repeat,
      linear-gradient(var(--bg), var(--bg)) 100% 8px / 3px 14px no-repeat,
      linear-gradient(var(--border), var(--border)) 17px 8px / calc(100% - 34px) 1px no-repeat,
      radial-gradient(circle at 100% 100%, transparent 12.6px, var(--border) 13.1px 13.6px, var(--bg) 14.1px) 3px 8px / 14px 14px no-repeat,
      radial-gradient(circle at 0 100%, transparent 12.6px, var(--border) 13.1px 13.6px, var(--bg) 14.1px) calc(100% - 3px) 8px / 14px 14px no-repeat;
  }
  .shell::before { top: 0; }
  .shell::after { bottom: 0; transform: scaleY(-1); }
}
@media (min-width: 1024px) and (max-width: 1279px) { body.has-ads .shell { --frame-end: 24px; } }   /* no rail there */

/* ---------- Keyboard keycaps: dark, on the icon bar's gradient, light labels ---------- */
:root { --key-bg: linear-gradient(180deg, hsl(212 16% 16%) 0%, hsl(210 10% 24%) 55%, hsl(210 9% 31%) 100%); }
:is(kbd, .kbd-btn, .search-foot kbd, .r-go) {
  background: var(--key-bg); color: hsl(210 20% 92%); border-color: hsl(212 16% 12%); border-bottom-color: hsl(212 18% 8%);
  box-shadow: inset 0 1px 0 hsl(0 0% 100% / .08);
}
.kbd-btn:hover { color: #fff; }

/* ---------- Search dialog: smaller keycaps up top, a dark footer ---------- */
.kbd-btn { min-width: 0; height: 18px; padding: 0 5px; font-size: 10px; }
.r-go { width: 24px; height: 20px; }
.r-go svg { width: 12px; height: 12px; }
.search-foot { background: var(--key-bg); border-top-color: hsl(212 16% 12%); color: hsl(210 20% 88% / .75); }
.search-foot kbd { background: hsl(0 0% 100% / .1); color: #fff; border-color: hsl(0 0% 100% / .14); border-bottom-color: hsl(0 0% 100% / .22); box-shadow: none; }
.search-dialog { border: 0; }   /* no light outline around the dark footer; the dialog's shadow defines its edge */
.search-box { padding-inline: var(--s-5) var(--s-4); }
.search-box input { height: 64px; font-size: 1.1875rem; }
.search-box > .i, .search-box > svg { width: 22px; height: 22px; }

/* Cards on hover: a 2px accent edge (1px border + 1px ring, so nothing shifts) */
:root:root :is(.tile, .pager-link):hover { box-shadow: 0 0 0 1px var(--accent), var(--shadow-control); }
.search-foot kbd { min-width: 18px; height: 18px; padding: 0 4px; font-size: 9.5px; border-bottom-width: 1.5px; }
.search-foot kbd svg { width: 11px; height: 11px; }
.search-results { padding: var(--s-3) 20px; }   /* results sit in from the dialog edges */
/* field, result rows and footer share the same edges: 20px list inset + 16px row padding = 36px */
.search-box { padding-inline: 36px; }
.search-foot { padding-inline: 36px; }
.search-results { scroll-padding-block: var(--s-3); }
.search-results a { min-height: 48px; padding-block: 10px; }
.search-dialog { max-height: min(78vh, 640px); }

.brand-home { display: none; }
/* ---------- Desktop bar logo: on hover it grows and flips over to a home icon ---------- */
@media (min-width: 1024px) {
  .topbar .brand { display: grid; perspective: 400px; }
  .topbar .brand > * { grid-area: 1 / 1; backface-visibility: hidden; transition: transform .5s cubic-bezier(.34, 1.4, .64, 1); }
  .topbar .brand-home { display: grid; place-items: center; color: #fff; transform: rotateY(-180deg); }
  .topbar .brand-home .i { width: 26px; height: 26px; }
  .topbar .brand:is(:hover, :focus-visible) .brand-logo { transform: rotateY(180deg) scale(1.1); }
  .topbar .brand:is(:hover, :focus-visible) .brand-home { transform: rotateY(0) scale(1.1); }
}
@media (min-width: 1024px) and (prefers-reduced-motion: reduce) {
  .topbar .brand > * { transition: opacity .15s; transform: none !important; backface-visibility: visible; }
  .topbar .brand-home { opacity: 0; }
  .topbar .brand:is(:hover, :focus-visible) .brand-logo { opacity: 0; }
  .topbar .brand:is(:hover, :focus-visible) .brand-home { opacity: 1; }
}

/* ---------- Dark bar buttons: smooth hover (glow + a little growth), dip on press ---------- */
@media (min-width: 1024px) {
  .topbar :is(.icon-btn, .search-trigger, .lang-menu summary) { transition: background-color .2s ease-out, color .2s ease-out, scale .28s cubic-bezier(.34, 1.56, .64, 1); }
  .topbar :is(.icon-btn, .search-trigger, .lang-menu summary):hover:not(:active) { scale: 1.08; }
  .topbar :is(.icon-btn, .search-trigger, .lang-menu summary):active { scale: .9; transition-duration: .2s, .2s, .12s; }
}

/* ---------- Tooltips: in almost at once, scaling up with a small bounce from the side nearest the control ---------- */
[data-hint]::after { scale: .85; transform-origin: 50% 100%;
  transition: opacity .14s ease-out, translate .26s cubic-bezier(.34, 1.56, .64, 1), scale .26s cubic-bezier(.34, 1.56, .64, 1); }
@media (hover: hover) { [data-hint]:hover::after { scale: 1; transition-delay: .06s; } }
[data-hint]:focus-visible::after { scale: 1; }
:is(.search-dialog, .lib-drawer, .sidebar-head) [data-hint]::after { transform-origin: 50% 0; }
@media (max-width: 1023px) { .topbar [data-hint]::after { transform-origin: 50% 0; } }
@media (min-width: 1024px) { .topbar [data-hint]::after { transform-origin: 0 50%; } [dir="rtl"] .topbar [data-hint]::after { transform-origin: 100% 50%; } }
.to-top[data-hint]::after { transform-origin: 100% 50%; }
[dir="rtl"] .to-top[data-hint]::after { transform-origin: 0 50%; }
.crumb-row [data-hint]::after { transform-origin: 0 0; }
[dir="rtl"] .crumb-row [data-hint]::after { transform-origin: 100% 0; }
@media (prefers-reduced-motion: reduce) { [data-hint]::after { scale: 1; transition: opacity .12s; } }

/* ---------- "Good to know": drops onto the page when it comes into view, tape pressed on after; the squiggle keeps wiggling ---------- */
.callout.will-reveal { opacity: 0; transform: translateY(18px) scale(.97); rotate: -2.5deg; }
.callout.will-reveal::before { scale: .3 1; opacity: 0; }
.callout.will-reveal.is-in { opacity: 1; transform: none; rotate: -.6deg;
  transition: opacity .45s ease-out, transform .7s cubic-bezier(.34, 1.4, .64, 1), rotate .7s cubic-bezier(.34, 1.4, .64, 1); }
[dir="rtl"] .callout.will-reveal { rotate: 2.5deg; }
[dir="rtl"] .callout.will-reveal.is-in { rotate: .6deg; }
.callout.will-reveal.is-in::before { scale: 1 1; opacity: 1; transition: scale .4s cubic-bezier(.34, 1.56, .64, 1) .45s, opacity .2s ease-out .45s; }
.callout h2::after { animation: note-wiggle 1.4s linear infinite; }
@keyframes note-wiggle { to { -webkit-mask-position: 12px center; mask-position: 12px center; } }
@media (prefers-reduced-motion: reduce) { .callout h2::after { animation: none; } }

/* ---------- Hero: little glowing shapes in the category colours drift out with the numbers ---------- */
.hero-shape { --c: oklch(0.72 0.17 var(--h)); position: absolute; left: 72%; top: 58%; display: block; width: 9px; height: 9px; opacity: 0; pointer-events: none;
  translate: -50% -50%; z-index: 1;
  animation: hero-shape 4.2s cubic-bezier(.25, .6, .35, 1) infinite; }
.s-circle { background: var(--c); border-radius: 50%; }
.s-ring { border: 2px solid var(--c); border-radius: 50%; }
.s-square { width: 8px; height: 8px; background: var(--c); border-radius: 2px; rotate: 20deg; }
.s-tri { width: 0; height: 0; border-inline: 5px solid transparent; border-bottom: 9px solid var(--c); }
.s-plus { width: 10px; height: 10px; background: linear-gradient(var(--c), var(--c)) center / 100% 2.5px no-repeat, linear-gradient(var(--c), var(--c)) center / 2.5px 100% no-repeat; }
.s-pct { width: auto; height: auto; font: 700 13px/1 var(--font); font-style: normal; color: var(--c); }
@keyframes hero-shape {
  0% { opacity: 0; transform: translate(0, 0) scale(.3) rotate(0); }
  15% { opacity: .9; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.7) rotate(90deg); }
}
.hero-mark span { z-index: 1; }
.hero-shape:nth-of-type(1) { --dx: -35px; --dy: -65px; animation-delay: 0.13s; }
.hero-shape:nth-of-type(2) { --dx: -24px; --dy: -93px; animation-delay: 1.63s; }
.hero-shape:nth-of-type(3) { --dx: -1px; --dy: -118px; animation-delay: 3.13s; }
.hero-shape:nth-of-type(4) { --dx: 17px; --dy: -72px; animation-delay: 0.43s; }
.hero-shape:nth-of-type(5) { --dx: 43px; --dy: -86px; animation-delay: 1.93s; }
.hero-shape:nth-of-type(6) { --dx: 77px; --dy: -90px; animation-delay: 3.43s; }
.hero-shape:nth-of-type(7) { --dx: 60px; --dy: -43px; animation-delay: 0.73s; }
.hero-shape:nth-of-type(8) { --dx: 89px; --dy: -36px; animation-delay: 2.23s; }
.hero-shape:nth-of-type(9) { --dx: 117px; --dy: -17px; animation-delay: 3.73s; }
.hero-shape:nth-of-type(10) { --dx: 74px; --dy: 7px; animation-delay: 1.03s; }
.hero-shape:nth-of-type(11) { --dx: 91px; --dy: 31px; animation-delay: 2.53s; }
.hero-shape:nth-of-type(12) { --dx: 99px; --dy: 64px; animation-delay: 4.03s; }
.hero-shape:nth-of-type(13) { --dx: 51px; --dy: 54px; animation-delay: 1.33s; }
.hero-shape:nth-of-type(14) { --dx: 48px; --dy: 83px; animation-delay: 2.83s; }
@media (prefers-reduced-motion: reduce) { .hero-shape { display: none; } }

/* ---------- Hero: a soft light glowing from behind the koala's calculator ---------- */
.hero-mark { background: none; isolation: isolate; }
.hero-mark::after { content: ""; position: absolute; inset: 0; z-index: 0; background: var(--sprite) no-repeat 100% 0 / 469.2308% auto; }
.hero-mark::before { content: ""; position: absolute; z-index: -1; left: 76%; top: 66%; width: 150px; height: 150px; translate: -50% -50%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, oklch(0.9 0.19 135 / .8) 0%, oklch(0.86 0.17 135 / .38) 35%, transparent 68%); filter: blur(8px);
  animation: hero-glow 3.2s ease-in-out infinite; }
@keyframes hero-glow { 0%, 100% { opacity: .6; scale: .9; } 50% { opacity: 1; scale: 1.08; } }
@media (prefers-reduced-motion: reduce) { .hero-mark::before { animation: none; } }

/* a hairline between the breadcrumb row and the page title */
.crumb-row { padding-bottom: var(--s-4); border-bottom: 1px solid var(--border); margin-bottom: var(--s-6); }
