/* ==========================================================================
   Familjearkivet – designsystem (dokumenterat i docs/DESIGNSYSTEM.md)
   Papper, sepia och bläck. EN accent: cyanotypiblå (blåkopians preussiska blå).
   Rubriker: Newsreader (serif). Gränssnitt: Atkinson Hyperlegible Next (sans,
   ritad för läsbarhet vid nedsatt syn). Båda självhostade, OFL-licens.
   ========================================================================== */

/* ---------- Typsnitt (self-hosted, inga externa anrop) ---------- */
@font-face {
  font-family: "Newsreader";
  /* optisk storlek låst vid 24 (rubrikstorlek) – 58 kB i stället för 132 kB med opsz-axeln (granskning 2026-10-29) */
  src: url("fonts/newsreader-opsz24.woff2") format("woff2-variations"), url("fonts/newsreader-opsz24.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("fonts/newsreader-italic.woff2") format("woff2-variations"), url("fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 200 800; font-style: italic; font-display: swap;
}
/* Reservtypsnitt med samma mått som de riktiga (size-adjust/ascent/descent mätta med fontTools 2026-10-29):
   texten byter typsnitt när filen laddats utan att raderna flyttar sig (CLS 0 även på långsamt nät). */
@font-face {
  font-family: "Atkinson reserv";
  src: local("Arial"), local("Helvetica"), local("Liberation Sans"), local("Arimo");
  size-adjust: 100.2%; ascent-override: 98.2%; descent-override: 31.5%; line-gap-override: 0%;
}
@font-face {
  font-family: "Newsreader reserv";
  src: local("Times New Roman"), local("Times"), local("Liberation Serif"), local("Tinos");
  size-adjust: 102%; ascent-override: 72%; descent-override: 26%; line-gap-override: 0%;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson.woff2") format("woff2-variations"), url("fonts/atkinson.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-italic.woff2") format("woff2-variations"), url("fonts/atkinson-italic.woff2") format("woff2");
  font-weight: 200 800; font-style: italic; font-display: swap;
}

/* ---------- Tokens: ljust läge (papper) ---------- */
:root {
  color-scheme: light;
  /* ytor */
  --paper:       #F3EEE5;   /* sidans bakgrund */
  --paper-deep:  #E8E1D4;   /* nedsänkt yta: bildscen, skelett, tomma rutor */
  --card:        #FBF8F2;   /* upphöjd yta: kort, paneler, menyer */
  --print:       #FFFDF8;   /* fotopapperets vita kant */
  --line:        #DDD3C3;   /* hårfina linjer */
  --line-strong: #BFB19B;   /* fältkanter, avdelare med betydelse */
  /* text */
  --ink:         #27221C;   /* bläck – brödtext, rubriker (≈ 14:1 mot papper) */
  --ink-2:       #5A5146;   /* sekundär text (≈ 7:1) */
  --ink-3:       #7B7062;   /* bara stor text/ikoner (≈ 4,6:1) */
  /* den enda accenten */
  --accent:      #1C5670;   /* cyanotypi – länkar, primärknapp, fokus (≈ 7,6:1) */
  --accent-hover:#143F53;
  --accent-ink:  #FFFFFF;   /* text på accent */
  --accent-soft: #DCE7EA;   /* vald flik, valt chip */
  /* status (används sparsamt, alltid med text) */
  --ok:          #2E6A44;  --ok-soft:   #E1EDE3;
  --warn:        #85560A;  --warn-soft: #F4E7CF;
  --err:         #A12A2A;  --err-soft:  #F6E0DC;
  /* bildscenen i bildvyn */
  --stage:       #E5DDCF;
  --stage-ink:   #27221C;
  --scrim:       rgba(30, 24, 18, .45);
  --mat:         var(--print);                 /* kanten runt bilden i bildvyn */
  --mat-pad:     clamp(5px, .6vw, 9px);

  /* typografi */
  --serif: "Newsreader", "Newsreader reserv", "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans:  "Atkinson Hyperlegible Next", "Atkinson reserv", "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system,
           "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs:  .8125rem;  /* 13 – minsta text, bara etiketter */
  --fs-s:   .9375rem;  /* 15 – metadata */
  --fs-m:   1.0625rem; /* 17 – brödtext */
  --fs-l:   1.3125rem; /* 21 – underrubrik */
  --fs-xl:  1.75rem;   /* 28 – sektionsrubrik */
  --fs-2xl: 2.375rem;  /* 38 – sidrubrik */
  --fs-3xl: clamp(2.5rem, 1.6rem + 3.6vw, 4.25rem); /* hälsningen på startsidan */
  --lh: 1.55;

  /* avstånd (4-punktsskala) */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem; --s8: 4.5rem;
  --gutter: clamp(1rem, .5rem + 2vw, 2.5rem);
  --maxw: 84rem;
  --tap: 44px;            /* minsta klickyta (WCAG 2.5.8 / Apple HIG) */

  /* radier – efter hierarki: foton nästan raka (papperskopior), kontroller mjuka, ark rundade */
  --r-photo: 3px; --r-ctl: 10px; --r-card: 14px; --r-sheet: 22px; --r-pill: 999px;

  /* skuggor – varma, låga */
  --sh-print: 0 1px 1px rgba(60, 44, 24, .10), 0 10px 24px -12px rgba(60, 44, 24, .35);
  --sh-pop:   0 2px 4px rgba(40, 30, 20, .08), 0 18px 40px -16px rgba(40, 30, 20, .40);

  /* rörelse */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 120ms; --t: 220ms; --t-slow: 380ms;

  --header-h: 4rem;
  --bottomnav-h: 4.25rem;
}

/* ---------- Tokens: mörkt läge (mörkrum) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #181512; --paper-deep: #110F0D; --card: #221E1A; --print: #2C2722;
    --line: #36302A; --line-strong: #544B41;
    --ink: #EFE8DC; --ink-2: #B9AE9F; --ink-3: #9A8F81;
    --accent: #8EC4D6; --accent-hover: #B3DAE6; --accent-ink: #0D1B21; --accent-soft: #1F343C;
    --ok: #8FCB9F; --ok-soft: #1E3324; --warn: #E5B65E; --warn-soft: #3A2D16; --err: #F0A097; --err-soft: #3F1F1C;
    --stage: #0E0C0B; --stage-ink: #EFE8DC; --scrim: rgba(0, 0, 0, .6); --mat: transparent; --mat-pad: 0px;
    --sh-print: 0 1px 1px rgba(0, 0, 0, .4), 0 12px 28px -12px rgba(0, 0, 0, .8);
    --sh-pop: 0 2px 4px rgba(0, 0, 0, .3), 0 20px 44px -16px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #181512; --paper-deep: #110F0D; --card: #221E1A; --print: #2C2722;
  --line: #36302A; --line-strong: #544B41;
  --ink: #EFE8DC; --ink-2: #B9AE9F; --ink-3: #9A8F81;
  --accent: #8EC4D6; --accent-hover: #B3DAE6; --accent-ink: #0D1B21; --accent-soft: #1F343C;
  --ok: #8FCB9F; --ok-soft: #1E3324; --warn: #E5B65E; --warn-soft: #3A2D16; --err: #F0A097; --err-soft: #3F1F1C;
  --stage: #0E0C0B; --stage-ink: #EFE8DC; --scrim: rgba(0, 0, 0, .6); --mat: transparent; --mat-pad: 0px;
  --sh-print: 0 1px 1px rgba(0, 0, 0, .4), 0 12px 28px -12px rgba(0, 0, 0, .8);
  --sh-pop: 0 2px 4px rgba(0, 0, 0, .3), 0 20px 44px -16px rgba(0, 0, 0, .8);
}

/* ---------- Bas ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 1rem); }
body {
  margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: var(--fs-m); line-height: var(--lh);
  font-variant-numeric: lining-nums; -webkit-font-smoothing: antialiased;
}
img, video, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.15; margin: 0; text-wrap: balance; letter-spacing: -.005em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-l); }
p { margin: 0 0 var(--s3); max-width: 68ch; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); }
strong { font-weight: 650; }
small, .meta { font-size: var(--fs-s); color: var(--ink-2); }
.muted { color: var(--ink-2); font-size: var(--fs-s); }
code { font-size: .9em; background: var(--paper-deep); padding: .05em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s5) 0; }
::selection { background: var(--accent-soft); }

/* Fokus: alltid synlig vid tangentbord – dubbel ring syns både på papper och på foton */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px;
  box-shadow: 0 0 0 5px var(--paper);
}
.tile:focus-visible, .print:focus-visible { outline-offset: 3px; }

