:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #1e3a8a;          /* all UI borders: dark blue */
  --border-strong: #172554;
  --cat-selected-bg: #dbeafe;  /* light blue: selected category on the blue top bar */
  --cat-selected-text: #1e3a8a;
  --accent: #2563eb;
  --bar: #2563eb;              /* action bar: same in light + dark, matches <meta name="theme-color"> */
  --accent-text: #ffffff;
  --accent-soft: #e8f0fe;
  --accent-soft-hover: #d4e3fd;
  --accent-border: #bfd4fb;
  --accent-strong: #1d4ed8;
  --selected-bg: #ffffff;
  --selected-border: #cbd5e1;
  --chip: #eef2f7;
  --ad: #f1f3f6;
  --danger: #b91c1c;
  /* Chart tokens (validated palette: blue / orange series, fixed status steps) */
  --tf-series-1: #2a78d6; --tf-series-2: #eb6834;
  --tf-status-good: #0ca30c; --tf-status-warning: #fab219; --tf-status-serious: #ec835a; --tf-status-critical: #d03b3b;
  --radius: 10px;
  --side-ad: 160px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #3b5bdb;          /* dark blue, light enough to see on the dark background */
    --border-strong: #748ffc;
    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, .16);
    --accent-soft-hover: rgba(59, 130, 246, .26);
    --accent-border: rgba(59, 130, 246, .40);
    --accent-strong: #2563eb;
    --selected-bg: #2a2f3a;
    --selected-border: #4b5563;
    --chip: #222733;
    --ad: #1b1f27;
    --danger: #f87171;
    --tf-series-1: #3987e5; --tf-series-2: #d95926;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: var(--side-ad) minmax(0, 1fr) var(--side-ad);
  grid-template-areas:
    "top    top    top"
    "adl    main   adr"
    "foot   foot   foot";
}
.top-bars    { grid-area: top; }
.ad-left     { grid-area: adl; }
.tool-area   { grid-area: main; }
.ad-right    { grid-area: adr; }
.site-footer { grid-area: foot; }


/* ---------- Pinned top bars: [logo + title + categories] then [tools] ---------- */
.top-bars {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 20;
  margin: 0 -16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
}
/* Blue action bar (theme colour) */
.site-header {
  display: flex; align-items: center; gap: 16px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px;   /* notch-safe when opened full screen */
  background: var(--bar); color: #fff;
}
.tools-menu { padding: 8px 16px; }
.brand {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--accent-text); text-decoration: none;
  font-weight: 700; font-size: 1.2rem; white-space: nowrap;
}
.brand-logo { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 50%; background: #fff; }
.categories { flex: 1 1 auto; min-width: 0; }
/* Category chips on the blue bar: translucent white; selected = light blue so it stands out */
.site-header .cat { background: rgba(255, 255, 255, .14); color: var(--accent-text); }
.site-header .cat:hover { background: rgba(255, 255, 255, .24); }
.site-header .cat[aria-selected="true"] { background: var(--cat-selected-bg); color: var(--cat-selected-text); }

/* ---------- Categories (horizontal scroll) ---------- */
.scroller {
  display: flex; gap: 8px;
  overflow-x: auto; padding: 4px 0;
  scroll-snap-type: x proximity;
  scrollbar-width: none;            /* no scroll bar: the ‹ › arrows scroll the row */
}
.scroller::-webkit-scrollbar { display: none; }
/* Categories and tools share one look: chip colour + border, solid accent when selected. */
.cat, .tool-card {
  flex: 0 0 auto; scroll-snap-align: start;
  border: 1px solid var(--border); background: var(--chip); color: var(--text);
  font: inherit; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s;
}
.cat:hover, .tool-card:hover { border-color: var(--border-strong); }
.cat[aria-selected="true"], .tool-card[aria-current="page"] {
  background: var(--accent); color: var(--accent-text); border-color: var(--border);
}

/* Category chip: icon then name */
.cat {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 6px 14px 6px 10px; white-space: nowrap;
}
.cat-icon { display: inline-flex; width: 18px; height: 18px; flex: 0 0 auto; }

/* Tool chip: icon then name on one line; one sideways-scrolling row */
.tool-list { gap: 8px; }
.tool-card {
  display: inline-flex; align-items: center; gap: 8px; max-width: 240px;
  padding: 7px 12px 7px 9px; border-radius: var(--radius); white-space: nowrap;
}
.tool-card img { width: 20px; height: 20px; flex: 0 0 auto; border-radius: 5px; background: var(--surface); }
.tool-name { font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.empty { color: var(--muted); padding: 8px 0; }

/* ---------- Ads ---------- */
.ad-slot {
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-radius: var(--radius);
}
.ad-provider:empty { display: none; }
.ad-house { display: block; width: 100%; line-height: 0; color: inherit; text-decoration: none; }
.house-tall { display: block; max-width: 100%; height: auto; border-radius: var(--radius); }
/* Side banners shrink to fit between the pinned top bars and the floating bottom bar */
.ad-left .house-tall, .ad-right .house-tall { width: auto; max-height: calc(100vh - 156px - 116px); margin: 0 auto; }

/* Wide house banner: plain HTML so it fills any width (same width as the page content) */
.house-wide {
  display: flex; align-items: center; gap: 14px;
  width: 100%; height: 90px; padding: 0 20px; box-sizing: border-box;
  border-radius: var(--radius); line-height: 1.3; color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
}
.hw-logo { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; background: #fff; }
.hw-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.hw-text b { font-size: 18px; }
.hw-text span { font-size: 14px; color: #e0e7ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hw-cta { flex: 0 0 auto; padding: 8px 18px; border-radius: 999px; background: #fff; color: #1d4ed8; font-weight: 700; }

/* Desktop: side slots use the tall image; phones swap the left slot to the wide banner */
.ad-left .house-wide, .ad-right .house-wide { display: none; }
.ad-left .ad-slot, .ad-right .ad-slot {
  position: -webkit-sticky; position: sticky; top: 156px;   /* below the pinned top bars */
  align-items: flex-start; justify-content: center;
}

/* Floating bottom ad: fixed to the bottom of the screen */
.ad-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; align-items: center;
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
.ad-bottom .ad-slot { position: relative; width: 100%; max-width: calc(1400px - 32px); height: 90px; }   /* same width as the page content */
/* Leave room at the end of the page so the copyright is never hidden behind the bar */
body.has-ad-bar { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
/* Height of whatever floats at the bottom of the screen (our ad bar or Google's anchor ad), for sticky tool bars */
body.has-ad-bar { --float-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }
body.has-anchor { --float-bottom: 100px; }
@media (max-width: 768px) {
  body.has-ad-bar { --float-bottom: 0px; }
  body.has-anchor { --float-bottom: 64px; }
}

.no-support {
  padding: 12px 16px; text-align: center; background: #fef3c7; color: #78350f; font-weight: 600;
}

/* ---------- Shared tool UI kit (tf-*) ----------
   Tools use these classes so every tool has the same buttons and theme colours.
   <div class="tf-toolbar"> <button class="tf-btn tf-btn-primary"><svg…/> Count</button> … </div>
*/
.tf-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
/* Input | output side by side; stacks automatically when the tool area is narrow (phones) */
.tf-split {
  display: grid; gap: 16px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
.tf-pane { min-width: 0; display: flex; flex-direction: column; }
.tf-toolbar .tf-spacer { flex: 1 1 auto; }
.tf-field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 6px; }
.tf-label { font-weight: 600; font-size: 14px; }
.tf-hint { color: var(--muted); font-size: 13px; }
.tf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 7px 16px; border-radius: 999px;
  /* default: solid theme blue */
  border: 1px solid var(--border); background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .15s, border-color .15s, color .15s;
}
.tf-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.tf-btn:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--border-strong); }
.tf-btn:active:not(:disabled) { transform: translateY(1px); }
.tf-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tf-btn:disabled { opacity: .5; cursor: default; }
.tf-btn-primary { background: var(--accent); border-color: var(--border); color: var(--accent-text); }
.tf-btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--border-strong); }
/* selected option in a group = white / grey */
.tf-btn[aria-pressed="true"] {
  background: var(--selected-bg); border-color: var(--border); color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08);
}
.tf-btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--selected-bg); border-color: var(--border-strong); }
.tf-btn-sm { min-height: 32px; padding: 5px 12px; font-size: 13px; }
.tf-btn-sm svg { width: 16px; height: 16px; }
/* Text "icon" for buttons whose meaning is a letter style (e.g. Aa, AB) */
.tf-glyph {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 4px; border-radius: 6px;
  background: rgba(255, 255, 255, .25); color: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0;
}
.tf-btn[aria-pressed="true"] .tf-glyph { background: var(--chip); color: var(--text); }
/* Option group ("pick one", e.g. A4 / Letter): the selected option is filled, the others are quiet.
   <div class="tf-toolbar tf-choice" role="group"> <button class="tf-btn tf-btn-sm" aria-pressed="true">A4</button> … */
.tf-choice .tf-btn { background: var(--surface); color: var(--text); }
.tf-choice .tf-btn:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); border-color: var(--border); }
.tf-choice .tf-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--border); box-shadow: none; }
.tf-choice .tf-btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--accent-strong); color: var(--accent-text); }
/* The bar with a tool's main action stays visible at the bottom of the screen while scrolling long page lists
   (above the floating ad bar on desktop: --float-bottom). */
