/* ============================================================
   MŮJ LES v2 — design system, in the Forestio family
   Můj Les is built on Forestio technology (Generation Forest
   s.r.o.), so it speaks Forestio's visual language: the platform's
   slate canvas and cards, the forestio.ai green band with its
   hexagon grid, Work Sans, and one yellow for everything you can
   press or have picked. Values come from the production frontend
   (forest-io/ForestConsumerWeb: tailwind.config.ts, the platform
   components and the hex map's colour table).
   One hero number per screen · risk keeps its own colour.
   ============================================================ */

:root {
  /* --- Forestio palette (named as in ForestConsumerWeb) --------------- */
  --fio-yellow:     #F2D719;  /* primary-400 — logo tile, CTA, selected hex */
  --fio-yellow-500: #E2BF10;  /* primary-500 — hover, text links           */
  --fio-yellow-200: #FAF58E;  /* primary-200 — focus ring on yellow        */
  --fio-amber-900:  #6E4615;  /* primary-900 — icon tiles                  */
  --fio-green-300:  #84E1BC;
  --fio-green-400:  #31C48D;  /* the leaf green — positive, carbon chart   */
  --fio-green-800:  #03543F;
  --fio-green-900:  #014737;  /* forestio.ai hero band                     */
  --fio-gray-900:   #111928;  /* platform canvas                           */
  --fio-gray-800:   #1F2A37;  /* platform card, navbar, rail               */
  --fio-gray-700:   #374151;  /* active nav item, hover                    */
  --fio-gray-600:   #4B5563;  /* control borders                           */
  --fio-gray-400:   #9CA3AF;  /* labels                                    */
  --fio-gray-300:   #D1D5DB;
  --fio-red-400:    #F98080;  /* the platform's "down" red                 */

  /* --- roles: every rule below speaks these, never the swatches ------- */
  --bg:          var(--fio-gray-900);
  --surface:     var(--fio-gray-800);
  --raised:      var(--fio-gray-700);   /* active nav, a control lifted off a card */
  --hover:       #263141;               /* hover on a card-coloured row — keeps --ink-faint at 5.2:1 */
  --well:        #18212E;               /* an inset box inside a card (gray-900 over gray-800) */
  --forest:      var(--fio-green-900);  /* the forestio.ai band: hero cards, onboarding, map ground */
  --forest-deep: #0A2E25;
  --forest-lit:  var(--fio-green-800);
  --accent:      var(--fio-yellow);     /* the one accent: CTA, score, selection, chart line */
  --accent-hover: var(--fio-yellow-500);
  --accent-ink:  var(--fio-gray-900);   /* text on the accent — 10.0:1 */
  --positive:    var(--fio-green-400);  /* 6.5:1 on --surface */
  --risk:        var(--fio-red-400);    /* risk & alerts only — 5.8:1 on --surface */
  --ink:         #FFFFFF;
  --ink-dim:     var(--fio-gray-300);   /* 9.8:1 on --surface */
  --ink-faint:   var(--fio-gray-400);   /* 5.7:1 on --surface, 6.9:1 on --bg — never on --raised */
  --line:        rgba(255, 255, 255, .08);
  --line-strong: var(--fio-gray-600);   /* outline of a control */
  --shadow:      0 1px 3px rgba(0, 0, 0, .28), 0 10px 26px rgba(0, 0, 0, .16);

  /* --- service chart hues ---------------------------------------------
     One hue per ecosystem service, so four cards read as four things
     instead of one repeated thing. The yellow stays reserved for score and
     CTA and the red for risk, so neither appears here. Re-validated on the
     Forestio card (#1F2A37) with the dataviz palette validator: lightness
     band, chroma floor, CVD ΔE ≥ 14 between neighbours, normal-vision floor
     15 and ≥ 3:1 against the card all pass. (A Forestio green-500 carbon was
     tried and failed: too close to the teal for normal vision, ΔE 11.) */
  --svc-carbon: #31983d;   /* biomass — forest green */
  --svc-oxygen: #139cb6;   /* air — teal             */
  --svc-water:  #426dd7;   /* water — blue           */
  --svc-soil:   #c68206;   /* soil — ochre           */

  /* --- the hexagon motif ----------------------------------------------
     The forestio.ai hero lays a honeycomb over the satellite image, a few
     cells lit. Drawn here as two mask tiles (outline grid + lit cells) so the
     colour still comes from a token; see .card-hero below. */
  --hex-grid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='45'%3E%3Cpath d='M13 0V7.5L26 15V30L13 37.5V45M13 37.5L0 30V15L13 7.5' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E");
  --hex-cells: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='78' height='135'%3E%3Cg fill='%23000'%3E%3Cpolygon fill-opacity='.9' points='39,9.5 50.26,16 50.26,29 39,35.5 27.74,29 27.74,16'/%3E%3Cpolygon fill-opacity='.5' points='26,77 37.26,83.5 37.26,96.5 26,103 14.74,96.5 14.74,83.5'/%3E%3Cpolygon fill-opacity='.3' points='65,99.5 76.26,106 76.26,119 65,125.5 53.74,119 53.74,106'/%3E%3C/g%3E%3C/svg%3E");
  --hex-ink: rgba(255, 255, 255, .24);
  /* the hexagon itself, for bullets and badges */
  --hexagon: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);

  /* Forestio forestation ramp — the ten classes of the platform hex map
     (ForestConsumerWeb mapbox/component.tsx colorTable), crimson = bare,
     emerald = full canopy. Model.HEX_RAMP carries the same ten colours for
     the SVG/MapLibre fills; this is the legend. */
  --hex-ramp: linear-gradient(90deg,
    #751A3D 0 10%, #6D2D46 10% 20%, #66404F 20% 30%, #5E5358 30% 40%, #576661 40% 50%,
    #4F7869 50% 60%, #488B72 60% 70%, #409E7B 70% 80%, #39B184 80% 90%, #31C48D 90% 100%);

  /* --- geometry: Forestio's rounded-lg / rounded-md --- */
  --radius: 8px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --pad: 20px;

  /* --- type scale --- */
  --font: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-hero: 56px;      /* the one hero number            */
  --fs-big: 30px;       /* secondary big values (Forestio stat cards: text-3xl) */
  --fs-h1: 24px;        /* screen title                   */
  --fs-value: 20px;     /* a number in a chip or tile     */
  --fs-h2: 16px;        /* card title; also form inputs — iOS zooms the page on focus below 16px */
  --fs-body: 14.5px;
  --fs-small: 12.5px;
  --fs-micro: 10.5px;   /* eyebrows, uppercase labels     */
  --fs-nano: 9.5px;     /* tracked caps inside a tight box: chip labels, the dial, map attribution.
                           Nine steps, and nothing below this one. Every size in the app is one of
                           these; a literal px font-size is a bug unless the line says why. */

  --speed: 160ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); }