[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
/* små avståndsklasser (CSP tillåter inga style-attribut) */
.mt-1 { margin-top: .4rem; } .mt-2 { margin-top: .6rem; } .mt-4 { margin-top: 1.25rem; } .mt-5 { margin-top: 1.5rem; }
.mt-6 { margin-top: 2rem; } .mb-3 { margin-bottom: .75rem; } .pull-up { margin-top: -.5rem; } .inline { display: inline; }
.subhead { margin: 1.25rem 0 .5rem; font-size: 1.05rem; }
.skip-link {
  position: absolute; left: var(--s4); top: -100px; z-index: 100; padding: var(--s2) var(--s4);
  background: var(--accent); color: var(--accent-ink); border-radius: var(--r-ctl);
}
.skip-link:focus { top: var(--s2); }

/* Ikoner (SVG-sprite i base.html) */
.ic { width: 1.375rem; height: 1.375rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7;
      stroke-linecap: round; stroke-linejoin: round; }
.ic--s { width: 1.125rem; height: 1.125rem; }
.ic--l { width: 1.75rem; height: 1.75rem; }
.ic--fill { fill: currentColor; stroke: none; }

/* ---------- Sidram ---------- */
.page { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: var(--s5) var(--gutter) var(--s8); }
.page--narrow { max-width: 46rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s5);
             margin-bottom: var(--s5); }
.page-head__title { display: flex; flex-direction: column; gap: var(--s1); }
.page-head__sub { color: var(--ink-2); font-size: var(--fs-m); margin: 0; }
.section { margin-top: var(--s7); }
.section:first-child { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); }
.section-head h2 { font-size: var(--fs-xl); }
.section-head__note { color: var(--ink-2); font-size: var(--fs-s); margin: var(--s1) 0 0; }
.section-head a { white-space: nowrap; font-size: var(--fs-s); }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.row--end { justify-content: flex-end; }

/* ---------- Toppmeny ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(10px); backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { height: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter);
                 display: flex; align-items: center; gap: var(--s5); }
.brand { font-family: var(--serif); font-size: 1.45rem; font-weight: 500; color: var(--ink); text-decoration: none;
         letter-spacing: -.01em; white-space: nowrap; display: inline-flex; align-items: center; gap: .55rem; min-height: var(--tap); }
.brand:hover { color: var(--ink); }
.brand__mark { width: 1.6rem; height: 1.6rem; color: var(--accent); }
.mainnav { display: flex; gap: var(--s1); }
.mainnav a {
  display: inline-flex; align-items: center; gap: .45rem; min-height: var(--tap); padding: 0 var(--s3);
  border-radius: var(--r-ctl); color: var(--ink-2); text-decoration: none; font-size: var(--fs-m);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.mainnav a:hover { color: var(--ink); background: var(--paper-deep); }
.mainnav a[aria-current="page"] { color: var(--ink); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.mainnav .ic { width: 1.2rem; height: 1.2rem; }
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }

/* sökfält i toppen (desktop) */
.searchbox { position: relative; display: flex; align-items: center; }
.searchbox .ic { position: absolute; left: .8rem; color: var(--ink-2); pointer-events: none; }
.searchbox input[type="search"] {
  width: 15rem; min-height: var(--tap); padding: 0 var(--s3) 0 2.6rem; border-radius: var(--r-pill);
  background: var(--card); border: 1px solid var(--line); transition: width var(--t) var(--ease), border-color var(--t-fast);
}
.searchbox input[type="search"]:focus { width: 20rem; border-color: var(--accent); }

/* profilmeny: <details> utan JS */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
                  min-height: var(--tap); padding: 0 .35rem 0 .35rem; border-radius: var(--r-pill); }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--paper-deep); }
.menu__name { font-size: var(--fs-s); color: var(--ink-2); }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 15rem; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--sh-pop);
  padding: var(--s2);
}
.menu__panel a, .menu__panel button.menu__item {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: var(--tap); padding: 0 var(--s3);
  border-radius: var(--r-ctl); color: var(--ink); text-decoration: none; background: none; border: 0;
  font: inherit; cursor: pointer; text-align: left;
}
.menu__panel a:hover, .menu__panel button.menu__item:hover { background: var(--paper-deep); }
.menu__panel .ic { color: var(--ink-2); }
.menu__sep { height: 1px; background: var(--line); margin: var(--s2) var(--s2); }
.menu__label { font-size: var(--fs-xs); color: var(--ink-2); padding: var(--s1) var(--s3); }
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 0 var(--s2) var(--s1); }
.theme-pick button { min-height: var(--tap); border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--paper);
                     color: var(--ink); font: inherit; font-size: var(--fs-s); cursor: pointer; }
.theme-pick button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Bottenmeny (mobil) ---------- */
.bottomnav { display: none; }

/* ---------- Brödsmulor ---------- */
.crumbs { font-size: var(--fs-s); color: var(--ink-2); }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; margin: 0; padding: 0; }
.crumbs li { display: inline-flex; align-items: center; gap: .15rem; }
.crumbs li + li::before { content: ""; width: .4rem; height: .4rem; margin: 0 .45rem 0 .25rem;
                          border-right: 1.5px solid var(--ink-3); border-top: 1.5px solid var(--ink-3); transform: rotate(45deg); }
.crumbs a { color: var(--ink-2); text-decoration: none; padding: .35rem 0; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs [aria-current] { color: var(--ink); }

/* ---------- Knappar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); min-width: var(--tap); padding: 0 1.1rem; border-radius: var(--r-ctl);
  font: inherit; font-size: var(--fs-m); font-weight: 600; line-height: 1.1; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--paper-deep); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--accent); font-weight: 600; padding: 0 .7rem; }
.btn--quiet:hover { background: var(--accent-soft); color: var(--accent-hover); }
.btn--ok { background: var(--ok); border-color: var(--ok); color: var(--card); }
.btn--ok:hover { background: color-mix(in srgb, var(--ok) 85%, var(--ink)); color: var(--card); }
.btn--danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, transparent); background: transparent; }
.btn--danger:hover { background: var(--err-soft); color: var(--err); }
.btn--small { min-height: 2.25rem; padding: 0 .8rem; font-size: var(--fs-s); }
.btn--icon { padding: 0; width: var(--tap); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
/* länkliknande knapp i löptext */
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline;
           text-underline-offset: .18em; min-height: auto; }

/* favorit (hjärta) – fyllt när aktivt */
.fav[aria-pressed="true"] { color: var(--err); }
.fav[aria-pressed="true"] .ic { fill: currentColor; }
.fav .ic { transition: transform var(--t) var(--ease); }
.fav.is-pop .ic { transform: scale(1.25); }

/* ---------- Formulär ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: var(--s4); }
.field__label, label.field > span:first-child { font-weight: 600; font-size: var(--fs-s); }
.field__hint { font-size: var(--fs-s); color: var(--ink-2); }
.input, input[type="text"], input[type="search"], input[type="password"], input:not([type]), select, textarea {
  min-height: var(--tap); padding: .55rem .8rem; border-radius: var(--r-ctl);
  border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); max-width: 100%;
}
textarea { min-height: 6rem; resize: vertical; line-height: 1.45; width: 100%; }
select { padding-right: 2.2rem; appearance: none; cursor: pointer;
         background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
         background-position: calc(100% - 1.15rem) 55%, calc(100% - .8rem) 55%; background-size: .35rem .35rem; background-repeat: no-repeat; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
::placeholder { color: var(--ink-3); opacity: 1; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.inline-form > input:not([type="hidden"]), .inline-form > select { flex: 1 1 10rem; min-width: 0; }
input[type="radio"], input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 2.25rem; padding: 0 .85rem;
  border-radius: var(--r-pill); background: var(--card); border: 1px solid var(--line); color: var(--ink);
  font-size: var(--fs-s); text-decoration: none; white-space: nowrap;
}
a.chip:hover { border-color: var(--line-strong); background: var(--paper-deep); color: var(--ink); }
.chip--on, a.chip--on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
a.chip--on:hover { background: var(--accent-hover); color: var(--accent-ink); }
.chip--warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip--ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip__x { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; margin-right: -.55rem; border-radius: 50%;
           border: 0; background: none; color: var(--ink-2); cursor: pointer; font-size: 1.1rem; line-height: 1; }
.chip__x:hover { background: var(--paper-deep); color: var(--err); }
.chip__n { color: var(--ink-2); font-size: var(--fs-xs); }
.chip--on .chip__n { color: inherit; opacity: .8; }

/* ---------- Kort ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s5); }
.card + .card { margin-top: var(--s4); }
.card__title { font-size: var(--fs-l); margin-bottom: var(--s3); }
.card--flat { background: transparent; }

/* utforska-kort (startsidan) */
.explore { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr)); gap: var(--s4); }
.explore__item {
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink); border-radius: var(--r-card);
  background: var(--card); border: 1px solid var(--line); overflow: hidden;
  transition: border-color var(--t-fast) var(--ease), transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.explore__item:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--sh-print); transform: translateY(-2px); }
