/* Site chrome on top of the original src/styles.css (loaded first, unchanged).
   The standalone image page never loads this file. Theme tokens live on the
   root element (so the viewport, gutters and scrollbars follow the theme);
   every other rule is scoped to .pv-site, pv-* classes or html[data-site-page].
   Targets: reflow at 320 CSS px, 200% text, visible focus with >= 3:1
   contrast, 44x44 CSS px controls.
   Theme: html[data-theme="light"|"dark"] is set by the site's head script and
   always wins; without it, prefers-color-scheme picks the same dark tokens.
   Layout is one column at every width. The header holds the menu button,
   brand, theme and language; the tool and game links live in the menu drawer,
   a native modal <dialog> that every page renders closed (HOME_NAV_FEEDBACK_SPEC,
   replacing the TOOL_UI_DENSITY_SPEC §1 left rail), so no rail column takes
   width and the page uses it. Tool pages put input, options and actions on the
   left and the result on the right from 60rem; below that the same DOM stacks
   input then result. No sticky/fixed or separately scrolling areas in the page;
   the drawer's placement comes from the browser's modal dialog. Rules only place existing
   elements: DOM and keyboard order never change, [hidden] keeps winning
   through display: none !important in styles.css, and no rule here targets
   .visually-hidden elements themselves. */

/* ---- Theme tokens. Light values equal the original palette. ---- */

html {
  --pv-focus: #1b1f24;
  --pv-halo: #ffffff;
  --pv-on-primary: #ffffff;
  --pv-soft: #eaf1fb;
  --pv-selected: #f3f7fd;
  --pv-control: #6b7480;
  --pv-rule: #e3e7ec;
  --pv-sunken: #f6f8fa;
  --pv-field: #ffffff;
  --pv-readonly: #f4f5f7;
  --pv-result-line: #9db6df;
  --pv-info-bg: #eef4fc;
  --pv-info-line: #c6d7f0;
  --pv-warning-bg: #fff7e0;
  --pv-warning-line: #e3c47e;
  --pv-error-bg: #fdf1f0;
  --pv-disabled-bg: #e9edf2;
  --pv-disabled-line: #c9d0d9;
  --pv-disabled-text: #5b6472;
  --pv-check-bg: #ffffff;
  --pv-check: #e3e6ea;
  --pv-selection: #cfe0fa;
  --pv-backdrop: rgb(0 0 0 / 0.45);
}

/* Dark: charcoal page, slightly lifted surfaces, light-blue accent with dark
   ink on filled buttons. The original variables are remapped too, so every
   styles.css rule that reads them follows. Keep in sync with the block below. */
html[data-theme="dark"] {
  color-scheme: dark;
  --text: #e6e9ee;
  --muted: #a9b2be;
  --line: #39414c;
  --panel: #1a1f26;
  --page: #111418;
  --accent: #8cb8ff;
  --accent-dark: #b7d2ff;
  --danger: #ff9b92;
  --warning: #f2c45d;
  --focus: #e6e9ee;
  --pv-focus: #e6e9ee;
  --pv-halo: #111418;
  --pv-on-primary: #0b1730;
  --pv-soft: #22324a;
  --pv-selected: #1c2a3e;
  --pv-control: #8a94a3;
  --pv-rule: #2a313a;
  --pv-sunken: #151a20;
  --pv-field: #12161b;
  --pv-readonly: #222830;
  --pv-result-line: #46689c;
  --pv-info-bg: #1a2638;
  --pv-info-line: #2f4669;
  --pv-warning-bg: #2e2614;
  --pv-warning-line: #6b5520;
  --pv-error-bg: #33191a;
  --pv-disabled-bg: #262c34;
  --pv-disabled-line: #3a424d;
  --pv-disabled-text: #9aa3af;
  --pv-check-bg: #2b3139;
  --pv-check: #3b434d;
  --pv-selection: #2f4f80;
  --pv-backdrop: rgb(0 0 0 / 0.65);
}