/* Focus not obscured (WCAG 2.4.11): the statusbar is sticky and the tab bar
   fixed, so a control tabbed to near either edge was scrolled to sit fully
   under one of them. Scroll padding keeps every focus scroll (and any other
   scroll-into-view) clear of both bars. The desktop rail is at the side. */
html {
  /* core.js keeps --bar-top / --bar-bottom at the bars' real heights (they
     grow with large text); the fallbacks are their normal-size heights */
  scroll-padding-top: var(--bar-top, calc(72px + env(safe-area-inset-top)));
  scroll-padding-bottom: var(--bar-bottom, calc(84px + env(safe-area-inset-bottom)));
}
html.is-desktop { scroll-padding-bottom: 0; }

/* First visit, before the deferred scripts have run: js/layout-mode.js sets
   .first-run when no forest is saved, so the page paints the onboarding
   hero's ground (the .onboard[data-step="1"] gradient) instead of an empty
   app shell with a tappable tab bar. core.js drops the class the moment it
   shows the hero or a screen. */
.first-run .statusbar, .first-run #screens, .first-run .tabbar { visibility: hidden; }
.first-run #app {
  background:
    radial-gradient(110% 60% at 90% 0%, var(--forest-lit) 0%, rgba(3, 84, 63, 0) 70%),
    linear-gradient(180deg, var(--forest) 0%, var(--forest-deep) 100%);
}

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  /* a typed forest name with no spaces scrolled the whole page sideways
     (robustness audit): break such words, only when they would overflow */
  overflow-wrap: break-word;
}

/* centered app column (phone-first, capped on desktop) */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  background: var(--bg);
}

/* keyboard focus ring — visible everywhere (a11y) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

::selection { background: rgba(242, 215, 25, .35); }

.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;
}

/* ============================== STATUSBAR ==============================
   The Forestio navbar: a gray-800 bar on a hairline, logo tile on the left,
   language on the right. */
.statusbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) var(--pad) 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--raised);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }

/* The Můj Les mark set the way Forestio sets its own: dark glyph on a yellow
   rounded tile (Forestio's tile is 32px with an 8px radius — 25 %). Used in the
   header, on the onboarding hero and in the profile footer. */
.mark-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 25%;
  background: var(--accent);
}
.mark-tile svg { width: 74%; height: auto; display: block; margin-top: 6%; overflow: visible; }
.mark-tile .mk-out { stroke: var(--accent-ink); }
.mark-tile .mk-in { stroke: var(--forest); }
.brand .word { line-height: 1.1; min-width: 0; }
.brand .word b {
  display: block; font-weight: 600; font-size: var(--fs-h2); letter-spacing: -.005em; color: var(--ink);
  white-space: nowrap;
}
.brand .word span {
  display: block; font-weight: 400; font-size: var(--fs-micro); letter-spacing: .02em;
  color: var(--ink-faint); margin-top: 2px; white-space: nowrap;
}

/* ============================== BY FORESTIO ==============================
   The header lockup "powered by / [tile] Forestio", next to the language
   switch: ONE element in index.html (.by-forestio) and this block. On narrow
   phones it folds to the tile, so the .legal-foot line under every screen
   carries the words too — the brand rule needs both (tests/brand.test.js). */
.by-forestio {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  flex: 0 1 auto; min-width: 0; margin-left: auto; /* may give way at 200 % text (LARGE TEXT) */
  line-height: 1; color: var(--ink-faint);
}
.by-forestio .pre { font-size: var(--fs-nano); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
.by-forestio .name {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-small); font-weight: 600; letter-spacing: -.005em; color: var(--ink-faint);
}
.by-forestio svg { width: 13px; height: 13px; display: block; flex: none; }
.is-desktop .statusbar .by-forestio + .lang { margin-left: 4px; }
/* Small phones: the bar holds the name, the lockup and two 44px language
   targets. The "technologie" line goes first; under 340px only Forestio's
   tile is left (its aria-label still says what it is). */
@media (max-width: 374px) {
  .statusbar { gap: 10px; padding-left: 16px; padding-right: 16px; }
  .by-forestio .pre { display: none; }
}
@media (max-width: 339px) {
  .by-forestio .name { font-size: 0; gap: 0; }
}
.is-desktop .by-forestio { padding-right: 14px; border-right: 1px solid var(--raised); }

/* language toggle — the platform's: the active language sits on yellow */
.lang { display: inline-flex; gap: 2px; flex: none; }
.lang button {
  min-width: 44px; min-height: 44px; padding: 5px 10px; /* 44×44: Apple HIG (device matrix C4) */
  font-family: var(--font); font-size: var(--fs-body); font-weight: 500; letter-spacing: .02em;
  background: none; border: none; border-radius: var(--radius-xs); color: var(--ink); cursor: pointer;
  transition: background var(--speed), color var(--speed);
}
.lang button.active { background: var(--accent); color: var(--accent-ink); }
.lang button:not(.active):hover { background: var(--raised); }

/* offline chip — the visible connectivity notice. Fixed above the tab bar
   (and above the onboarding overlay, which needs the network most), so it
   never pushes the layout around and is not hidden under the desktop's fixed
   top bar. Neutral, not red: being offline is a state, not a risk. */
.offline-chip {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 57;
  width: max-content; max-width: calc(100vw - 2 * var(--pad));
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--raised);
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 500;
  text-align: center;
  box-shadow: var(--shadow);
}
.is-desktop .offline-chip { bottom: 24px; left: calc(50% + 118px); }
/* Over the onboarding overlay the chip sat on "Pokračovat" and then on the
   name field (robustness audit): there it goes to the top edge instead. */
html.onboarding .offline-chip { bottom: auto; top: calc(8px + env(safe-area-inset-top)); left: 50%; z-index: 81; }

/* Copernicus licence notice under Sentinel-derived imagery and charts: a
   credit line on its own line, quieter than the note it closes */
.sat-credit { display: block; margin-top: 4px; font-size: var(--fs-micro); color: var(--ink-faint); }

/* privacy notice (a bottom sheet, js/screens/privacy.js) — long-form text,
   so it gets a reading rhythm the cards do not need */
.privacy { color: var(--ink-dim); line-height: 1.55; }
.privacy p { margin: 0 0 10px; }
.privacy h3 {
  margin: 18px 0 6px;
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint);
}
.privacy ul { margin: 0 0 10px; padding-left: 18px; }
.privacy li { margin-bottom: 6px; }
/* text the operator still has to supply — visible on purpose */
.privacy .privacy-placeholder { color: var(--ink); }
.privacy .btn { width: 100%; margin-top: 8px; }
.privacy .privacy-updated { margin: 14px 0 0; font-size: 0.85em; }
/* the quiet link under the onboarding hero's buttons */
.privacy-link {
  display: block; margin: 14px auto 0; padding: 10px 12px; min-height: 44px;
  background: none; border: 0; cursor: pointer;
  font: inherit; font-size: var(--fs-small); color: var(--ink-dim);
  text-decoration: underline; text-underline-offset: 3px;
}
.privacy-link:hover { color: var(--ink); }