.explore__cover { aspect-ratio: 3 / 2; background: var(--paper-deep); position: relative; overflow: hidden; display: grid; place-items: center; color: var(--ink-3); }
.explore__cover img { width: 100%; height: 100%; object-fit: cover; }
.explore__cover--face img { width: 58%; height: auto; aspect-ratio: 1; border-radius: 50%; box-shadow: 0 0 0 5px var(--print), var(--sh-print); }
.explore__cover .ic { width: 2.6rem; height: 2.6rem; stroke-width: 1.3; }
.explore__body { padding: var(--s3) var(--s4) var(--s4); display: flex; flex-direction: column; gap: .1rem; }
.explore__title { font-family: var(--serif); font-size: var(--fs-l); font-weight: 500; }
.explore__count { color: var(--ink-2); font-size: var(--fs-s); }

/* ---------- Meddelanden (toast) ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; top: calc(var(--header-h) + .75rem); transform: translateX(-50%);
          width: min(36rem, calc(100% - 2rem)); display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s3); padding: .8rem .8rem .8rem 1rem;
  border-radius: var(--r-card); background: var(--ink); color: var(--paper); box-shadow: var(--sh-pop);
  animation: toast-in var(--t-slow) var(--ease) both;
}
.toast__text { flex: 1; padding-top: .55rem; }
.toast--err { background: var(--err-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--err) 40%, transparent); }
.toast--err .toast__text::before { content: "Det gick inte: "; font-weight: 700; color: var(--err); }
.toast__close { flex: none; width: var(--tap); height: var(--tap); border-radius: var(--r-ctl); border: 0; background: transparent;
                color: inherit; cursor: pointer; display: grid; place-items: center; }
.toast__close:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.toast.is-leaving { animation: toast-out var(--t) var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
/* meddelande i flödet (formulärfel m.m.) */
.notice { padding: .8rem 1rem; border-radius: var(--r-ctl); background: var(--warn-soft); color: var(--ink); margin-bottom: var(--s4); }
.notice--err { background: var(--err-soft); }
.notice--ok { background: var(--ok-soft); }

/* ---------- Dialog ---------- */
dialog.dialog {
  width: min(28rem, calc(100% - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-sheet);
  background: var(--card); color: var(--ink); box-shadow: var(--sh-pop);
}
dialog.dialog::backdrop { background: var(--scrim); }
dialog.dialog[open] { animation: dialog-in var(--t) var(--ease) both; }
.dialog__body { padding: var(--s5) var(--s5) var(--s4); }
.dialog__title { font-size: var(--fs-l); margin-bottom: var(--s2); }
.dialog__actions { display: flex; flex-wrap: wrap-reverse; justify-content: flex-end; gap: var(--s2); padding: 0 var(--s5) var(--s5); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Tomma lägen ---------- */
.empty { text-align: center; max-width: 34rem; margin: var(--s7) auto; padding: var(--s6) var(--s5);
         border: 1px dashed var(--line-strong); border-radius: var(--r-card); }
.empty__icon { width: 3rem; height: 3rem; margin: 0 auto var(--s3); color: var(--ink-3); stroke-width: 1.3; }
.empty__title { font-size: var(--fs-xl); margin-bottom: var(--s2); }
.empty__text { color: var(--ink-2); margin: 0 auto var(--s4); }

/* ---------- Laddningsskelett ---------- */
.skeleton { background: var(--paper-deep); border-radius: var(--r-photo); position: relative; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
                   background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--card) 55%, transparent), transparent);
                   animation: shimmer 1.6s infinite; }
.skeleton--text { height: 1em; border-radius: 4px; width: 60%; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Bildrutnät (kontaktkarta) ----------
   Fasta proportioner: varje ruta är kvadratisk innan bilden laddats → inget hopp (CLS 0). */
.grid { --tile: 10.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr)); gap: 5px; }
.grid--dense { --tile: 6.5rem; gap: 4px; }
.tile {
  position: relative; display: block; aspect-ratio: 1; overflow: hidden; border-radius: var(--r-photo);
  background: var(--paper-deep); color: #fff; text-decoration: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow) var(--ease), filter var(--t) var(--ease); }
.tile:hover img { transform: scale(1.03); }
.tile__badge {
  position: absolute; left: 6px; bottom: 6px; padding: .1rem .45rem; border-radius: 4px; font-size: var(--fs-xs); line-height: 1.5;
  background: rgba(24, 20, 16, .72); color: #FFF8EC; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.tile__badge--warn { background: rgba(248, 232, 204, .92); color: #5C3B05; }
.tile__video { position: absolute; right: 6px; top: 6px; display: inline-flex; align-items: center; gap: .25rem;
               padding: .1rem .45rem .1rem .3rem; border-radius: 4px; background: rgba(24, 20, 16, .72); color: #FFF8EC; font-size: var(--fs-xs); }
.tile__video .ic { width: .9rem; height: .9rem; }
.tile__cap { position: absolute; inset: auto 0 0 0; padding: 1.6rem .6rem .5rem; color: #FFF8EC; font-size: var(--fs-s);
             background: linear-gradient(transparent, rgba(20, 16, 12, .78)); }
.tile--empty { display: grid; place-items: center; color: var(--ink-3); }

/* remsa: en rad rutor, vågrät rullning på smal skärm */
.strip { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 7 * 6px) / 8); gap: 6px; }
.strip > .tile { scroll-snap-align: start; }

/* stora rutor (Återupptäck): fyra i bredd, 4:3 */
.strip--large { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-columns: auto; gap: 8px; }
.strip--large > .tile { aspect-ratio: 4 / 3; }

/* ---------- Papperskopior (startsidans minnen, bildvyn) ---------- */
.print {
  display: block; background: var(--print); padding: 7px 7px 7px; border-radius: 2px; box-shadow: var(--sh-print);
  text-decoration: none; color: var(--ink); transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}
.print img { display: block; height: 100%; width: auto; background: var(--paper-deep); }
a.print:hover { transform: translateY(-3px); color: var(--ink); }

/* ---------- Personcirklar ---------- */
.avatar { --size: 3.5rem; width: var(--size); height: var(--size); flex: none; border-radius: 50%; overflow: hidden; display: inline-grid;
          place-items: center; background: var(--paper-deep); color: var(--ink-2); font-family: var(--serif); font-size: calc(var(--size) * .38); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--s { --size: 2.25rem; }
.avatar--l { --size: 6rem; }
.avatar--xl { --size: 8.5rem; box-shadow: 0 0 0 6px var(--print), var(--sh-print); }
.avatar--me { --size: 2.25rem; background: var(--accent); color: var(--accent-ink); font-family: var(--sans); font-weight: 700; font-size: .95rem; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--s5) var(--s4); }
.person-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .55rem; text-decoration: none; color: var(--ink); }
.person-card .avatar { --size: 100%; aspect-ratio: 1; max-width: 8.5rem; height: auto; transition: box-shadow var(--t) var(--ease); }
.person-card:hover { color: var(--ink); }
.person-card:hover .avatar { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent); }
.person-card__name { font-family: var(--serif); font-size: var(--fs-l); line-height: 1.2; }
.person-card__meta { color: var(--ink-2); font-size: var(--fs-s); margin-top: -.35rem; }
.person-card--unnamed .person-card__name { font-family: var(--sans); font-size: var(--fs-s); color: var(--ink-2); }

/* ---------- Sidindelning ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin: var(--s6) 0 0; flex-wrap: wrap; }
.pager__info { color: var(--ink-2); font-size: var(--fs-s); min-width: 8rem; text-align: center; }

/* ---------- Flikar ---------- */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); margin-bottom: var(--s5); overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: .45rem; min-height: var(--tap); padding: 0 var(--s4); white-space: nowrap;
          color: var(--ink-2); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.count { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .4rem; border-radius: var(--r-pill);
         background: var(--paper-deep); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; }

/* ==========================================================================
   STARTSIDAN
   ========================================================================== */
.hello { padding: var(--s6) 0 var(--s5); }
.hello__date { font-family: var(--serif); font-style: italic; font-size: var(--fs-l); color: var(--ink-2); margin: 0 0 var(--s2); }
.hello h1 { font-size: var(--fs-3xl); font-weight: 400; letter-spacing: -.02em; line-height: 1.02; }
.hello__lead { font-size: var(--fs-l); color: var(--ink-2); margin: var(--s4) 0 0; max-width: 40ch; line-height: 1.4; }

/* minnen: papperskopior på bordet, grupperade per år */
.memories { display: flex; gap: var(--s6); overflow-x: auto; padding: var(--s2) var(--s1) var(--s5); margin: 0 calc(-1 * var(--s1));
            scroll-snap-type: x proximity; scrollbar-width: thin; }
.memory { flex: none; scroll-snap-align: start; }
.memory__prints { display: flex; gap: var(--s4); align-items: flex-end; height: 15rem; }
.memory__prints .print { height: 100%; }
.memory__prints .print:first-child { height: 100%; }
.memory__prints .print:not(:first-child) { height: 78%; }
.memory__year { display: flex; align-items: baseline; gap: var(--s3); margin-top: var(--s3); }
.memory__year b { font-family: var(--serif); font-weight: 500; font-size: var(--fs-xl); font-variant-numeric: oldstyle-nums; }
.memory__year span { color: var(--ink-2); font-size: var(--fs-s); }