/* No explicit choice (script missing or not yet run): follow the OS. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;
    --text: #e6e9ee;
    --muted: #a9b2be;
    --line: #39414c;
    --panel: #1a1f26;
    --page: #111418;
    --accent: #8cb8ff;
    --accent-dark: #b7d2ff;
    --danger: #ff9b92;
    --warning: #f2c45d;
    --focus: #e6e9ee;
    --pv-focus: #e6e9ee;
    --pv-halo: #111418;
    --pv-on-primary: #0b1730;
    --pv-soft: #22324a;
    --pv-selected: #1c2a3e;
    --pv-control: #8a94a3;
    --pv-rule: #2a313a;
    --pv-sunken: #151a20;
    --pv-field: #12161b;
    --pv-readonly: #222830;
    --pv-result-line: #46689c;
    --pv-info-bg: #1a2638;
    --pv-info-line: #2f4669;
    --pv-warning-bg: #2e2614;
    --pv-warning-line: #6b5520;
    --pv-error-bg: #33191a;
    --pv-disabled-bg: #262c34;
    --pv-disabled-line: #3a424d;
    --pv-disabled-text: #9aa3af;
    --pv-check-bg: #2b3139;
    --pv-check: #3b434d;
    --pv-selection: #2f4f80;
    --pv-backdrop: rgb(0 0 0 / 0.65);
  }
}

.pv-site {
  --pv-gutter: 1rem;
  --pv-shell: 84rem;
  --pv-read: 44rem;
  --pv-home: 64rem;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--page);
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: break-word;
}
.pv-site ::selection { background: var(--pv-selection); color: var(--text); }

/* Ordinary links only: anchor buttons keep the .button colours. */
.pv-site a:not(.button) { color: var(--accent); text-underline-offset: 0.15em; }
.pv-site a:not(.button):hover { color: var(--accent-dark); text-decoration-thickness: 2px; }
/* The converter's download is an anchor drawn as a filled accent button: the ordinary-link colour
   above (same or higher specificity than the tool's own rule) would equal its background. Same
   specificity, later in the cascade, for the normal and hover states (focus only adds the ring). */
.pv-site a.pv-image-convert__button--primary,
.pv-site a.pv-image-convert__button--primary:hover { color: var(--pv-on-primary); }

/* Ring in the text colour with a page-coloured halo: visible on the page,
   panels and filled buttons in both themes. */
.pv-site a:focus-visible,
.pv-site button:focus-visible,
.pv-site .button:focus-visible,
.pv-site input:focus-visible,
.pv-site select:focus-visible,
.pv-site textarea:focus-visible,
.pv-site summary:focus-visible,
.pv-site .visually-hidden:focus-visible + label.button {
  outline: 3px solid var(--pv-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--pv-halo);
}
/* <main tabindex="-1"> only receives focus as the skip-link target. */
.pv-site main:focus { outline: none; }

/* Skip link: first focusable element, shown on focus. */
.pv-skip {
  position: absolute;
  left: 0.5rem;
  top: -10rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--text);
  border-radius: 0.5rem;
  font-weight: 700;
}
.pv-site .pv-skip:focus { top: 0.5rem; color: var(--text); }

/* ---- Header. DOM: menu button, brand, menu drawer, theme button, language nav; rows follow that
   order. Below 20rem each control takes its own row (shared rows there spilled the one-word brand
   past the page or broke the language and theme labels into fragments at 320 CSS px / 200% text);
   from 20rem menu | brand, then theme | language; from 40rem all four on one row (at 20rem, i.e.
   320 CSS px, one row squeezed the language label into fragments). The closed drawer takes no grid
   cell. No track may shrink below the brand's own content: control labels wrap inside the control
   only when even their own row is too narrow (overflow-wrap: anywhere; the 44px target stays). ---- */