/* ============================== LEGAL FOOT ==============================
   "Provozuje Generation Forest s.r.o. · powered by Forestio" — under every
   screen (index.html, inside #screens so it scrolls with the content and
   clears the tab bar) and on the onboarding hero (.ob-legal). Quiet, but
   AA: --ink-faint on the canvas. */
.legal-foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 6px;
  margin: 22px 0 4px; padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-small); color: var(--ink-faint); text-align: center;
}
.legal-foot > span { white-space: nowrap; }   /* each half wraps as a whole */
.legal-foot b { font-weight: 600; color: var(--ink-dim); }
.legal-foot .sep { opacity: .7; }
.ob-legal { border-top: 0; margin: 4px 0 0; padding-top: 0; }
.is-desktop #screens > .legal-foot { margin-top: 32px; }

/* ============================== LARGE TEXT ==============================
   WCAG 1.4.4: at 200 % text (Safari text zoom, Firefox "zoom text only")
   the header ran 83–115px past a 390px phone, CZ/EN with it, and that
   overflow widened the page so the fixed tab bar lost "Profil" too. These
   only act once something no longer fits: at normal sizes the header is one
   line, both halves of the legal line stay whole, and no tab label wraps. */
body { overflow-wrap: break-word; } /* a word wider than its line ("FOREST", a 2x amount) breaks instead of widening the page */
.list-item { overflow-wrap: normal; } /* its narrow text column on a 320px phone: keep words whole, as before */
.statusbar { flex-wrap: wrap; row-gap: 4px; }
.brand .word b, .brand .word span { white-space: normal; }
.legal-foot > span { white-space: normal; }
.tab-label { max-width: 100%; text-align: center; } /* a tab still keeps its label's longest word as its minimum width */
@media (max-width: 359px) { .tab { min-width: 0; } } /* no room for four whole words: break one rather than push a tab off-screen */

/* ============================== SCREENS ============================== */
/* [hidden] must always win, even over explicit display values (e.g. flex steps) */
[hidden] { display: none !important; }

#screens {
  padding: var(--pad) var(--pad) calc(92px + env(safe-area-inset-bottom));
}
#screens > section[hidden] { display: none; }

/* ============================== CARDS ==============================
   Platform cards: gray-800 on the gray-900 canvas, rounded-lg, a soft shadow. */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

/* hero card — the ONE number of the screen, on the forestio.ai band: deep
   forest green, the honeycomb lit in its upper corner. The band re-points the
   ink tokens, so anything set in --ink-dim/--ink-faint inside it stays AA on
   green (the slate greys would not: gray-400 on #014737 is 4.2:1). */
.card-hero {
  --ink-dim: #DCEBE4;     /* 8.7:1 on --forest */
  --ink-faint: #B4CCC1;   /* 6.3:1 on --forest, 5.3:1 on the lit corner */
  --line: rgba(255, 255, 255, .16);
  --raised: rgba(255, 255, 255, .1);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  text-align: center;
  padding: calc(var(--pad) + 8px) var(--pad);
  background: linear-gradient(160deg, var(--forest-lit) 0%, var(--forest) 46%, var(--forest-deep) 100%);
  border-color: rgba(255, 255, 255, .06);
}
.card-hero > * { position: relative; }

/* the honeycomb: outline grid (::before) + a few lit cells (::after), both
   masked to fade out from the top-right corner like the forestio.ai hero */