/* ==========================================================================
   TIDSLINJEN – tidsaxel (räls), årtionden, år, grupperade rutnät
   ========================================================================== */
.with-rail { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: var(--s6); align-items: start; }
.tl-head .crumbs { margin-bottom: var(--s2); }
.tl-title { font-size: clamp(2.375rem, 1.9rem + 1.6vw, 3.25rem); font-weight: 400; letter-spacing: -.015em; }
.tl-title__soft { color: var(--ink-3); font-weight: 300; }
.stepper { display: flex; gap: var(--s2); }

/* rälsen: en lodrät tidsaxel – årtionden med åren för det valda årtiondet utfällda */
.rail { position: sticky; top: calc(var(--header-h) + var(--s4)); max-height: calc(100vh - var(--header-h) - 2rem); overflow: auto;
        scrollbar-width: thin; padding: 0 var(--s2) var(--s4) 0; }
.rail__title { font-size: var(--fs-xs); color: var(--ink-2); margin: var(--s5) 0 var(--s1) var(--s3); text-transform: uppercase; letter-spacing: .08em; }
.rail__title:first-child { margin-top: 0; }
.rail a { position: relative; display: flex; justify-content: space-between; align-items: center; gap: var(--s2); min-height: 2.5rem;
          padding: 0 var(--s3); border-radius: var(--r-ctl); color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums; }
.rail a:hover { background: var(--paper-deep); color: var(--ink); }
.rail a[aria-current="true"] { background: var(--accent-soft); font-weight: 650; }
.rail__n { color: var(--ink-2); font-size: var(--fs-xs); font-weight: 400; }
.rail__decade .rail__label { font-family: var(--serif); font-size: 1.2rem; }
.rail__group.is-open > .rail__decade { color: var(--accent); }
/* åren hänger på en tunn tidslinje under årtiondet */
.rail__years { position: relative; margin: var(--s1) 0 var(--s2) var(--s4); padding-left: var(--s2); border-left: 2px solid var(--line); }
.rail__years a { min-height: 2.25rem; padding-left: var(--s3); }
.rail__years a::before { content: ""; position: absolute; left: calc(-1 * var(--s2) - 5px); top: 50%; width: 8px; height: 8px; margin-top: -4px;
                         border-radius: 50%; background: var(--paper); border: 2px solid var(--line-strong); }
.rail__years a[aria-current="true"]::before { background: var(--accent); border-color: var(--accent); }
.rail__year { font-family: var(--serif); font-size: 1.1rem; }
.rail a.rail__src { min-height: 2.25rem; font-size: var(--fs-s); color: var(--ink-2); }
.rail a.rail__src[aria-current="true"] { background: none; color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.rail__all .rail__label, .rail__unknown .rail__label { font-weight: 600; font-size: var(--fs-s); }
.rail__unknown { margin-top: var(--s2); }
.filterbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s5); }

/* årtionden: kontaktark med en stor bild och tre små, årtalet i serif */
.decades { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr)); gap: var(--s5) var(--s4); }
.decade { display: flex; flex-direction: column; gap: var(--s3); text-decoration: none; color: var(--ink); }
.decade:hover { color: var(--ink); }
.decade__sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; background: var(--print); border-radius: 3px;
                 box-shadow: var(--sh-print); transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease); }
.decade__sheet img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--paper-deep); border-radius: 1px; }
.decade__sheet img:first-child { grid-column: 1 / -1; aspect-ratio: 3 / 2; }
/* färre än fyra bilder: en kvadratisk bild – lika hög som kontaktarket (3:2 + en rad med tre) */
.decade__sheet--1 img:first-child, .decade__sheet--2 img:first-child, .decade__sheet--3 img:first-child { aspect-ratio: 1 / 1.003; }
.decade__sheet--2 img + img, .decade__sheet--3 img + img { display: none; }
.decade__sheet--0 { aspect-ratio: 1; place-items: center; grid-template-columns: 1fr; background: var(--paper-deep); box-shadow: none;
                    border: 1px dashed var(--line-strong); color: var(--ink-3); }
.decade__sheet--0 .ic { width: 2.6rem; height: 2.6rem; stroke-width: 1.3; }
.decade:hover .decade__sheet { transform: translateY(-3px) rotate(-.4deg); }
.decade:nth-child(even):hover .decade__sheet { transform: translateY(-3px) rotate(.4deg); }
.decade__body { display: flex; flex-direction: column; gap: .1rem; padding: 0 var(--s1); }
.decade__title { font-family: var(--serif); font-size: var(--fs-xl); line-height: 1.1; font-variant-numeric: oldstyle-nums; }
.decade__title span { color: var(--ink-2); }   /* ink-3 räcker bara för stor text (mobil: 21 px → för litet) */
.decade--unknown .decade__title { font-size: var(--fs-l); padding-top: .35rem; }
.decade__meta { color: var(--ink-2); font-size: var(--fs-s); }
.tl-decades { margin-bottom: var(--s7); }

/* år inom ett årtionde */
.years { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: var(--s3); margin-bottom: var(--s6); }
.year-card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: var(--s3); align-items: center;
             padding: var(--s2); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); text-decoration: none;
             color: var(--ink); transition: border-color var(--t-fast), box-shadow var(--t); }
.year-card:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--sh-print); }
.year-card__img { grid-row: 1 / 3; width: 3rem; height: 3rem; border-radius: var(--r-photo); overflow: hidden; background: var(--paper-deep); }
.year-card__img img { width: 100%; height: 100%; object-fit: cover; }
.year-card__y { font-family: var(--serif); font-size: var(--fs-l); line-height: 1.1; align-self: end; }
.year-card__n { color: var(--ink-2); font-size: var(--fs-xs); align-self: start; }

/* grupperat rutnät med klistrade datumrubriker */
.groups { display: flex; flex-direction: column; gap: var(--s5); }
.group__head {
  position: sticky; top: var(--sticky-top, var(--header-h)); z-index: 5; display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem var(--s3);
  margin: 0 calc(-1 * var(--s2)) var(--s2); padding: var(--s2) var(--s2);
  background: var(--paper); font-size: var(--fs-l); font-weight: 500;
}
.group__head time { font-family: var(--serif); }
.group__sub { font-family: var(--sans); font-size: var(--fs-s); color: var(--ink-2); font-weight: 400; }
/* kontaktark: små grupper bredvid varandra; större grupper tar hela bredden */
.groups--flow { flex-direction: row; flex-wrap: wrap; column-gap: var(--s5); row-gap: var(--s5); }
.groups--flow > .group { flex: 1 1 100%; min-width: 0; }
.groups--flow > .group--small { flex: 0 1 auto; max-width: 100%; }
/* rutorna får krympa så att en grupp om fyra aldrig blir bredare än skärmen (mobil) */
.groups--flow > .group--small > .grid { grid-template-columns: repeat(var(--n, 4), minmax(0, var(--tile))); }
.group--n1 { --n: 1; } .group--n2 { --n: 2; } .group--n3 { --n: 3; } .group--n4 { --n: 4; }
.groups--flow > .group--small > .group__head { margin-right: 0; }
.legend { display: flex; gap: var(--s3); align-items: flex-start; max-width: none; margin: 0 0 var(--s4); padding: var(--s3) var(--s4);
          background: var(--card); border: 1px solid var(--line); border-radius: var(--r-ctl); font-size: var(--fs-s); color: var(--ink-2); }
.legend b { color: var(--ink); font-weight: 650; }
.legend__badge { position: static; flex: none; margin-top: .1rem; }
.more { display: flex; flex-direction: column; align-items: center; gap: var(--s2); margin: var(--s6) 0 0; }
.more--prev { margin: 0 0 var(--s4); align-items: flex-start; }
.more__btn { min-width: 14rem; }
.more__btn.is-loading { opacity: .65; }
.more__btn.is-loading .more__ic { animation: nudge 0.9s var(--ease) infinite; }
.more__end { color: var(--ink-2); font-size: var(--fs-s); font-family: var(--serif); font-style: italic; }
@keyframes nudge { 50% { transform: translateX(4px); } }

/* ==========================================================================
   BILDVYN
   ========================================================================== */
.page.viewer-page { padding: 0; max-width: none; }
.viewer-bar { display: flex; align-items: center; gap: var(--s3); min-height: 3.75rem; padding: var(--s2) var(--gutter);
              border-bottom: 1px solid var(--line); background: var(--paper); flex-wrap: wrap; }
.viewer-bar__back { display: inline-flex; align-items: center; gap: .3rem; font-weight: 600; text-decoration: none;
                    min-height: var(--tap); padding: 0 .7rem 0 .35rem; border-radius: var(--r-ctl); }