.pv-header {
  display: grid;
  /* One content-sized track: every control on its own row, at its own width. */
  grid-template-columns: auto;
  grid-template-areas:
    "menu"
    "brand"
    "theme"
    "lang";
  align-items: center;
  gap: 0.375rem 0.5rem;
  padding: 0.25rem max(var(--pv-gutter), calc((100% - var(--pv-shell)) / 2)) 0.625rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.pv-header ul,
.pv-footer ul,
.pv-cards,
.pv-recovery {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pv-brand,
.pv-nav a,
.pv-lang a,
.pv-footer a,
.pv-recovery a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.25rem 0.5rem;
}

.pv-site a.pv-brand {
  grid-area: brand;
  justify-self: start;
  padding-inline: 0;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
}

/* ---- Menu drawer: a native modal <dialog> at the inline start, at most 20rem and always leaving a
   strip of the backdrop to click. The browser's dialog:modal rules position it and let a long menu
   scroll inside it; here it only gets its size, surface and the backdrop colour. All content sits in
   one panel, so a click on the dialog box itself is a backdrop click. ---- */

.pv-drawer {
  margin: 0;
  inset-inline-end: auto;
  width: min(20rem, calc(100% - 3rem));
  max-width: none;
  height: 100%;
  max-height: none;
  padding: 0;
  border: 0;
  border-inline-end: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
.pv-drawer::backdrop { background: var(--pv-backdrop); }
/* The page behind keeps its scroll position and does not scroll while the drawer is open. */
html:has(.pv-drawer[open]) { overflow: hidden; }
.pv-drawer__panel { min-height: 100%; padding: 0.5rem 0.75rem 2rem; }
.pv-drawer__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.pv-site .pv-drawer__head h2 { margin: 0; font-size: 1.125rem; }

.pv-nav { min-width: 0; }
.pv-site .pv-nav h3 { margin: 1rem 0 0.25rem; color: var(--muted); font-size: 0.9375rem; }
/* One full-width row per link; a long label wraps inside its row. */
.pv-nav ul { display: grid; gap: 0.25rem; }
.pv-nav li { display: flex; min-width: 0; }
.pv-site .pv-nav a {
  flex: 1 1 auto;
  width: 100%;
  justify-content: flex-start;
  padding: 0.375rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: start;
  text-decoration: none;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.pv-site .pv-nav a:hover { background: var(--pv-soft); color: var(--accent-dark); }

/* Menu button, close button, theme button and language link: one compact control style. */
.pv-menu-toggle { grid-area: menu; justify-self: start; }
.pv-theme-toggle { grid-area: theme; justify-self: start; }
.pv-lang { grid-area: lang; justify-self: start; min-width: 0; max-width: 100%; }
/* A long label wraps inside its control (44px target kept) instead of widening the page. */
.pv-site .pv-menu-toggle,
.pv-site .pv-drawer__close,
.pv-site .pv-theme-toggle,
.pv-site .pv-lang a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  word-break: keep-all;
  cursor: pointer;
  touch-action: manipulation;
}
.pv-site .pv-menu-toggle:hover,
.pv-site .pv-drawer__close:hover,
.pv-site .pv-theme-toggle:hover,
.pv-site .pv-lang a:hover { border-color: var(--accent); background: var(--pv-soft); color: var(--accent-dark); }
/* Pressed (dark on): a doubled accent border and bold label, not colour alone. */
.pv-site .pv-theme-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--pv-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px var(--accent);
  font-weight: 700;
}
.pv-site .pv-theme-toggle[aria-pressed="true"]:hover { border-color: var(--accent-dark); box-shadow: inset 0 0 0 1px var(--accent-dark); }
/* Keep the focus halo together with the pressed inner border. */
.pv-site .pv-theme-toggle[aria-pressed="true"]:focus-visible { box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 5px var(--pv-halo); }

/* Current page: weight and a solid underline, not colour alone. */
.pv-site [aria-current="page"],
.pv-site a.pv-brand[aria-current="page"] { font-weight: 700; text-decoration: underline; text-decoration-thickness: 3px; }
.pv-site .pv-nav a[aria-current="page"] {
  border-color: var(--accent);
  background: var(--pv-soft);
  color: var(--accent-dark);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 0.3em;
}

.pv-banner {
  margin: 0;
  padding: 0.5rem max(var(--pv-gutter), calc((100% - var(--pv-shell)) / 2));
  background: var(--pv-warning-bg);
  color: var(--text);
  border-bottom: 2px solid var(--warning);
  font-weight: 600;
}

/* ---- Main container: reading width by default, wide for home and tools. ---- */

.pv-site .pv-main {
  width: 100%;
  min-width: 0;
  max-width: calc(var(--pv-read) + 2 * var(--pv-gutter));
  margin: 0 auto;
  padding: 1.25rem var(--pv-gutter) 2.5rem;
}
html[data-site-page="home"] .pv-main { max-width: calc(var(--pv-home) + 2 * var(--pv-gutter)); }
html[data-site-page="image"] .pv-main,
html[data-site-page="text"] .pv-main,
html[data-site-page="imageConvert"] .pv-main,
html[data-site-page="splitBill"] .pv-main,
html[data-site-page="imageBatch"] .pv-main,
html[data-site-page="imagePdf"] .pv-main,
html[data-site-page="minesweeper"] .pv-main,
html[data-site-page="sudoku"] .pv-main { max-width: calc(var(--pv-shell) + 2 * var(--pv-gutter)); }

.pv-site h1 {
  margin: 0.25rem 0 0.75rem;
  font-size: 1.5rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
  word-break: keep-all;
}
.pv-site h2,
.pv-site h3 { line-height: 1.35; word-break: keep-all; }
.pv-site .lead { max-width: 48rem; margin: 0 0 1rem; }
/* Secondary notes read at 0.9375rem (TOOL_UI_DENSITY_SPEC §1.3). */
.pv-site .help { font-size: 0.9375rem; }

/* ---- Surfaces, actions, notes and results (shared by every page). ---- */

.pv-site .panel {
  margin: 0 0 1rem;
  padding: 1rem;
  border-color: var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
}
.pv-site .panel > h2 { margin: 0 0 0.75rem; font-size: 1.125rem; }

.pv-site .button {
  padding: 0.5rem 1.125rem;
  line-height: 1.3;
  text-align: center;
  word-break: keep-all;
}
.pv-site .button.primary { color: var(--pv-on-primary); }
.pv-site .button.secondary { background: var(--panel); }
.pv-site .button.secondary:hover { border-color: var(--accent-dark); background: var(--pv-soft); color: var(--accent-dark); }
.pv-site .button.large { min-height: 3rem; font-size: 1.0625rem; }
/* Disabled: readable grey instead of a faded colour, identical on hover. */
.pv-site .button:disabled,
.pv-site .button:disabled:hover {
  opacity: 1;
  border-color: var(--pv-disabled-line);
  background: var(--pv-disabled-bg);
  color: var(--pv-disabled-text);
}

/* Information (not a warning): tinted box with a quiet border. */
.pv-site .pv-notice,
html[data-site-page="home"] .pv-main > .help {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--pv-info-line);
  border-radius: 0.5rem;
  background: var(--pv-info-bg);
  color: var(--text);
  font-size: 0.9375rem;
}
.pv-notice { font-weight: 600; }
/* The calculator's own local/leave notice (inside its root): the same quiet information box. */
.pv-site .pv-split-bill__persistence {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--pv-info-line);
  border-radius: 0.5rem;
  background: var(--pv-info-bg);
  color: var(--text);
  font-size: 0.9375rem;
}