.card-hero::before,
.card-hero::after,
.onboard[data-step="1"]::before,
.onboard[data-step="1"]::after { content: none; }
@supports ((mask-composite: intersect) or (-webkit-mask-composite: source-in)) {
  .card-hero::before, .card-hero::after,
  .onboard[data-step="1"]::before, .onboard[data-step="1"]::after {
    content: "";
    position: absolute; inset: 0; z-index: -1;
    pointer-events: none;
    background: var(--hex-ink);
    -webkit-mask-composite: source-in;
            mask-composite: intersect;
  }
  .card-hero::before, .onboard[data-step="1"]::before {
    -webkit-mask-image: var(--hex-grid), radial-gradient(ellipse 62% 78% at 92% 6%, #000 0%, rgba(0, 0, 0, .55) 38%, transparent 72%);
            mask-image: var(--hex-grid), radial-gradient(ellipse 62% 78% at 92% 6%, #000 0%, rgba(0, 0, 0, .55) 38%, transparent 72%);
    -webkit-mask-size: 26px 45px, 100% 100%;
            mask-size: 26px 45px, 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
            mask-repeat: repeat, no-repeat;
  }
  .card-hero::after, .onboard[data-step="1"]::after {
    background: rgba(255, 255, 255, .14);
    -webkit-mask-image: var(--hex-cells), radial-gradient(ellipse 50% 66% at 92% 6%, #000 0%, transparent 70%);
            mask-image: var(--hex-cells), radial-gradient(ellipse 50% 66% at 92% 6%, #000 0%, transparent 70%);
    -webkit-mask-size: 78px 135px, 100% 100%;
            mask-size: 78px 135px, 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
            mask-repeat: repeat, no-repeat;
  }
  /* full-screen hero: the field stays in the top corner, clear of the name */
  .onboard[data-step="1"]::before {
    -webkit-mask-image: var(--hex-grid), radial-gradient(ellipse 80% 46% at 96% 0%, #000 0%, rgba(0, 0, 0, .5) 40%, transparent 75%);
            mask-image: var(--hex-grid), radial-gradient(ellipse 80% 46% at 96% 0%, #000 0%, rgba(0, 0, 0, .5) 40%, transparent 75%);
  }
  .onboard[data-step="1"]::after {
    -webkit-mask-image: var(--hex-cells), radial-gradient(ellipse 60% 34% at 96% 0%, #000 0%, transparent 72%);
            mask-image: var(--hex-cells), radial-gradient(ellipse 60% 34% at 96% 0%, #000 0%, transparent 72%);
  }
}

/* big numbers — Forestio states figures plainly: semibold, tabular */
.big-num {
  font-size: clamp(36px, 12vw, var(--fs-hero));
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.05;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.big-num small { font-size: .42em; font-weight: 500; color: var(--ink-dim); letter-spacing: 0; }
/* App.bigCZK: 7+ digits ("53 466 309 Kč") at 12vw ran past the hero card on
   every phone; long amounts step down so the whole number always shows. */
.big-num.is-long { font-size: clamp(28px, 9vw, 52px); }

/* provenance line — every serious number states its source */
.source-line {
  font-size: var(--fs-small); letter-spacing: .01em;
  color: var(--ink-faint); margin-top: 10px;
}
.big-num-sub {
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-dim); margin-top: 6px;
}

/* Inside the score dial the same label has to live within the ring: at the
   shared tracking "VÝBORNÁ KONDICE" ran over the stroke, and English is longer
   still. Scoped here so the label keeps its full size everywhere else. */
.ring-label .big-num-sub {
  font-size: var(--fs-nano);
  letter-spacing: .04em;   /* Work Sans caps run wider than Outfit's — keeps EN clear of the stroke */
  line-height: 1.3;
  max-width: 74%;
  margin-top: 4px;
}

/* ============================== SCORE DIAL ==============================
   Instrument, not gauge: hairline tick crown + thin progress stroke in the
   Forestio yellow — the colour the platform gives a selected hexagon. */
.score-ring { position: relative; width: 190px; height: 190px; margin: 8px auto; }
.score-ring::before {
  content: "";
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(
    rgba(255, 255, 255, .34) 0deg .6deg, transparent .6deg 6deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  pointer-events: none;
}
.score-ring svg {
  position: absolute; inset: 12px;
  width: calc(100% - 24px); height: calc(100% - 24px); display: block;
  transform: rotate(-90deg);
}
.score-ring .track { fill: none; stroke: rgba(255, 255, 255, .14); }
.score-ring .prog {
  fill: none; stroke: var(--accent); stroke-linecap: round;
  transition: stroke-dashoffset .7s cubic-bezier(.2, .8, .2, 1);
}
.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.ring-label .big-num { font-size: var(--fs-hero); font-weight: 600; }

/* ============================== STATS ============================== */
.stat-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
}
.stat-row:last-child { border-bottom: none; padding-bottom: 0; }
.stat-row .lbl { color: var(--ink-dim); }
.stat-row .val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.stat-row.total { border-top: 1px solid var(--line-strong); border-bottom: none; padding-top: 13px; }
.stat-row.total .val { font-weight: 700; }

/* A stat chip is the forest-health panel's figure box: tracked caps label,
   semibold value. On the canvas it is a platform card; inside a card it is an
   inset well, so it never disappears into its parent. */
.stat-chip {
  flex: 1 1 0; min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.card .stat-chip { background: var(--well); }
.stat-chip .k {
  display: block; font-size: var(--fs-nano); font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint);
}
.stat-chip .v {
  display: block; font-size: var(--fs-value); font-weight: 600; letter-spacing: -.01em;
  margin-top: 5px; font-variant-numeric: tabular-nums;
}
.stat-chip .v small { font-size: var(--fs-small); font-weight: 500; color: var(--ink-dim); margin-left: 3px; }

/* ============================== ALERTS (risk colour only) ============================== */
.alert-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(249, 128, 128, .08);
  border: 1px solid rgba(249, 128, 128, .34);
  border-radius: var(--radius);
  padding: 16px var(--pad);
  margin-bottom: 14px;
  color: var(--ink);
}
.alert-card svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--risk); }
.alert-card b, .alert-card strong { color: var(--risk); }

/* ============================== CHARTS ============================== */
.sparkline { display: block; width: 100%; height: auto; }

.bar {
  position: relative; height: 6px;
  background: rgba(255, 255, 255, .08);
  border-radius: 999px; overflow: hidden;
}
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: var(--accent);
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.bar.risk > i { background: var(--risk); }

/* ============================== BUTTONS ==============================
   Forestio's: solid yellow with dark text for the action, an outlined slate
   button for everything else. rounded-lg, medium weight. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 48px; padding: 12px 20px;
  font-family: var(--font); font-size: var(--fs-body); font-weight: 500; letter-spacing: .01em;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer;
  transition: transform var(--speed), background var(--speed),
              color var(--speed), box-shadow var(--speed), border-color var(--speed);
}
.btn:hover { background: var(--accent-hover); }
.btn:focus-visible { outline: 3px solid var(--fio-yellow-200); outline-offset: 2px; border-radius: var(--radius); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
.btn-ghost:hover { background: var(--raised); border-color: var(--fio-gray-400); }
.btn-ghost:focus-visible { outline-color: var(--accent); }

/* destructive — deliberately outside the accent and the risk colour */
.btn-danger {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: none;
}
.btn-danger:hover { background: var(--raised); }
.btn-danger:focus-visible { outline-color: var(--accent); }

/* ============================== CHIPS ==============================
   Outlined slate like the platform's Filter button; the picked one goes
   yellow, as the active language and a selected hexagon do. */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 7px 14px;
  font-family: var(--font); font-size: var(--fs-small); font-weight: 500;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.chip:hover { color: var(--ink); background: var(--raised); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* real-data badge — the platform's "Reforest" tag: deep green, mint text,
   a lit hexagon for the satellite feed behind the section */
.badge-real {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 9px;
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--fio-green-300);
  background: var(--fio-green-800);
  border-radius: var(--radius-xs);
}
.badge-real::before {
  content: ""; width: 8px; height: 9px; flex: none;
  background: var(--positive); clip-path: var(--hexagon);
}

/* digitization-queue badge — same tag, slate + pulsing hexagon while imagery downloads;
   a still, faint hexagon once it is delayed or refused (a delay, not a forest risk) */
.badge-pending {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 3px 9px;
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-dim);
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
}
.badge-pending::before {
  content: ""; width: 8px; height: 9px;
  background: var(--accent); clip-path: var(--hexagon);
  animation: pending-pulse 1.6s ease-in-out infinite;
}
.badge-pending.is-stalled::before { animation: none; background: var(--ink-faint); }
@media (prefers-reduced-motion: reduce) { .badge-pending::before { animation: none; } }
@keyframes pending-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* Forestio's icon tile (the platform's stat cards): amber-900 square, the
   icon in yellow — 5.7:1. */
.icon-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--fio-amber-900);
  color: var(--accent);
}
.icon-tile svg { width: 55%; height: 55%; display: block; }

/* ============================== LISTS ============================== */
.list-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 56px;
  padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); font-family: var(--font); font-size: var(--fs-body);
  text-align: left;
  transition: background var(--speed), border-color var(--speed);
}
.card .list-item { background: var(--well); }
button.list-item { cursor: pointer; }
button.list-item:hover { background: var(--hover); border-color: var(--line-strong); }
.list-item .grow { flex: 1 1 auto; min-width: 0; }
.list-item .title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .meta { display: block; font-size: var(--fs-small); color: var(--ink-faint); margin-top: 2px; }
.list-item .end { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; }

/* A record's kind as a Forestio tag — the platform's project chip ("Reforest"
   on deep green): small, rounded-md, a hexagon in the text colour. Planting
   wears the platform's own Reforest colours, harvest the amber of its icon
   tiles, the rest slate. All ≥ 6:1. */
.tag {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  padding: 1px 8px;
  font-size: var(--fs-micro); font-weight: 500; line-height: 1.7; letter-spacing: .01em;
  color: var(--ink-dim); background: var(--raised);
  border-radius: var(--radius-xs);
}
.tag::before { content: ""; width: 7px; height: 8px; flex: none; background: currentColor; clip-path: var(--hexagon); }
.tag-planting { color: var(--fio-green-300); background: var(--fio-green-800); }
.tag-harvest { color: #F7E94D; background: var(--fio-amber-900); }   /* primary-300 on primary-900 — 6.5:1 */
.diary-row .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }

/* ============================== SECTION HEADINGS ==============================
   Tracked caps behind a yellow hexagon — the bullet Forestio's own documents use. */
.section-h {
  display: flex; align-items: center; gap: 9px;
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-dim);
  margin: 26px 0 12px;
}
.section-h::before {
  content: ""; flex: none; width: 9px; height: 10px;
  background: var(--accent); clip-path: var(--hexagon);
}
.section-h:first-child { margin-top: 0; }

/* ============================== TABBAR ==============================
   The platform rail turned sideways: slate bar, the current place on a
   gray-700 plate with its icon in yellow. */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 45;
  width: 100%; max-width: 480px;
  display: flex; gap: 4px;
  padding: 8px calc(var(--pad) - 8px) calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--raised);
}
.tab {
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 52px; padding: 6px 4px;
  font-family: var(--font); font-size: var(--fs-micro); font-weight: 500; letter-spacing: .02em;
  color: var(--ink-faint);
  background: none; border: none; border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--speed), background var(--speed);
}
.tab svg { width: 23px; height: 23px; }
.tab:hover { color: var(--ink); }
.tab.active, .tab[aria-current="page"] { color: var(--ink); background: var(--raised); }
.tab.active svg, .tab[aria-current="page"] svg { color: var(--accent); }

/* ============================== SHEET (bottom sheet) ============================== */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 12, 20, .62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--speed);
}
.sheet-backdrop.open { opacity: 1; }
.sheet-backdrop[hidden] { display: none; }

.sheet {
  position: fixed; bottom: 0; left: 50%; z-index: 61;
  width: 100%; max-width: 480px;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 10px var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--raised); border-bottom: none;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, .45);
  transform: translate(-50%, 105%);
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet.open { transform: translate(-50%, 0); }
.sheet[hidden] { display: none; }
.sheet-handle {
  width: 42px; height: 4px; margin: 2px auto 14px;
  border-radius: 999px; background: var(--line-strong);
}
.sheet h2 { font-size: var(--fs-h2); font-weight: 600; letter-spacing: -.005em; margin-bottom: 12px; padding-right: 48px; }
.sheet-close {
  position: absolute; top: 8px; right: 8px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-h1); line-height: 1; color: var(--ink-dim);
  background: transparent; border: 1px solid var(--line-strong); border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--speed), background var(--speed);
}
.sheet-close:hover { color: var(--ink); background: var(--raised); }
.sheet-body { font-size: var(--fs-body); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.sheet-actions[hidden] { display: none; }

/* ============================== ONBOARD OVERLAY ============================== */
.onboard {
  position: fixed; inset: 0; z-index: 55;
  display: flex; flex-direction: column;
  width: 100%; max-width: 480px;
  margin: 0 auto;
  overflow-y: auto;
  isolation: isolate;
  padding: calc(var(--pad) + env(safe-area-inset-top)) var(--pad) calc(var(--pad) + env(safe-area-inset-bottom));
  background: var(--bg);
}
.onboard[hidden] { display: none; }
.onboard-step { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.onboard-step h1 { font-size: var(--fs-h1); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; margin-bottom: 8px; }
.onboard-step .lead { color: var(--ink-dim); margin-bottom: 18px; }
.onboard-step .spacer { flex: 1 1 auto; }
/* Top bar: the CZ/EN switch (onboard.js clones the header's .lang group) on
   the left, the step dots in the middle, the right left free for the close
   button of a re-opened overlay. */
.ob-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 12px; }
.ob-top .ob-lang { justify-self: start; }
@media (orientation: landscape) and (max-height: 520px) { .ob-top { margin-bottom: 0; } }

/* Step 1 — the brand moment — is the forestio.ai hero: the green band with
   the honeycomb lit in its corner, the name in uppercase display type, a
   yellow call to action. The ink tokens are re-pointed for green as on the
   hero cards; the progress dots read --line and --accent. */
.onboard[data-step="1"] {
  --ink-dim: #DCEBE4;
  --ink-faint: #B4CCC1;
  --line: rgba(255, 255, 255, .24);
  --line-strong: rgba(255, 255, 255, .45);
  --raised: rgba(255, 255, 255, .12);
  background:
    radial-gradient(110% 60% at 90% 0%, var(--forest-lit) 0%, rgba(3, 84, 63, 0) 70%),
    linear-gradient(180deg, var(--forest) 0%, var(--forest-deep) 100%);
}
.ob-hero-body { text-align: center; }
.ob-hero-mark { display: flex; justify-content: center; margin-bottom: 28px; }
.ob-hero-eyebrow {
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent);
}
.onboard-step h1.ob-hero-title {
  font-size: clamp(40px, 12vw, 64px);
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1.02;
  margin: 14px 0 16px;
}
.ob-hero-lead { font-size: var(--fs-h2); line-height: 1.55; max-width: 32ch; margin: 0 auto; }
.ob-hero-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============================== SEARCH ============================== */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input {
  width: 100%; min-height: 48px; padding: 12px 15px;
  font-family: var(--font); font-size: var(--fs-h2);
  color: var(--ink);
  background: var(--raised);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  outline: none;
  transition: border-color var(--speed), background var(--speed);
}
.search-box input::placeholder { color: var(--ink-dim); }
.search-box input:focus { border-color: var(--accent); }
.search-box .results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 50;
  display: none;
  max-height: 260px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-box .results.open { display: block; }
.search-box .results button {
  display: block; width: 100%; min-height: 44px; padding: 11px 15px;
  text-align: left; font-family: var(--font); font-size: var(--fs-body);
  color: var(--ink); background: none; border: none; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.search-box .results button:last-child { border-bottom: none; }
.search-box .results button:hover,
.search-box .results button.active { background: var(--raised); }
.search-box .results button small { display: block; font-size: var(--fs-small); color: var(--ink-dim); margin-top: 2px; }

/* ============================== MAP ============================== */
.map-wrap {
  position: relative;
  height: 300px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--forest);
  margin-bottom: 14px;
}
.map-wrap.tall { height: min(52dvh, 460px); }
/* keyboard parcel pick: crosshair at map centre while the map has focus */
.map-wrap:focus-visible::after {
  content: "";
  position: absolute; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 2px solid var(--accent); border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(17, 25, 40, .5);
  pointer-events: none;
}
.map-wrap .maplibregl-ctrl-attrib { font-size: var(--fs-nano); background: rgba(17, 25, 40, .72); color: var(--ink-dim); }
.map-wrap .maplibregl-ctrl-attrib a { color: var(--ink-dim); }