.viewer-bar__back:hover { background: var(--accent-soft); }
.viewer-bar__back .short { display: none; }
.viewer-bar .crumbs { flex: 1; min-width: 0; }
.viewer-bar__actions { display: flex; gap: var(--s1); margin-left: auto; }
.viewer-bar__actions .btn--quiet { color: var(--ink); font-weight: 500; }
.viewer-bar__actions .btn--quiet:hover { color: var(--ink); background: var(--paper-deep); }
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 24rem; min-height: calc(100vh - var(--header-h) - 3.75rem); }
.viewer.is-panel-hidden { grid-template-columns: minmax(0, 1fr) 0; }
.viewer.is-panel-hidden .panel { display: none; }

.stage { position: relative; background: var(--stage); color: var(--stage-ink); overflow: hidden; display: grid; place-items: center;
         min-height: 62vh; padding: clamp(1rem, 3vw, 3rem) clamp(3.5rem, 6vw, 6rem); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.stage__frame { position: relative; width: 100%; max-height: var(--img-maxh); display: grid; place-items: center; }
.stage { --img-maxh: calc(100vh - var(--header-h) - 3.75rem - 2 * clamp(1rem, 3vw, 3rem)); }
/* bilden som papperskopia i ljust läge, fritt i mörkt */
.stage__img {
  display: block; width: auto; height: auto; max-width: 100%; max-height: var(--img-maxh);
  background: var(--mat); padding: var(--mat-pad); box-shadow: var(--sh-print); border-radius: 2px;
  object-fit: contain; transform-origin: 0 0; will-change: transform; cursor: zoom-in;
}
/* Känt bildförhållande (--ar sätts i sidans <style nonce>): bredden är bestämd innan bilden laddats → inget
   layouthopp (CLS 0). Bredden = det som får plats på bredden eller höjden, höjden följer förhållandet. */
.stage__img[data-ar] { width: min(100%, calc(var(--img-maxh) * var(--ar))); height: auto; aspect-ratio: var(--ar); }
.stage video.stage__img { cursor: auto; }
.stage.is-zoomed .stage__img { cursor: grab; }
.stage.is-panning .stage__img { cursor: grabbing; }
.stage__nav {
  position: absolute; top: 50%; z-index: 2; transform: translateY(-50%); width: 3.5rem; height: 3.5rem; border-radius: 50%;
  display: grid; place-items: center; color: var(--stage-ink); text-decoration: none;
  background: color-mix(in srgb, var(--card) 70%, transparent); border: 1px solid color-mix(in srgb, var(--stage-ink) 15%, transparent);
  transition: background var(--t-fast), opacity var(--t);
}
.stage__nav:hover { background: var(--card); color: var(--ink); }
.stage__nav--prev { left: clamp(.5rem, 1.5vw, 1.25rem); }
.stage__nav--next { right: clamp(.5rem, 1.5vw, 1.25rem); }
.stage__nav .ic { width: 1.6rem; height: 1.6rem; }
.stage.is-zoomed .stage__nav { opacity: 0; pointer-events: none; }
.stage__hint { position: absolute; left: 50%; bottom: .75rem; transform: translateX(-50%); font-size: var(--fs-xs);
               color: color-mix(in srgb, var(--stage-ink) 70%, transparent); white-space: nowrap; pointer-events: none; }
.stage__status { position: absolute; top: .75rem; left: 50%; transform: translateX(-50%); z-index: 3; }

/* helskärm: alltid svart scen, bara bilden */
.stage:fullscreen { background: #000; padding: 0; --stage-ink: #EEE; }
.stage:fullscreen { --img-maxh: 100vh; }
.stage:fullscreen .stage__img { background: none; padding: 0; box-shadow: none; }
.stage.is-fs-fallback { position: fixed; inset: 0; z-index: 90; background: #000; padding: 0; --stage-ink: #EEE; }
.stage.is-fs-fallback { --img-maxh: 100vh; }
.stage.is-fs-fallback .stage__img { background: none; padding: 0; box-shadow: none; }
.stage .stage__exit { display: none; position: absolute; top: .75rem; right: .75rem; z-index: 3; }
.stage:fullscreen .stage__exit, .stage.is-fs-fallback .stage__exit { display: inline-flex; }

/* infopanelen */
.panel { background: var(--card); border-left: 1px solid var(--line); padding: var(--s5) var(--s5) var(--s7); overflow-y: auto;
         max-height: calc(100vh - var(--header-h) - 3.75rem); position: sticky; top: var(--header-h); }
.panel .panel__handle, .panel .panel__close { display: none; }
.panel__date { font-family: var(--serif); font-size: 1.6rem; font-weight: 500; line-height: 1.2; display: block; }
.panel__time { display: block; font-family: var(--sans); font-size: var(--fs-m); color: var(--ink-2); margin-top: .15rem; }
.panel__source { color: var(--ink-2); font-size: var(--fs-s); margin: var(--s1) 0 0; }
.panel section { padding: var(--s5) 0; border-top: 1px solid var(--line); }
.panel section:first-of-type { border-top: 0; padding-top: 0; }
.panel h2 { font-size: var(--fs-l); margin-bottom: var(--s3); display: flex; align-items: baseline; gap: var(--s2); }
.panel h2 .count { font-family: var(--sans); }
.panel details > summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: var(--tap); display: inline-flex; align-items: center; }
.panel details[open] > summary { margin-bottom: var(--s2); }
.facerow { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); align-items: start; padding: var(--s3) 0; }
.facerow + .facerow { border-top: 1px dashed var(--line); }
.facerow__name { font-weight: 650; }
.facerow__name a { color: var(--ink); text-decoration: none; }
.facerow__name a:hover { color: var(--accent); text-decoration: underline; }
.facerow__status { color: var(--ink-2); font-size: var(--fs-s); }
.facerow__actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.facerow__actions form { margin: 0; }
.facerow select { width: 100%; margin-top: var(--s2); font-size: var(--fs-s); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .3rem var(--s4); margin: 0 0 var(--s4); font-size: var(--fs-s); }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.25rem, 1fr)); gap: 4px; }
.mini-grid .tile--keep { box-shadow: 0 0 0 2px var(--ok); }

/* relaterat */
.related { max-width: var(--maxw); margin: 0 auto; padding: var(--s6) var(--gutter) var(--s8); }
.related .section { margin-top: var(--s6); }
.related .section:first-child { margin-top: 0; }
.related .grid { --tile: 8.5rem; }

/* ==========================================================================
   ÖVRIGA VYER (personer, sortering, inloggning)
   ========================================================================== */
.pairs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: var(--s4); }
.pair { border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s4); background: var(--card); display: flex; flex-direction: column; gap: var(--s3); }
.pair__people { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; }
.pair__person { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--ink); flex: 1 1 11rem; min-width: 0; }
.pair__person span { display: flex; flex-direction: column; font-size: var(--fs-s); }
.pair__person b { font-weight: 650; font-size: var(--fs-m); overflow-wrap: anywhere; }
.pair__actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.pair__actions .muted { margin-left: auto; }
.facegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: var(--s4); }
.faceitem { display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center; text-decoration: none; color: var(--ink); }
.faceitem img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; background: var(--paper-deep); }
.faceitem__meta { font-size: var(--fs-xs); color: var(--ink-2); }
.faceitem .row { justify-content: center; }
.profile { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s5); align-items: center; margin-bottom: var(--s6); }
.profile__name { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.profile__name input { font-family: var(--serif); font-size: var(--fs-xl); min-height: 3.25rem; padding: .2rem .7rem; flex: 1 1 14rem;
                       background: transparent; border-color: transparent; border-bottom: 1px dashed var(--line-strong); border-radius: var(--r-ctl) var(--r-ctl) 0 0; }
.profile__name input:hover, .profile__name input:focus-visible { background: var(--card); border-color: var(--line-strong); border-radius: var(--r-ctl); }
.toolbox { margin-top: var(--s3); }
.toolbox > summary { cursor: pointer; color: var(--accent); font-weight: 600; min-height: var(--tap); display: inline-flex; align-items: center; }
.toolbox__body { display: flex; flex-wrap: wrap; gap: var(--s3); padding: var(--s3) 0; }
.dupgroup { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)); gap: var(--s4); margin: var(--s4) 0; }
.dup { display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-s); }
.dup .tile { aspect-ratio: 1; }
.dup__pick { display: flex; align-items: center; gap: var(--s2); font-weight: 600; min-height: var(--tap); cursor: pointer; }
.dup__meta { color: var(--ink-2); font-size: var(--fs-xs); overflow-wrap: anywhere; line-height: 1.45; }
.folder { display: grid; gap: var(--s3); }
.hidden-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: var(--s4) var(--s3); }
.hidden-item { display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.hidden-item > .tile { width: 100%; opacity: .8; }
.toast__action { margin: .2rem 0; }
.toast__action .btn { min-height: 2.5rem; background: var(--paper); color: var(--ink); border-color: transparent; }
.folder__name { font-weight: 650; overflow-wrap: anywhere; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--gutter); }
.login { width: min(24rem, 100%); }
.login__brand { text-align: center; margin-bottom: var(--s6); }
.login__brand .brand__mark { width: 3rem; height: 3rem; margin: 0 auto var(--s3); }
.login__brand h1 { font-size: var(--fs-2xl); font-weight: 400; }
.login__brand p { color: var(--ink-2); margin: var(--s2) auto 0; }
.login .btn { width: 100%; margin-top: var(--s2); }
.login input { width: 100%; }