/* Warnings: amber surface and border; the text keeps its own weight/colour. */
.pv-staging,
.pv-site .help.warning {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pv-warning-line);
  border-radius: 0.5rem;
  background: var(--pv-warning-bg);
}

.pv-site .alert:not(:empty) { border-color: var(--danger); background: var(--pv-error-bg); color: var(--danger); }

.pv-site .status:empty { margin: 0; }
.pv-site .status:not(:empty) {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--pv-info-line);
  border-radius: 0.5rem;
  background: var(--pv-info-bg);
}

/* ---- Image tool (original markup, ids and aria-labelledby kept). ---- */

/* The file chooser is the first action: full-width on phones, fixed width later. */
.pv-site [aria-labelledby="file-heading"] label.button { flex: 1 1 10rem; }
.pv-site .file-name:empty { margin: 0; }
.pv-site .file-name:not(:empty) {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  background: var(--pv-sunken);
}
.pv-site #download-name { overflow-wrap: anywhere; }

/* Radio cards: the label's overlay makes the whole card a target, while the
   radio itself is lifted above it and keeps its own pointer and focus.
   A fieldset is min-content wide by default and the card's text track kept
   its longest word as a minimum, so at 320 CSS px / 200% text the groups grew
   past the panel. The fieldset now takes the panel width, the text track may
   shrink to the card (words wrap inside it, inherited break-word) and a
   side-by-side card keeps 7rem only where its row has room. */
.pv-site .choices { min-inline-size: 0; }
.pv-site .choices .choice {
  position: relative;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border-color: var(--line);
  background: var(--panel);
}
.pv-site .choices.inline .choice { min-width: min(7rem, 100%); }
.pv-site .choices .choice label::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0.5rem;
}
.pv-site .choices .choice input[type="radio"] { position: relative; z-index: 1; accent-color: var(--accent); }
.pv-site .choices .choice:hover { border-color: var(--accent); }
.pv-site .choices .choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--pv-selected);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.pv-site .field input[type="text"] {
  border: 1px solid var(--pv-control);
  background: var(--pv-field);
  color: var(--text);
}
.pv-site .field input[aria-invalid="true"] { border: 2px solid var(--danger); }