/* ============================== SKELETON ============================== */
.skeleton {
  position: relative;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .06);
  overflow: hidden;
  min-height: 16px;
  color: transparent;
}
.skeleton::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .07) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ============================== TYPO HELPERS (component-level) ============================== */
.card h2, .card .card-title { font-size: var(--fs-h2); font-weight: 600; letter-spacing: -.005em; margin-bottom: 12px; }
.card .eyebrow {
  font-size: var(--fs-micro); font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 8px;
}
/* on the green band the eyebrow is the yellow label of the forestio.ai hero */
.card-hero .eyebrow { color: var(--accent); }
.card .note { font-size: var(--fs-small); color: var(--ink-faint); margin-top: 12px; line-height: 1.55; }

/* ============================== MOTION KILL SWITCH ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* screen-specific rules are appended below this line by the architect only */

/* ============================== DESKTOP ==============================
   The phone column is the design; on a wide screen it left two thirds of the
   display empty, which reads as an unfinished demo on a laptop or a projector.
   Same app, same markup — only the shell rearranges: the bottom tab bar becomes
   a left rail and each screen's cards flow into as many columns as fit.

   Driven by a class rather than a media query, so the layout can also be pinned
   from the URL (?view=mobile / ?view=desktop) — two links that always show the
   same thing beat one link that depends on how wide the window happens to be.
   index.html sets the class before first paint; with no ?view it follows the
   viewport at 1024px exactly as a media query would.
   ==================================================================== */

.is-desktop #app {
  max-width: none;
  padding-left: 236px;              /* room for the rail */
  min-height: 100dvh;
}

/* tab bar → vertical navigation rail */
.is-desktop .tabbar {
  top: 0; bottom: 0; left: 0;
  transform: none;
  width: 236px; max-width: 236px;
  height: 100dvh;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  padding: 88px 14px 24px;
  border-top: 0;
  border-right: 1px solid var(--raised);
}
.is-desktop .tab {
  flex: 0 0 auto;
  flex-direction: row;
  justify-content: flex-start;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.is-desktop .tab .tab-label { font-size: var(--fs-body); font-weight: 500; letter-spacing: 0; }
.is-desktop .tab:hover:not(.active) { background: var(--hover); }

/* brand sits above the rail, so the top bar carries only the language switch */
.is-desktop .statusbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 46;
  padding: 14px var(--pad) 14px 22px;
  border-bottom: 1px solid var(--raised);
}
.is-desktop .statusbar .brand { width: 212px; flex: none; }
.is-desktop .statusbar .lang { margin-left: auto; }

/* content: a centred dashboard grid instead of one tall column */
.is-desktop #screens {
  max-width: 1360px;
  margin: 0 auto;
  padding: calc(68px + var(--pad)) var(--pad) 48px;
}
.is-desktop #screens > section[data-screen] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 18px;
  align-items: stretch;             /* cards in a row share its height */
}
.is-desktop .card { margin-bottom: 0; }

/* Full-width rows: the greeting, the one hero number, the stat chips,
   section headings and the paragraphs that introduce a group of cards.
   Everything else is a card and takes one column. */
.is-desktop #screens > section > div:not([class]),
.is-desktop #screens > section > .source-line,
.is-desktop #screens > section > h2,
.is-desktop #screens > section > p { grid-column: 1 / -1; }

/* The hero band runs the full content width like every other row. It used to
   be a 980px strip centred above 1316px cards, which gave each screen two left
   edges. It still takes a row of its own: the grid sizes a row by its tallest
   item, so a hero beside a tall card would leave a void underneath it. (Home
   composes its own band — see HOME COMPOSITION below.) */
.is-desktop #screens > section > .card-hero,
.is-desktop #screens > section > .metric-row {
  grid-column: 1 / -1;
  width: 100%;
}
.is-desktop #screens > section > .metric-row { margin-bottom: 4px; }
.is-desktop .card-hero { padding: 30px var(--pad); }

/* Very wide screens: the columns are capped by #screens' own max-width above
   (1440px fits exactly four 330px tracks), so auto-fit reaches four columns on
   its own. A fixed repeat(4) used to be pinned here, but a fixed track count
   cannot collapse: a row holding one or three cards kept the leftover tracks
   as empty canvas, which made 1600px look worse than 1599px. */

/* ============================================================
   ADDITIVE BLOCK — wood volume metric (zásoba dřeva / timber volume)
   Only new rules; nothing above is restructured.
   The home stat-chip row grew from 3 to 4 chips. On a phone four
   chips in one flex line squeeze the value ("1 234 m³") and the
   longer Czech label ("ZÁSOBA DŘEVA") past their box, so the row
   wraps to 2×2 and goes back to a single line once there is room.
   ============================================================ */
.metric-row-wrap { flex-wrap: wrap; }
.metric-row-wrap > .stat-chip { flex: 1 1 calc(50% - 5px); }
@media (min-width: 620px) {
  .metric-row-wrap > .stat-chip { flex: 1 1 0; }
}

/* ============================================================
   RESPONSIVE BLOCK — everything between a phone in the hand and a
   4K monitor. Written against a screenshot audit of 40+ viewports.
   Additive: nothing above is restructured.
   ============================================================ */

/* ---- 1. Cards that are alone in their grid row --------------------
   The desktop grid is repeat(auto-fit, minmax(330px, 1fr)). auto-fit
   only collapses a track that is empty across the WHOLE grid, so a
   section holding a single card (Export, Nastavení, OLH, sousedský
   efekt…) sat in column 1 and left the other columns as bare canvas —
   on Profile and Care that was more than half the screen. Cards that
   are genuinely alone opt into the full row instead, capped and
   centred like the score band above them so they read as a deliberate
   band rather than a stretched letterbox. */
.is-desktop #screens > section > .card-full,
.is-desktop #screens > section > .card-grid,
.is-desktop #screens > section > .chip-row {
  grid-column: 1 / -1;
}

/* A group of cards that belong together (the value pair, the forest list)
   spans the row and lays itself out from its OWN item count. It has to be
   its own grid: in the page grid a full-width header keeps every track
   occupied, so auto-fit can never collapse the leftovers, and a two-card
   group in a three-track row left a column of bare canvas. */
.card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card-grid > .card { margin-bottom: 0; }
/* Grid children default to min-width:auto and refuse to shrink below their
   content — these cards were plain block children before, so without this a
   phone gets a horizontally scrolling page. */
.card-grid > *,
.card-stack > * { min-width: 0; }

/* A vertical stack inside one track — short cards that belong beside a tall
   one rather than in a row with it. */
.card-stack { display: grid; gap: 14px; align-content: start; }
.card-stack > .card,
.card-stack > .alert-card { margin-bottom: 0; }


/* Long intro copy reached ~185 characters per line once the grid hit
   its cap. Prose gets a reading measure; the cards keep the width. */
.is-desktop #screens > section > p { max-width: 74ch; }

/* ---- 2. The tablet band (620–1023px) ------------------------------
   Below 1024px the .is-desktop class is off, so #app stayed a 480px
   phone column centred in the window: on an iPad in portrait that is
   ~40% content and ~60% empty navy. Two columns, no nav rail — the
   rail wants ~900px of comfortable width, so the tabbar stays at the
   bottom right up to the desktop switch. */