body.plain .page { min-height: 100vh; display: grid; place-items: center; }

/* ---------- Chips: tillägg (del 2) ---------- */
.chip--off { color: var(--ink-3); background: transparent; border-style: dashed; }
.chip--soft { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.chip--soft .ic { color: var(--accent); }
.chip--person { padding-left: .25rem; }
.chip--person .avatar { --size: 1.75rem; font-size: .7rem; }
.chip__link { display: inline-flex; align-items: center; gap: .35rem; color: inherit; text-decoration: none; }
.chip__link:hover { color: var(--accent); text-decoration: underline; }
.avatar--m { --size: 3rem; }
.avatar--hero { --size: clamp(9rem, 7rem + 6vw, 13.5rem); box-shadow: 0 0 0 7px var(--print), var(--sh-print); font-size: calc(var(--size) * .32); }

/* ==========================================================================
   PERSONER – lista, profil, släkt, över tid
   ========================================================================== */
.people-search { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); max-width: 32rem; margin-bottom: var(--s6); }
.people-search > .ic { position: absolute; left: .9rem; top: calc(var(--tap) / 2 - .6875rem); color: var(--ink-2); pointer-events: none; }
.people-search input { flex: 1 1 14rem; padding-left: 2.7rem; border-radius: var(--r-pill); }
.js .people-search [data-filter-submit] { display: none; }
.people-search__none { flex-basis: 100%; margin: var(--s2) 0 0; }
.people--named { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: var(--s6) var(--s5); }
.people--named .avatar { box-shadow: 0 0 0 5px var(--print), var(--sh-print); }
.people--unnamed { grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: var(--s4) var(--s3); }
.people--unnamed .avatar { max-width: 6.5rem; opacity: .92; }
.people--row { grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); }
.person-card__meta { font-variant-numeric: tabular-nums; }
.person-card__years { font-family: var(--serif); color: var(--ink-2); font-size: var(--fs-m); margin-top: -.45rem; font-variant-numeric: oldstyle-nums; }
.person-card__years + .person-card__meta { margin-top: -.6rem; }

.profile-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s6); align-items: start; margin: var(--s5) 0 var(--s6); }
.profile-hero__face { padding-top: var(--s2); }
.profile-hero__body { min-width: 0; padding-top: var(--s3); }
.profile-hero .profile__name input { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.9rem); font-weight: 400; min-height: 3.75rem; padding-left: .25rem; }
.profile-hero__life { display: flex; flex-wrap: wrap; gap: .2rem var(--s4); align-items: baseline; margin: var(--s1) 0 0 .25rem; color: var(--ink-2); }
.profile-hero__years { font-family: var(--serif); font-size: var(--fs-l); color: var(--ink); font-variant-numeric: oldstyle-nums; }
.profile-hero__meta { color: var(--ink-2); font-size: var(--fs-s); margin: var(--s2) 0 0 .25rem; }
.profile-hero__actions { margin-top: var(--s4); }
.bio { margin: var(--s4) 0 0 .25rem; max-width: 62ch; font-family: var(--serif); font-size: 1.2rem; line-height: 1.55; }
.bio p { margin: 0 0 var(--s3); }
.bio p:first-child::first-letter { font-size: 2.6em; float: left; line-height: .9; padding: .06em .08em 0 0; color: var(--accent); }
.details-form { display: grid; gap: 0; max-width: 40rem; padding: var(--s3) 0; }
.details-form__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.details-form .btn { justify-self: start; }
.review { margin-bottom: var(--s6); }

.profile-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s6); align-items: start; }
.profile-grid > .section { margin-top: var(--s6); }
.kin__groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: var(--s4) var(--s5); }
.kin__title { font-family: var(--sans); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .08em;
              color: var(--ink-2); margin-bottom: var(--s2); }
.kin__list, .together__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s1); }
.kin__item { display: flex; align-items: center; gap: var(--s1); }
.kin__person { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3); padding: var(--s1) var(--s2) var(--s1) var(--s1);
               border-radius: var(--r-pill); color: var(--ink); text-decoration: none; transition: background var(--t-fast); }
.kin__person:hover { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.kin__person span:last-child { display: flex; flex-direction: column; min-width: 0; }
.kin__person b { font-weight: 600; font-family: var(--serif); font-size: var(--fs-l); line-height: 1.2; overflow-wrap: anywhere; }
.kin__person small { color: var(--ink-2); font-size: var(--fs-s); }
.kin__remove { display: grid; place-items: center; width: var(--tap); height: var(--tap); border: 0; border-radius: 50%; background: none;
               color: var(--ink-3); cursor: pointer; }
.kin__remove:hover { background: var(--err-soft); color: var(--err); }
.kin__derived { font-size: var(--fs-xs); color: var(--ink-3); padding-right: var(--s2); white-space: nowrap; }
.rel-form { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; padding: var(--s3) 0; }
.rel-form .field { margin: 0; flex: 1 1 10rem; }
.rel-form .field span { font-weight: 400; color: var(--ink-2); }

/* år-staplar: när personen finns i arkivet */
.yearbars { display: flex; align-items: flex-end; gap: 2px; height: 7.5rem; padding-bottom: 1.6rem; overflow-x: auto; scrollbar-width: thin; }
.yearbar { position: relative; flex: 1 0 .55rem; max-width: 2.25rem; height: 100%; display: flex; align-items: flex-end; text-decoration: none; }
.yearbar__bar { width: 100%; height: max(var(--h), 3px); background: var(--accent); opacity: .78; border-radius: 2px 2px 0 0;
                transition: opacity var(--t-fast), transform var(--t-fast); transform-origin: bottom; }
.yearbar--h0 { --h: 0%; } .yearbar--h5 { --h: 5%; } .yearbar--h10 { --h: 10%; } .yearbar--h15 { --h: 15%; }
.yearbar--h20 { --h: 20%; } .yearbar--h25 { --h: 25%; } .yearbar--h30 { --h: 30%; } .yearbar--h35 { --h: 35%; }
.yearbar--h40 { --h: 40%; } .yearbar--h45 { --h: 45%; } .yearbar--h50 { --h: 50%; } .yearbar--h55 { --h: 55%; }
.yearbar--h60 { --h: 60%; } .yearbar--h65 { --h: 65%; } .yearbar--h70 { --h: 70%; } .yearbar--h75 { --h: 75%; }
.yearbar--h80 { --h: 80%; } .yearbar--h85 { --h: 85%; } .yearbar--h90 { --h: 90%; } .yearbar--h95 { --h: 95%; }
.yearbar--h100 { --h: 100%; }
.yearbar--zero .yearbar__bar { height: 3px; background: var(--line); opacity: 1; }
.yearbar:hover .yearbar__bar, .yearbar:focus-visible .yearbar__bar { opacity: 1; background: var(--accent-hover); }
.yearbar__y { position: absolute; top: calc(100% + .3rem); left: 50%; transform: translateX(-50%); font-size: var(--fs-xs); color: var(--ink-2);
              font-variant-numeric: tabular-nums; display: none; white-space: nowrap; }
.yearbar--tick .yearbar__y, .yearbar:hover .yearbar__y { display: block; }
.yearbar--first .yearbar__y { left: 0; transform: none; }
.yearbar--last .yearbar__y { left: auto; right: 0; transform: none; }
.yearbar:hover .yearbar__y { color: var(--ink); font-weight: 650; z-index: 1; background: var(--paper); padding: 0 .2rem; }
.tabs--inline { border-bottom: 0; margin: 0; }
.tabs--inline a { min-height: 2.5rem; padding: 0 var(--s3); font-size: var(--fs-s); }

/* ==========================================================================
   SÖK – fält, förslag, tolkning, filter, textträffar
   ========================================================================== */
.search-form { display: flex; gap: var(--s2); align-items: flex-start; max-width: 44rem; margin-bottom: var(--s4); }
.search-form__field { position: relative; flex: 1; min-width: 0; }
.search-form__field > .ic { position: absolute; left: .95rem; top: calc(3.25rem / 2 - .6875rem); color: var(--ink-2); pointer-events: none; }
.search-form input[type="search"] { width: 100%; min-height: 3.25rem; padding-left: 2.9rem; font-size: var(--fs-l); border-radius: var(--r-pill); }
.search-form .btn { min-height: 3.25rem; padding: 0 1.4rem; border-radius: var(--r-pill); }

.suggest { position: absolute; z-index: 45; left: 0; right: 0; top: calc(100% + .35rem); max-height: min(28rem, 70vh); overflow-y: auto;
           background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--sh-pop); padding: var(--s2); }