.tf-actionbar {
  position: -webkit-sticky; position: sticky; bottom: var(--float-bottom, 0px); z-index: 5;
  margin: 12px 0 0; padding: 10px 0; background: var(--surface);
  box-shadow: 0 -10px 12px -10px rgba(15, 23, 42, .18);
}
/* Round icon-only button (move up / down, remove) — always give it an aria-label */
.tf-btn-icon { min-height: 32px; width: 32px; padding: 0; background: var(--surface); color: var(--text); }
.tf-btn-icon:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); border-color: var(--border); }
.tf-btn-icon svg { width: 16px; height: 16px; }
.tf-btn-quiet { background: var(--surface); color: var(--text); }
.tf-btn-quiet:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.tf-input {
  font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px; min-height: 32px; box-sizing: border-box;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.tf-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Text panes (lmpb-text): label + actions, text area, error, status line */
.tf-actions { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.tf-text-pane .tf-field-head { flex-wrap: wrap; }
.tf-text-pane .tf-field-head .tf-label { white-space: nowrap; }
@media (max-width: 600px) { .tf-textarea { min-height: 180px; height: min(38vh, 300px); } }
.tf-textarea {
  width: 100%; box-sizing: border-box; min-height: 220px; padding: 10px; border-radius: 8px; resize: vertical;
  font: inherit; line-height: 1.5; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.tf-textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tf-textarea.is-output { background: var(--chip); }
.tf-textarea.is-over { border-style: dashed; background: var(--accent-soft); }
.tf-textarea.has-error { border-color: var(--danger); }
.tf-code { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; font-size: 13px; tab-size: 4; white-space: pre; }
.tf-pane-status { min-height: 1.3em; margin-top: 4px; color: var(--muted); font-size: 12px; }
.tf-pane-error { margin-top: 6px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--danger); color: var(--danger); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.tf-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; user-select: none; }
.tf-check input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.tf-choice-label { margin-right: 2px; }
.tf-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Calculator fields (lmpb-calc) */
.tf-fields { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); align-items: start; }
.tf-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tf-num { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); overflow: hidden; }
.tf-num:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.tf-num .tf-num-input { flex: 1 1 auto; min-width: 0; border: 0; border-radius: 0; background: transparent; font-size: 16px; min-height: 40px; }
.tf-num .tf-num-input:focus-visible { outline: 0; }
.tf-num-affix { display: inline-flex; align-items: center; padding: 0 10px; background: var(--chip); color: var(--muted); font-size: 14px; white-space: nowrap; }
.tf-field.has-error .tf-num { border-color: var(--danger); }
.tf-field-error { color: var(--danger); font-size: 13px; }
.tf-range { width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.tf-select, .tf-date { font-size: 16px; min-height: 40px; }

/* Result tiles: the main numbers of a calculation */
.tf-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); margin: 16px 0; }
.tf-tile { border: 1px solid var(--selected-border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); min-width: 0; }
.tf-tile.is-primary { border-color: var(--border); background: var(--accent-soft); }
.tf-tile-label { color: var(--muted); font-size: 13px; }
.tf-tile-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tf-tile.is-primary .tf-tile-value { color: var(--accent); font-size: 1.6rem; }
.tf-tile-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Data tables (schedules, conversion tables) */
.tf-table { overflow-x: auto; border: 1px solid var(--selected-border); border-radius: var(--radius); }
.tf-table:empty { display: none; }
.tf-table table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--surface); }
.tf-table caption { text-align: left; padding: 8px 12px; font-weight: 600; }
.tf-table th, .tf-table td { padding: 6px 12px; text-align: left; border-bottom: 1px solid var(--selected-border); white-space: nowrap; }
.tf-table th { background: var(--chip); font-weight: 600; position: sticky; top: 0; }
.tf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tf-table tr:last-child td { border-bottom: 0; }