@media (min-width: 620px) and (max-width: 1023.98px) {
  #app { max-width: 760px; }
  #screens { padding-left: var(--pad); padding-right: var(--pad); }
  #screens > section[data-screen] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }
  #screens > section[data-screen] > .card { margin-bottom: 0; }
  #screens > section > .card-hero,
  #screens > section > .card-full,
  #screens > section > .card-grid,
  #screens > section > .chip-row,
  #screens > section > .metric-row,
  #screens > section > div:not([class]),
  #screens > section > .source-line,
  #screens > section > h2,
  #screens > section > p { grid-column: 1 / -1; }
  .sheet { max-width: 620px; }
  /* The tab bar kept its 480px phone width under a 760px column: content
     showed on both sides of it (device matrix I1, 20 tablet/landscape profiles). */
  .tabbar { max-width: 760px; }
  .tab { max-width: 180px; }
  .tabbar { justify-content: center; }
  /* The onboarding overlay was 620px on a 760px shell, so the inert status
     bar — with a CZ/EN switch that looked tappable and did nothing — showed
     beside it (matrix I2). Same as desktop: cover the shell, centre the column,
     and stop a tall portrait tablet pushing the CTA 1000px below the logo (C3). */
  .onboard { max-width: none; z-index: 80; align-items: center; padding-left: var(--pad); padding-right: var(--pad); }
  .onboard > * { width: 100%; max-width: 620px; }
  .sheet-backdrop { z-index: 84; }
  .sheet { z-index: 85; }
}
@media (min-width: 620px) and (max-width: 1023.98px) and (min-height: 900px) {
  .onboard { justify-content: center; }
  .onboard-step { flex: 0 1 auto; max-height: 760px; }
}

/* ---- 3. Onboarding on a desktop ----------------------------------
   .onboard is a 480px column with inset:0, and it never had a desktop
   rule: at ≥1024px the nav rail and the language switcher stayed
   visible AND clickable on either side of it, so a first-run user
   could navigate away from onboarding into an app with no forest in
   it. The overlay now covers the shell and centres its column, and on
   a tall monitor the step stops growing so the CTA does not end up
   1500px below the logo. */
.is-desktop .onboard {
  max-width: none;
  z-index: 80;                      /* above the rail (45) and statusbar (46) */
  align-items: center;
  padding-left: var(--pad);
  padding-right: var(--pad);
}
.is-desktop .onboard > * { width: 100%; max-width: 480px; }
/* A sheet opened FROM the overlay (the privacy notice on the hero) must sit
   above it; at 60/61 it opened invisibly underneath on desktop. */
.is-desktop .sheet-backdrop { z-index: 84; }
.is-desktop .sheet { z-index: 85; }
@media (min-height: 900px) {
  .is-desktop .onboard { justify-content: center; }
  .is-desktop .onboard-step { flex: 0 1 auto; max-height: 760px; }
}

/* The bottom sheet centres on the window, but on desktop the content
   area starts after the 236px rail — it was visibly off-centre. */
.is-desktop .sheet { left: calc(236px + (100% - 236px) / 2); }

/* ---- 4. A phone held sideways ------------------------------------
   There was no height- or orientation-keyed query in the file at all.
   In landscape the statusbar, greeting, hero padding and the fixed
   190px score ring together overflow a ~375px-tall viewport, so the
   Forest Score — the one number the whole screen exists for — sat
   behind the tabbar. Everything shrinks to fit. */