.suggest--top { left: auto; width: 24rem; }
.suggest__group + .suggest__group { border-top: 1px solid var(--line); margin-top: var(--s1); padding-top: var(--s1); }
.suggest__title { font-size: var(--fs-xs); color: var(--ink-2); padding: var(--s1) var(--s3); text-transform: uppercase; letter-spacing: .08em; }
.suggest__item { display: flex; align-items: center; gap: var(--s3); min-height: var(--tap); padding: .3rem var(--s3); border-radius: var(--r-ctl);
                 color: var(--ink); text-decoration: none; }
.suggest__item:hover, .suggest__item[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); }
.suggest__body { display: flex; flex-direction: column; min-width: 0; }
.suggest__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__sub { font-size: var(--fs-xs); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__all { margin-top: var(--s1); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-ctl) var(--r-ctl); color: var(--accent); font-weight: 600; }

.interp { margin: 0 0 var(--s4); }
.interp__line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0; max-width: none; }
.interp__label { color: var(--ink-2); font-size: var(--fs-s); }
.interp__fix { margin: 0 0 var(--s2); }
.facets { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); padding: var(--s3) 0 var(--s4); margin-bottom: var(--s5); border-bottom: 1px solid var(--line); }
.facets__group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.facets__label { font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin-right: var(--s1); }
.search-people .people { margin-bottom: 0; }
.texthits { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: var(--s3); }
.texthit { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s2); border-radius: var(--r-card); background: var(--card);
           border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color var(--t-fast), box-shadow var(--t); }
.texthit:hover { color: var(--ink); border-color: var(--line-strong); box-shadow: var(--sh-print); }
.texthit__img { flex: none; width: 4.5rem; height: 4.5rem; border-radius: var(--r-photo); overflow: hidden; background: var(--paper-deep); }
.texthit__img img { width: 100%; height: 100%; object-fit: cover; }
.texthit__body { display: flex; flex-direction: column; gap: .15rem; min-width: 0; padding-top: .1rem; }
.texthit__label { font-size: var(--fs-xs); color: var(--ink-2); }
.texthit__text { font-size: var(--fs-s); line-height: 1.45; overflow-wrap: anywhere; }
mark { background: color-mix(in srgb, var(--warn) 22%, transparent); color: inherit; padding: 0 .1em; border-radius: 2px; }
.ideas { display: grid; gap: var(--s5); }
.ideas__title { font-family: var(--sans); font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .08em;
                color: var(--ink-2); margin-bottom: var(--s2); }

/* album */
.album-hero { display: flex; align-items: flex-end; gap: var(--s5); margin: var(--s3) 0 var(--s6); }
.album-hero__cover { width: 8.5rem; flex: none; transform: rotate(-1.5deg); }
.album-hero__cover img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }

/* ==========================================================================
   SMAL SKÄRM (mobil) – bottenmeny, ark underifrån, remsor som rullar
   ========================================================================== */