/* Previews: same checkerboard geometry as styles.css, theme-aware squares;
   the image pixels themselves are never filtered. */
.pv-site .preview {
  border-color: var(--line);
  background-color: var(--pv-check-bg);
  background-image:
    linear-gradient(45deg, var(--pv-check) 25%, transparent 25%),
    linear-gradient(-45deg, var(--pv-check) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--pv-check) 75%),
    linear-gradient(-45deg, transparent 75%, var(--pv-check) 75%);
}

.pv-site .facts { gap: 0; }
.pv-site .facts > div {
  grid-template-columns: 8rem minmax(0, 1fr);
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--pv-rule);
}
.pv-site .facts > div:last-child { border-bottom: 0; }
.pv-site .facts dd { font-weight: 600; }
/* "Exact size" stays a closed native disclosure with a 44px target. */
.pv-site .exact-size summary { min-height: 2.75rem; padding: 0.625rem 0; line-height: 1.5; }

.pv-site #result-section { border-color: var(--pv-result-line); }

.pv-site .pv-tool-notes { margin: 0 0 1rem; font-size: 0.875rem; color: var(--muted); }
.pv-site .pv-tool-notes p { max-width: 60rem; margin: 0.5rem 0; }

/* Lower help: quiet secondary surface, two closed native disclosures
   (How to use, FAQ) with 44px summaries, balanced columns where they fit. */
.pv-site [data-site-help] { background: var(--pv-sunken); }
.pv-site .pv-help__group { margin: 0; border-top: 1px solid var(--pv-rule); }
.pv-site .pv-help__group > summary {
  min-height: 2.75rem;
  padding: 0.625rem 0;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
}
.pv-site .pv-help__group[open] > summary { margin-bottom: 0.25rem; }
.pv-site .pv-help__group > .notes { padding-bottom: 0.75rem; }
.pv-site [data-site-help] .notes {
  margin: 0;
  columns: 22rem 3;
  column-gap: 3rem;
  font-size: 0.9375rem;
}
.pv-site [data-site-help] .notes li { margin: 0 0 0.625rem; break-inside: avoid; }

/* ---- Text tool inside the site: every tool token mapped to the theme
   (the tool's own defaults load after this file, hence the extra class). ---- */