/* Image tools (lmpb-img): file list with before → after sizes, before/after compare slider */
.tf-imgfiles { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.tf-imgfile {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--selected-border);
  border-radius: var(--radius); background: var(--surface);
}
.tf-imgfile[data-state="done"] { border-color: #16a34a; }
.tf-imgfile[data-state="error"] { border-color: var(--danger); }
.tf-imgfile-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; background: var(--chip); }
.tf-imgfile-noprev { display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.tf-imgfile-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tf-imgfile-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-imgfile-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tf-imgfile[data-state="done"] .tf-imgfile-meta { color: var(--text); }
.tf-imgfile[data-state="error"] .tf-imgfile-meta { color: var(--danger); font-weight: 600; }
.tf-imgfile[data-state="busy"] .tf-imgfile-meta::after { content: ""; display: inline-block; width: 10px; height: 10px; margin-left: 6px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: tf-spin .8s linear infinite; vertical-align: -1px; }
@keyframes tf-spin { to { transform: rotate(360deg); } }
.tf-imgfile-acts { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
@media (max-width: 520px) { .tf-imgfile { flex-wrap: wrap; } .tf-imgfile-acts { width: 100%; justify-content: flex-end; } }
.tf-img-bar { flex-wrap: wrap; }
.tf-img-total { font-weight: 600; color: var(--text); }
.tf-img-viewer { margin-top: 12px; }
.tf-compare { position: relative; overflow: hidden; border-radius: 8px; max-height: 70vh; cursor: ew-resize; touch-action: none; user-select: none;
  background: repeating-conic-gradient(#e5e7eb 0 25%, #fff 0 50%) 0 0 / 18px 18px; box-shadow: 0 0 0 1px var(--selected-border); }
.tf-compare img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; }
.tf-compare-after { position: absolute; inset: 0; }
.tf-compare-after img { width: 100%; height: 100%; }
.tf-compare-handle { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.tf-compare-handle::after { content: "⇆"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%;
  background: #fff; color: #111; display: flex; align-items: center; justify-content: center; font-size: 18px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.tf-compare-handle:focus-visible { outline: 3px solid var(--accent); }
.tf-compare-label { position: absolute; top: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12px; pointer-events: none; }
.tf-compare-l { left: 8px; } .tf-compare-r { right: 8px; }

/* Charts (lmpb-calc): legend, tooltip, share bar, stacked columns, banded meter. Text uses text tokens only. */
.tf-chart { position: relative; margin: 12px 0; }
.tf-chart-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.tf-legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.tf-legend li { display: inline-flex; align-items: center; gap: 6px; }
.tf-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.tf-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.tf-tip {
  position: absolute; z-index: 5; pointer-events: none; padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5;
  background: var(--surface); color: var(--text); border: 1px solid var(--selected-border); box-shadow: 0 4px 14px rgba(15, 23, 42, .18); white-space: nowrap;
}
.tf-tip-row { display: flex; align-items: center; gap: 6px; }
.tf-sharebar-track { display: flex; gap: 2px; height: 28px; border-radius: 6px; overflow: hidden; background: var(--surface); }
.tf-sharebar-seg { display: flex; align-items: center; justify-content: center; min-width: 2px; }
.tf-sharebar-seg:first-child { border-radius: 6px 0 0 6px; } .tf-sharebar-seg:last-child { border-radius: 0 6px 6px 0; }
.tf-sharebar-in { color: #fff; font-size: 12px; font-weight: 700; text-shadow: 0 0 2px rgba(0, 0, 0, .35); }
.tf-sharebar-track + .tf-legend { margin: 8px 0 0; }
.tf-columns-plot { position: relative; }
.tf-columns svg { display: block; overflow: visible; }
.tf-columns .tf-grid { stroke: var(--selected-border); stroke-width: 1; opacity: .6; }
.tf-columns .tf-axis { stroke: var(--muted); stroke-width: 1; }
.tf-columns .tf-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tf-columns .tf-hit:hover { fill: var(--accent-soft); fill-opacity: .35; }
.tf-meterbands { padding: 26px 0 0; }
.tf-meterbands-track { position: relative; height: 14px; }
.tf-meterbands-seg { position: absolute; top: 0; bottom: 0; border-right: 2px solid var(--surface); box-sizing: border-box; }
.tf-meterbands-seg:first-child { border-radius: 7px 0 0 7px; }
.tf-meterbands-seg:last-of-type { border-radius: 0 7px 7px 0; border-right: 0; }
.tf-meterbands-marker { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 2px; background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.tf-meterbands-tag { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 4px; font-weight: 700; font-size: 13px; white-space: nowrap; }
.tf-meterbands-scale, .tf-meterbands-labels { position: relative; height: 18px; font-size: 11px; color: var(--muted); }
.tf-meterbands-scale span, .tf-meterbands-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; top: 2px; }
.tf-meterbands-labels { font-size: 12px; color: var(--text); }
@media (max-width: 520px) { .tf-meterbands-labels span { font-size: 10px; } }

/* Strength meter (password generator): data-level 0–4 */
.tf-meter { height: 8px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.tf-meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--danger); transition: width .2s; }
.tf-meter[data-level="1"] > span { width: 25%; background: #ea580c; }
.tf-meter[data-level="2"] > span { width: 50%; background: #ca8a04; }
.tf-meter[data-level="3"] > span { width: 75%; background: #16a34a; }
.tf-meter[data-level="4"] > span { width: 100%; background: #15803d; }

/* File tools: drop zone → file list → action → result card (used by the PDF tools via lmpb-pdf) */
.tf-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 200px; padding: 24px 16px; box-sizing: border-box; text-align: center;
  border: 2px dashed var(--accent-border); border-radius: var(--radius); background: var(--accent-soft);
  transition: background-color .15s, border-color .15s;
}
.tf-drop.is-over { border-color: var(--accent); background: var(--accent-soft-hover); }
.tf-drop.is-compact { min-height: 0; padding: 12px; flex-direction: row; flex-wrap: wrap; }
.tf-drop.is-compact .tf-drop-icon, .tf-drop.is-compact .tf-drop-title { display: none; }
.tf-drop-icon { width: 44px; height: 44px; color: var(--accent); }
.tf-drop-title { font-size: 1.1rem; font-weight: 600; }
.tf-files { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.tf-file {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.tf-file.has-error { border-color: var(--danger); }
.tf-file-thumb {
  flex: 0 0 auto; width: 44px; height: 58px; border-radius: 4px; background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); object-fit: contain;
}
.tf-file-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tf-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf-file-meta { color: var(--muted); font-size: 13px; }
.tf-file-error { color: var(--danger); font-size: 13px; }
.tf-file-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
.tf-drag { cursor: grab; touch-action: none; color: var(--muted); display: inline-flex; padding: 4px; }
.tf-drag svg { width: 20px; height: 20px; }
/* Drag to reorder (lmpb-pdf sortable): the item is "in hand" (ghost), its place is empty, a dashed slot shows the drop spot */
.tf-drag-source { display: none !important; }
.tf-slot {
  flex: 0 0 auto; box-sizing: border-box; list-style: none;
  border: 2px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft);
}
.tf-ghost-wrap { position: fixed; left: 0; top: 0; z-index: 300; pointer-events: none; margin: 0; padding: 0; }
.tf-ghost { list-style: none; box-sizing: border-box; box-shadow: 0 14px 30px rgba(15, 23, 42, .3); opacity: .96; }
body.tf-is-dragging, body.tf-is-dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.tf-result {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 0; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--accent-soft);
}
.tf-result-main { flex: 1 1 200px; min-width: 0; }
.tf-result-name { font-weight: 700; overflow-wrap: anywhere; }
.tf-error { color: var(--danger); font-weight: 600; }
.tf-file-icon {
  flex: 0 0 auto; width: 34px; height: 42px; border-radius: 5px; background: #dc2626; color: #fff; box-sizing: border-box;
  display: inline-flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; font-size: 10px; font-weight: 800;
}
.tf-file-icon[data-kind="word"] { background: #2563eb; }
.tf-file-icon[data-kind="excel"] { background: #16a34a; }
.tf-file-icon[data-kind="ppt"] { background: #ea580c; }
.tf-file-icon[data-kind="file"] { background: #64748b; }
.tf-single-error { margin: 8px 0 0; }

/* Page board (lmpb-pdf pageBoard): thumbnails of every page, optionally selectable / rotatable / sortable */
.tf-pages {
  list-style: none; margin: 12px 0 0; padding: 10px; display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.tf-page {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; box-sizing: border-box; min-width: 0;
  border: 2px solid transparent; outline: 1px solid var(--border); outline-offset: -2px; border-radius: 8px; background: var(--surface);
}
.tf-page-top, .tf-page-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-height: 26px; }
.tf-page-tools { display: inline-flex; gap: 4px; margin-left: auto; }
.tf-page .tf-btn-icon { min-height: 26px; width: 26px; }
.tf-page .tf-btn-icon svg { width: 14px; height: 14px; }
.tf-page .tf-drag { padding: 2px; }
.tf-page .tf-drag svg { width: 18px; height: 18px; }
/* Page number: on the thumbnail's top-left corner, so the top row only holds the grip and buttons (fits on phones) */
.tf-page-num {
  position: absolute; top: 38px; left: 10px; z-index: 1;
  min-width: 22px; height: 22px; padding: 0 6px; box-sizing: border-box; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; background: var(--chip); font-size: 12px; font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface);
}
.tf-page-img { position: relative; height: 124px; display: flex; align-items: center; justify-content: center; border-radius: 4px; }
.tf-page-img canvas { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.tf-page-ph {
  width: 88px; height: 116px; display: flex; align-items: center; justify-content: center;
  background: #fff; color: #9ca3af; font-weight: 700; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12);
}
.tf-page-check {
  position: absolute; right: 2px; bottom: 2px; width: 24px; height: 24px; border-radius: 999px; display: none;
  align-items: center; justify-content: center; background: var(--accent); color: #fff; box-shadow: 0 0 0 2px var(--surface);
}
.tf-page-check svg { width: 14px; height: 14px; }
.tf-pages.is-selectable .tf-page-img { cursor: pointer; }
.tf-pages.is-selectable .tf-page-img:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tf-page.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.tf-page.is-selected .tf-page-check { display: inline-flex; }
@media (pointer: fine) { .tf-pages .tf-page:has(.tf-drag) { cursor: grab; user-select: none; } .tf-page button { cursor: pointer; } }
@media (max-width: 480px) { .tf-pages { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; padding: 8px; } }

/* Page stage (lmpb-pdf pageStage / placeBox): a large page with an overlay for boxes and drawings */
.tf-stage { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.tf-stage-nav { display: flex; align-items: center; gap: 10px; }
.tf-stage-view { position: relative; max-width: 100%; touch-action: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); background: #fff; }
.tf-stage-canvas canvas { display: block; }
.tf-stage-overlay { position: absolute; inset: 0; }
.tf-box { position: absolute; box-sizing: border-box; border: 1.5px dashed var(--accent); cursor: move; touch-action: none; outline: none; }
.tf-box:focus-visible, .tf-box:focus { border-style: solid; box-shadow: 0 0 0 2px var(--accent-soft); }
.tf-box > img, .tf-box > canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.tf-box-resize {
  position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px; border-radius: 999px; cursor: nwse-resize;
  background: var(--accent); border: 2px solid #fff; box-sizing: border-box;
}
.tf-box-del {
  position: absolute; right: -11px; top: -11px; width: 22px; height: 22px; padding: 0; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff; background: var(--danger); color: #fff;
}
.tf-box-del svg { width: 12px; height: 12px; }

/* One-PDF page tools (lmpb-pdf mountPageTool): picker → controls → page board → summary + action */
.pt-work { margin-top: 12px; }
.pt-controls .tf-hint { margin: 4px 0; }
.pt-controls .tf-toolbar { margin: 6px 0; }
.pt-bar .pt-summary { flex: 1 1 260px; margin: 0; }

/* Images → PDF tools (lmpb-pdf mountImagesToPdf): image grid + page options */
.tf-page-img img { max-width: 92px; max-height: 92px; object-fit: contain; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); transition: transform .15s; }
.ip-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.ip-bad { outline-color: var(--danger); }
.ip-bad .ip-name { color: var(--danger); white-space: normal; }
.ip-options { display: grid; gap: 4px 16px; margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.ip-opt .tf-toolbar { margin: 4px 0 8px; }
.ip-actions .ip-status { flex: 1 1 260px; margin: 0; }
@media (max-width: 480px) {
  .tf-file { flex-wrap: wrap; }
  .tf-file-main { flex: 1 1 0; }
  .tf-file-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- Tool area ---------- */
.tool-area {
  position: relative;
  min-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.tool-intro h1, .tool-intro h2#tool-title { margin: 0 0 4px; font-size: 1.5rem; }
.tool-intro p { margin: 0 0 16px; color: var(--muted); }

/* ---------- Loader ---------- */
/* Loading popup: fixed to the screen (visible whatever the scroll position), above the bars and ads */
.loader {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100;   /* not "inset" (Safari < 14.1) */
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, .45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: loader-fade .15s ease-out;
}
.loader-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  width: min(380px, 100%); padding: 28px 24px 20px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-top: 4px solid var(--accent); border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, .35);
  animation: loader-pop .2s ease-out;
}
@keyframes loader-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes loader-pop { from { transform: translateY(8px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .loader, .loader-card { animation: none; } }
.loader-icon { width: 72px; height: 72px; border-radius: 16px; }
.loader-name { font-weight: 700; font-size: 1.2rem; }
.loader-msg { color: var(--muted); min-height: 1.5em; }
.loader.error .loader-msg { color: var(--danger); }
.bar {
  width: 100%; height: 8px; border-radius: 999px;
  background: var(--chip); overflow: hidden;
}
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .15s; }
.bar.indeterminate .bar-fill { width: 35%; animation: slide 1.1s ease-in-out infinite; }
.loader.error .bar { display: none; }

/* Result popup ("your file is ready"): same overlay + card as the loader, wider, with a file list */
.result-card { position: relative; width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box; }
.result-close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--muted);
}
.result-close:hover { background: var(--chip); color: var(--text); }
.result-close:focus-visible { outline: 2px solid var(--accent); }
.result-close svg { width: 20px; height: 20px; }
.result-ok {
  width: 56px; height: 56px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: #dcfce7; color: #15803d;
}
.result-ok svg { width: 30px; height: 30px; }
.result-title { margin: 0; font-size: 1.25rem; }
.result-msg { margin: 0; color: var(--muted); }
.result-msg:empty, .result-extra:empty { display: none; }
.result-extra { width: 100%; }
.result-files { list-style: none; margin: 4px 0 0; padding: 0; width: 100%; display: grid; gap: 8px; text-align: left; }
.result-file {
  display: flex; align-items: center; gap: 10px; padding: 10px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
}
.result-file-icon {
  flex: 0 0 auto; width: 40px; height: 48px; border-radius: 6px; background: #dc2626; color: #fff;
  display: inline-flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; box-sizing: border-box;
  font-size: 11px; font-weight: 800; letter-spacing: .02em;
}
.result-file-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.result-name { display: flex; align-items: center; min-width: 0; }
.result-name .tf-input { flex: 1 1 auto; min-width: 0; width: 100%; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.result-ext {
  flex: 0 0 auto; padding: 0 8px; min-height: 32px; display: inline-flex; align-items: center; box-sizing: border-box;
  border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--chip); color: var(--muted); font-size: 14px;
}
.result-file-meta { color: var(--muted); font-size: 13px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
@media (max-width: 480px) {
  .result-file { flex-wrap: wrap; }
  .result-file > .tf-btn { width: 100%; }
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.retry {
  font: inherit; font-weight: 600; padding: 8px 24px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--accent); color: var(--accent-text);
}
.retry:hover { background: var(--accent-strong); }
.powered { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 0 20px; }

/* Phone: hide right ad, move left ad between tools menu and tool area */
@media (max-width: 768px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "adl" "main" "foot";
  }
  .ad-right { display: none; }
  .ad-left .ad-slot { min-height: 0; position: static; }
  .ad-left .house-tall { display: none; }
  .ad-left .house-wide { display: flex; }
  .house-wide { height: 64px; padding: 0 12px; gap: 10px; }
  .hw-logo { width: 36px; height: 36px; }
  .hw-text b { font-size: 15px; }
  .hw-text span { font-size: 12px; }
  .hw-cta { display: none; }
  .ad-bottom .ad-slot { height: 56px; }
  .ad-bottom .house-wide { height: 56px; }
  body.has-ad-bar { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}

/* Shown only in the Tool Factory's local preview */
.preview-banner {
  position: sticky; top: 0; z-index: 50;
  padding: 6px 16px; text-align: center;
  background: #f59e0b; color: #111827; font-size: 13px; font-weight: 600;
}

/* Phone: keep logo + categories in one bar; shorten the brand */
@media (max-width: 480px) {
  .site-header { gap: 10px; }
  .brand { font-size: 1rem; gap: 6px; }
  .brand-logo { width: 32px; height: 32px; }
}


/* ---------- ‹ › arrows for sideways-scrolling rows ---------- */
.arrow-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.arrow-wrap > .scroller, .arrow-wrap > .card-row { flex: 1 1 auto; min-width: 0; }
.arrow-btn {
  display: none; flex: 0 0 auto; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 1px solid var(--border); background: var(--accent); color: var(--accent-text);
  -webkit-tap-highlight-color: transparent; transition: opacity .15s, background-color .15s;
}
.arrow-btn svg { width: 18px; height: 18px; }
.arrow-btn:hover { background: var(--accent-strong); }
.arrow-wrap.has-overflow .arrow-btn { display: inline-flex; }
.arrow-btn.is-off { opacity: .3; pointer-events: none; }
/* On the blue action bar: white arrows */
.arrows-bar .arrow-btn { background: rgba(255, 255, 255, .18); color: #fff; }
.arrows-bar .arrow-btn:hover { background: rgba(255, 255, 255, .3); }
.arrows-cards .arrow-btn { width: 36px; height: 36px; }

/* ---------- Home screen ---------- */
/* On the home screen: no side ads, no tools row under the action bar; only the bottom ad. */
body.is-home .ad-left, body.is-home .ad-right, body.is-home .tools-menu { display: none; }
/* Layout shift: on the home page everything below the hero waits for home.js (the lists, FAQ, footer and bottom ad
   appear together, so nothing visible moves). Only when scripts run ("js" class); home.js removes home-pending. */
.js body.home-pending .home > :not(.home-hero), .js body.home-pending .site-footer, .js body.home-pending .ad-bottom { display: none; }
/* Tool pages: room for the tool while it loads, so the text below it moves less when it appears. */
body:not(.is-home) .tool-stage:empty { min-height: 420px; }
@media (max-width: 640px) { body:not(.is-home) .tool-stage:empty { min-height: 360px; } }
body.is-home .page { grid-template-areas: "top top top" "main main main" "foot foot foot"; }
@media (max-width: 768px) {
  body.is-home .page { grid-template-areas: "top" "main" "foot"; }
}

.home { display: flex; flex-direction: column; gap: 24px; }
.home h3 { margin: 0 0 12px; font-size: 1.1rem; }

/* 1. About + search, with the logo */
.home-hero {
  /* logo | search area | empty column as wide as the logo -> search area is centred in the box */
  display: grid; grid-template-columns: 150px minmax(0, 1fr) 150px; align-items: center; gap: 28px;
  padding: 24px; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
}
.home-logo { width: 150px; height: 150px; flex: 0 0 auto; border-radius: 50%; background: #fff; }
@media (max-width: 768px) {
  .home-hero { grid-template-columns: 1fr; justify-items: center; gap: 16px; }   /* small screens: logo centred above */
  .home-hero-text { width: 100%; }
  .home-logo { width: 110px; height: 110px; }
}
.home-hero-text { text-align: center; min-width: 0; }
.home-title { margin: 0 0 6px; font-size: clamp(1.35rem, 3vw, 1.9rem); line-height: 1.25; }
.home-sub { margin: 0 0 16px; color: var(--muted); }
.home-search { position: relative; max-width: 640px; margin: 0 auto; }
.home-search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; color: var(--muted); pointer-events: none;
}
.home-search input {
  width: 100%; font: inherit; font-size: 16px;            /* 16px: no zoom-on-focus on iPhone */
  padding: 12px 16px 12px 44px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.home-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.home-empty { color: var(--muted); margin: 0; }

/* Containers for New / Popular / Recently used / Search results */
.home-box {
  padding: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}
.home-recent { background: var(--accent-soft); }

/* ---------- Home layouts: .home[data-view] = classic (default) | modern ----------
   Blocks of the other layout are hidden; order moves blocks without changing the HTML (search engines still read it). */
.home > * { order: 0; }
.home:not([data-view="modern"]) #home-cats-block { display: none; }

/* Category tiles */
.cat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.cat-tile {
  display: flex; align-items: center; gap: 12px; padding: 14px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--chip);
  color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s, background-color .15s;
}
.cat-tile:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--surface); }
.cat-tile .cat-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.cat-tile .cat-icon svg { width: 24px; height: 24px; }
.cat-text { display: flex; flex-direction: column; min-width: 0; }
.cat-text b { font-size: 15px; line-height: 1.25; }
.cat-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 768px) {
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cat-tile { padding: 10px; gap: 8px; }
  .cat-tile .cat-icon { width: 36px; height: 36px; }
}

/* One row of cards: 5 visible on desktop, 3 on phones; ‹ › arrows scroll the rest */
.card-row {
  --per-view: 5; --gap: 12px;
  display: grid; grid-auto-flow: column; gap: var(--gap);
  grid-auto-columns: calc((100% - (var(--per-view) - 1) * var(--gap)) / var(--per-view));
  overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px;
  scrollbar-width: none;
}
.card-row::-webkit-scrollbar { display: none; }
/* Grid of cards (New tools, Recently used): same 5 / 3 columns, wraps instead of scrolling.
   .one-row keeps just the first row: the latest 5 on desktop, 3 on phones. */
.card-grid {
  --per-view: 5; --gap: 12px;
  display: grid; gap: var(--gap); padding: 2px;
  grid-template-columns: repeat(var(--per-view), minmax(0, 1fr));
}
.card-grid.one-row > .tool-tile:nth-child(n+6) { display: none; }
@media (max-width: 768px) {
  .card-row, .card-grid { --per-view: 3; --gap: 8px; }
  .card-grid.one-row > .tool-tile:nth-child(n+4) { display: none; }
}

/* Card: icon, then name, then description */
.tool-tile {
  position: relative; scroll-snap-align: start; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 14px 10px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  border: 1px solid var(--border); background: var(--chip);
  transition: border-color .15s, transform .15s, background-color .15s;
}
.tool-tile:hover { border-color: var(--border-strong); transform: translateY(-2px); background: var(--surface); }
.tool-tile img { width: 48px; height: 48px; border-radius: 12px; }
.tool-tile b { font-size: 14px; line-height: 1.25; }
.tool-tile span:not(.tile-badge) {
  font-size: 12px; line-height: 1.35; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
/* Recently used: the last used tool is highlighted */
.tool-tile.is-last { background: var(--surface); border-width: 2px; border-color: var(--accent); box-shadow: 0 4px 14px rgba(37, 99, 235, .18); }
.tile-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-text);
}
@media (max-width: 768px) {
  .tool-tile { padding: 10px 6px; }
  .tool-tile img { width: 40px; height: 40px; }
  .tool-tile b { font-size: 13px; }
  .tile-badge { position: static; margin-bottom: -2px; }
}

/* 2. Why LMPB Tools: blue band with five feature cards (each with its own icon colour) */
.home-why {
  position: relative; overflow: hidden;
  padding: 28px 24px; border-radius: calc(var(--radius) + 4px);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 60%, #312e81 100%);
  color: #fff;
}
/* soft decorative circles */
.home-why::before, .home-why::after {
  content: ""; position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255, 255, 255, .08);
}
.home-why::before { width: 260px; height: 260px; right: -80px; top: -110px; }
.home-why::after { width: 180px; height: 180px; left: -60px; bottom: -90px; }
.why-head { position: relative; text-align: center; margin-bottom: 22px; }
.why-head h2 { margin: 0 0 6px; font-size: clamp(1.25rem, 2.6vw, 1.6rem); }
.why-head p { margin: 0; color: rgba(255, 255, 255, .85); }
.why-grid {
  position: relative; list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px; grid-template-columns: repeat(6, minmax(0, 1fr));
}
.why-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 20px 14px 18px; border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .18);
  transition: transform .2s, box-shadow .2s;
}
.why-card:hover { transform: translateY(-4px); box-shadow: 0 12px 26px rgba(15, 23, 42, .26); }
.why-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 16px; margin-bottom: 4px;
  color: var(--why); background: color-mix(in srgb, var(--why) 14%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--why) 30%, transparent);
}
@supports not (background: color-mix(in srgb, red 10%, transparent)) {
  .why-icon { background: var(--chip); }                        /* older browsers */
}
.why-icon svg { width: 28px; height: 28px; }
.why-card b { font-size: 1rem; }
.why-card > span:last-child { font-size: 13px; line-height: 1.45; color: var(--muted); }
@media (max-width: 1100px) { .why-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 768px) {
  .home-why { padding: 22px 14px; }
  .why-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .why-card { padding: 14px 10px; }
  .why-icon { width: 46px; height: 46px; border-radius: 13px; }
  .why-icon svg { width: 24px; height: 24px; }
}

/* 5. FAQ */
.home-faq { display: flex; flex-direction: column; gap: 8px; }
.home-faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0 14px; }
.home-faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.home-faq p { margin: 0 0 12px; color: var(--muted); }

/* Text below a tool: intro, how to, features, FAQ, related tools (tools.json → content) */
.tool-content { margin: 20px 0 8px; padding: 4px 4px 0; line-height: 1.65; }
.tool-content h2 { font-size: 1.15rem; margin: 22px 0 8px; }
.tool-content .tc-intro p { margin: 0 0 10px; }
.tool-content ol, .tool-content ul { margin: 0; padding-left: 1.4em; }
.tool-content li { margin: 4px 0; }
.tool-content .tc-faq { display: flex; flex-direction: column; gap: 8px; }
.tool-content .tc-faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0 14px; }
.tool-content .tc-faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.tool-content .tc-faq p { margin: 0 0 12px; color: var(--muted); }
/* Related tools (or popular tools as a fallback): the same cards as the home page, 4 per row (2 on phones) */
.tool-content .tc-related { --per-view: 4; margin-bottom: 8px; }
.tool-content .tc-related .tool-tile { color: var(--text); }
@media (max-width: 768px) { .tool-content .tc-related { --per-view: 2; } }
.tool-content .tc-section p { margin: 0 0 10px; }
.tool-content .tc-table { overflow-x: auto; margin: 4px 0 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.tool-content .tc-table table { border-collapse: collapse; width: 100%; font-size: 14px; background: var(--surface); }
.tool-content .tc-table th, .tool-content .tc-table td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--selected-border); }
.tool-content .tc-table th { background: var(--accent-soft); font-weight: 600; }
.tool-content .tc-table tr:last-child td { border-bottom: 0; }

/* Breadcrumb above a tool's H1: Home › Category › Tool */
.crumbs ol { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* All tools page (/all-tools/): search, category tiles, then one collapsible section per category */
.home-all-link { font-size: 13px; font-weight: 500; margin-left: 8px; color: var(--accent); }
.all-tools [hidden] { display: none !important; }
.all-tools .at-search { position: sticky; top: 8px; z-index: 5; display: flex; align-items: center; gap: 10px; margin: 4px 0 18px; }
.all-tools .at-search input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 12px 16px 12px 44px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text); box-shadow: 0 4px 16px rgba(15, 23, 42, .08);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 16px 50% / 18px;
}
.all-tools .at-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.all-tools .at-count { font-size: 14px; color: var(--muted); white-space: nowrap; }
/* Category tiles */
.all-tools .at-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0 0 26px; }
.all-tools .at-cat {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 16px 10px 14px; border-radius: 14px; text-decoration: none; color: var(--text);
  border: 1px solid color-mix(in srgb, var(--tint) 30%, transparent); background: color-mix(in srgb, var(--tint) 8%, var(--surface));
  transition: transform .15s, box-shadow .15s, background-color .15s;
}
.all-tools .at-cat:hover { transform: translateY(-2px); box-shadow: 0 8px 20px color-mix(in srgb, var(--tint) 22%, transparent); background: color-mix(in srgb, var(--tint) 14%, var(--surface)); }
/* The name always takes two lines' height (one-line names centred in it), so icons, names and counts line up. */
.all-tools .at-cat b { display: flex; align-items: center; justify-content: center; min-height: 2.5em; font-size: 15px; line-height: 1.25; margin-top: 6px; }
.all-tools .at-cat small { font-size: 13px; color: var(--muted); }
.all-tools .at-ico { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; background: var(--tint); color: #fff; }
.all-tools .at-ico svg { width: 22px; height: 22px; }
/* Collapsible category sections */
.all-tools .at-group { scroll-margin-top: 80px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.all-tools .at-group summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; list-style: none; user-select: none; }
.all-tools .at-group summary::-webkit-details-marker { display: none; }
.all-tools .at-group summary::after {
  content: ""; margin-left: 8px; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .2s;
}
.all-tools .at-group details[open] > summary::after { transform: rotate(45deg); }
.all-tools .at-group summary:hover { background: color-mix(in srgb, var(--tint) 6%, var(--surface)); }
.all-tools .at-group summary .at-ico { width: 32px; height: 32px; border-radius: 9px; }
.all-tools .at-group summary .at-ico svg { width: 18px; height: 18px; }
.all-tools .at-group h2 { margin: 0; font-size: 1.1rem; flex: 1; }
.all-tools .at-n { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; color: var(--tint); background: color-mix(in srgb, var(--tint) 12%, var(--surface)); }
.all-tools details[open] > summary { border-bottom: 1px solid var(--border); }
/* Tools inside a category */
.all-tools .at-list { list-style: none; margin: 0; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.all-tools .at-list a { display: flex; align-items: flex-start; gap: 12px; padding: 10px; border-radius: 10px; text-decoration: none; color: var(--text); height: 100%; box-sizing: border-box; transition: background-color .15s; }
.all-tools .at-list a:hover { background: color-mix(in srgb, var(--tint) 8%, var(--surface)); }
.all-tools .at-list a:hover .at-name { color: var(--accent); }
.all-tools .at-list img { width: 32px; height: 32px; border-radius: 8px; flex: 0 0 auto; }
.all-tools .at-name { display: block; font-weight: 600; line-height: 1.3; }
.all-tools .at-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.all-tools .at-empty { padding: 24px; text-align: center; color: var(--muted); }
@media (max-width: 600px) {
  .all-tools .at-cats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .all-tools .at-cat { padding: 12px 8px 10px; gap: 2px; }
  .all-tools .at-cat .at-ico { width: 34px; height: 34px; }
  .all-tools .at-cat b { margin-top: 4px; font-size: 14px; }
  .all-tools .at-cat small { font-size: 12px; }
  .all-tools .at-list { grid-template-columns: minmax(0, 1fr); padding: 6px; gap: 2px; }
  .all-tools .at-search { top: 4px; }
}

/* 7. All tools: grouped by category, icon + name */
.home-all { columns: 3 220px; column-gap: 24px; }
.all-group { break-inside: avoid; margin-bottom: 16px; }
.all-group h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.all-cat { all: unset; cursor: pointer; }
.all-cat:hover { color: var(--accent); text-decoration: underline; }
.all-cat:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.all-group ul { list-style: none; margin: 0; padding: 0; }
.all-group a {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  color: var(--text); text-decoration: none; font-weight: 600;
}
.all-group a:hover span { color: var(--accent); text-decoration: underline; }
.all-group img { width: 24px; height: 24px; border-radius: 6px; flex: 0 0 auto; }

/* Loading popup buttons (Retry / Close on errors) */
.loader-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.retry-secondary { background: var(--surface); color: var(--text); }
.retry-secondary:hover { background: var(--chip); }
/* Recently used, before anything was opened: one line spanning the row */
.card-row.is-empty, .card-grid.is-empty { display: block; }
.card-row .recent-empty, .card-grid .recent-empty { padding: 6px 2px; }

/* Phones: action bar shows only the logo (no site name) to leave room for the categories */
@media (max-width: 768px) {
  .brand-name { display: none; }
  .brand-logo { width: 36px; height: 36px; }
  .site-header { gap: 10px; }
}

/* Phones: half the side padding everywhere (page edge, bars, tool area, section boxes) */
@media (max-width: 768px) {
  .page { padding-left: 8px; padding-right: 8px; gap: 8px; }
  .top-bars { margin-left: -8px; margin-right: -8px; }
  .site-header { padding-left: 8px; padding-right: 8px; }
  .tools-menu { padding-left: 8px; padding-right: 8px; }
  .tool-area { padding: 14px 10px; }
  .ad-bottom { padding-left: 8px; padding-right: 8px; }
  .home { gap: 16px; }
  .home-hero { padding: 16px 12px; }
  .home-box { padding: 12px 8px; }
  .home-why { padding: 18px 8px; }
  .why-grid { gap: 8px; }
}

/* Phones: the bottom ad is a normal in-content ad just above the footer (not floating) */
@media (max-width: 768px) {
  .page { grid-template-areas: "top" "adl" "main" "adb" "foot"; }
  body.is-home .page { grid-template-areas: "top" "main" "adb" "foot"; }
  .ad-bottom {
    grid-area: adb; position: static;
    padding: 0; background: none; border: 0; box-shadow: none;
  }
  .ad-bottom .ad-slot { height: auto; }
  .ad-bottom .house-wide { height: 64px; }
  body.has-ad-bar { padding-bottom: 0; }        /* nothing floats over the page any more */
}

/* ---------- Footer links + policy pages (About / Privacy / Terms / Contact) ---------- */
/* Footer menu strip: About / Contact / policies (generated by the site builder on every page) */
.legal-links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px;
  margin: 0 0 10px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.legal-links a {
  color: var(--text); text-decoration: none; font-weight: 500;
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.legal-links a:hover { background: var(--accent-soft); color: var(--accent); }
.legal-links a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.legal-page .legal-links { width: 100%; max-width: 820px; box-sizing: border-box; }
@media (max-width: 768px) {
  .legal-links { gap: 2px 4px; padding: 6px; }
  .legal-links a { padding: 5px 9px; }
}
.legal-page { padding: 0 16px; }
.legal-page .site-footer { display: flex; flex-direction: column; align-items: center; }
.legal-header { margin: 0 -16px; justify-content: space-between; }
.legal-back { color: #fff; text-decoration: none; font-weight: 600; }
.legal-back:hover { text-decoration: underline; }
.legal {
  max-width: 820px; margin: 24px auto; padding: 24px 28px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  line-height: 1.65;
}
.legal h1 { margin: 0 0 8px; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.legal h2 { margin: 24px 0 8px; font-size: 1.1rem; }
.legal a { color: var(--accent); }
.legal-updated { color: var(--muted); font-size: 13px; margin-top: 0; }
.legal-contact { font-size: 1.1rem; font-weight: 600; }
@media (max-width: 768px) {
  .legal-page { padding: 0 8px; }
  .legal-header { margin: 0 -8px; }
  .legal { margin: 12px auto; padding: 16px 14px; }
}

/* Google's anchor ad (Auto ads) is showing at the bottom: hide our bar so there are never two */
body.has-anchor .ad-bottom { display: none; }
body.has-anchor.has-ad-bar { padding-bottom: 0; }

/* Phones: the bottom ad is a normal in-content ad just above the footer (not floating) */
@media (max-width: 768px) {
  .page { grid-template-areas: "top" "adl" "main" "adb" "foot"; }
  body.is-home .page { grid-template-areas: "top" "main" "adb" "foot"; }
  .ad-bottom {
    grid-area: adb; position: static;
    padding: 0; background: none; border: 0; box-shadow: none;
  }
  .ad-bottom .ad-slot { height: auto; }
  .ad-bottom .house-wide { height: 64px; }
  body.has-ad-bar { padding-bottom: 0; }        /* nothing floats over the page any more */
}


/* =====================================================================================================
   Site header (every page): navy bar with logo, main links, search with results, menu drawer
   ===================================================================================================== */
:root { --nav: #0b1f4d; --nav-hover: rgba(255, 255, 255, .12); }
.site-top {
  display: flex; align-items: center; gap: 20px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 24px 10px;
  background: var(--nav); color: #fff;
}
.site-top .brand { color: #fff; }
.top-nav { display: flex; gap: 4px; }
.top-nav a { color: #dbe4f5; text-decoration: none; font-weight: 500; padding: 6px 12px; border-radius: 8px; white-space: nowrap; }
.top-nav a:hover { background: var(--nav-hover); color: #fff; }
.top-search { position: relative; margin: 0 0 0 auto; flex: 0 1 300px; min-width: 0; }
.top-search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: rgba(255, 255, 255, .75); pointer-events: none; }
.top-search input {
  width: 100%; font: inherit; font-size: 14px; padding: 8px 12px 8px 34px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .1); color: #fff;
}
.top-search input::placeholder { color: rgba(255, 255, 255, .7); }
.top-search input:focus { outline: 2px solid #93c5fd; outline-offset: 1px; background: rgba(255, 255, 255, .16); }
.top-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; min-width: 280px;
  max-height: 70vh; overflow: auto; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 25%, transparent);
  box-shadow: 0 16px 40px rgba(15, 23, 42, .25);
}
.top-result { display: grid; grid-template-columns: 28px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; padding: 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
.top-result img { grid-row: span 2; border-radius: 7px; }
.top-result b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-result span { font-size: 12px; color: var(--muted); }
.top-result:hover, .top-result:focus { background: var(--accent-soft); outline: none; }
.top-empty { margin: 8px; color: var(--muted); font-size: 14px; }
.top-menu { position: relative; }
.top-menu > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px; color: #fff;
}
.top-menu > summary::-webkit-details-marker { display: none; }
.top-menu > summary svg { width: 24px; height: 24px; }
.top-menu > summary:hover, .top-menu[open] > summary { background: var(--nav-hover); }
/* The ☰ drawer uses the header's navy, so it reads as part of the bar (same in light and dark mode). */
.top-drawer {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(360px, calc(100vw - 24px));
  max-height: min(75vh, 640px); overflow: auto; padding: 8px; border-radius: 14px; color: #fff;
  background: var(--nav); border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 20px 48px rgba(11, 31, 77, .45);
  scrollbar-color: rgba(255, 255, 255, .3) transparent;
}
.top-drawer details { border-radius: 10px; }
.top-drawer summary { display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; border-radius: 10px; font-weight: 600; list-style: none; }
.top-drawer summary::-webkit-details-marker { display: none; }
.top-drawer summary:hover { background: var(--nav-hover); }
.top-drawer summary small { margin-left: auto; color: rgba(255, 255, 255, .6); font-weight: 500; }
.top-drawer details[open] > summary { color: #93c5fd; background: rgba(255, 255, 255, .06); }
.top-drawer-tools { display: grid; padding: 2px 6px 8px 38px; }
.top-drawer-tools a { color: #dbe4f5; text-decoration: none; padding: 5px 8px; border-radius: 6px; font-size: 14px; }
.top-drawer-tools a:hover { background: var(--nav-hover); color: #fff; }
.top-drawer a:focus-visible, .top-drawer summary:focus-visible { outline: 2px solid #93c5fd; outline-offset: -2px; }
/* The old blue category bar is replaced by the header menu and search. */
.site-header { display: none; }
/* Home: no tool row under the header; a quiet line instead of the bar border. */
body.is-home .top-bars { border-bottom: 0; box-shadow: 0 2px 10px rgba(11, 31, 77, .18); }
@media (max-width: 900px) { .top-nav { display: none; } }
@media (max-width: 768px) {
  .site-top { gap: 10px; padding-left: 12px; padding-right: 12px; }
  .site-top .brand-name { font-size: 1.05rem; }
  .top-search { flex: 1 1 auto; }
}
@media (max-width: 420px) { .site-top .brand-name { display: none; } }
/* Pages without the tool area (policy pages, All tools) */
.legal-page > .site-top { margin: 0 -16px; }

/* =====================================================================================================
   Tool pages: a small hero at the top of the tool (breadcrumbs, name, description)
   ===================================================================================================== */
.tool-intro {
  margin: -20px -20px 18px; padding: 16px 20px 14px; border-radius: var(--radius) var(--radius) 0 0;
  background: radial-gradient(circle at 6% 20%, #dbeafe 0, transparent 45%), radial-gradient(circle at 96% 90%, #ede9fe 0, transparent 50%), linear-gradient(120deg, #eff6ff, #f5f3ff);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 15%, transparent);
}
@media (prefers-color-scheme: dark) {
  .tool-intro { background: radial-gradient(circle at 6% 20%, rgba(59, 130, 246, .2) 0, transparent 45%), radial-gradient(circle at 96% 90%, rgba(139, 92, 246, .18) 0, transparent 50%), linear-gradient(120deg, #111827, #1e1b4b); }
}
.tool-intro p { margin-bottom: 0; }
@media (max-width: 768px) { .tool-intro { margin: -12px -12px 14px; padding: 12px; } }

/* =====================================================================================================
   Policy and All tools pages: side ads like the tool pages
   ===================================================================================================== */
.legal-layout { display: grid; grid-template-columns: var(--side-ad) minmax(0, 1fr) var(--side-ad); gap: 16px; align-items: start; max-width: 1400px; margin: 0 auto; }
.legal-layout > .ad { grid-area: auto; position: sticky; top: 16px; margin-top: 24px; }
.legal-layout > .legal { margin-left: 0; margin-right: 0; max-width: none; min-width: 0; }
@media (max-width: 1100px) {
  .legal-layout { grid-template-columns: minmax(0, 1fr); }
  .legal-layout > .ad { display: none; }
}

/* =====================================================================================================
   Site footer (every page): brand, link columns, site information, copyright, back to top
   ===================================================================================================== */
.site-footer.site-footer {
  display: block; text-align: left; color: #cbd5e1; font-size: 14px;
  background: #0f172a; margin: 24px -16px 0; padding: 32px max(24px, calc((100% - 1200px) / 2)) 18px;
}
/* Phones: the page's side padding is 8px, so the footer bleeds 8px (16px made the page scroll sideways). */
@media (max-width: 768px) { .site-footer.site-footer { margin-left: -8px; margin-right: -8px; } }

/* Flutter (the Programming tools' workspace) adds a hidden "typography measurement" paragraph to <body> with
   9999px letter and word spacing: about 320000px wide. Phone browsers count it and zoom the page out with a
   sideways scroll. Flutter only reads its computed spacing, so its box can be clipped to nothing. */
body > p[aria-hidden="true"][style*="letter-spacing: 9999px"] { max-width: 1px !important; overflow: hidden !important; }
.foot-grid { display: grid; gap: 24px 32px; grid-template-columns: minmax(200px, 1.3fr) repeat(2, minmax(140px, 1fr)) minmax(240px, 1.6fr); }
.foot-logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.foot-logo img { border-radius: 50%; background: #fff; }
.foot-name { font-size: 1.15rem; }
.foot-brand p { margin: 8px 0 0; color: #94a3b8; }
.foot-col h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: #fff; }
.foot-col > a { display: block; color: #cbd5e1; text-decoration: none; padding: 3px 0; }
.foot-col > a:hover { color: #fff; text-decoration: underline; }
.site-footer .legal-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: start; gap: 0 16px; margin: 0; padding: 0; background: none; border: 0; }
.site-footer .legal-links a { color: #cbd5e1; padding: 3px 0; border-radius: 0; font-weight: 400; white-space: normal; }
.site-footer .legal-links a:hover { background: none; color: #fff; text-decoration: underline; }
.site-footer .legal-links a[aria-current="page"] { background: none; color: #fff; font-weight: 600; }
.foot-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 26px; padding-top: 16px; border-top: 1px solid #1e293b; color: #94a3b8; font-size: 13px; }
.to-top { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: #1e293b; color: #fff; }
.to-top:hover { background: var(--accent); }
.to-top svg { width: 18px; height: 18px; }
.legal-page .site-footer.site-footer { display: block; }
@media (max-width: 900px) { .foot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .foot-grid { grid-template-columns: minmax(0, 1fr); } }

/* =====================================================================================================
   Home: modern layout (.home[data-view="modern"])
   ===================================================================================================== */
.home-sub-modern, .hero-art, .hero-features,
.home:not([data-view="modern"]) #home-pop-block, .home:not([data-view="modern"]) #home-conv-block { display: none; }
/* Programming section (both layouts): one card per language */
.prog-intro { margin: -4px 0 14px; color: var(--muted); }
.prog-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.prog-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 16px; text-decoration: none; color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, #283593 10%, var(--surface)), var(--surface)); border: 1px solid color-mix(in srgb, #283593 30%, transparent);
  transition: transform .15s, box-shadow .15s; }
.prog-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(40, 53, 147, .18); }
.prog-card img { flex: none; width: 48px; height: 48px; border-radius: 12px; }
.prog-text { display: flex; flex-direction: column; min-width: 0; }
.prog-text b { font-size: 16px; }
.prog-text small { font-size: 13px; color: var(--muted); }
/* Two buttons per language: Tutorial (the lessons) and Practice (the editor) */
.prog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.prog-btn {
  display: inline-flex; align-items: center; padding: 6px 16px; border-radius: 999px; font-size: 14px; font-weight: 700;
  text-decoration: none; background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
}
.prog-btn:hover { background: var(--accent-strong); }
.prog-btn-alt { background: var(--surface); color: var(--accent); }
.prog-btn-alt:hover { background: var(--accent-soft); }
.home-anchor { display: block; height: 0; scroll-margin-top: 90px; }
.home-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.home-head h2 { margin: 0; font-size: clamp(1.25rem, 2.4vw, 1.55rem); }
.home-more { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap; }
.home-more:hover { text-decoration: underline; }
body.is-home:has(#home[data-view="modern"]) .tool-area { border: 0; background: none; padding: 0; border-radius: 0; }
.home[data-view="modern"] { gap: 34px; }
.home[data-view="modern"] #home-new-block, .home[data-view="modern"] #home-featured-block, .home[data-view="modern"] #home-all-block,
.home[data-view="modern"] .home-search, .home[data-view="modern"] #home-results-block, .home[data-view="modern"] .home-why { display: none; }
/* order: hero, popular, categories, conversions, recent, FAQ */
.home[data-view="modern"] #home-recent-block { order: 1; }
.home[data-view="modern"] #home-faq-block { order: 2; }
/* Hero: soft gradient, title and subtitle, the five features as cards, illustration on the right */
.home[data-view="modern"] .home-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) 230px; align-items: start; gap: 8px 20px;
  margin: 0 -16px; padding: 26px max(24px, calc((100% - 1160px) / 2)) 24px; border: 0; border-radius: 0;
  background: radial-gradient(circle at 8% 20%, #dbeafe 0, transparent 40%), radial-gradient(circle at 90% 80%, #ede9fe 0, transparent 45%), linear-gradient(120deg, #eff6ff, #f5f3ff);
}
@media (prefers-color-scheme: dark) {
  .home[data-view="modern"] .home-hero { background: radial-gradient(circle at 8% 20%, rgba(59, 130, 246, .22) 0, transparent 40%), radial-gradient(circle at 90% 80%, rgba(139, 92, 246, .2) 0, transparent 45%), linear-gradient(120deg, #111827, #1e1b4b); }
}
.home[data-view="modern"] .home-logo, .home[data-view="modern"] .home-sub:not(.home-sub-modern) { display: none; }
.home[data-view="modern"] .home-hero-text { text-align: left; }
.home[data-view="modern"] .home-title { font-size: clamp(1.5rem, 3.2vw, 2.15rem); letter-spacing: -.01em; margin-bottom: 6px; }
.home[data-view="modern"] .home-sub-modern { display: block; max-width: 640px; margin: 0 0 16px; font-size: 1.02rem; }
.home[data-view="modern"] .hero-art { display: block; margin-top: -10px; }
.hero-art svg { width: 100%; height: auto; display: block; }
/* The six site features in the hero */
.home[data-view="modern"] .hero-features { display: block; grid-column: 1 / -1; }
/* Features read as facts, not buttons: icon + label in a row, no card, no hover */
.hero-features .why-grid { display: flex; flex-wrap: wrap; gap: 10px 26px; list-style: none; margin: 2px 0 0; padding: 0; }
.hero-features .why-card {
  display: inline-flex; flex-direction: row; align-items: center; gap: 8px; padding: 0; text-align: left;
  border: 0; border-radius: 0; background: none; box-shadow: none; cursor: default; transition: none;
}
.hero-features .why-card:hover { transform: none; box-shadow: none; }
.hero-features .why-icon { width: 28px; height: 28px; border-radius: 50%; margin: 0; flex: 0 0 auto; }
.hero-features .why-icon svg { width: 16px; height: 16px; }
.hero-features .why-card b { font-size: 14px; font-weight: 600; white-space: nowrap; }
.hero-features .why-card > span:last-child { display: none; }
/* Popular tool cards */
.pop-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pop-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; min-width: 0; text-decoration: none; color: var(--text);
  background: var(--surface); border-radius: 14px; border: 1px solid color-mix(in srgb, var(--border) 14%, transparent);
  box-shadow: 0 4px 14px rgba(15, 23, 42, .06); transition: transform .15s, box-shadow .15s;
}
.pop-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, .12); }
.pop-card img { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; }
.pop-text { display: flex; flex-direction: column; min-width: 0; }
.pop-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-text small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Category tiles, coloured */
.home[data-view="modern"] #home-cats-block { padding: 0; border: 0; background: none; }
.home[data-view="modern"] #home-cats-block > h3 { font-size: clamp(1.25rem, 2.4vw, 1.55rem); margin-bottom: 14px; }
.home[data-view="modern"] .cat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.home[data-view="modern"] .cat-tile {
  min-height: 92px; border: 0; padding: 18px 16px; border-radius: 14px; font: inherit; cursor: pointer; text-align: left;
  background: color-mix(in srgb, var(--tint, var(--accent)) 9%, var(--surface));
}
.home[data-view="modern"] .cat-tile:hover { background: color-mix(in srgb, var(--tint, var(--accent)) 16%, var(--surface)); }
.home[data-view="modern"] .cat-tile .cat-icon { background: var(--tint, var(--accent)); color: #fff; border-radius: 11px; }
.home[data-view="modern"] .cat-more { --tint: #64748b; }
/* Conversions */
.conv-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.conv-panel { padding: 18px; border-radius: 16px; background: color-mix(in srgb, var(--tint, var(--accent)) 7%, var(--surface)); display: grid; gap: 12px; align-content: start; }
.conv-panel h3 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.1rem; }
.conv-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--tint, var(--accent)); color: #fff; }
.conv-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.conv-link { padding: 8px 14px; border-radius: 10px; background: var(--surface); color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; box-shadow: 0 1px 3px rgba(15, 23, 42, .06); }
.conv-link:hover { box-shadow: 0 0 0 1px var(--accent); }
/* FAQ in a 3-column grid with light boxes */
.home[data-view="modern"] .home-faq { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: start; }
.home[data-view="modern"] .home-faq details { border-color: color-mix(in srgb, var(--border) 18%, transparent); border-radius: 10px; }
.home[data-view="modern"] #home-faq-block > h3 { font-size: 1.15rem; }
@media (max-width: 1100px) {
  .pop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home[data-view="modern"] .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .home[data-view="modern"] .home-faq { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  .home[data-view="modern"] .home-hero { grid-template-columns: minmax(0, 1fr); padding-top: 20px; }
  .home[data-view="modern"] .hero-art { display: none; }
  .hero-features .why-grid { gap: 8px 18px; }
  .pop-grid, .conv-grid, .home[data-view="modern"] .home-faq { grid-template-columns: minmax(0, 1fr); }
  .home[data-view="modern"] .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pop-grid > .pop-card:nth-child(n+7) { display: none; }
}
/* Modern home: Recently used looks like the popular tool cards (same heading, white cards, icon on the left) */
.home[data-view="modern"] #home-recent-block { padding: 0; border: 0; background: none; }
.home[data-view="modern"] #home-recent-block > h3 { font-size: clamp(1.25rem, 2.4vw, 1.55rem); margin: 0 0 14px; }
.home[data-view="modern"] #home-recent { --per-view: 4; --gap: 14px; }
.home[data-view="modern"] #home-recent > .tool-tile:nth-child(n+5) { display: none; }
.home[data-view="modern"] #home-recent .tool-tile {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 14px; row-gap: 0;
  align-items: center; align-content: center; text-align: left; padding: 16px; min-height: 0;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 14%, transparent); border-radius: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, .06);
}
.home[data-view="modern"] #home-recent .tool-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 23, 42, .12); }
.home[data-view="modern"] #home-recent .tool-tile img { grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: 12px; }
.home[data-view="modern"] #home-recent .tool-tile b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home[data-view="modern"] #home-recent .tool-tile span:not(.tile-badge) { font-size: 12.5px; -webkit-line-clamp: 1; line-clamp: 1; }
.home[data-view="modern"] #home-recent .tool-tile.is-last { border: 1px solid var(--accent); box-shadow: 0 4px 14px rgba(37, 99, 235, .14); }
.home[data-view="modern"] #home-recent .tile-badge { position: absolute; top: 8px; right: 10px; margin: 0; }
@media (max-width: 1100px) { .home[data-view="modern"] #home-recent { --per-view: 2; } }
@media (max-width: 768px) {
  .home[data-view="modern"] #home-recent { --per-view: 1; }
  .home[data-view="modern"] #home-recent > .tool-tile:nth-child(n+4) { display: none; }
}

/* =====================================================================================================
   Programming pages (body.prog-page: a language's editor): the page is an IDE window, one screen that never scrolls
   (only the code, the file list and the terminal scroll, inside the editor). From top to bottom: the site header,
   the editor (all the space left: app.js measures the stage and sets --prog-editor-h for the
   tools' .cc-studio), and a status bar (name, description, tutorial link, site information links, copyright; the
   footer is hidden). No ads on the editor (no side ads, no bottom ad); the status bar hides while the on-screen
   keyboard is open on phones (body.kbd-open). The window is
   the visible part of the screen (--app-h / --vv-top from app.js: the keyboard shrinks it on phones).
   The lessons are the tutorial pages (body.tut-page, below).
   ===================================================================================================== */
html:has(body.prog-page), body.prog-page { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.prog-page, body.prog-page.has-ad-bar { padding-bottom: 0; }
body.prog-page .page {
  position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--app-h, 100vh); height: var(--app-h, 100dvh);
  max-width: none; gap: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top" "main";
}
/* Google's anchor ad over the bottom of the screen: the window ends above it */
body.prog-page.has-anchor .page { height: calc(var(--app-h, 100dvh) - var(--float-bottom, 0px)); }
body.prog-page .tools-menu, body.prog-page .site-footer, body.prog-page .tool-content,
body.prog-page .ad-bottom, body.prog-page .ad-left, body.prog-page .ad-right { display: none; }
body.prog-page .tool-area {
  display: flex; flex-direction: column; min-height: 0; padding: 8px 0 0;
  background: none; border: 0; border-radius: 0; box-shadow: none;
}
body.prog-page .tool-stage { order: 2; flex: 1 1 0; min-height: 0; overflow: hidden; }
body.prog-page .tool-stage:empty { min-height: 0; }
/* The tools' editor box fills the stage exactly (their own min-height would make the window scroll) */
body.prog-page .tool-stage .cc-studio { min-height: 0; max-height: none; }
/* The status bar */
body.prog-page .tool-intro {
  order: 3; flex: none; display: flex; align-items: center; gap: 10px; min-width: 0; height: 28px;
  margin: 6px 0 0; padding: 0 10px; border: 0; border-radius: var(--radius) var(--radius) 0 0; box-shadow: none;
  background: var(--nav, #0b1f4d); color: #cbd5e1; font-size: 12px; white-space: nowrap;
}
body.prog-page .tool-intro h1 { flex: none; margin: 0; font-size: 12px; font-weight: 700; color: #fff; }
/* The description and the tutorial link are items of the bar itself: the description gives way (ellipsis), the link never */
body.prog-page .tool-intro #tool-desc { display: contents; color: inherit; }
body.prog-page .tool-intro .tool-desc-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body.prog-page .tool-intro #tool-desc a { flex: none; color: #fff; font-weight: 600; text-decoration: none; }
body.prog-page .tool-intro a:hover { text-decoration: underline; }
.prog-status-links { display: none; }
body.prog-page .prog-status-links {
  display: flex; flex: 0 1 auto; gap: 12px; min-width: 0; overflow-x: auto; scrollbar-width: none;
}
.prog-status-links::-webkit-scrollbar { display: none; }
.prog-status-links a { color: #cbd5e1; text-decoration: none; }
.prog-status-links span { color: #94a3b8; }
@media (max-width: 1100px) { body.prog-page .tool-intro .tool-desc-text { display: none; } }

@media (max-width: 768px) {
  /* Phones: header, chips, editor, status bar */
  body.prog-page .page { padding: 0 6px; }
  body.prog-page .top-bars { margin: 0 -6px; }
  body.prog-page .tool-area { padding-top: 6px; }
  body.prog-page .tool-intro { gap: 8px; margin-top: 4px; padding: 0 8px; border-radius: 0; margin-left: -6px; margin-right: -6px; }
  /* Typing: the keyboard takes the bottom of the screen, the editor gets everything that is left */
  body.prog-page.kbd-open .tool-intro { display: none; }
}

/* =====================================================================================================
   Tutorial pages (body.tut-page, website/tutorials/<lang>/*.md built by the site builder), laid out like the
   well-known tutorial sites: under the site header the tutorials bar (every tutorial, the editor), the topic list
   beside the lesson (progress, the current topic filled), Previous / Next buttons under the title and at the end,
   examples with a "Try it in the editor" link, a practice card. Side ads like the tool pages (the top ad on phones);
   no bottom ad. No site script: the pinned header is the site header and the tutorials bar.
   ===================================================================================================== */
body.tut-page {
  --tut-accent: #1e3a8a; --tut-accent-hover: #0b1f4d; --tut-accent-soft: #e8f0fe; --tut-accent-text: #1e3a8a;   /* the site navy (--nav) and blue */
  --tut-bar: #13296b; --tut-bar-h: 44px;
  --tut-top: calc(61px + var(--tut-bar-h) + 12px);
}
@media (prefers-color-scheme: dark) {
  body.tut-page { --tut-accent: #2563eb; --tut-accent-hover: #1d4ed8; --tut-accent-soft: rgba(59, 130, 246, .16); --tut-accent-text: #93c5fd; --tut-bar: #111a33; }
}
body.tut-page .ad-left .ad-slot, body.tut-page .ad-right .ad-slot { top: var(--tut-top); }
body.tut-page .ad-left .house-tall, body.tut-page .ad-right .house-tall { max-height: calc(100vh - var(--tut-top) - 16px); }

/* The tutorials bar (pinned with the site header) */
.tut-bar { background: var(--tut-bar); }
.tut-bar-in {
  display: flex; align-items: stretch; gap: 2px; height: var(--tut-bar-h); max-width: 1400px; margin: 0 auto; padding: 0 16px;
  overflow-x: auto; scrollbar-width: none;
}
.tut-bar-in::-webkit-scrollbar { display: none; }
.tut-bar a {
  display: inline-flex; align-items: center; padding: 0 16px; white-space: nowrap;
  color: #f1f5f9; font-size: 15px; font-weight: 600; text-decoration: none;
}
.tut-bar a:hover { background: rgba(255, 255, 255, .1); }
.tut-bar a[aria-current] { background: #2563eb; color: #fff; }
.tut-bar a.tut-bar-editor { margin-left: auto; }

/* Lesson area */
.tool-area.tut-area { min-width: 0; min-height: 0; padding: 12px 0 28px; background: none; border: 0; box-shadow: none; }
.tut-area > .crumbs { margin: 0 0 10px; }
.tut { display: grid; grid-template-columns: var(--tut-side-w, 240px) 14px minmax(0, 1fr); column-gap: 4px; align-items: start; }
/* The drag handle between the topic list and the lesson (wide screens): a line that turns blue, and a round « button
   (hide the topics; » shows them again) that stays in view under the header */
.tut-resize { position: relative; align-self: stretch; cursor: col-resize; touch-action: none; outline: none; }
.tut-resize::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 6px; width: 2px; border-radius: 2px;
  background: color-mix(in srgb, var(--border) 12%, transparent); transition: background-color .15s;
}
.tut-resize:hover::before, .tut-resize:focus-visible::before, .tut.is-resizing .tut-resize::before { background: var(--tut-accent); }
.tut-collapse {
  position: -webkit-sticky; position: sticky; top: calc(var(--tut-top) + 6px); z-index: 2; display: grid; place-items: center;
  width: 24px; height: 24px; margin: 6px 0 0 -5px; padding: 0 0 2px; border-radius: 50%; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--border) 35%, transparent); background: var(--surface); color: var(--tut-accent-text);
  font: 700 15px/1 system-ui, sans-serif; box-shadow: 0 1px 4px rgba(15, 23, 42, .12);
}
.tut-collapse:hover, .tut-collapse:focus-visible { background: var(--tut-accent); border-color: var(--tut-accent); color: #fff; outline: none; }
.tut.is-resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
/* Topics hidden: the lesson takes the whole width, the handle (with ») stays at the left */
@media (min-width: 901px) {
  .tut .tut-resize { grid-column: 2; }
  .tut .tut-main { grid-column: 3; }
  .tut.is-collapsed { grid-template-columns: 0 14px minmax(0, 1fr); }
  .tut.is-collapsed .tut-side { display: none; }
}

/* Topic list */
.tut-side {
  position: -webkit-sticky; position: sticky; top: var(--tut-top);
  max-height: calc(100vh - var(--tut-top) - 16px); overflow: auto; scrollbar-width: thin;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 25%, transparent); border-radius: var(--radius);
}
.tut-toc > summary {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 1;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 16px 6px;
  list-style: none; cursor: pointer; font-size: 18px; background: var(--surface);
}
.tut-toc > summary::-webkit-details-marker { display: none; }
.tut-toc > summary small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tut-toc > summary small::after { content: " ▾"; }
.tut-toc[open] > summary small::after { content: " ▴"; }
.tut-progress {
  position: -webkit-sticky; position: sticky; top: 44px; z-index: 1;   /* stays under the title (44px) while the list scrolls */
  display: flex; flex-direction: column; gap: 6px; padding: 2px 16px 12px; color: var(--muted); font-size: 12px; background: var(--surface);
}
.tut-progress i { display: block; height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--tut-accent) var(--done), var(--chip) var(--done)); }
.tut-toc ol { list-style: none; margin: 0; padding: 0 0 12px; border-top: 1px solid color-mix(in srgb, var(--border) 18%, transparent); }
.tut-toc li a {
  display: block; padding: 6px 16px; color: var(--text); font-size: 14.5px; line-height: 1.35; text-decoration: none;
}
.tut-toc li a:hover { background: var(--chip); }
.tut-toc li a[aria-current="page"] { background: var(--tut-accent); color: #fff; font-weight: 700; }
.tut-group { padding: 14px 16px 6px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* The lesson */
.tut-main {
  min-width: 0; padding: 20px 32px 28px; font-size: 16.5px; line-height: 1.7;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--border) 25%, transparent); border-radius: var(--radius);
}
.tut-main h1 { margin: 10px 0 16px; font-size: clamp(1.8rem, 3.4vw, 2.5rem); line-height: 1.15; letter-spacing: -.01em; }
.tut-main h2 {
  margin: 34px 0 12px; padding: 4px 0 4px 14px; border-left: 5px solid var(--tut-accent);
  font-size: 1.45rem; line-height: 1.3;
}
.tut-main h3 { margin: 24px 0 8px; font-size: 1.15rem; }
.tut-main p { margin: 0 0 14px; }
.tut-main ul, .tut-main ol { margin: 0 0 16px; padding-left: 24px; }
.tut-main li { margin: 5px 0; }
.tut-main li::marker { color: var(--tut-accent); }
.tut-main a { color: var(--accent); }
.tut-main strong { color: var(--text); }
.tut-main :not(pre) > code {
  padding: 1px 6px; border-radius: 5px; background: var(--chip); color: #dc2626;
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace; font-size: .88em; overflow-wrap: anywhere;
}
@media (prefers-color-scheme: dark) { .tut-main :not(pre) > code { color: #fca5a5; } }
.tut-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.tut-level { padding: 3px 10px; border-radius: 999px; background: var(--tut-accent-soft); color: var(--tut-accent-text); font-size: 12px; font-weight: 700; }
.tut-open { padding: 6px 14px; border: 1px solid var(--tut-accent); border-radius: 999px; font-size: 14px; font-weight: 700; text-decoration: none; }
.tut-main .tut-open { color: var(--tut-accent-text); }
.tut-open:hover { background: var(--tut-accent-soft); }

/* Previous / Next buttons under the title */
.tut-steps { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 22px; }
.tut-main .tut-step {
  padding: 8px 20px; border-radius: 6px; background: var(--tut-accent); color: #fff;
  font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tut-main .tut-step:hover { background: var(--tut-accent-hover); }

/* Examples. Code: dark in both themes, colours from the C / C++ highlighter (tk-*) */
.tut-example {
  margin: 18px 0 24px; padding: 0 14px 14px; border-radius: var(--radius); overflow: hidden;
  background: var(--chip); border: 1px solid color-mix(in srgb, var(--border) 18%, transparent);
}
.tut-example-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0 10px;
  font-size: 18px; font-weight: 700;
}
.tut-example > pre.tut-code, .tut-example > .tut-file:first-of-type { border-radius: 8px 8px 0 0; }
.tut-example > pre.tut-code:last-of-type { border-radius: 0 0 8px 8px; }
.tut-example > pre.tut-code:only-of-type { border-radius: 8px; border-left: 4px solid var(--tut-accent); }
.tut-main .tut-try {
  flex: none; padding: 7px 16px; border-radius: 6px; background: var(--tut-accent); color: #fff;
  font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.tut-main .tut-try:hover { background: var(--tut-accent-hover); }
.tut-main .tut-try::after { content: " »"; }
pre.tut-code {
  margin: 0; padding: 14px 16px; overflow: auto; background: #0f172a; color: #e2e8f0; tab-size: 4;
  font: 14.5px/1.6 ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
pre.tut-code code { font: inherit; }
pre.tut-fragment { margin: 14px 0 18px; border-radius: 8px; border-left: 4px solid var(--tut-accent); }
.tut-file { padding: 6px 14px; background: #1e293b; color: #cbd5e1; border-top: 1px solid #334155; font: 600 13px ui-monospace, Consolas, monospace; }
.tut-file:first-of-type { border-top: 0; }
.tk-com { color: #94a3b8; font-style: italic; }
.tk-str { color: #86efac; }
.tk-pre { color: #f9a8d4; }
.tk-num { color: #fcd34d; }
.tk-key { color: #93c5fd; font-weight: 600; }
.tk-type { color: #c4b5fd; }
.tut-example .tut-io { margin-top: 10px; border-radius: 8px; background: var(--surface); }
.tut-io-label { padding: 8px 14px 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.tut-io pre {
  margin: 0; padding: 4px 14px 12px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text);
  font: 14px/1.5 ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}
.tut-io-input pre { color: var(--accent); }
.tut-main > .tut-io { margin: 14px 0 18px; border: 1px solid color-mix(in srgb, var(--border) 25%, transparent); border-radius: var(--radius); background: var(--chip); }
.tut-main > .tut-io-text pre { padding-top: 12px; }
.tut-table { margin: 16px 0 20px; overflow-x: auto; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--border) 25%, transparent); }
.tut-table table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.45; }
.tut-table th, .tut-table td { padding: 9px 12px; border-bottom: 1px solid color-mix(in srgb, var(--border) 18%, transparent); text-align: left; vertical-align: top; }
.tut-table th { background: var(--tut-bar); color: #fff; font-weight: 600; }
.tut-table tbody tr:nth-child(even) { background: var(--chip); }
.tut-table tbody tr:last-child td { border-bottom: 0; }

/* Practice card at the end of the lesson */
.tut-practice {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px;
  margin: 34px 0 0; padding: 18px 20px; border-radius: var(--radius);
  background: linear-gradient(120deg, #0b1f4d, #2563eb); color: #e0e7ff;
}
.tut-practice div { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 260px; }
.tut-practice b { color: #fff; font-size: 18px; }
.tut-practice span { font-size: 14.5px; line-height: 1.5; }
.tut-main .tut-practice a {
  flex: none; padding: 9px 18px; border-radius: 6px; background: #fff; color: #1e3a8a;
  font-size: 15px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.tut-main .tut-practice a:hover { background: #e8f0fe; }

/* Previous / Next cards at the end */
.tut-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }
.tut-main .tut-pager a {
  display: flex; flex-direction: column; min-width: 0; max-width: 48%; padding: 10px 18px;
  border: 1px solid color-mix(in srgb, var(--border) 30%, transparent); border-radius: var(--radius); color: var(--text); text-decoration: none;
}
.tut-main .tut-pager a:hover { border-color: var(--tut-accent); background: var(--tut-accent-soft); }
.tut-pager a[rel="next"] { margin-left: auto; text-align: right; }
.tut-pager small { color: var(--muted); font-size: 13px; }
.tut-pager b { color: var(--tut-accent-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  /* Narrow screens: the topic list is a closed drop-down above the lesson (an inline script closes it before paint) */
  .tut { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .tut-resize { display: none; }
  .tut-side { position: static; max-height: none; overflow: visible; }
  .tut-toc > summary { position: static; padding-bottom: 12px; font-size: 16px; }
  .tut-progress { position: static; }
  .tut-toc:not([open]) .tut-progress { display: none; }
  .tut-toc ol { max-height: 60vh; overflow: auto; }
}
@media (max-width: 768px) {
  body.tut-page { --tut-bar-h: 40px; }
  .tut-bar-in { padding: 0 4px; }
  .tut-bar a { padding: 0 12px; font-size: 14px; }
  .tool-area.tut-area { padding: 6px 0 18px; }
  .tut-main { padding: 14px 14px 20px; font-size: 16px; }
  .tut-main h2 { font-size: 1.3rem; padding-left: 10px; border-left-width: 4px; }
  .tut-example { padding: 0 10px 10px; }
  pre.tut-code { padding: 12px; font-size: 13px; }
  .tut-main .tut-step { padding: 7px 14px; font-size: 14px; }
}