@media (max-width: 960px) {
  .mainnav, .searchbox { display: none; }
  .menu__name { display: none; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 30;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--card) 94%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem;
                 color: var(--ink-2); text-decoration: none; font-size: var(--fs-xs); font-weight: 600; min-height: var(--tap); }
  .bottomnav a .ic { width: 1.55rem; height: 1.55rem; }
  .bottomnav a[aria-current="page"] { color: var(--accent); }
  .bottomnav a[aria-current="page"] .ic { stroke-width: 2.1; }
  body.has-bottomnav { padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
  .toasts { top: auto; bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + .75rem); }
  /* bildvyn: meddelandet överst, så att det inte täcker Föregående/Nästa */
  .is-viewer .toasts { top: calc(var(--vbar, 3.25rem) + env(safe-area-inset-top) + .5rem); bottom: auto; }
  /* tidsaxeln blir en vågrät remsa som ligger kvar överst; datumrubrikerna klistras under den */
  .is-timeline { --rail-h: 3.5rem; --sticky-top: calc(var(--header-h) + var(--rail-h)); }
  .with-rail { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .rail { position: sticky; top: var(--header-h); z-index: 6; max-height: none; display: flex; align-items: center; gap: var(--s1);
          height: var(--rail-h); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 var(--gutter);
          margin: 0 calc(-1 * var(--gutter)); background: color-mix(in srgb, var(--paper) 94%, transparent);
          -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .rail::-webkit-scrollbar { display: none; }
  .rail__title, .rail__src { display: none; }
  .rail__group, .rail__years { display: contents; }
  .rail a { flex: none; gap: .4rem; min-height: 2.5rem; border: 1px solid var(--line); background: var(--card); border-radius: var(--r-pill); }
  .rail__years a { min-height: 2.25rem; background: transparent; border-style: dashed; }
  .rail__years a::before { display: none; }
  .rail__decade .rail__label { font-size: 1.05rem; }
  .rail__unknown { margin-top: 0; }
  .rail a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .rail a[aria-current="true"] .rail__n { color: inherit; opacity: .85; }
  .rail__group.is-open > .rail__decade:not([aria-current]) { border-color: var(--accent); }
  .profile-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .filterbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: calc(-1 * var(--gutter)); padding-right: var(--gutter); }
  .filterbar::-webkit-scrollbar { display: none; }
  .filterbar .chip { flex: none; }
  .facegrid { grid-template-columns: repeat(auto-fill, minmax(5.75rem, 1fr)); gap: var(--s3); }
  .suggest--top { display: none; }
  .strip { grid-auto-columns: 38%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 2px; }
  .strip--large { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 72%; }
  .strip::-webkit-scrollbar { display: none; }
  .memory__prints { height: 11rem; }

  /* bildvyn på mobil: toppmenyn göms – fotografiet får skärmen, bottenmenyn finns kvar */
  .is-viewer .topbar { display: none; }
  .is-viewer { --header-h: 0px; --vbar: 3.25rem; --steps: 3.75rem; }
  .viewer, .viewer.is-panel-hidden { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .viewer-bar { padding: 0 var(--s2); gap: var(--s1); min-height: 0; height: var(--vbar); flex-wrap: nowrap;
                padding-top: env(safe-area-inset-top); box-sizing: content-box; }
  .viewer-bar .crumbs { display: none; }
  .viewer-bar__back .long { display: none; }
  .viewer-bar__back { min-width: 0; flex: 0 1 auto; }
  .viewer-bar__back .short { display: inline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .viewer-bar__actions { flex: none; }
  .viewer-bar__actions .btn__label { display: none; }
  .viewer-bar__actions .btn--quiet { width: var(--tap); padding: 0; }
  .stage { --stage-h: calc(100svh - var(--vbar) - env(safe-area-inset-top) - var(--bottomnav-h) - env(safe-area-inset-bottom) - var(--steps));
           height: var(--stage-h); min-height: 0; padding: var(--s2); }
  .stage { --img-maxh: calc(var(--stage-h) - 2 * var(--s2)); }
  .stage__nav { display: none; }
  .stage__hint { display: none; }
  .mobile-steps { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); height: var(--steps);
                  padding: 0 var(--s2); background: var(--stage); }
  .mobile-steps .btn { flex: 1; background: color-mix(in srgb, var(--card) 80%, transparent); }
  .viewer .panel { position: static; max-height: none; border-left: 0; border-top: 1px solid var(--line); }
  /* med JS: panelen blir ett ark som glider upp underifrån */
  .js .viewer .panel {
    position: fixed; inset: auto 0 0 0; z-index: 70; max-height: 82svh; border-top: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    box-shadow: var(--sh-pop); transform: translateY(105%); transition: transform var(--t-slow) var(--ease); visibility: hidden;
    padding-top: var(--s2); display: block;
  }
  .js .viewer.is-sheet-open .panel { transform: none; visibility: visible; }
  .js .viewer.is-panel-hidden .panel { display: block; }
  .js .panel .panel__handle { display: block; width: 3rem; height: 5px; border-radius: 3px; background: var(--line-strong); margin: var(--s1) auto var(--s3); }
  .js .panel .panel__close { display: inline-flex; position: absolute; right: var(--s3); top: var(--s2); }
  .sheet-scrim { position: fixed; inset: 0; z-index: 65; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity var(--t); }
  .is-sheet-open + .sheet-scrim, .sheet-scrim.is-on { opacity: 1; pointer-events: auto; }
  .related { padding-top: var(--s5); }
  .related .grid { --tile: 6.25rem; }
  .profile { grid-template-columns: minmax(0, 1fr); justify-items: start; }
  .profile-hero { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .profile-hero__face { justify-self: start; }
  .profile__name input { min-width: 0; }
}
@media (min-width: 961px) {
  .mobile-steps, .sheet-scrim { display: none; }
  .bottomnav-only { display: none; }
}
@media (max-width: 560px) {
  :root { --fs-2xl: 2rem; --fs-xl: 1.5rem; }
  .grid { --tile: 6.75rem; gap: 3px; }
  .hello { padding-top: var(--s4); }
  .page { padding-top: var(--s4); }
  .people { grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: var(--s4) var(--s3); }
  .person-card__name { font-size: var(--fs-m); }
  .explore { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .explore__body { padding: var(--s2) var(--s3) var(--s3); }
  .brand { font-size: 1.3rem; }
  .card { padding: var(--s4); }
  .decades { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s3); }
  .decade__title { font-size: var(--fs-l); }
  .decade__sheet { padding: 4px; gap: 3px; }
  .people--named { grid-template-columns: repeat(auto-fill, minmax(7.25rem, 1fr)); gap: var(--s5) var(--s3); }
  .details-form__row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .search-form .btn { padding: 0 1rem; }     /* knappen syns även på mobil – alla vet inte att Retur söker */
  .album-hero__cover { width: 5.5rem; }
  .stepper .btn { padding: 0 .6rem; }
  .group__head { font-size: var(--fs-m); }
}

/* ---------- Pekskärm: alla klickytor minst 44 px (även små knappar och chips) ---------- */
@media (pointer: coarse) {
  .btn--small, .chip, .tabs--inline a, .rail a, .rail__years a, .stepper .btn { min-height: var(--tap); }
  .yearbar { flex-basis: 1.5rem; }      /* 24 px breda staplar (WCAG 2.5.8) – raden rullar i sidled */
  .chip__x { width: 2.25rem; height: 2.25rem; }
}


/* ==========================================================================
   Del 4 (2026-10-29): bibliotek, admin, uppladdning, röjning – se DESIGNSYSTEM.md
   ========================================================================== */
/* profilmenyn: bibliotek att visa (admin) */
.menu__form { padding: 0 var(--s2) var(--s2); }
.menu__pick { display: flex; gap: var(--s2); align-items: center; }
.menu__pick select { flex: 1 1 auto; min-width: 0; }

/* fyllnadsgrad mot kvoten – alltid med text bredvid, aldrig bara stapeln */
.quota { display: grid; gap: var(--s1); }
.quota__track { height: .75rem; border-radius: var(--r-pill); background: var(--paper-deep); border: 1px solid var(--line); overflow: hidden; }
.quota__fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; }
.quota__fill--warn { background: var(--warn); }
.quota__fill--full { background: var(--err); }
.quota__fill--0 { width: 0%; } .quota__fill--5 { width: 5%; } .quota__fill--10 { width: 10%; } .quota__fill--15 { width: 15%; }
.quota__fill--20 { width: 20%; } .quota__fill--25 { width: 25%; } .quota__fill--30 { width: 30%; } .quota__fill--35 { width: 35%; }
.quota__fill--40 { width: 40%; } .quota__fill--45 { width: 45%; } .quota__fill--50 { width: 50%; } .quota__fill--55 { width: 55%; }
.quota__fill--60 { width: 60%; } .quota__fill--65 { width: 65%; } .quota__fill--70 { width: 70%; } .quota__fill--75 { width: 75%; }
.quota__fill--80 { width: 80%; } .quota__fill--85 { width: 85%; } .quota__fill--90 { width: 90%; } .quota__fill--95 { width: 95%; }
.quota__fill--100 { width: 100%; }
.quota__text { font-size: var(--fs-s); color: var(--ink-2); }

/* admin */
.admin-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.admin-grid .card + .card { margin-top: 0; }
.lib-card { display: grid; gap: var(--s3); align-content: start; scroll-margin-top: calc(var(--header-h) + var(--s4)); }
.lib-card__name { font-family: var(--serif); font-size: var(--fs-l); margin: 0; }
.lib-card__meta { font-size: var(--fs-s); color: var(--ink-2); overflow-wrap: anywhere; }
.form-grid { display: grid; gap: 0 var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.form-grid .field input, .form-grid .field select { width: 100%; }
.choice { display: flex; gap: var(--s2); align-items: center; min-height: var(--tap); cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.choice input { flex: none; }
.choices { display: grid; gap: 0 var(--s4); margin: 0 0 var(--s4); padding: 0; border: 0; }
.choices legend { font-weight: 600; font-size: var(--fs-s); padding: 0; margin-bottom: var(--s1); }
.userlist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.user-row { display: grid; gap: var(--s3); padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); }
.user-row--off { background: transparent; }
.user-row__head { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: baseline; }
.user-row__name { font-weight: 650; font-size: var(--fs-m); }
.user-row__meta { font-size: var(--fs-s); color: var(--ink-2); }
.user-row__actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.user-row details { width: 100%; }
.user-row summary { display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; color: var(--accent); font-weight: 600; }

/* uppladdning */
.dropzone { display: grid; gap: var(--s3); justify-items: center; text-align: center; padding: var(--s6) var(--s4);
            border: 2px dashed var(--line-strong); border-radius: var(--r-card); background: var(--card); margin-bottom: var(--s4);
            transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone__icon { width: 2.5rem; height: 2.5rem; color: var(--ink-3); }
.dropzone__title { font-family: var(--serif); font-size: var(--fs-l); margin: 0; }
.dropzone input[type="file"] { width: 100%; max-width: 30rem; min-width: 0; font-size: var(--fs-s); }
.dropzone input[type="file"]::file-selector-button { min-height: var(--tap); padding: 0 1rem; margin-right: var(--s3); border-radius: var(--r-ctl);
            border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.filelist { list-style: none; margin: 0; padding: 0; width: 100%; max-height: 14rem; overflow: auto; text-align: left; font-size: var(--fs-s);
            border-top: 1px solid var(--line); }
.filelist li { display: flex; justify-content: space-between; gap: var(--s3); padding: .35rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.filelist li span:last-child { color: var(--ink-2); white-space: nowrap; }
.result-list { margin: var(--s2) 0 0; padding-left: 1.2rem; font-size: var(--fs-s); overflow-wrap: anywhere; }

/* röjning: översikt, flikar med antal och storlek, rutnät med skäl under varje fil */
.statgrid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); margin: var(--s4) 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: var(--s4); }
.stat__n { display: block; font-family: var(--serif); font-size: var(--fs-xl); line-height: 1.1; }
.stat__label { display: block; font-size: var(--fs-s); color: var(--ink-2); }
a.stat { color: var(--ink); text-decoration: none; }
a.stat:hover { border-color: var(--line-strong); background: var(--paper-deep); }
.stat--keep { border-color: var(--ok); }
.stat--look { border-color: var(--warn); }
.toplist { margin: 0; padding-left: 1.2rem; font-size: var(--fs-s); }
.toplist li { margin: .2rem 0; overflow-wrap: anywhere; }
.roj-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 12.5rem), 1fr)); }
.roj-item { display: flex; flex-direction: column; gap: var(--s2); font-size: var(--fs-s); scroll-margin-top: calc(var(--header-h) + var(--s4)); }
.roj-item__thumb { aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; border-radius: var(--r-photo);
                   background: var(--paper-deep); color: var(--ink-2); font-size: var(--fs-s); text-align: center; padding: var(--s2); }
.roj-item__thumb img { width: 100%; height: 100%; object-fit: cover; }
.roj-item__thumb:has(img) { padding: 0; }
.roj-item__name { font-weight: 650; overflow-wrap: anywhere; }
.roj-item__reason { color: var(--ink); }
.roj-item__path { color: var(--ink-2); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.roj-item__actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: auto; }
.roj-item--decided .roj-item__thumb { box-shadow: 0 0 0 3px var(--ok); }
.roj-item--junked .roj-item__thumb { opacity: .55; }
.roj-bar { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; margin: var(--s4) 0;
           padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); }
.roj-bar__text { margin: 0; }
.sources { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s2); }
.sources li { padding: 0 var(--s3); border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--card); }
.sources .choice { width: 100%; }
.sources__where { margin-left: auto; color: var(--ink-2); font-size: var(--fs-s); text-align: right; }
.runlist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.runlist a { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s3); align-items: baseline; justify-content: space-between; padding: var(--s3) var(--s4);
             min-height: var(--tap); border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--card); color: var(--ink); text-decoration: none; }
.runlist a:hover { border-color: var(--line-strong); background: var(--paper-deep); }
.runlist__meta { color: var(--ink-2); font-size: var(--fs-s); }
@media (pointer: coarse) {
  .menu__pick .btn--small { min-height: var(--tap); }
}

/* ---------- Rörelse: respektera önskan om mindre rörelse ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
                           transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .tile:hover img, a.print:hover, .explore__item:hover { transform: none; }
}

/* ---------- Utskrift ---------- */
@media print {
  .topbar, .bottomnav, .viewer-bar, .stage__nav, .panel form, .related, .toasts { display: none !important; }
  body { background: #fff; }
}