.pv-site .pocuvo-text {
  --pocuvo-text-accent: var(--accent);
  --pocuvo-text-accent-dark: var(--accent-dark);
  --pocuvo-text-accent-soft: var(--pv-soft);
  --pocuvo-text-accent-text: var(--pv-on-primary);
  --pocuvo-text-primary: var(--accent);
  --pocuvo-text-primary-hover: var(--accent-dark);
  --pocuvo-text-surface: var(--panel);
  --pocuvo-text-field-bg: var(--pv-field);
  --pocuvo-text-readonly-bg: var(--pv-readonly);
  --pocuvo-text-border: var(--pv-control);
  --pocuvo-text-muted: var(--muted);
  --pocuvo-text-focus: var(--pv-focus);
  --pocuvo-text-error: var(--danger);
  --pocuvo-text-error-bg: var(--pv-error-bg);
  --pocuvo-text-warning-bg: var(--pv-warning-bg);
  --pocuvo-text-warning-border: var(--pv-warning-line);
  --pocuvo-text-info-bg: var(--pv-info-bg);
  --pocuvo-text-info-border: var(--pv-info-line);
  --pocuvo-text-disabled-bg: var(--pv-disabled-bg);
  --pocuvo-text-disabled-border: var(--pv-disabled-line);
  --pocuvo-text-disabled-text: var(--pv-disabled-text);
}
/* The page h1 already names the tool; its own h2 stays, quieter. */
.pv-site .pocuvo-text .pocuvo-text__heading { margin: 0 0 0.25rem; color: var(--muted); font-size: 1.0625rem; }
.pv-site .pocuvo-text .pocuvo-text__intro { max-width: 48rem; }
.pv-site .pocuvo-text .pocuvo-text__notes { max-width: 60rem; margin-bottom: 1.25rem; color: var(--muted); font-size: 0.9375rem; }
.pv-site .pocuvo-text .pocuvo-text__layout { gap: 1rem; }
.pv-site .pocuvo-text .pocuvo-text__pane,
.pv-site .pocuvo-text .pocuvo-text__controls {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--panel);
}
.pv-site .pocuvo-text .pocuvo-text__pane--result { border-color: var(--pv-result-line); }
.pv-site .pocuvo-text .pocuvo-text__label { font-size: 1.0625rem; }
/* The pane is the group surface; the fieldset keeps its legend without a second frame. */
.pv-site .pocuvo-text .pocuvo-text__options { padding: 0; border: 0; }
.pv-site .pocuvo-text .pocuvo-text__legend { margin-bottom: 0.25rem; padding: 0; font-size: 1.0625rem; }
.pv-site .pocuvo-text .pocuvo-text__controls > .pocuvo-text__actions {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* ---- Home: a gateway to the tools. ---- */

html[data-site-page="home"] .pv-main > .lead { max-width: 40rem; margin-bottom: 1.5rem; }
.pv-cards { display: grid; gap: 1rem; margin-bottom: 1.25rem; }
.pv-site .pv-card { display: flex; flex-direction: column; margin: 0; padding: 1.25rem; }
.pv-card h3 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.pv-site .pv-card p { margin: 0 0 1rem; color: var(--muted); }
.pv-site .pv-card p:last-child { margin: auto 0 0; }
.pv-site .pv-card .button { width: 100%; }
/* Long words wrap inside the home cards instead of widening the one-column track: an auto grid
   track grows to the widest item's min-content, which overflow-wrap: break-word (inherited from
   .pv-site) does not lower, so at 320 CSS px with enlarged text the longest word of a card label
   plus the card and button padding pushed the cards past the page. anywhere keeps the min-content
   small (as for the header controls); nothing is hidden, clamped or shrunk. */
html[data-site-page="home"] .pv-card,
html[data-site-page="home"] .pv-card h3,
html[data-site-page="home"] .pv-card p,
html[data-site-page="home"] .pv-card .button { overflow-wrap: anywhere; }

/* ---- Reading pages (about, privacy, contact, not found). ---- */

.pv-site .pv-main > h2 { margin: 1.75rem 0 0.5rem; font-size: 1.25rem; }
.pv-site .pv-main > p { margin: 0 0 1rem; }

.pv-recovery { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }

/* ---- Footer and leave dialog. ---- */

.pv-footer {
  margin: auto 0 0;
  padding: 0.75rem max(var(--pv-gutter), calc((100% - var(--pv-shell)) / 2)) 1.5rem;
  border-top: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.9375rem;
}
.pv-footer ul { display: flex; flex-wrap: wrap; gap: 0 1rem; }

.pv-dialog {
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 2px solid var(--text);
  border-radius: 0.75rem;
  color: var(--text);
  background: var(--panel);
}
.pv-dialog::backdrop { background: var(--pv-backdrop); }
.pv-dialog p { margin: 0 0 1rem; font-weight: 600; }

/* ---- Under 10rem (media-query rem follows the default font, so e.g. 320 CSS px at a 64px default
   font is 5rem and at 32px is 10rem): theme | language side by side need 2 × 1rem gutter + the theme
   label track (about 4.5rem) + 0.5rem gap + the 2.75rem language target ≈ 9.75rem plus a scrollbar,
   so they take one row each instead of being pushed past the page. The brand, tool link and footer
   labels are whole words (keep-all, inherited break-word), which keep their full width as a minimum;
   here they may break inside a word so they wrap inside their own boxes. Nothing is hidden, clipped
   or shrunk; the 44px targets, fonts and DOM order stay. From 10rem nothing here applies. ---- */

@media not all and (min-width: 10rem) {
  .pv-header {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "menu"
      "brand"
      "theme"
      "lang";
  }
  .pv-site a.pv-brand,
  .pv-site .pv-nav a,
  .pv-footer a { overflow-wrap: anywhere; }
}

/* ---- Under 20rem (e.g. 320 CSS px at a 32px default font): the image radio cards put the radio above
   its label and help, and the facts stack each label over its value, so the text gets the whole card or
   row width. Beside the radio the text track was about 81px there and split most words; the fixed 8rem
   fact label column alone filled the panel, left the value column 0px wide and pushed the closed
   "Exact size" summary past the page. From 20rem nothing here applies. ---- */

@media not all and (min-width: 20rem) {
  .pv-site .choices .choice { grid-template-columns: minmax(0, 1fr); }
  .pv-site .choices .choice .help { grid-column: auto; }
  .pv-site .facts > div { grid-template-columns: minmax(0, 1fr); }
}

/* ---- From 20rem: menu | brand, then theme | language; the brand track keeps its own width. ---- */

@media (min-width: 20rem) {
  .pv-header {
    grid-template-columns: auto minmax(min-content, 1fr);
    grid-template-areas:
      "menu brand"
      "theme lang";
  }
}

/* ---- Tablet: roomier surfaces; the header controls fit on one row. ---- */

@media (min-width: 40rem) {
  .pv-header {
    grid-template-columns: auto minmax(min-content, 1fr) auto auto;
    grid-template-areas: "menu brand theme lang";
  }
  .pv-cards { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
  .pv-site .pv-card .button { width: auto; min-width: 14rem; }
  .pv-site [aria-labelledby="file-heading"] label.button { flex: 0 0 auto; min-width: 12rem; }
}

@media (min-width: 48rem) {
  .pv-site { --pv-gutter: 1.5rem; }

  .pv-header { padding-block: 0.5rem; }

  .pv-site h1 { font-size: 1.875rem; }
  .pv-site .pv-main { padding-top: 1.75rem; }
  .pv-site .panel { padding: 1.25rem 1.5rem; }
  .pv-site .pv-card { padding: 1.5rem; }
  .pv-site .pocuvo-text .pocuvo-text__pane,
  .pv-site .pocuvo-text .pocuvo-text__controls { padding: 1.25rem; }
  .pv-site .pocuvo-text .pocuvo-text__layout { gap: 1.5rem; }

  /* Reading pages become one comfortable sheet. */
  html[data-site-page="about"] .pv-main,
  html[data-site-page="privacy"] .pv-main,
  html[data-site-page="contact"] .pv-main,
  html:not([data-site-page]) .pv-main {
    width: calc(100% - 2 * var(--pv-gutter));
    max-width: calc(var(--pv-read) + 5rem);
    margin: 2rem auto 2.5rem;
    padding: 2rem 2.5rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: var(--panel);
  }
}

/* ---- Desktop: the same one-column shell and header row (no rail); tool pages get their input and
   result work columns. ---- */

@media (min-width: 60rem) {
  /* Image: file → original → settings → process on the left; the result (or
     its honest empty state) → comparison → download on the right; then the
     tool notes and the lower help across both columns. The flexible row
     absorbs a taller result, so the left panels never spread apart. */
  html[data-site-page="image"] .pv-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto 1fr auto auto;
    grid-template-areas:
      "title title"
      "lead lead"
      "notice notice"
      "file result"
      "source result"
      "settings result"
      "notes notes"
      "help help";
    column-gap: 1.5rem;
    align-items: start;
  }
  html[data-site-page="image"] .pv-main > h1 { grid-area: title; }
  html[data-site-page="image"] .pv-main > .lead { grid-area: lead; }
  html[data-site-page="image"] .pv-main > .pv-notice { grid-area: notice; justify-self: start; }
  html[data-site-page="image"] .pv-main > [aria-labelledby="file-heading"] { grid-area: file; }
  html[data-site-page="image"] .pv-main > #source-section { grid-area: source; }
  html[data-site-page="image"] .pv-main > [aria-labelledby="settings-heading"] { grid-area: settings; }
  html[data-site-page="image"] .pv-main > #result-empty,
  html[data-site-page="image"] .pv-main > #result-section { grid-area: result; }
  html[data-site-page="image"] .pv-main > .pv-tool-notes { grid-area: notes; }
  html[data-site-page="image"] .pv-main > [data-site-help] { grid-area: help; }

  /* Each half column shows its preview at full column width, facts below. */
  html[data-site-page="image"] #source-section .preview-row,
  html[data-site-page="image"] #result-section .preview-row { grid-template-columns: minmax(0, 1fr); }

  /* Desktop text areas: a readable fixed starting height, still user-resizable. */
  html[data-site-page="text"] .pocuvo-text .pocuvo-text__pane > .pocuvo-text__textarea { min-height: 18rem; }
}

/* ---- Wide: roomier gutters; still two work columns (no third text column). ---- */

@media (min-width: 80rem) {
  .pv-site { --pv-gutter: 2rem; }
}
