﻿/* ALFA-Lär – warm and playful, respectful for teenagers and staff (WCAG 2.2 AA).
   Interface colours follow the chosen appearance (Ljust/Mörkt). Worksheets (.a4, .mini-sheet)
   are always black on white, with grayscale images – they never use the interface tokens. */

@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("fonts/AtkinsonHyperlegible-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    src: url("fonts/AtkinsonHyperlegible-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

/* The project's own dotted font for Stav-stöd (tools/StavStodFont). */
@font-face {
    font-family: "ALFA Stav-stod";
    src: url("fonts/AlfaStavStod-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: block;
}

:root {
    color-scheme: light;
    --bg: #fff7ef;
    --bg-pattern: radial-gradient(circle at 12% -10%, #ffe2c7 0, transparent 38%), radial-gradient(circle at 100% 0, #e3f1ff 0, transparent 30%);
    --surface: #ffffff;
    --surface-2: #fff1e4;
    --ink: #1f2340;
    --muted: #51587a;
    --line: #ead9c8;
    --line-strong: #8a7f96;
    --primary: #c2410c;
    --primary-hover: #9a3412;
    --on-primary: #ffffff;
    --primary-soft: #ffe6d5;
    --link: #9a3412;
    --teal: #0f766e;
    --teal-soft: #d9f4ee;
    --sun: #f5b700;
    --sun-soft: #fff1c2;
    --lilac: #6d3fd1;
    --lilac-soft: #eee7ff;
    --sky-soft: #e1efff;
    --mine: #1d4ed8;
    --mine-soft: #e1efff;
    --group: #15803d;
    --group-soft: #e3f6ea;
    --focus: #6d3fd1;
    --danger: #b42318;
    --danger-soft: #fdebe9;
    --success: #1e7a43;
    --success-soft: #e3f6ea;
    --warn: #8a5300;
    --warn-soft: #fff2d6;
    --shadow: 0 1px 2px rgba(31, 35, 64, .06), 0 6px 18px rgba(31, 35, 64, .07);
    --topbar: rgba(255, 255, 255, .92);
    --input-bg: #ffffff;
    --radius: 16px;
    --radius-small: 10px;
    --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Mörkt: Stålblå, a calm grey-blue with a light sky-blue accent – the only dark appearance (B148; replaces the five
   shades of B68). */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #16202e;
    --bg-pattern: radial-gradient(circle at 12% -10%, #233348 0, transparent 40%), radial-gradient(circle at 100% 0, #232b3f 0, transparent 32%);
    --surface: #1e2a3b;
    --surface-2: #253347;
    --ink: #eef2f7;
    --muted: #b6c2d3;
    --line: #36475f;
    --line-strong: #8696ad;
    --primary: #9cc8f0;
    --primary-hover: #bcdaf5;
    --on-primary: #0f1a2a;
    --primary-soft: #263c57;
    --link: #a9d1f5;
    --teal: #5fe0c9;
    --teal-soft: #173c4a;
    --sun: #ffd166;
    --sun-soft: #3a3423;
    --lilac: #c4b0ff;
    --lilac-soft: #2b2a5a;
    --sky-soft: #22364f;
    --mine: #9cc3ff;
    --mine-soft: #1b3466;
    --group: #86e0a8;
    --group-soft: #173b33;
    --focus: #ffd166;
    --danger: #ff8a80;
    --danger-soft: #3d1f2a;
    --success: #7ee2a8;
    --success-soft: #173b33;
    --warn: #ffd27a;
    --warn-soft: #3a3020;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 22px rgba(0, 0, 0, .25);
    --topbar: rgba(24, 34, 48, .94);
    --input-bg: #1a2534;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1.0625rem;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75em; }
a { color: var(--link); text-underline-offset: .15em; }

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap;
}

.skip-link {
    position: absolute; left: 1rem; top: -4rem; z-index: 30;
    background: var(--surface); color: var(--ink); padding: .5rem 1rem;
    border: 2px solid var(--focus); border-radius: var(--radius-small);
}
.skip-link:focus { top: .75rem; }

.icon { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- App shell: fixed top menu + scrolling content container ---------- */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.topbar {
    flex: none; position: relative; z-index: 20;
    background: var(--topbar); border-bottom: 1px solid var(--line);
    box-shadow: 0 2px 10px rgba(31, 35, 64, .05);
}
.topbar__inner {
    max-width: 1440px; margin: 0 auto; padding: .55rem 1.25rem;
    display: flex; align-items: center; gap: .75rem 1.5rem;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.25rem; }
/* ALFALär-symbolen (B152): the colours follow the tokens, so Ljust and Mörkt need no separate files. */
.logo-mark { display: block; flex: none; }
.logo-mark__sheet { stroke: var(--primary); }
.logo-mark__pictures { fill: var(--primary); }
.logo-mark__lines { stroke: var(--ink); }
.brand__mark { width: 2.15rem; height: 2.42rem; }
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
/* Öppen beta (B165): a small label beside the name on every page. */
.beta-badge {
    display: inline-block; vertical-align: .15em; margin-left: .3rem; padding: .05rem .45rem; border-radius: 999px;
    font-size: .7rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
    color: var(--warn); background: var(--warn-soft); border: 1px solid currentColor;
}
.beta-note { margin-top: .5rem; }
.feedback-note { margin: .5rem 0; }
.brand__sub { font-weight: 400; font-size: .78rem; color: var(--muted); }

.main-nav { display: flex; gap: .3rem; margin-left: auto; }
.main-nav a {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem .95rem; border-radius: 999px; min-height: 2.75rem;
    color: var(--ink); text-decoration: none; font-weight: 700;
}
.main-nav a:hover { background: var(--surface-2); }
.main-nav a.active { background: var(--primary); color: var(--on-primary); }
.topbar__tools { display: flex; align-items: center; gap: .5rem; }

.appearance { display: inline-flex; padding: .2rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.appearance button {
    font: inherit; font-size: .88rem; font-weight: 700; color: var(--muted);
    display: inline-flex; align-items: center; gap: .3rem;
    border: 0; background: transparent; border-radius: 999px; padding: .35rem .7rem; min-height: 2.25rem; cursor: pointer;
}
.appearance button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.appearance--menu { display: none; }
.top-menu__phone { display: none; }
.account__signup-note { display: none; }

.app-main { flex: 1; overflow-y: auto; overscroll-behavior: contain; background: var(--bg-pattern), var(--bg); scroll-padding-top: 1rem; scroll-padding-bottom: 1.5rem; }
.app-main:focus { outline: none; }
.page { max-width: 1440px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.app-footer { max-width: 1440px; margin: 0 auto; padding: 1rem 1.5rem 2rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }
.page--narrow { max-width: 28rem; }
.page:focus { outline: none; }
h1:focus { outline: none; } /* programmatic focus after navigation (FocusOnNavigate) */

/* ---------- Text helpers ---------- */
.lead { font-size: 1.15rem; color: var(--muted); max-width: 48rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; font-weight: 400; }
.stack > * + * { margin-top: 1.25rem; }
.eyebrow { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--teal); margin-bottom: .35rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin: 2.25rem 0 1rem; }
.section-head h2 { margin: 0; }

/* ---------- Cards and panels ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.5rem; box-shadow: var(--shadow); }
.card--link { color: var(--ink); text-decoration: none; }
.card--link:hover { border-color: var(--primary); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
details.panel > summary { cursor: pointer; font-weight: 700; padding: .25rem 0; }
details.panel[open] > summary { margin-bottom: .75rem; }

/* ---------- Forms ---------- */
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; margin: 0 0 1.25rem; background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
legend { font-weight: 700; font-size: 1.1rem; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); }
fieldset.question { background: var(--surface-2); box-shadow: none; }
/* B173: the recipe parts (Före start, Ingredienser, Redskap, Steg) fold away; the summary is a full-width, clickable bar. */
details.recipe-part { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 1rem; padding: 0 1rem; }
details.recipe-part > summary { cursor: pointer; font-weight: 700; font-size: 1.05rem; padding: .8rem 0; list-style-position: inside; }
details.recipe-part[open] { padding-bottom: 1rem; }
details.recipe-part[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: .75rem; }
/* Foldable steps in Skapa material (B82): the legend holds a button; a folded step keeps its choices. */
.step__legend { padding: 0; background: none; max-width: 100%; } /* a long step summary must not widen the page on a phone */
.step__toggle {
    display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-weight: 700; font-size: 1.1rem; color: var(--ink);
    padding: .15rem .75rem .15rem .6rem; border: 0; border-radius: 999px; background: var(--surface-2); cursor: pointer;
}
.step__toggle:hover { background: var(--primary-soft); }
.step__toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.step__chevron { width: .55rem; height: .55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -.2rem .1rem 0; }
.step--closed .step__chevron { transform: rotate(-45deg); margin-top: 0; }
.step__title { flex: none; white-space: nowrap; } /* never "3. Bas-" / "val" on a phone; the summary shortens instead */
.step__state { font-size: .85rem; font-weight: 600; color: var(--muted); }
.step--closed { padding-bottom: .6rem; }
/* Short choices sit side by side when there is room (B156), e.g. Visa ordet next to Bildstorlek; everything else
   (headings, hints, switches, lists) keeps its own row. Applies to every task in Skapa material. */
.step__body { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 1rem; }
.step__body[hidden] { display: none; }
.step__body > * { flex: 1 1 100%; min-width: 0; }
.step__body > .field--inline, .step__body > .choice-select { flex: 1 1 15rem; max-width: 24rem; }
.step__body > .btn { flex: 0 0 auto; }
/* B162: a single switch, a lone button with its hint and a short number field sit beside other short choices. */
.step__body > .switch-row:has(> .switch:only-child), .step__body > .field:has(> .btn--fit) { flex: 1 1 13rem; max-width: 24rem; }
.step__body > .switch-row:has(> .switch:only-child) { grid-template-columns: 1fr; }
/* B170: the switch title lines up with the labels beside it (the card's border and padding sit above the line). */
.step__body > .switch-row { margin-top: calc(-.45rem - 1.5px); margin-bottom: .65rem; }
.step__body > .step__sub:has(+ .switch-row) { margin-bottom: 1.05rem; } /* keeps the heading clear of a switch card pulled up above */
.step__body > .field:has(> input.input--short) { flex: 0 1 9rem; }
.step__body > .word-options .field { flex: 0 1 14rem; }
/* B167: Antal ord is a two-digit field and Generera sits beside it, level with the inputs (below the labels). */
.step__body > .word-options .field:has(> input.input--short) { flex: 0 0 6.5rem; }
.step__body > .word-options .field--end { flex: 0 0 auto; padding-top: 1.75rem; }
.step__body > .random-words { margin-bottom: .85rem; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; flex: 1 1 12rem; min-width: 0; }
.field label, .field .label { font-weight: 700; }
.field--check { flex-direction: row; align-items: center; gap: .5rem; flex: 0 0 auto; align-self: flex-end; padding-bottom: .5rem; }
.field--inline { max-width: 24rem; }
.field-row { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.field-row--three .field { flex-basis: 10rem; }
/* B170: four answer fields (Rätt svar + three Fel svar) sit two and two instead of leaving one alone on a row. */
.field-row--three:has(> .field:nth-child(4)) .field { flex-basis: calc(50% - .5rem); }

input, select, textarea {
    font: inherit; color: var(--ink);
    padding: .55rem .75rem; min-height: 2.75rem;
    border: 1.5px solid var(--line-strong); border-radius: var(--radius-small); background: var(--input-bg);
    width: 100%;
}
input:hover, select:hover, textarea:hover { border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: 1.25rem; height: 1.25rem; min-height: 0; accent-color: var(--primary); }
/* Short number fields such as Textstorlek (pt): room for two digits and the spinner. */
.input--short { width: 5.5rem; }
textarea { resize: vertical; }
/* Ord in 4. Innehåll: words on a row, "säng | lampa | soffa" (two lines high, grows by dragging). */
.words-field { min-height: 0; line-height: 1.5; }
:disabled { cursor: not-allowed; }

/* Switch (checkbox styled as a toggle, state also written as text) */
.switch { display: flex; align-items: flex-start; gap: .75rem; padding: .75rem .9rem; border: 1.5px solid var(--line); border-radius: var(--radius-small); background: var(--surface); cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 3rem; height: 1.75rem; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; margin: 0; border: 0; padding: 0; min-height: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { transform: translateX(1.25rem); }
.switch__text { display: flex; flex-direction: column; gap: .1rem; }
.switch__title { font-weight: 700; }
.switch__state { font-size: .85rem; font-weight: 700; color: var(--muted); }
.switch:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.switch:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; margin-bottom: .85rem; }

/* Segmented choice (radio buttons) */
.segmented { display: flex; flex-wrap: wrap; gap: .4rem; border: 0; padding: 0; margin: 0 0 .85rem; background: none; box-shadow: none; }
.segmented legend { background: none; padding: 0; margin-bottom: .35rem; font-size: 1rem; }
.segmented label { position: relative; display: inline-flex; flex-direction: column; gap: .05rem; padding: .5rem .9rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius-small); cursor: pointer; background: var(--surface); min-height: 2.75rem; justify-content: center; }
.segmented label small { color: var(--muted); font-size: .8rem; }
/* The hidden radio covers its own label: focusing it never scrolls the page (it once sat outside the scroll container and made the whole app jump). */
.segmented input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.segmented label:has(input:checked) strong::before { content: "✓ "; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
/* A choice that cannot change the sheet (e.g. Färg with Bildstil Simpel): greyed out, the reason is in the hint below. */
.segmented label:has(input:disabled) { opacity: .5; cursor: not-allowed; background: var(--surface-2); }
.segmented label:has(input:disabled:checked) { box-shadow: none; border-color: var(--line-strong); background: var(--surface-2); }
/* The last chosen choice that cannot be unchosen (Räknesätt, B129) still looks chosen. */
.segmented--required label:has(input:disabled:checked) { opacity: 1; cursor: default; border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.switch:has(input:disabled), .switch input:disabled { cursor: not-allowed; }
.switch:has(input:disabled) { opacity: .55; background: var(--surface-2); border-color: var(--line); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
    min-height: 2.75rem; padding: .5rem 1.1rem;
    border: 1.5px solid var(--primary); border-radius: 999px;
    background: var(--surface); color: var(--link);
}
.btn:hover { background: var(--primary-soft); }
.btn:disabled { opacity: .55; }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--small { min-height: 2.25rem; padding: .3rem .8rem; font-size: .92rem; }
.btn--quiet { border-color: transparent; background: transparent; }
.btn--quiet:hover { background: var(--surface-2); }
.btn--danger { border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--link { border: none; background: none; color: var(--link); text-decoration: underline; min-height: auto; padding: .25rem; border-radius: 4px; }
.btn--selected { background: var(--primary); color: var(--on-primary); }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.confirm { display: inline-flex; gap: .35rem; flex-wrap: wrap; }

/* ---------- Alerts and badges ---------- */
.alert { border-radius: var(--radius-small); padding: .85rem 1rem; margin: 0 0 1rem; border-left: 6px solid; color: var(--ink); }
.alert ul { margin: .25rem 0 0; padding-left: 1.25rem; }
.alert p:last-child { margin-bottom: 0; }
.alert--error { background: var(--danger-soft); border-color: var(--danger); }
.alert--success { background: var(--success-soft); border-color: var(--success); }
.alert--warn { background: var(--warn-soft); border-color: var(--warn); }
.alert--info { background: var(--sky-soft); border-color: var(--teal); }
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; background: var(--teal-soft); color: var(--ink); border: 1px solid var(--teal); }
.badge--muted { background: var(--surface-2); color: var(--muted); border-color: var(--line-strong); }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge--example { background: var(--sun-soft); color: var(--ink); border-color: var(--sun); }
/* B187: an example sheet is about 30 % see-through, so it reads as an example and not as a finished sheet. */
.preview-pages--example img { opacity: .7; }
.picker-label { margin: .5rem 0 .2rem; font-size: .9rem; font-weight: 700; color: var(--ink); } /* names a picture picker when a row has more than one (recipe ingredient and measure) */
.muted > .badge { margin-left: .35rem; } /* a badge after inline text, e.g. "4 arbetsblad Arbetsområde" in Dina häften */

/* ---------- Template choice cards ---------- */
/* Välj uppgift (B82): small cards four across in a list that scrolls downwards, next to a larger picture of the chosen
   task with its description. The detail column sets the height; the list fills it and scrolls. */
.choice-cards { min-width: 0; }
.choice-cards:focus { outline: none; }
/* B130: the chosen task at the top once the list is hidden, with "Välj mall" to open it again. */
.chosen-task { display: flex; align-items: center; gap: 1rem; margin: 0 0 1.25rem; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.chosen-task__thumb { flex: 0 0 4.5rem; width: 4.5rem; height: 6.4rem; overflow: hidden; }
.chosen-task__text { flex: 1 1 auto; min-width: 0; }
.chosen-task__step { margin: 0; color: var(--muted); font-size: .85rem; font-weight: 700; }
.chosen-task__name { margin: .1rem 0 .2rem; font-size: 1.3rem; }
.chosen-task__name:focus { outline: none; }
.chosen-task__name:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.chosen-task__change { flex: 0 0 auto; }
@media (max-width: 40rem) {
    .chosen-task { flex-wrap: wrap; }
    .chosen-task__change { width: 100%; }
}
.task-picker { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; align-items: stretch; }
.task-picker__list { position: relative; min-height: 20rem; }
.task-picker__grid {
    position: absolute; inset: 0; overflow-y: auto; overscroll-behavior-y: contain;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; align-content: start;
    padding: .35rem .35rem 2.75rem; scrollbar-width: auto; scrollbar-color: var(--primary) var(--surface-2);
}
.task-picker__more {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 1.5rem .5rem .35rem; text-align: center;
    font-size: .9rem; font-weight: 700; color: var(--primary); pointer-events: none;
    background: linear-gradient(transparent, var(--surface) 55%);
}
.task-picker__detail { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; align-self: start; }
.task-picker__detail .mini-sheet { display: block; margin-bottom: .75rem; }
.task-picker__name { margin: 0 0 .25rem; font-size: 1.15rem; }
.task-picker__text { margin: 0; color: var(--muted); }
.task-picker__template { margin: .5rem 0 0; font-size: .9rem; display: flex; align-items: center; gap: .35rem; }
.choice-card {
    display: grid; grid-template-columns: auto 1fr; gap: .25rem .5rem; align-content: start;
    padding: .6rem; border: 2px solid var(--line); border-radius: var(--radius);
    cursor: pointer; background: var(--surface); position: relative;
}
.choice-card:hover { border-color: var(--primary); }
.choice-card input { grid-row: 1; margin-top: .2rem; }
/* The name sits above the picture (B148). */
.choice-card .mini-sheet { grid-row: 2; grid-column: 1 / -1; margin-top: .4rem; }
.choice-card__title { grid-row: 1; grid-column: 2; font-weight: 700; font-size: .95rem; }
.choice-card--selected { border: 3px solid var(--primary); background: var(--primary-soft); padding: calc(.6rem - 1px); }
.choice-card__badge {
    position: absolute; bottom: .35rem; right: .35rem; display: inline-flex; align-items: center; gap: .25rem;
    padding: .1rem .45rem .1rem .35rem; border-radius: 999px; background: var(--primary); color: var(--on-primary);
    font-size: .8rem; font-weight: 700;
}
.choice-card__badge .icon { width: .9rem; height: .9rem; }
.choice-card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Task types with their own page (Räkna, Klockslag …) sit among the word templates; the arrow takes the radio's place. */
.choice-card--link { color: inherit; text-decoration: none; }
.choice-card--link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice-card__arrow { grid-row: 1; color: var(--primary); font-weight: 700; }
@media (max-width: 1000px) {
    .task-picker { grid-template-columns: minmax(0, 1fr); }
    .task-picker__detail { order: -1; display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1rem; align-items: start; }
    .task-picker__detail .mini-sheet { margin: 0; }
    .task-picker__list { min-height: 0; }
    .task-picker__grid { position: static; max-height: 26rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .task-picker__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Stav-stöd: own distance between the dots (B70). */
.dot-spacing { margin: .5rem 0 1rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dot-spacing__label { font-weight: 700; display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; }
.dot-spacing__value { font-weight: 400; color: var(--muted); }
.dot-spacing__row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin-top: .4rem; }
.dot-spacing__row input[type="range"] { flex: 1 1 12rem; width: auto; min-height: 0; padding: 0; border: 0; background: transparent; accent-color: var(--primary); }
.dot-spacing .hint { margin: .3rem 0 0; }

/* "Val för arket": closed by default so the sheet itself is what you see; opens to the same choices as before. */
.sheet-settings { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: .75rem; }
.sheet-settings > summary {
    cursor: pointer; padding: .55rem .8rem; font-weight: 700; list-style: none;
    display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem;
}
.sheet-settings > summary::-webkit-details-marker { display: none; }
.sheet-settings > summary::before { content: "▸"; color: var(--primary); }
.sheet-settings[open] > summary::before { content: "▾"; }
.sheet-settings > summary .hint { font-weight: 400; }
.sheet-settings > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sheet-settings[open] { padding-bottom: .5rem; }
.sheet-settings[open] > :not(summary) { margin-inline: .8rem; }

/* ---------- Lists ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; }
.material-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.material-row {
    display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: center; justify-content: space-between;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow);
}
.material-row__title { font-weight: 700; font-size: 1.1rem; }
.material-row__meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .92rem; }
.empty { background: var(--surface); border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 2rem; text-align: center; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table caption { text-align: left; font-weight: 700; padding: .5rem 0; }
.table th, .table td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); }

.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 2px solid var(--line); margin-bottom: 1.25rem; }
.tab { font: inherit; font-weight: 700; padding: .6rem 1rem; border: none; background: none; cursor: pointer; color: var(--muted); border-bottom: 4px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0; }
.tab:hover { background: var(--surface-2); }
.tab--active { color: var(--ink); border-bottom-color: var(--primary); }

.image-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.image-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; display: flex; flex-direction: column; gap: .35rem; align-items: center; text-align: center; }
.image-card img { width: 6rem; height: 6rem; object-fit: contain; background: #fff; border-radius: 8px; }
.image-card__word { font-weight: 700; }
.image-card__meta { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; font-size: .82rem; color: var(--muted); }

/* ---------- Editor and create page ---------- */
.editor-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.editor-head h1 { margin-bottom: .2rem; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
/* B174 (replaces the scrolling preview of B155): the choices on the left scroll in their own box that stays in view; the
   preview on the right is part of the page and scrolls with it, as on most sites. On narrow screens everything follows the page. */
.editor > :first-child { position: sticky; top: 0; max-height: calc(100vh - 5.5rem); overflow-y: auto; overscroll-behavior: contain; padding: 1rem .75rem 1rem 0; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.editor__preview { padding: 1rem .5rem 1rem; }
.preview-jump { display: none; }
.preview-layer__bar { display: none; }
.preview-panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.preview-panel__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; }
.preview-panel__head h2 { margin: 0; font-size: 1.1rem; }
.preview-toggle { display: flex; gap: .35rem; }
.page-panel__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.block-card { border: 1px solid var(--line); border-left: 6px solid var(--teal); border-radius: var(--radius-small); padding: .75rem 1rem; margin-bottom: .85rem; background: var(--surface); }
.block-card--error { border-left-color: var(--danger); background: var(--danger-soft); }
.block-card__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.block-card__head h3 { margin: 0; }
.item-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .6rem; }
.item { border: 1px solid var(--line); border-radius: var(--radius-small); padding: .6rem .75rem; background: var(--surface-2); }
.item__buttons { display: flex; flex-wrap: wrap; gap: .25rem; }
.option-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.options { padding: .75rem 1rem; box-shadow: none; }
.add-block { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding-top: .5rem; border-top: 1px dashed var(--line); }
.add-block label { font-weight: 700; }
.add-block select { width: auto; }
.pdf-frame { width: 100%; height: 80vh; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1rem; background: #fff; }
.print-note { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.print-note::before { content: ""; width: .7rem; height: .7rem; border-radius: 3px; background: #fff; border: 1.5px solid #111; }
/* Välj ord (B164): the words scroll inside their own box, so the rest of the step stays in place. */
.word-scroll {
    max-height: 15rem; overflow-y: auto; overscroll-behavior: contain; margin: .25rem 0 .75rem;
    padding: .5rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.word-scroll .word-chips { margin: 0; }
.word-chips { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; padding: 0; margin: .25rem 0 .75rem; }
.chip { font: inherit; font-size: .9rem; border: 1.5px solid var(--line-strong); border-radius: 999px; padding: .2rem .7rem; background: var(--surface); color: var(--ink); cursor: pointer; min-height: 2rem; }
.chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.chip[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.forms-table { width: 100%; border-collapse: collapse; }
.forms-table th, .forms-table td { padding: .3rem .4rem; text-align: left; vertical-align: middle; }
.forms-table input, .forms-table select { min-height: 2.4rem; }

/* Dialog for unsaved changes */
.leave-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(12, 20, 40, .45); padding: 1rem; }
.leave-dialog__box { background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 1.5rem; max-width: 30rem; box-shadow: var(--shadow); border: 2px solid var(--warn); }

/* ---------- Combobox (Tema) ---------- */

/* ---------- Image picker ---------- */
.picker { margin: .25rem 0 .5rem; }
.picker__current { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
/* "Importera bild": a button-styled label around a hidden file input (keyboard focus shows on the label). */
.btn--file { cursor: pointer; }
.btn--file:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn--disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.picker__thumb { width: 3.5rem; height: 3.5rem; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.picker__thumb--empty { display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; color: #4a4a4a; border-style: dashed; text-align: center; }
.picker__panel { margin-top: .5rem; padding: .75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-small); background: var(--surface-2); }
.picker__grid { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(6rem, 1fr)); gap: .4rem; max-height: 20rem; overflow-y: auto; }
.picker__option { width: 100%; font: inherit; font-size: .85rem; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.picker__option img { width: 3.5rem; height: 3.5rem; object-fit: contain; background: #fff; border-radius: 6px; }
.picker__option--selected { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.picker__upload summary { cursor: pointer; font-weight: 700; }

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 2.25rem; box-shadow: var(--shadow); position: relative; z-index: 1; }
.hero h1 { font-size: clamp(1.9rem, 3.4vw, 2.75rem); margin-bottom: .4rem; }
.hero__lead { font-size: 1.2rem; color: var(--muted); max-width: none; } /* fills the box, so the welcome box is lower */
.hero__actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; align-items: center; }

.recent { position: relative; display: inline-block; }
.recent__panel { position: absolute; z-index: 25; left: 0; top: calc(100% + .35rem); width: min(26rem, 85vw); background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: .5rem; }
.recent__panel ul { list-style: none; margin: 0; padding: 0; }
.recent__panel li a { display: flex; flex-direction: column; padding: .55rem .7rem; border-radius: 10px; color: var(--ink); text-decoration: none; }
.recent__panel li a:hover, .recent__panel li a:focus-visible { background: var(--primary-soft); }
.recent__panel small { color: var(--muted); }
.recent__note { font-size: .82rem; color: var(--muted); padding: .35rem .7rem 0; margin: 0; border-top: 1px solid var(--line); }

.examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.example { display: flex; flex-direction: column; gap: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; }
.example:hover { border-color: var(--primary); }
.example__title { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .45rem; }
.example__dot { width: .8rem; height: .8rem; border-radius: 50%; flex: none; }
.example__text { color: var(--muted); font-size: .92rem; }
.example__cta { margin-top: auto; font-weight: 700; color: var(--link); }

.tint-1 { background: #ffd9c2; } .tint-2 { background: #c9f0e5; } .tint-3 { background: #fff0b3; } .tint-4 { background: #e3dcff; }

/* ---------- Login ---------- */
.login { margin-top: 4rem; background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--primary); border-radius: var(--radius); padding: 2rem; }

/* ---------- Worksheets: always black on white, grayscale images ---------- */
.a4-stack { display: grid; gap: 1rem; }
.a4 { container-type: inline-size; background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); border: 1px solid #c8c8c8; color: #111; color-scheme: light; }
.a4 img, .mini-sheet img { filter: grayscale(1); }
.a4--color img { filter: none; }
/* Example sheets rendered by the PDF renderer already have their colours (Färg, palette): no filter (B72). */
.mini-sheet--image img { filter: none; }
.a4__inner {
    --u: calc(100cqw / 595);
    --ink-print: #111;
    --muted-print: #4a4a4a;
    --line-print: #555;
    min-height: calc(842 * var(--u));
    padding: calc(40 * var(--u)) calc(51 * var(--u));
    font-family: var(--font); color: var(--ink-print);
    font-size: calc(12 * var(--u));
    display: flex; flex-direction: column;
    position: relative;
}
.a4__band { position: absolute; left: calc(51 * var(--u)); right: calc(51 * var(--u)); top: calc(40 * var(--u)); height: calc(4 * var(--u)); background: var(--ink-print); }
.a4__brand { font-size: calc(9 * var(--u)); font-weight: 700; color: var(--muted-print); margin-top: calc(12 * var(--u)); display: flex; justify-content: space-between; }
.a4__site { margin-left: auto; font-weight: 400; font-size: calc(8 * var(--u)); }
.a4__site + .a4__facit { margin-left: calc(8 * var(--u)); }
.a4__facit { border: calc(1.5 * var(--u)) solid var(--ink-print); padding: 0 calc(8 * var(--u)); font-size: calc(10 * var(--u)); }
.a4__title { font-size: calc(24 * var(--u)); font-weight: 700; margin-top: calc(6 * var(--u)); line-height: 1.2; }
.a4__theme { font-size: calc(11 * var(--u)); color: var(--muted-print); }
.a4__content { flex: 1; display: flex; flex-direction: column; gap: calc(14 * var(--u)); margin-top: calc(14 * var(--u)); }
.a4__footer { display: flex; justify-content: space-between; border-top: 1px solid var(--line-print); padding-top: calc(6 * var(--u)); margin-top: calc(16 * var(--u)); font-size: calc(10 * var(--u)); color: var(--muted-print); }

.pv-block { border-radius: 4px; }
.pv-block--active { outline: 2px dashed #6d3fd1; outline-offset: calc(4 * var(--u)); }
.pv-heading { font-weight: 700; font-size: calc(max(15, var(--fs) * .7) * var(--u)); }
.pv-text { padding: 0 calc(8 * var(--u)); font-size: calc(var(--fs) * var(--u)); }
.pv-text p { margin: 0 0 calc(var(--fs) * .5 * var(--u)); }
.pv-word { font-weight: 700; font-size: calc(var(--fs) * var(--u)); }
.pv-num { font-weight: 700; color: var(--muted-print); min-width: calc(24 * var(--u)); }
.pv-dot { width: calc(10 * var(--u)); height: calc(10 * var(--u)); border-radius: 50%; background: var(--ink-print); flex: none; }

.pv-img { object-fit: contain; flex: none; }
.pv-img--small { width: calc(48 * var(--u)); height: calc(48 * var(--u)); }
.pv-img--medium { width: calc(70 * var(--u)); height: calc(70 * var(--u)); }
.pv-img--large { width: calc(96 * var(--u)); height: calc(96 * var(--u)); }
.pv-img--missing { display: inline-flex; align-items: center; justify-content: center; border: 1.5px dashed #767676; border-radius: 6px; color: #4a4a4a; font-size: calc(9 * var(--u)); text-align: center; }
.pv-img--pair { display: inline-flex; align-items: center; gap: calc(4 * var(--u)); }
.pv-img--pair img { width: 48%; height: 60%; object-fit: contain; }

.pv-images { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: calc(10 * var(--u)); padding: 0 calc(8 * var(--u)); }
.pv-card { display: flex; align-items: center; gap: calc(20 * var(--u)); border: 1px solid var(--line-print); border-radius: calc(6 * var(--u)); padding: calc(12 * var(--u)) calc(20 * var(--u)); }
.pv-card--above { flex-direction: column; text-align: center; gap: calc(8 * var(--u)); }

.pv-match { display: grid; grid-template-columns: 4fr 3fr 4fr; row-gap: calc(12 * var(--u)); padding: 0 calc(8 * var(--u)); align-items: center; }
.pv-match__left, .pv-match__right { display: flex; align-items: center; gap: calc(10 * var(--u)); }
.pv-match__left { justify-content: flex-start; }
.pv-match__left .pv-dot { margin-left: auto; }
.pv-match__mid { text-align: center; font-size: calc(14 * var(--u)); }

.pv-mc { padding: 0 calc(8 * var(--u)); }
.pv-question { font-weight: 700; font-size: calc(max(12, var(--fs) * .85) * var(--u)); margin-bottom: calc(8 * var(--u)); }
.pv-options { display: flex; flex-direction: column; gap: calc(6 * var(--u)); font-size: calc(max(12, var(--fs) * .85) * var(--u)); }
.pv-options--row { flex-direction: row; }
.pv-options--row .pv-option { flex: 1; }
.pv-option { display: flex; align-items: center; gap: calc(8 * var(--u)); }
.pv-option--correct { font-weight: 700; text-decoration: underline; }
.pv-circle { width: calc(14 * var(--u)); height: calc(14 * var(--u)); border: 1.5px solid var(--ink-print); border-radius: 50%; flex: none; }
.pv-option--correct .pv-circle { background: var(--ink-print); }

.pv-fill { display: flex; flex-direction: column; gap: calc(var(--fs) * .8 * var(--u)); padding: 0 calc(8 * var(--u)); font-size: calc(var(--fs) * var(--u)); }
.pv-wordbank { border: 1.5px solid var(--ink-print); border-radius: calc(6 * var(--u)); padding: calc(10 * var(--u)); font-weight: 700; white-space: pre-wrap; }
.pv-fill__row { display: flex; align-items: center; gap: calc(12 * var(--u)); }
.pv-blank { display: inline-block; width: 7em; border-bottom: 1.5px solid var(--ink-print); margin: 0 .25em; vertical-align: baseline; }
.pv-answer { text-decoration: underline; margin: 0 .25em; }
.pv-trace-inline { font-family: "ALFA Stav-stod", var(--font); font-size: max(1.3em, calc(24 * var(--u))); font-weight: 400; border-bottom: 1.5px solid var(--ink-print); padding: 0 .2em; line-height: 1; }

.pv-write { padding: 0 calc(8 * var(--u)); }
.pv-prompt { font-size: calc(max(12, var(--fs) * .8) * var(--u)); margin-bottom: calc(6 * var(--u)); }
.pv-write__row { display: flex; align-items: flex-end; gap: calc(16 * var(--u)); }
.pv-write__word { min-width: calc(max(80, var(--fs) * 4) * var(--u)); padding-bottom: calc(4 * var(--u)); }
.pv-lines { flex: 1; display: flex; flex-direction: column; }
.pv-line { display: flex; align-items: flex-end; height: calc(max(28, var(--fs) * 1.8) * var(--u)); border-bottom: 1.2px solid var(--ink-print); }

/* Ord och bild rows: image → word → Stav-stöd → Skriv själv. Grid keeps columns aligned across rows. */
.pv-wordrows { display: grid; column-gap: calc(16 * var(--u)); row-gap: calc(10 * var(--u)); padding: 0 calc(8 * var(--u)); align-items: end; }
.pv-wordrows .pv-word { align-self: center; overflow-wrap: normal; }
.pv-wordbank--rows { margin: 0 calc(8 * var(--u)) calc(10 * var(--u)); }
.pv-wordrows--pairs > :nth-child(4n + 3) { margin-left: calc(16 * var(--u)); }
.pv-wordrows .pv-img { align-self: center; }
.pv-section { display: flex; align-items: flex-end; min-width: 0; }
.pv-trace, .pv-writespace { border-bottom: 1.2px solid var(--ink-print); min-height: calc(var(--ts) * 1.25 * var(--u)); max-width: 100%; display: flex; align-items: flex-end; overflow: hidden; }
.pv-word--nowrap { white-space: nowrap; }
.pv-trace span { font-family: "ALFA Stav-stod", var(--font); line-height: 1; padding-left: calc(4 * var(--u)); white-space: nowrap; }
.pv-writespace strong { font-size: calc(var(--fs) * var(--u)); padding: 0 0 calc(2 * var(--u)) calc(4 * var(--u)); }
.pv-missing-char { font-family: var(--font); outline: 1px dashed #767676; }

/* Small sheets on the home and create pages */
.mini-sheet { background: #fff; border: 1px solid #c8c8c8; border-radius: 6px; overflow: hidden; color: #111; aspect-ratio: 595 / 842; position: relative; color-scheme: light; }
.mini-sheet .a4 { border: 0; box-shadow: none; }
.mini-sheet .a4__inner { min-height: 0; }
.mini-sheet .a4__footer { display: none; }
.mini-sheet--fade::after { content: ""; position: absolute; inset: auto 0 0 0; height: 25%; background: linear-gradient(transparent, #fff); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .main-nav a { padding: .5rem .7rem; }
    .main-nav a .nav-text-long { display: none; }
}

@media (max-width: 1000px) {
    .editor { grid-template-columns: minmax(0, 1fr); }
    .editor__preview { padding: 0; }
    .editor > :first-child { position: static; max-height: none; overflow: visible; padding: 0; }
    .preview-jump { display: inline-flex; position: fixed; right: 1rem; bottom: 1rem; z-index: 20; box-shadow: var(--shadow); }
    /* B178: on small screens the preview is a layer of its own, opened with Visa utskriften. */
    .editor:has(.preview-jump) .editor__preview:not(.editor__preview--open) { display: none; }
    .editor__preview--open { position: fixed; inset: 0; z-index: 60; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); padding: .75rem 1rem 2rem; }
    .editor__preview--open .preview-layer__bar { display: flex; position: sticky; top: -.75rem; z-index: 2; margin: -.75rem -1rem .75rem; padding: .6rem 1rem; background: var(--bg); border-bottom: 1px solid var(--line); }
    /* Room under the form, so the floating Visa utskriften never covers the last field. */
    .editor:has(.preview-jump) > :first-child { padding-bottom: 4.5rem; }
    .editor:has(.editor__preview--open) .preview-jump { display: none; }
    .hero { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
    .topbar__inner { flex-wrap: wrap; padding: .5rem .75rem; gap: .5rem; }
    .topbar__tools { margin-left: auto; }
    .main-nav { order: 3; width: 100%; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; }
    .main-nav a { flex-direction: column; gap: .1rem; padding: .35rem .2rem; font-size: .8rem; text-align: center; border-radius: 12px; min-height: 3.25rem; justify-content: center; }
    .brand__sub { display: none; }
    .appearance button .appearance__text { display: none; }
}

@media (max-width: 600px) {
    /* B179: one line on phones – Ljust/Mörkt moves into Meny, the beta label shrinks to fit. */
    .topbar__inner { flex-wrap: nowrap; }
    .topbar__tools .appearance { display: none; }
    .account__signup { display: none; }
    .account__signup-note { display: block; }
    .top-menu > .top-menu__panel { position: fixed; top: 3.6rem; left: .75rem; right: .75rem; }
    .appearance--menu { display: flex; margin: .5rem .25rem .25rem; }
    .top-plan { display: none; } /* B200: in Meny instead, so the account fits */
    .top-menu__phone { display: flex; }
    .appearance--menu button { flex: 1; justify-content: center; }
    .appearance--menu button .appearance__text { display: inline; }
    .brand { font-size: 1.1rem; gap: .4rem; }
    .page { padding: 1.25rem 1rem 3rem; }
    h1 { font-size: 1.6rem; }
    .hero { padding: 1.5rem 1.1rem; border-radius: 20px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Blazor validation */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); }
.table-wrap { overflow-x: auto; max-width: 100%; }

/* Clocks (B44): same SVG face as the PDF */
.pv-clocks { padding: 0 calc(8 * var(--u)); }
.pv-clocks__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: calc(12 * var(--u)); }
.pv-clock { display: flex; flex-direction: column; align-items: center; gap: calc(6 * var(--u)); }
.pv-clock__caption { font-size: calc(max(12, var(--fs) * .7) * var(--u)); min-height: 1.2em; }
.pv-clock__face { width: calc(124 * var(--u)); height: calc(124 * var(--u)); filter: none !important; }
.pv-clock__digital { width: calc(96 * var(--u)); height: calc(34 * var(--u)); border: calc(1.5 * var(--u)) solid var(--ink-print); border-radius: calc(6 * var(--u)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: calc(18 * var(--u)); white-space: pre; }

/* Material bank (B39, B42) */
.bank-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.bank-card { display: flex; flex-direction: column; gap: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.bank-card > .button-row { margin-top: auto; } /* buttons line up when titles and subjects wrap */
.bank-card .mini-sheet { display: block; aspect-ratio: 595 / 520; } /* B179: the top of the sheet, where the content is; Visa hela bladet shows all */
.bank-card__title { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.bank-card__meta { color: var(--muted); font-size: .9rem; }
.bank-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .bank-view { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Exact print preview (page images from the PDF renderer) ---------- */
.paper-summary { margin: 0 0 .5rem; }
.paper-stack, .sheet-stack { display: grid; gap: 1.25rem; }
.paper { margin: 0; display: grid; gap: .35rem; justify-items: center; }
.paper img, .paper-sheet__page { display: block; width: 100%; height: auto; background: #fff; border: 1px solid #c8c8c8; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.paper--a4 img { aspect-ratio: 210 / 297; }
.paper figcaption, .paper-sheet figcaption { font-size: .85rem; color: var(--muted); }
.paper-sheet { margin: 0; display: grid; gap: .35rem; }
.paper-sheet__halves { display: grid; grid-template-columns: 1fr 1fr; background: #fff; border: 1px solid #c8c8c8; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); aspect-ratio: 297 / 210; }
.paper-sheet__halves .paper-sheet__page { border: 0; box-shadow: none; aspect-ratio: 148 / 210; width: 100%; height: 100%; }
.paper-sheet__halves .paper-sheet__page + .paper-sheet__page { border-left: 1px dashed #9a9a9a; }
.paper-sheet__page--blank { display: flex; align-items: center; justify-content: center; color: #6a6a6a; font-size: .9rem; }
.paper-sheet__numbers { display: grid; grid-template-columns: 1fr 1fr; text-align: center; font-size: .8rem; color: var(--muted); }
.print-help { margin: 0 0 .75rem; }
.print-help ol { margin: .4rem 0; padding-left: 1.25rem; }
.sheet-options { display: grid; gap: .25rem; margin-bottom: .75rem; }
.sheet-options .segmented { margin-bottom: .35rem; }
.segmented--compact label { flex-direction: row; align-items: center; gap: .35rem; min-height: 2.5rem; padding: .35rem .8rem; }
.sentence-card { border: 1px solid var(--line); border-radius: var(--radius-small); padding: .75rem; display: grid; gap: .5rem; background: var(--surface); }
.sentence-card__result { font-size: .95rem; }
.section-list { margin: .25rem 0 .75rem; padding-left: 1.25rem; }
.section-list li { margin-bottom: .2rem; }

/* Räkna (ALFA-24) and Bakgrundspalett (B61) */
.breadcrumb { font-size: .9rem; color: var(--muted); margin-bottom: .35rem; }
.chip-list { list-style: none; padding: 0; margin: 0 0 .5rem; display: flex; flex-wrap: wrap; gap: .4rem .75rem; }
.chip-item { display: inline-flex; align-items: center; gap: .15rem; }
.checkbox { display: flex; gap: .5rem; align-items: flex-start; margin: .35rem 0; }
.palette-swatches label { flex-direction: row; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 4px; border: 2px solid; flex: none; }
.entry-card { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.pv-arith { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--ts) * .5 * var(--u)) calc(var(--ts) * 1.5 * var(--u)); font-size: calc(var(--ts) * var(--u)); }
.pv-arith__box { display: inline-block; min-width: 2.4em; border: 1.5px solid var(--ink-print); border-radius: 3px; text-align: center; font-weight: 700; }
.pv-money { display: flex; gap: calc(4 * var(--u)); margin: calc(6 * var(--u)) 0; font-size: calc(12 * var(--u)); font-weight: 700; }
.pv-coin, .pv-note { display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid var(--ink-print); background: #fff; }
.pv-coin { width: calc(30 * var(--u)); height: calc(30 * var(--u)); border-radius: 50%; }
.pv-note { width: calc(60 * var(--u)); height: calc(30 * var(--u)); border-radius: 3px; }
.pv-money-product { display: inline-block; margin: calc(3 * var(--u)) calc(8 * var(--u)) 0 0; font-size: calc(11 * var(--u)); }
.pv-steps { margin: calc(6 * var(--u)) 0 0; padding-left: calc(20 * var(--u)); font-size: calc(var(--ts) * .8 * var(--u)); }

/* The app scrolls inside .app-main only. The page itself never scrolls, so nothing can push the menu out of view. */
@media screen {
    html:has(.app), html:has(.app) body { height: 100%; overflow: hidden; }
}

.btn--reshuffle { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.recipe-list { list-style: none; padding: 0; margin: 0 0 2rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1rem; }
.recipe-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-small); padding: 1rem; }
.recipe-card h3 { margin-bottom: .25rem; }
.recipe-card__dish { display: block; width: 6rem; height: 6rem; object-fit: contain; margin-bottom: .5rem; }
.recipe-pick { margin: .5rem 0 1rem; padding: 1rem; border: 2px solid var(--primary); border-radius: var(--radius-small); background: var(--primary-soft); }
.recipe-pick__title { margin: 0 0 .75rem; }
.recipe-list--single { grid-template-columns: minmax(0, 32rem); margin-bottom: 0; }
.tool-section { margin-bottom: 1.5rem; }
.tool-cards { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: .75rem; }
.tool-card { display: flex; flex-direction: column; gap: .3rem; height: 100%; padding: .9rem 1rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius-small); background: var(--surface); color: var(--ink); text-decoration: none; }
.tool-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.tool-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tool-card strong { color: var(--primary); font-size: 1.05rem; }
.mini-sheet--image img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }

.btn--fit { justify-self: start; width: auto; margin-top: .35rem; }
/* "Prova utan konto" (B85): one column, readable on a phone. */
.guest { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.guest__form { display: grid; gap: 1rem; margin: 1rem 0; }
.guest__form .btn--primary { justify-self: start; }
.step__sub { font-size: 1rem; margin: 1.25rem 0 .5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* Bildbank (/bilder): one scroll area (the page), sticky filters, 12 pictures per row on wide screens. */
.gallery-filters { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: .75rem 0 .5rem; margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .5rem; }
.gallery-filters__row { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: flex-end; }
.gallery-filters__row .field { margin: 0; }
.gallery__group { margin: 1.25rem 0 .5rem; scroll-margin-top: 7rem; }
.gallery__heading { font-size: 1.1rem; margin: 0 0 .5rem; }
.gallery__grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .5rem; }
.gallery__item { width: 100%; display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .4rem .3rem .5rem; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.gallery__item:hover { border-color: var(--primary); background: var(--primary-soft); }
.gallery__item:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.gallery__item img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 8px; }
.gallery__word { font-weight: 700; font-size: .85rem; line-height: 1.2; overflow-wrap: anywhere; text-align: center; }
.gallery--print img { filter: grayscale(1); }
.gallery-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; background: rgba(12, 18, 36, .55); }
.gallery-dialog__box { display: grid; grid-template-columns: minmax(0, 20rem) minmax(0, 1fr); gap: 1.5rem; max-width: 46rem; width: 100%; max-height: calc(100vh - 2rem); overflow-y: auto; background: var(--surface); color: var(--ink); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.gallery-dialog__image img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.gallery-dialog__info h2 { margin-top: 0; }
.gallery-dialog__facts { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.gallery-dialog__facts dt { font-weight: 700; }
.gallery-dialog__facts dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.gallery-dialog__actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 1200px) { .gallery__grid { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (max-width: 900px) { .gallery__grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 600px) {
    .gallery__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .gallery-filters { position: static; }
    .gallery-dialog__box { grid-template-columns: minmax(0, 1fr); }
}

/* Platsbesparingar (B92) */
.step__summary { font-size: .9rem; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
.more { margin: .25rem 0 .75rem; font-size: .9rem; color: var(--muted); }
.more > summary { cursor: pointer; font-weight: 600; color: var(--ink); width: fit-content; border-radius: 6px; }
.more > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.more > div { margin-top: .35rem; max-width: 48rem; }
.sheet-options { display: flex; flex-wrap: wrap; gap: 0 2rem; align-items: flex-start; }
.sheet-options__item { min-width: 0; flex: 0 1 auto; }
.choice-pair { display: flex; flex-wrap: wrap; gap: 0 2rem; align-items: flex-start; }
.choice-pair > * { min-width: 0; }
.step__toggle { max-width: 100%; }

/* Testa utan inloggning (B93) */
.account-links { display: flex; gap: .35rem; align-items: center; }
.hero__guest { margin: .25rem 0 0; padding: .5rem .8rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); width: fit-content; max-width: 100%; }

/* Toppraden: Meny och konto (B94) */
.top-menu, .account__pop { position: relative; }
.top-menu > summary, .account__pop > summary { list-style: none; cursor: pointer; }
.top-menu > summary::-webkit-details-marker, .account__pop > summary::-webkit-details-marker { display: none; }
.top-menu { margin-left: 1rem; }
/* Skapa fokusplan (B200) next to Meny. */
.top-plan { margin-left: .5rem; white-space: nowrap; }
.top-menu__bars, .top-menu__bars::before, .top-menu__bars::after { display: inline-block; width: 1rem; height: 2px; background: currentColor; border-radius: 2px; position: relative; vertical-align: middle; }
.top-menu__bars::before, .top-menu__bars::after { content: ""; position: absolute; left: 0; }
.top-menu__bars::before { top: -5px; }
.top-menu__bars::after { top: 5px; }
.top-menu__panel, .account__panel { position: absolute; top: calc(100% + .4rem); z-index: 40; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .5rem; }
.top-menu__panel { left: 0; min-width: 15rem; display: flex; flex-direction: column; }
.top-menu__panel a, .account__links a { display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
.top-menu__panel a:hover, .account__links a:hover { background: var(--surface-2); }
.top-menu__panel a.active { background: var(--primary); color: var(--on-primary); }
.account { display: flex; gap: .35rem; align-items: center; }
.account__panel { right: 0; width: min(20rem, calc(100vw - 2rem)); padding: 1rem; }
.account__form .field { margin-bottom: .6rem; }
.account__form input { width: 100%; }
/* Glömt lösenord (B197): a small fold-out under the login form. */
.account__forgot { margin-top: .75rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.account__forgot summary { cursor: pointer; font-size: .95rem; }
.account__forgot .account__form { margin-top: .6rem; }
.account__panel .hint { margin: .5rem 0 0; }
.account__user { display: inline-flex; align-items: center; gap: .45rem; padding: .2rem .7rem .2rem .2rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 700; }
.account__user:hover { border-color: var(--primary); }
.account__user:focus-visible, .top-menu > summary:focus-visible, .account__pop > summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.account__avatar { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-size: .85rem; font-weight: 800; }
.account__who { margin: 0 0 .5rem; }
.account__links { display: flex; flex-direction: column; margin: 0 -.3rem .75rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .35rem 0; }
@media (max-width: 600px) {
    .account__name { display: none; }
    .top-menu { margin-left: .25rem; }
}
.topbar__tools { margin-left: auto; }
.top-menu > summary, .account__pop > summary { white-space: nowrap; }
.hero__guest { width: auto; }

/* Tätare val (B95): rullgardinsmenyer i stället för knappgrupper; reglage och kryssrutor lite mindre. */
.choice-select { margin-bottom: .6rem; }
.choice-select select { width: 100%; }
.switch { padding: .45rem .7rem; gap: .6rem; }
.switch input { width: 2.6rem; height: 1.5rem; }
.switch input::after { width: 1.1rem; height: 1.1rem; }
.switch input:checked::after { transform: translateX(1.1rem); }
.switch-row { margin: .4rem 0; }
.checkbox { margin: .3rem 0; }
.field { margin-bottom: .65rem; }
.gallery-filters__row .field { flex: 1 1 11rem; }
.gallery-filters__row .field:has(#g-style), .gallery-filters__row .field:has(#g-category) { flex: 1 1 14rem; }

/* ---------- Material (B133): Mitt material (blått) och Gruppens material (grönt) ---------- */
.library { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1.25rem; align-items: start; }
.library-box { --box: var(--mine); --box-soft: var(--mine-soft); background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--box); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem 1.2rem; min-width: 0; }
.library-box--group { --box: var(--group); --box-soft: var(--group-soft); }
.library-box__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem .75rem; margin-bottom: .75rem; }
.library-box__title { display: flex; align-items: center; gap: .5rem; margin: 0; font-size: 1.35rem; }
.library-box__symbol { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--box-soft); color: var(--box); border: 2px solid var(--box); font-size: 1rem; font-weight: 700; }
.library-box__tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: .75rem; }
.library-box__tools .field { flex: 1 1 12rem; margin: 0; }
.library-box__foot { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.library-box__count { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; }
.template-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .75rem; }
.template-card { display: flex; flex-direction: column; gap: .3rem; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface); min-width: 0; }
.template-card:hover, .template-card:focus-within { border-color: var(--box); box-shadow: inset 0 0 0 1px var(--box); }
.template-card__thumb { display: block; aspect-ratio: 210 / 297; background: #fff; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.template-card__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.template-card__title { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.template-card__meta { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.badge--group { background: var(--group-soft); color: var(--ink); border-color: var(--group); }
.badge--mine { background: var(--mine-soft); color: var(--ink); border-color: var(--mine); }
.share-panel { border-left: 6px solid var(--group); }
.share-panel__groups { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .4rem; }
.save-status { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; font-weight: 700; }
.save-status--ok { color: var(--success); }
.save-status--busy { color: var(--muted); }
.save-status--error { color: var(--danger); }
.group-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.group-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; align-items: center; padding: .75rem 1rem; border: 1px solid var(--line); border-left: 6px solid var(--group); border-radius: var(--radius-small); background: var(--surface); }
.group-row__name { font-weight: 700; }
.invite-link { font-family: ui-monospace, monospace; font-size: .85rem; word-break: break-all; background: var(--surface-2); padding: .5rem; border-radius: 6px; }
.howto { background: var(--group-soft); border: 1px solid var(--group); border-radius: var(--radius-small); padding: .6rem 1rem; margin-bottom: 1rem; }
.howto ol { margin: .25rem 0 0; padding-left: 1.25rem; }

/* Häften (B143) */
.choice { display: flex; gap: .5rem; align-items: flex-start; margin: .3rem 0; }
.choice input { margin-top: .3rem; }
.booklet-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 24rem); gap: 1.25rem; align-items: start; }
.booklet-layout__preview { position: sticky; top: 1rem; max-height: calc(100vh - 6rem); overflow: auto; }
.booklet-parts { list-style: none; padding: 0; margin: 0 0 1rem; counter-reset: part; }
.booklet-part { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; align-items: center; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .5rem; background: var(--surface); }
.booklet-part::before { counter-increment: part; content: counter(part) "."; font-weight: 700; color: var(--muted); margin-right: .25rem; }
.booklet-part__text { flex: 1 1 12rem; display: flex; flex-direction: column; }
.booklet-part__actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.paper-stack--booklet { display: grid; gap: .75rem; }
.paper--a5 img, .paper--a4 img { width: 100%; height: auto; display: block; }
.paper--blank { display: flex; flex-direction: column; }
.paper__blank { display: flex; align-items: center; justify-content: center; aspect-ratio: 1 / 1.414; border: 2px dashed #9a9a9a; border-radius: 6px; color: #6a6a6a; background: #fff; /* the printed paper is white in both themes */ }
.add-to-booklet { margin-top: .75rem; flex-basis: 100%; }
.fit-result { font-weight: 700; }
@media (max-width: 900px) {
    .booklet-layout { grid-template-columns: 1fr; }
    .booklet-layout__preview { position: static; max-height: none; }
}

/* Tema (B158): opens downwards, at most 10 rows, scrolls. */
.theme-picker__box { position: relative; max-width: 24rem; }
.theme-picker__button { display: flex; justify-content: space-between; align-items: center; gap: .5rem; width: 100%; min-height: 2.75rem; padding: .45rem .75rem; font: inherit; text-align: left; color: var(--ink); background: var(--input-bg, var(--surface)); border: 1.5px solid var(--line-strong); border-radius: var(--radius-small); cursor: pointer; }
.theme-picker__button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-picker__chevron { width: .55rem; height: .55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -.25rem; flex: none; }
.theme-picker__list { position: absolute; z-index: 30; top: calc(100% + .25rem); left: 0; width: 100%; max-height: calc(10 * 2.4rem); overflow-y: auto; margin: 0; padding: .25rem; list-style: none; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius-small); box-shadow: var(--shadow); }
.theme-picker__option { min-height: 2.4rem; display: flex; align-items: center; padding: .3rem .6rem; border-radius: 6px; cursor: pointer; }
.theme-picker__option:hover, .theme-picker__option--active { background: var(--primary-soft); outline: 2px solid var(--primary); outline-offset: -2px; }
.theme-picker__option[aria-selected="true"]::after { content: " ✓"; margin-left: .35rem; font-weight: 700; }
.theme-picker__group { padding: .5rem .6rem .15rem; font-size: .8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