@media (orientation: landscape) and (max-height: 520px) {
  /* The greeting's size comes from this token via an inline style, so
     retuning the token is the only way to reach it from CSS. */
  :root { --fs-h1: 18px; }
  .statusbar { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .card-hero { padding: 12px var(--pad); }
  .score-ring { width: 128px; height: 128px; margin: 2px auto; }
  .ring-label .big-num { font-size: var(--fs-big); }
  #screens { padding-top: 12px; }

  /* The diary sheet ran 90px past its own box, scrolling "Zrušit"
     out of sight with no visible affordance. */
  .sheet { max-height: 94dvh; }
  .sheet-actions { flex-direction: row; margin-top: 10px; gap: 8px; }
  .sheet-actions > .btn { flex: 1 1 0; }

  /* A 52px column tab took 22 % of a 320px-high screen and still covered
     half the score ring (device matrix C1): icon beside the label, 40px. */
  .tab { flex-direction: row; justify-content: center; gap: 8px; min-height: 44px; padding: 4px 8px; }
  .tabbar { padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  /* the onboarding hero and map were sized for portrait: the CTA sat below
     the fold and the map showed 70–190px of its 300px */
  .ob-hero-mark { margin-bottom: 10px; }
  .onboard .map-wrap.tall { min-height: min(300px, 62dvh) !important; } /* beats the inline 300px */
}

/* ---- 5. List titles ----------------------------------------------
   Marketplace listings ellipsised their own names at ≤400px
   ("Těžba & doprava Dřevotra…"), and the same happened in the narrow grid
   cells of tablets and desktop ("Smazat data v tomto za…" at 1024px, device
   matrix C2). Two lines beat a truncated name, at every width. */
.list-item .title {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ---- 6. Draw it myself (onboarding) --------------------------------
   The owner traces the forest by hand when the cadastre has nothing. */
.map-wrap.drawing { cursor: crosshair; outline: 2px solid var(--positive); outline-offset: -2px; }
.draw-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.draw-count { min-height: 1.4em; text-align: center; font-size: var(--fs-small); color: var(--positive); font-variant-numeric: tabular-nums; }
.draw-actions { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 8px; }
.draw-actions .btn { width: 100%; min-height: 44px; padding-inline: 10px; font-size: var(--fs-small); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ============================================================
   HOME COMPOSITION — one content width, no voids.
   Additive. Phone and tablet keep the single-column order they had;
   everything below only takes effect on the desktop layout.
   ============================================================ */

/* On a phone the section is block flow and .card-stack zeroes its cards'
   margins, so the satellite card sat flush on the card below once the old
   wrapper (which spaced them with its grid gap) was gone. */
#screens > section > .card-stack { margin-bottom: 14px; }
.is-desktop #screens > section > .card-stack { margin-bottom: 0; }
@media (min-width: 620px) and (max-width: 1023.98px) {
  #screens > section > .card-stack { margin-bottom: 0; }
}

/* Score + its four numbers: one band. A phone stacks them as before. */
.summary-band { grid-template-columns: minmax(0, 1fr); }
.summary-side { min-width: 0; }
.card-grid > .alert-card { margin-bottom: 0; }

/* The band and the inside of the satellite card share ONE vertical gutter, so
   the right-hand column starts on the same x all the way down the page. The
   card is inset by its own padding and uses a wider gap, so its picture column
   is the band's column minus that difference — the two calc()s below are the
   same line measured from two different boxes. */
.is-desktop .summary-band,
.is-desktop .sat-body { display: grid; --home-lead: .42; }
.is-desktop .summary-band {
  gap: 18px;
  grid-template-columns: calc(100% * var(--home-lead)) minmax(0, 1fr);
}
.is-desktop .sat-body {
  gap: 28px;
  grid-template-columns:
    calc((100% + 2 * var(--pad)) * var(--home-lead) - var(--pad) - 10px)
    minmax(0, 1fr);
}
.is-desktop .summary-band > .card-hero { display: flex; flex-direction: column; justify-content: center; }

/* The four numbers become a 2x2 of tiles as tall as the score card, with the
   modelling note pinned under them. */
.is-desktop .summary-side { display: flex; flex-direction: column; gap: 10px; }
.is-desktop .summary-side > .metric-row {
  flex: 1 1 auto;
  display: grid !important;          /* the row is display:flex inline */
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  margin-bottom: 0 !important;
}
.is-desktop .summary-side .stat-chip {
  display: flex; flex-direction: column; justify-content: center;
  padding: 16px 20px;
}
.is-desktop .summary-side .stat-chip .v { font-size: var(--fs-big); font-weight: 700; margin-top: 8px; }
.is-desktop .summary-side > .source-line { margin: 0 !important; }

/* Satellite card: picture left, controls and readings right. */
.is-desktop .sat-body { align-items: stretch; margin-top: 4px; }
.is-desktop .sat-side { display: flex; flex-direction: column; min-width: 0; }
/* The source line is pinned to the foot of the column, level with the
   caption under the picture, so both columns end on one baseline. */
.is-desktop .sat-side > .note:last-child { margin-top: auto; padding-top: 12px; }

/* The short cards below share the row evenly, whether there are two or three. */
.is-desktop #screens > section[data-screen="home"] > .card-grid:not(.summary-band) {
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 18px;
}

/* ============================================================
   UX AUDIT PASS — additive.
   ============================================================ */

/* A heading focused by script (screen change → focus moves to the title for
   screen readers) drew the keyboard ring around "MY FOREST" on first load.
   It is not operable, so it never needs a ring. */
[tabindex="-1"]:focus { outline: none; }

/* Buttons are width:100%, which is right in a 346px phone card and a 1270px
   letterbox in a full-row desktop card. Capped and left-aligned with the copy
   they follow; the hero's CTA stays centred under its centred number. */
.is-desktop .card > .btn { max-width: 360px; }
.is-desktop .card-hero > .btn { margin-inline: auto; display: flex; }

/* Cards sharing a row share its height (align-items: stretch on the page
   grid, above). They stay ordinary block cards: turning them into flex columns
   to pin buttons to the foot stopped margins collapsing inside every card, and
   the buttons' inline margins overrode the pin anyway. */

/* Marketplace: a name at the far left and its button 1200px away at the far
   right is a long way to track across. Two columns on desktop. */
/* (it needs the full row spelled out: classless divs get it from the page
   grid's :not([class]) rule, and this one now has a class) */
#screens > section > .svc-list { grid-column: 1 / -1; }
.is-desktop .svc-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }

/* A section heading belongs to the cards under it: more air above than below. */
.is-desktop #screens > section > h2 { margin-top: 18px; margin-bottom: -6px; }
/* Tablet: the satellite card used to share a two-column row with the short
   cards; now that it takes the row, a stacked body would mean a 600px picture
   and chart labels scaled to 20px. Same picture | controls split as desktop. */
@media (min-width: 620px) and (max-width: 1023.98px) {
  .sat-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: stretch; }
  .sat-side { display: flex; flex-direction: column; min-width: 0; }
  .sat-side > .note:last-child { margin-top: auto; padding-top: 12px; }
}
/* In that half-width column four chips across clip "Normal" (and the longer
   Czech status words); 2x2 until the column is wide enough again. */
@media (min-width: 620px) and (max-width: 1199.98px) {
  .sat-side .metric-row-wrap > .stat-chip { flex: 1 1 calc(50% - 5px); }
}

/* ---- Screen header: one pattern on every screen ---- */
.screen-head { margin-bottom: 18px; }
.screen-head h1 { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.screen-head p { color: var(--ink-dim); font-size: var(--fs-body); line-height: 1.55; margin-top: 4px; max-width: 74ch; }
#screens > section > .screen-head { grid-column: 1 / -1; }
.is-desktop .screen-head { margin-bottom: 0; }   /* the page grid's gap spaces it */
@media (min-width: 620px) and (max-width: 1023.98px) { .screen-head { margin-bottom: 0; } }

/* ---- Export: flat rows, three across when there is room ---- */
#screens > section > .export-list { grid-column: 1 / -1; }
.is-desktop .export-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
/* A row that is a grid item is spaced by the grid's gap; its own list margin
   left the forest row 10px shorter than the "Add forest" tile beside it. */
.card-grid > .list-item { margin-bottom: 0; }

/* ---- Actions sit on the foot of a stretched card ----
   Cards in a row share its height, which left a short card's button floating
   under its copy with a void beneath. Scoped to cards that END in a button and
   sit in a multi-card row — not every card: a blanket flex column stopped
   margins collapsing inside cards that never needed it (the calendar's
   eyebrow + chart grew 8px). The buttons carry an inline margin-top, hence
   !important; the element above keeps the minimum gap when nothing stretches. */
.is-desktop #screens > section[data-screen] > .card:has(> .btn:last-child):not(.card-full):not(.card-hero) {
  display: flex; flex-direction: column;
}
.is-desktop #screens > section[data-screen] > .card:has(> .btn:last-child):not(.card-full):not(.card-hero) > .btn {
  margin-top: auto !important;
}
.is-desktop #screens > section[data-screen] > .card:has(> .btn:last-child):not(.card-full):not(.card-hero) > :nth-last-child(2) {
  margin-bottom: 14px;
}

/* ---- Chart lines keep their weight ----
   A width:100% SVG scales its strokes with the column, so the same 2-unit line
   drew at 2px in a phone card and ~4px in a desktop one. Labels are held in
   pixels by App.fitSvgText; this does the same for the lines. Scoped to charts:
   icons and the score dial are drawn at a fixed size and rely on scaling. */
svg.chart path, svg.chart line, svg.chart polyline, svg.chart circle { vector-effect: non-scaling-stroke; }

/* ---- Earnings on a phone: fold the long tail ----
   Phone only. From the tablet band up there is room, the button disappears and
   nothing is ever hidden — the classes are inert there. */
.phone-more { display: none; }
@media (max-width: 619.98px) {
  html:not(.is-desktop) .phone-folded { display: none; }
  html:not(.is-desktop) .phone-more { display: inline-flex; margin-bottom: 14px; }
}

/* ============================== RENDER FAILURE ==============================
   core.js renderFailure(): a screen that threw while rendering. */
.render-failure h2 { margin: 0 0 8px; font-size: var(--fs-h3); }
.render-failure p { margin: 0 0 16px; color: var(--ink-dim); }
.render-failure-actions { display: flex; flex-wrap: wrap; gap: 10px; }
