@layer reset, tokens, layout, components, utilities;

@font-face {
  font-family: "Fraunces";
  src: url("82a385539fea-fraunces-roman.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("f4dc03664d4e-fraunces-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, ul, ol, figure, fieldset, blockquote { margin: 0; }
  ul, ol { padding: 0; list-style: none; }
  fieldset { padding: 0; border: 0; min-width: 0; }
  legend { padding: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; color: inherit; }
  summary { cursor: pointer; list-style: none; }
  summary::-webkit-details-marker { display: none; }
}

@layer tokens {
  :root {
    /* "Kieszonka" (SDNA-0117 D1, owner 19.11.2026): warm paper, near-black ink, a dark green accent; red only
       for the card's margin line, the date stamp and alerts. */
    color-scheme: light;
    --canvas: #f1eee6;
    --paper: #fbf9f4;
    --paper-2: #eee8dc;
    --ink: #1f201c;
    --ink-2: #3a3b35;
    --muted: #5c5d54;
    --line: #ddd6c7;
    --field-line: #858172;
    --dash: #c9c2af;
    --accent: #2f5d46;
    --accent-ink: #2a5640;
    --accent-soft: #e3e9df;
    --pink: #a8322a;
    --danger-bg: #f5e1dc;
    --danger-ink: #86251c;
    --shadow-lift: 0 1px 2px #1f201c14, 0 12px 28px -16px #1f201c40;
    --blob-b: #efe0d8;
    --stamp: #a8322a;
    --rule: #ece6d9;
    --backdrop: #1f201c66;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 40px;
    --ease: cubic-bezier(.2, .8, .2, 1);
    interpolate-size: allow-keywords;
  }
  :root[data-theme="dark"] {
      color-scheme: dark;
      --canvas: #161815;
      --paper: #1f221d;
      --paper-2: #2a2e27;
      --ink: #ece8dc;
      --ink-2: #d6d1c3;
      --muted: #a9a695;
      --line: #363a32;
      --field-line: #747968;
      --dash: #454b40;
      --accent: #8fc1a4;
      --accent-ink: #9fcdb2;
      --accent-soft: #26332b;
      --pink: #f0907f;
      --danger-bg: #3b1f1b;
      --danger-ink: #f4b6aa;
      --shadow-lift: 0 1px 2px #0008, 0 12px 28px -16px #000a;
      --blob-b: #33282a;
      --stamp: #f0907f;
      --rule: #30342c;
      --backdrop: #000a;
  }
}

@layer layout {
  body {
    min-height: 100svh;
    background: var(--canvas);
    color: var(--ink);
    font: 400 1rem/1.6 var(--sans);
    -webkit-font-smoothing: antialiased;
  }
  h1, h2, h3, h4 { text-wrap: balance; font-weight: 500; }
  p { text-wrap: pretty; }
  main { min-width: 0; }
  main:focus { outline: none; }

  .app { position: relative; display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); min-height: 100svh; }
  .rail {
    position: sticky; top: 0; height: 100svh; overflow: hidden;
    display: flex; flex-direction: column; gap: var(--s6);
    padding: 2.25rem var(--s4) var(--s5);
    background: var(--paper); border-right: 1px solid var(--line);
  }
  /* Clip, not hidden: no scroll box, so sticky parts stay sticky. Below about 1350px the workspace reaches the
     viewport edge, where StoryArt's leaf would otherwise add a few pixels of sideways scroll. */
  .workspace { width: 100%; max-width: 78rem; margin: 0 auto; padding: 0 clamp(var(--s4), 3vw, 2.75rem) 4rem; overflow-x: clip; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); min-height: 5rem; }

  @media (max-width: 56rem) {
    /* Keyboard focus scrolls clear of the fixed bottom nav (WCAG 2.4.11). */
    html { scroll-padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); }
    .app { grid-template-columns: minmax(0, 1fr); }
    .rail {
      position: static; height: auto; flex-direction: row; align-items: center; overflow: visible;
      padding: var(--s3) var(--s4); border-right: 0; border-bottom: 1px solid var(--line);
    }
    .topbar { position: absolute; top: 0; right: var(--s4); min-height: 4.25rem; }
    .workspace { padding-top: var(--s5); padding-bottom: 6rem; }
  }
}

@layer components {
  a { color: var(--accent-ink); text-underline-offset: 3px; }
  :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
  ::selection { background: var(--accent-soft); color: var(--ink); }
  .icon { width: 1.25em; height: 1.25em; flex: none; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  .skip-link {
    position: fixed; z-index: 40; top: var(--s3); left: var(--s3);
    padding: var(--s3) var(--s4); background: var(--paper); border-radius: 10px; translate: 0 -200%;
  }
  .skip-link:focus { translate: 0 0; }

  /* Brand and rail */
  .brand { display: inline-flex; align-items: center; gap: var(--s3); color: var(--ink); text-decoration: none; }
  .brand-mark { width: 48px; height: 42px; }
  /* The two-tone mark (D3, owner 19.11.2026): the book in the text colour, the sound wave in the accent. */
  .brand-book { fill: var(--ink); }
  .brand-wave { fill: var(--accent); }
  .brand span { font: 600 1.5rem/1 var(--serif); letter-spacing: -.02em; white-space: nowrap; }
  .rail > .brand { flex-direction: column; gap: var(--s2); align-self: center; }
  .rail > .brand .brand-mark { width: 76px; height: 67px; }
  @media (max-width: 56rem) {
    .rail > .brand { flex: none; flex-direction: row; align-self: auto; }
    .rail > .brand .brand-mark { width: 40px; height: 35px; }
    .rail > .brand span { font-size: 1.3rem; }
  }

  .nav { display: grid; gap: var(--s2); }
  .nav-link {
    display: flex; align-items: center; gap: var(--s3);
    padding: .8rem var(--s4); border-radius: 6px;
    color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: .95rem;
  }
  .nav-link:hover { background: var(--paper-2); }
  .nav-link[aria-current="page"] { background: var(--paper-2); color: var(--accent-ink); font-weight: 600; }
  .nav-link[aria-current="page"] .icon { fill: color-mix(in srgb, var(--accent) 25%, transparent); }
  @media (max-width: 56rem) {
    .nav {
      position: fixed; z-index: 20; inset: auto 0 0 0;
      grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0;
      padding: var(--s1) var(--s1) max(var(--s1), env(safe-area-inset-bottom));
      background: color-mix(in srgb, var(--paper) 90%, transparent);
      backdrop-filter: blur(14px) saturate(1.4);
      border-top: 1px solid var(--line);
    }
    .nav-link { min-width: 0; flex-direction: column; gap: 2px; padding: var(--s2) var(--s1); font-size: .75rem; text-align: center; }
    .nav-link { border-radius: 0; }
    .nav-link[aria-current="page"] { background: none; box-shadow: inset 0 2px var(--accent); }
    .nav-link .icon { width: 1.5rem; height: 1.5rem; }
  }

  .rail-foot { margin-top: auto; display: grid; gap: var(--s3); padding: 6rem var(--s2) 0; font-size: .75rem; color: var(--muted); }
  /* The side rail folds to icons on wide screens (owner, 19.11.2026, SDNA-0117 E3); a phone keeps its bottom bar. */
  .rail-toggle button {
    display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 50%;
    background: var(--paper); color: var(--ink-2); cursor: pointer;
  }
  .rail-toggle button:hover { border-color: var(--accent); color: var(--accent-ink); }
  .rail-toggle .icon { rotate: 90deg; }
  .rail-compact .rail-toggle .icon { rotate: -90deg; }
  @media (min-width: 56.01rem) {
    .app.rail-compact { grid-template-columns: 4.75rem minmax(0, 1fr); }
    .rail-compact .rail { padding-inline: var(--s2); align-items: center; }
    .rail-compact .rail > .brand span, .rail-compact .nav-link span, .rail-compact .rail-meta {
      position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
    }
    .rail-compact .rail > .brand .brand-mark { width: 44px; height: 39px; }
    .rail-compact .nav { width: 100%; }
    .rail-compact .nav-link { justify-content: center; padding: .8rem 0; }
    .rail-compact .rail-foot { padding: 0; justify-items: center; }
    /* Folded, a lost connection is only its dot; the words stay for screen readers. */
    .rail-compact .connection { font-size: 0; }
  }
  @media (max-width: 56rem) { .rail-toggle { display: none; } }
  .connection { display: flex; align-items: center; gap: var(--s2); }
  .connection .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }
  /* Connected is the normal state: only a lost connection shows (SDNA-0117). */
  .connection:not(.connection-lost) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

  /* Topbar and account menu */
  .where { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: .875rem; }
  .topbar-tools { display: flex; align-items: center; gap: var(--s3); }
  .theme-toggle button {
    display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 50%;
    background: var(--paper); color: var(--ink-2); cursor: pointer;
  }
  .theme-toggle button:hover { border-color: var(--accent); color: var(--accent-ink); }
  @media (max-width: 22.5rem) {
    /* At 320 px the wordmark clears the theme toggle. */
    .rail > .brand span { font-size: 1.15rem; }
    .topbar-tools { gap: var(--s2); }
  }
  .account { position: relative; }
  .account > summary { display: flex; align-items: center; gap: var(--s3); padding: var(--s1); border-radius: 999px; }
  .account-name { font-weight: 600; font-size: .9rem; line-height: 1.25; }
  .account-name small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
  .account > summary > .icon { color: var(--muted); }
  .avatar {
    display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%;
    background: var(--accent); color: var(--paper); font: 600 .95rem var(--serif); box-shadow: 0 0 0 3px var(--paper);
  }
  .account-menu {
    position: absolute; z-index: 30; right: 0; top: calc(100% + var(--s2)); width: 15rem;
    display: grid; gap: 2px; padding: var(--s2); border: 1px solid var(--line); border-radius: 8px;
    background: var(--paper); box-shadow: var(--shadow-lift); font-size: .9rem;
  }
  .account-menu a, .account-menu button {
    display: block; width: 100%; padding: var(--s2) var(--s3); border: 0; border-radius: 8px;
    background: none; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer;
  }
  .account-menu a:hover, .account-menu button:hover { background: var(--accent-soft); }
  .account-menu form { border-top: 1px solid var(--line); margin-top: var(--s1); padding-top: var(--s1); }

  /* Banners */
  .banner {
    display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4);
    padding: var(--s3) var(--s4); border-radius: 6px; font-size: .875rem;
  }
  .banner-preview, .banner-fixture { background: var(--accent-soft); color: var(--ink-2); }
  .banner-fixture { border-left: 3px solid var(--accent); }
  .banner-tag { flex: none; padding: 2px 10px; border-radius: 6px; background: var(--paper); color: var(--accent-ink); font-size: .75rem; font-weight: 600; }
  .banner-error { background: var(--danger-bg); color: var(--danger-ink); }

  /* Type */
  .context-note { color: var(--muted); font: 400 .875rem/1.4 var(--sans); font-variant-numeric: tabular-nums; }
  .display { font: 500 clamp(2.6rem, 1.7rem + 3.2vw, 4.4rem)/1.04 var(--serif); letter-spacing: -.025em; }
  .lede { max-width: 36rem; color: var(--muted); font-size: clamp(1.05rem, 1rem + .3vw, 1.2rem); line-height: 1.55; }
  .caption, .hint, .fine { color: var(--muted); font-size: .8125rem; }
  h2 { font: 500 clamp(1.6rem, 1.3rem + 1vw, 2.2rem)/1.15 var(--serif); letter-spacing: -.015em; }

  /* Buttons */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    min-height: 2.75rem; padding: var(--s2) var(--s4); border-radius: 6px;
    border: 1px solid var(--line); background: var(--paper); color: var(--ink);
    font-weight: 600; font-size: .875rem; line-height: 1.2; text-decoration: none; cursor: pointer;
  }
  .btn:hover { border-color: var(--accent); }
  .btn-cta {
    min-height: 3.25rem; padding: 0 1.25rem; border: 0; color: var(--paper); font-size: 1rem;
    background: var(--accent);
  }
  .btn-cta:hover { filter: brightness(1.07); }
  .btn-cta:disabled { filter: grayscale(.75); opacity: .55; cursor: not-allowed; }
  .btn-wide { min-width: min(100%, 23rem); justify-content: space-between; }
  .btn-quiet { background: transparent; }
  /* The decision note and its list link share one row (owner, 19.11.2026). */
  .want-status {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px var(--s3);
    color: var(--accent-ink); font: 500 .78rem/1.3 var(--mono);
  }

  /* Forms */
  label { font-weight: 600; font-size: .875rem; }
  input[type="text"], input[type="password"], input[type="datetime-local"], textarea, select {
    display: block; width: 100%; padding: .8rem var(--s4);
    border: 1px solid var(--field-line); border-radius: 6px; background: var(--paper);
    font-size: 1rem; line-height: 1.5;
  }
  .field input, .field select, .field textarea { margin-top: var(--s2); }
  textarea { resize: vertical; min-height: 6rem; }
  input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent); }
  ::placeholder { color: var(--muted); opacity: .9; }
  input[type="radio"], input[type="checkbox"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); flex: none; }
  .field label small { font-weight: 400; color: var(--muted); }

  /* Book rating (layout.RatingStars): half stars are radios, the chosen value's word stands beside them. */
  .stars { min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: var(--s1); }
  .stars legend { padding: 0; font-weight: 600; font-size: .875rem; }
  .stars legend small { font-weight: 400; color: var(--muted); }
  .stars-row { display: flex; flex-wrap: wrap; align-items: center; }
  .star { position: relative; display: block; height: 3rem; overflow: hidden; cursor: pointer; }
  .star-whole { width: 3rem; }
  .star-left, .star-right { width: 1.5rem; }
  .star input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
  .star-shape {
    position: absolute; top: .25rem; left: .25rem; width: 2.5rem; max-width: none; height: 2.5rem; pointer-events: none;
    fill: transparent; stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round;
  }
  .star-right .star-shape { left: -1.25rem; }
  .stars-row:has(.star input:checked) .star-shape { fill: var(--accent); stroke: var(--accent); }
  .stars-row .star:has(input:checked) ~ .star .star-shape { fill: transparent; stroke: var(--muted); }
  .star:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; border-radius: 8px; }
  @media (hover: hover) {
    .stars-row:hover .star .star-shape { fill: var(--accent-soft); stroke: var(--accent); }
    .stars-row:hover .star:hover ~ .star .star-shape { fill: transparent; stroke: var(--muted); }
  }
  .stars-word { margin-left: var(--s3); font-size: .9rem; color: var(--ink-2); }
  .stars-word > span { display: none; }
  .stars-word strong { color: var(--ink); font-variant-numeric: tabular-nums; }
  .stars:not(:has(.star input:checked)) .stars-word [data-word=""] { display: inline; }
  .stars:has(input[value="1"]:checked) .stars-word [data-word="1"] { display: inline; }
  .stars:has(input[value="1.5"]:checked) .stars-word [data-word="1.5"] { display: inline; }
  .stars:has(input[value="2"]:checked) .stars-word [data-word="2"] { display: inline; }
  .stars:has(input[value="2.5"]:checked) .stars-word [data-word="2.5"] { display: inline; }
  .stars:has(input[value="3"]:checked) .stars-word [data-word="3"] { display: inline; }
  .stars:has(input[value="3.5"]:checked) .stars-word [data-word="3.5"] { display: inline; }
  .stars:has(input[value="4"]:checked) .stars-word [data-word="4"] { display: inline; }
  .stars:has(input[value="4.5"]:checked) .stars-word [data-word="4.5"] { display: inline; }
  .stars:has(input[value="5"]:checked) .stars-word [data-word="5"] { display: inline; }
  .stars-none { display: inline-flex; align-items: center; gap: var(--s2); width: fit-content; min-height: 2.75rem; font-size: .875rem; color: var(--ink-2); cursor: pointer; }

  /* Hero */
  .hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--s5); padding-top: var(--s4); }
  .hero-copy { display: grid; gap: var(--s4); padding-bottom: var(--s6); }
  .hero-compact .hero-copy { padding-bottom: var(--s5); }
  @media (max-width: 64rem) { .hero { grid-template-columns: minmax(0, 1fr); isolation: isolate; } }

  .story-art { position: relative; width: 25rem; height: 15.5rem; margin-bottom: -2.25rem; }
  .story-art > * { position: absolute; }
  .hand-note { font: italic 400 1.2rem/1.35 var(--serif); color: var(--accent); }
  .story-art .hand-note { left: 0; top: 1.5rem; rotate: -7deg; }
  .hand-arrow { left: 6.5rem; top: 7.5rem; width: 4.5rem; color: var(--accent); rotate: 8deg; }
  /* Standing books: flat tops with a page edge, two bands on the spine. */
  .story-book-small { bottom: 0; border-radius: 5px 5px 3px 3px; }
  .story-book-small::before { content: ""; position: absolute; left: 3px; right: 3px; top: -5px; height: 6px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, #fffaf3, #efe6da); box-shadow: inset 0 -1px #0000000d; }
  .story-book-small::after { content: ""; position: absolute; inset: 16% 22%; border-block: 2px solid #ffffff59; }
  .story-book-1 { left: 10.6rem; width: 3.3rem; height: 11.6rem; background: #2f5d46; box-shadow: inset -7px 0 #ffffff1f, 0 14px 24px -14px #1f201c66; }
  .story-book-2 { left: 14.1rem; width: 2.7rem; height: 8rem; background: #8e2f25; box-shadow: inset -6px 0 #ffffff1f; rotate: 12deg; transform-origin: bottom left; }
  .story-book-3 { left: 16.9rem; width: 2.1rem; height: 9.6rem; background: #27405e; box-shadow: inset -5px 0 #ffffff1f; opacity: .9; }
  .story-book {
    left: 18.6rem; width: 6.6rem; height: 15rem; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: var(--s3);
    padding: var(--s4) var(--s2); border-radius: 8px 8px 3px 3px;
    background: #ebe4d4; box-shadow: inset -10px 0 #ffffff59, 0 18px 30px -16px #1f201c55;
  }
  .story-book span { color: #3a3b35; font: italic 400 .8rem/1.3 var(--serif); text-align: center; }
  .story-mark { width: 1.75rem; height: auto; opacity: .85; }
  .leaf { width: 3.2rem; height: 7rem; border-radius: 0 100% 0 100%; background: #c3cfbd; opacity: .55; }
  .leaf-1 { right: -1.2rem; top: 1.5rem; rotate: 25deg; }
  .leaf-2 { right: .8rem; top: -.5rem; rotate: -10deg; width: 2.4rem; height: 5.5rem; }
  @media (max-width: 64rem) {
    .hero { overflow-x: clip; }
    .story-art { position: absolute; z-index: -1; right: 0; top: 0; margin: 0; scale: .55; transform-origin: top right; opacity: .3; }
    .story-art .hand-note, .hand-arrow, .leaf { display: none; }
  }
  @media (max-width: 40rem) {
    /* On a phone the art stands small beside the heading, fully visible, so no band of the screen stays empty
       beside it (owner, 17.11.2026; from 12.11 it stood alone above the request card). */
    .hero:has(> .story-art) { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s4) var(--s3); padding-bottom: var(--s5); }
    .hero:has(> .story-art) > .hero-copy { display: contents; }
    .hero:has(> .story-art) > .hero-copy > * { grid-column: 1 / -1; }
    .hero:has(> .story-art) > .hero-copy > h1 { grid-column: 1; grid-row: 1; }
    .story-art { position: relative; z-index: auto; grid-column: 2; grid-row: 1; width: 14.8rem; zoom: .42; scale: 1; opacity: 1; margin: 0; }
    /* Only the books stand here; the hand note on their left is hidden, so they move into its place. */
    .story-book-1 { left: .2rem; }
    .story-book-2 { left: 3.7rem; }
    .story-book-3 { left: 6.5rem; }
    .story-book { left: 8.2rem; }
  }

  /* Request card */
  .request-card {
    position: relative; z-index: 1; margin-bottom: var(--s6);
    padding: var(--s5) clamp(var(--s4), 2.5vw, 1.75rem);
    border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
  }
  .request-card form { display: grid; gap: var(--s4); }
  /* A returning reader's request folded to one line (SDNA-0117 B1). */
  /* The folded line keeps an accent frame for every reader, motion or not (owner, 17.11.2026). */
  .request-fold { padding: 0; overflow: hidden; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
  .request-fold > details > summary {
    position: relative; isolation: isolate; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); min-height: 3.5rem;
    padding: var(--s3) clamp(var(--s4), 2.5vw, 1.75rem); color: var(--accent-ink); font: 600 1.15rem/1.3 var(--serif); cursor: pointer; list-style: none;
  }
  .request-fold > details > summary::-webkit-details-marker { display: none; }
  /* The card clips its corners, so the focus ring is drawn inside the line. */
  .request-fold > details > summary:focus-visible { outline-offset: -3px; border-radius: 9px; }
  .request-fold > details > summary .icon { width: 1.4rem; height: 1.4rem; color: var(--accent); }
  .request-fold > details[open] > summary .icon { rotate: 45deg; }
  .request-fold > details > summary small { flex-basis: 100%; color: var(--muted); font: 400 .8125rem/1.4 var(--sans); }
  .request-fold > details > form { padding: 0 clamp(var(--s4), 2.5vw, 1.75rem) var(--s5); }
  /* A heading and the note or tools beside it stand on one baseline (owner, 12.11.2026). */
  .request-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s5); }
  .request-head h2 { display: flex; align-items: center; gap: var(--s3); font: 600 1.25rem/1.3 var(--serif); letter-spacing: -.01em; }
  .request-head h2 .icon { width: 1.5rem; height: 1.5rem; color: var(--accent); }
  .request-tip { color: var(--muted); font-size: .8rem; }
  .textarea-wrap { position: relative; }
  .textarea-wrap textarea { padding-bottom: 2rem; background: var(--paper-2); }
  .counter { position: absolute; right: var(--s4); bottom: var(--s3); color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
  /* Every control stands on one text baseline, so the subscription box sits level with the format and language
     controls and its note hangs below the line (owner, 12.11.2026). */
  .request-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s3); }
  .request-row > .lang { padding-left: var(--s3); border-left: 1px solid var(--line); }
  .request-row > .btn-cta { margin-left: auto; }
  /* The subscription note wraps under its label so the main button keeps its place in the row. Only the label
     line sets the baseline, and the divider spans a control's height around that line, as beside the language. */
  .request-row > .check { position: relative; max-width: 15rem; padding-left: var(--s3); }
  .request-row > .check::before { content: ""; position: absolute; left: 0; top: calc((1.5rem - 2.5rem) / 2); height: 2.5rem; border-left: 1px solid var(--line); }
  .request-row > .check > span { align-self: baseline; line-height: 1.5rem; }
  .request-row > .check small { line-height: 1.35; }
  .request-row > .check input { margin-top: calc((1.5rem - 1.15rem) / 2); }
  @media (max-width: 80rem) {
    .request-row > .lang, .request-row > .check { padding-left: 0; border-left: 0; }
    .request-row > .check::before { content: none; }
  }
  @media (max-width: 40rem) { .request-row > .btn-cta { width: 100%; } }

  .segmented { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
  .segmented legend { float: left; margin-right: var(--s3); font-weight: 600; font-size: .875rem; }
  .segments { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); }
  .segments label {
    position: relative; display: flex; align-items: center; gap: var(--s2);
    min-height: 2.5rem; padding: 0 .8rem; border-radius: 5px; font-weight: 500; cursor: pointer;
  }
  .segments input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
  /* The chosen answer is filled like the chosen decision on a card, clearly apart from the others (owner, 19.11.2026). */
  .segments label:has(:checked) { background: var(--accent); color: var(--paper); font-weight: 600; }
  .segments label:has(:focus-visible) { outline: 3px solid var(--accent); outline-offset: 1px; }
  @media (max-width: 30rem) {
    .segmented, .segments { width: 100%; }
    .segments { display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 8px; }
    .segments label { justify-content: center; padding: 0 var(--s1); border-radius: 5px; font-size: .875rem; }
    .segments .icon { display: none; }
  }
  .lang { display: flex; align-items: center; gap: var(--s3); }
  .lang-label { font-weight: 600; font-size: .875rem; }
  .lang-pill { display: inline-flex; align-items: center; gap: var(--s2); min-height: 2.5rem; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 6px; font-size: .9rem; }
  .check { display: flex; align-items: flex-start; gap: var(--s3); cursor: pointer; }
  .check input { margin-top: .15rem; }
  .check small { display: block; font-weight: 400; font-size: .78rem; color: var(--muted); }
  .more > summary { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: .875rem; font-weight: 600; }
  .more > summary:hover, .offers > summary:hover, .more-settings > summary:hover { color: var(--ink); }
  .more > summary::after { content: "+"; font-weight: 400; }
  .more[open] > summary::after { content: "−"; }
  .more-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: var(--s4); padding-top: var(--s3); }
  .choice-group { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); padding: var(--s4); border: 1px solid var(--line); border-radius: 6px; }
  .choice-group legend { padding: 0 var(--s2); font-weight: 600; font-size: .875rem; }
  .choice-group label { display: flex; align-items: center; gap: var(--s2); min-height: 2.25rem; font-weight: 400; }
  .request-note { padding: var(--s3) var(--s4); border-radius: 6px; background: var(--accent-soft); font-size: .875rem; }
  .taste-known { display: grid; gap: var(--s2); }

  /* Progress */
  .progress { position: relative; z-index: 1; margin-bottom: var(--s5); padding: var(--s5); border-radius: 10px; background: var(--accent-soft); }
  .progress-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s4); }
  .progress-head h2 { font-size: 1.4rem; }
  .progress-head p { color: var(--muted); font-size: .875rem; }
  /* A vertical line of stages: done, the active one with what happens now, pending. */
  .progress-count { margin-bottom: var(--s3); color: var(--accent-ink); font: 600 .75rem/1.4 var(--sans); letter-spacing: .14em; text-transform: uppercase; }
  .timeline { display: grid; }
  .timeline-step { position: relative; display: grid; grid-template-columns: 1.5rem minmax(0, 1fr); gap: var(--s3); padding-bottom: var(--s3); color: var(--muted); font-size: .875rem; }
  .timeline-step:not(:last-child)::before { content: ""; position: absolute; top: 1.5rem; bottom: 0; left: .75rem; width: 2px; translate: -50% 0; background: var(--dash); }
  .timeline-done:not(:last-child)::before { background: var(--accent); }
  .timeline-mark { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border: 2px solid var(--dash); border-radius: 50%; background: var(--paper); }
  .timeline-done .timeline-mark { border-color: var(--accent); background: var(--accent); color: var(--paper); }
  .timeline-done .timeline-mark .icon { width: .9rem; height: .9rem; }
  .timeline-active .timeline-mark { border-color: var(--accent); }
  .timeline-active .timeline-mark .spinner { width: .9rem; height: .9rem; margin: 0; }
  .timeline-body { min-width: 0; padding-top: .15rem; }
  .timeline-active { color: var(--ink); }
  .timeline-active .timeline-label { font-weight: 600; }
  .timeline-detail { margin-top: var(--s1); color: var(--ink-2); }

  /* The request card folded while a shelf is selected, and the first-shelf guide. */
  .request-card-busy { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding-block: var(--s3); background: var(--paper-2); }
  .request-card-busy h2 { display: flex; align-items: center; gap: var(--s2); font: 600 1rem/1.3 var(--serif); color: var(--ink-2); }
  .request-busy { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3); border-radius: 6px; background: var(--accent-soft); font-size: .875rem; }
  .first-shelf-guide { max-width: 60ch; margin-bottom: var(--s4); color: var(--ink-2); }

  /* Section head */
  .section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s3) var(--s5); }
  /* Counters and the shelf state read as quiet text beside a heading, not pills (owner, 12.11.2026). */
  .count { color: var(--muted); font: 400 .78rem/1 var(--mono); letter-spacing: 0; font-variant-numeric: tabular-nums; }
  /* The order day as a library-card stamp, only beside shelf names (signature D6, owner 12.11.2026). */
  /* A red library date stamp with a double rule (SDNA-0117 D1). */
  .stamp {
    display: inline-block; margin-inline: 8px; padding: 0 var(--s1); border: 1.5px solid currentColor; border-radius: 3px;
    outline: 1px solid currentColor; outline-offset: 2px; color: var(--stamp); font: 600 .78rem/1.6 var(--mono);
    letter-spacing: 0; font-variant-numeric: tabular-nums; white-space: nowrap;
  }
  /* On the heading's baseline, like the counter and the shelf state beside it. */
  .section-head h2 .stamp { margin-left: var(--s2); }
  .library-text .stamp { justify-self: start; margin-bottom: var(--s1); }
  .section-sub { margin: var(--s2) 0 var(--s5); color: var(--muted); font-size: 1rem; }
  .set-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }

  /* Shelf R3 */
  /* A real cover fills its 2:3 box like a placeholder; .cover's later padding no longer frames the picture. */
  .cover.cover-image { width: 100%; height: auto; padding: 0; object-fit: cover; background: var(--paper-2); }
  .clarification { display: grid; gap: var(--s3); }
  .clarification h2 { font-size: 1.35rem; }
  .clarification-form { display: grid; gap: var(--s3); }
  .choice-buttons { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .set-note { margin: calc(-1 * var(--s3)) 0 var(--s5); color: var(--muted); font-size: .875rem; }
  .picks > .sparse-note { margin-bottom: var(--s5); }
  .section-head h2 .badge { margin-left: var(--s2); padding: 0; border: 0; background: none; font-family: var(--sans); font-size: .875rem; letter-spacing: 0; }
  .card-links { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
  .card-report { padding-top: var(--s2); }
  .card-actions a.btn { flex: 1 1 auto; min-height: 2.5rem; font-size: .8rem; }
  .offer-static { display: grid; padding: var(--s2) var(--s3); }
  .action-dialog {
    width: min(100% - 2 * var(--s4), 36rem); max-height: calc(100svh - 2 * var(--s4)); overflow: auto;
    margin: auto; padding: var(--s5); border: 1px solid var(--line); border-radius: 10px;
    background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lift);
  }
  .action-dialog:not([open]) { display: none; }
  /* Without JavaScript the dialog is part of the page: on its own (main) or after the library list. */
  main > .action-dialog[open], #dialog-root > .action-dialog:not(:modal) { position: static; margin: var(--s5) auto; }
  /* At 320 px five half-star rows (24 px targets) need 240 px: less padding, the page form full width. */
  @media (max-width: 24rem) {
    .action-dialog { padding: var(--s4); }
    main > .action-dialog[open], #dialog-root > .action-dialog:not(:modal) { width: 100%; }
  }
  .action-dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
  .action-dialog form { display: grid; gap: var(--s4); }
  .action-dialog h2 { font-size: 1.4rem; }
  .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); }

  /* Slots */
  .slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: var(--s5); }
  .slots-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); align-items: start; }
  .slots > li { min-width: 0; container-type: inline-size; }
  .slot {
    position: relative; overflow: hidden; display: grid; align-content: start; gap: var(--s3);
    min-height: 18rem; padding: var(--s5); border: 1.5px dashed var(--dash); border-radius: 10px;
    background: var(--paper);
  }
  .slot-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--s5); }
  .slot-num { font: 500 2.9rem/1 var(--serif); letter-spacing: -.02em; color: var(--accent-ink); }
  .slot-add {
    display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
    background: var(--paper); color: var(--ink); box-shadow: 0 4px 14px -4px #1f201c33;
  }
  .slot h3 { font: 500 1.2rem/1.3 var(--serif); }
  .slot p { color: var(--muted); font-size: .875rem; }
  .slot-lines { display: grid; gap: var(--s2); margin-top: var(--s2); }
  .slot-lines i { display: block; height: .55rem; border-radius: 4px; background: var(--line); }
  .slot-lines i + i { width: 60%; }

  /* Cards: "Kieszonka" (SDNA-0117 D1, owner 19.11.2026). A card is a catalogue card with a red margin line; the
     format is its index tab on the top edge; the cover stands in a book pocket that holds our score and the tags. */
  .slots-cards > li { padding-top: 1.55rem; }
  .card {
    --card-pad: var(--s4); --dip: 1rem;
    --margin-line: linear-gradient(var(--stamp), var(--stamp)) .45rem 0 / 1px 100% no-repeat;
    position: relative; display: grid; gap: var(--s4); padding: var(--card-pad);
    border: 1px solid var(--line); border-radius: 10px; background: var(--margin-line), var(--paper);
    scroll-margin-top: calc(var(--s5) + 1.55rem);
  }
  .card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
  .card-top { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--s2) var(--s4); align-items: start; }
  .card-top > .cover { grid-column: 1; grid-row: 1; }
  .card-head { grid-column: 2; grid-row: 1; display: grid; gap: 6px; min-width: 0; }
  .card-tab {
    position: absolute; right: var(--s4); bottom: 100%; z-index: 2; width: max-content; max-width: calc(100% - 2 * var(--s4));
    padding: 2px 10px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; background: var(--paper);
  }
  /* The pocket: one tone off the card, across its full width, with a thumb notch in the middle of its edge. It sits
     in front of the cover, whose foot is slipped into it. */
  .pocket {
    grid-column: 1 / -1; grid-row: 2; position: relative; z-index: 1; display: grid; gap: 6px; justify-items: start;
    margin-inline: calc(-1 * var(--card-pad)); padding: calc(var(--dip) + 6px) var(--card-pad) var(--s3);
    background: var(--margin-line), var(--paper-2);
    mask: radial-gradient(circle .8rem at 50% 0, #0000 97%, #000 100%);
  }
  .card-top:has(> .pocket) > .cover { align-self: end; margin-bottom: calc(-1 * var(--dip) - var(--s2)); }
  .pocket-empty { padding-bottom: var(--s2); }
  .card-top .cover-edition, .card-top .cover-star { visibility: hidden; }
  @container (max-width: 20rem) {
    .card { --card-pad: var(--s3); --dip: .875rem; }
    .card-top { grid-template-columns: 5.5rem minmax(0, 1fr); column-gap: var(--s3); }
    .cover-title { font-size: .85rem; }
    .card h3 { font-size: 1.2rem; }
  }
  .cover {
    position: relative; display: flex; flex-direction: column; gap: var(--s2);
    aspect-ratio: 2 / 3; padding: .8rem .7rem; border-radius: 2px 4px 4px 2px; overflow: hidden; color: #fff;
  }
  .cover-kicker, .cover-edition { font: 600 .5rem/1.4 var(--sans); letter-spacing: .22em; text-transform: uppercase; opacity: .85; }
  .cover-title { font: 400 1.05rem/1.1 var(--serif); overflow-wrap: break-word; hyphens: auto; }
  .cover-edition { margin-top: auto; }
  .cover-star { position: absolute; right: .6rem; bottom: .6rem; width: 1.4rem; height: 1.4rem; opacity: .45; }
  /* Placeholder covers in flat cloth tones; white titles from 7.2:1 (D4 resolved by the palette). */
  .hue-0 { background: #2f5d46; }
  .hue-1 { background: #8e2f25; }
  .hue-2 { background: #27405e; }
  .hue-3 { background: #6b4a2b; }
  .hue-4 { background: #4f5a4c; }
  .hue-5 { background: #5a3a4f; }
  .card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
  .card h3 { font: 500 1.45rem/1.12 var(--serif); letter-spacing: -.01em; overflow-wrap: break-word; }
  .author { color: var(--muted); font-size: .85rem; }
  /* Our score as a word under a typewriter field label, without the 1-4 meter (owner, 19.11.2026). */
  .score { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); }
  .score-name { color: var(--muted); font: 400 .78rem/1.5 var(--mono); }
  .score-word { color: var(--accent-ink); font: italic 500 .95rem/1.2 var(--serif); }
  /* Tags that define the book: quiet outline chips in the card text colour, so they read as tags and not as
     the end of the score line, yet stay quieter than the decisions (owner, 12.11.2026, round 3). */
  .tags { display: flex; flex-wrap: wrap; gap: var(--s1); }
  .tags li { padding: 1px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink-2); font-size: .8125rem; line-height: 1.35; }
  .card-section { display: grid; gap: var(--s2); }
  .summary { color: var(--ink-2); font-size: .9rem; line-height: 1.65; }
  .recording { display: flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: .8rem; }
  .recording .icon { width: 1rem; height: 1rem; }
  .reason { color: var(--ink); font: 400 1rem/1.6 var(--serif); }
  /* The reason sits on faint ruled lines, like a catalogue card. */
  .reason:not(.reason-note) { background: linear-gradient(transparent calc(100% - 1px), var(--rule) 0) 0 0 / 100% 1.6em; }
  /* A withdrawn reason is a service note, not the narration (SDNA-0117). */
  .reason-note { color: var(--ink-2); font: 400 .9375rem/1.55 var(--sans); }
  .uncertainty { padding: var(--s2) var(--s3); border-left: 2px solid var(--pink); border-radius: 0 10px 10px 0; background: var(--paper-2); color: var(--muted); font-size: .8rem; }
  /* The card prose (owner's choice A, 04.11.2026): the reason leads in Fraunces under an italic label like
     the score word; the description folds to two quiet lines, like the offers below it. */
  .reason-label { color: var(--accent-ink); font: italic 500 .95rem/1.3 var(--serif); }
  .reason-block { gap: var(--s1); }
  .about-title { color: var(--ink-2); font: 600 .8125rem/1.4 var(--sans); }
  .about-fold > summary { display: grid; grid-template-columns: .75rem minmax(0, 1fr); align-items: baseline; gap: 2px var(--s1); }
  .about-fold > summary::before { content: ""; align-self: center; width: .35rem; height: .35rem; border: solid var(--ink-2); border-width: 0 1.5px 1.5px 0; rotate: -45deg; }
  .about-fold[open] > summary::before { rotate: 45deg; }
  .about-peek { grid-column: 2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; color: var(--muted); font-size: .8125rem; line-height: 1.55; }
  .about-fold[open] .about-peek { display: none; }
  /* Unfolded, the description keeps the size of its two-line peek, so opening it does not look like a jump. */
  .about-fold > .summary { padding: var(--s1) 0 0 calc(.75rem + var(--s1)); color: var(--muted); font-size: .8125rem; line-height: 1.55; }
  .offers { border-top: 1px solid var(--line); padding-top: var(--s3); }
  .offers > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); font-size: .8rem; font-weight: 600; color: var(--ink-2); }
  .offers > summary::before { content: ""; align-self: center; width: .35rem; height: .35rem; border: solid currentColor; border-width: 0 1.5px 1.5px 0; rotate: -45deg; }
  .offers[open] > summary::before { rotate: 45deg; }
  /* The offer count stays on the summary's line ("3 oferty · abonament"); a narrow card uses the plain face, as the
     typewriter face would need text under 12 px there. */
  .offers > summary span { color: var(--muted); font: 400 .75rem/1.3 var(--mono); white-space: nowrap; }
  @container (max-width: 20rem) { .offers > summary span { font-family: var(--sans); } }
  .offers ul { display: grid; gap: 2px; padding-top: var(--s2); }
  .offers a { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); padding: var(--s2) var(--s3); border-radius: 8px; color: var(--ink); text-decoration: none; }
  .offers a:hover { background: var(--accent-soft); }
  .offer-shop { font-weight: 600; font-size: .8rem; }
  .offer-kind { grid-row: 2; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; color: var(--muted); font-size: .72rem; }
  .offer-tag { padding: 1px 8px; border-radius: 4px; background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2); }
  .offer-tag-own { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
  .offer-go { grid-row: span 2; align-self: center; color: var(--muted); }
  /* An offer in the reader's subscription says so with its tag only; the row looks like the others, so no shop
     seems favoured (owner, 19.11.2026). */
  .offers .fine { padding: var(--s2) var(--s3) 0; font-size: .72rem; }
  .card-actions { display: grid; gap: var(--s2); }
  .card-links { font-size: .75rem; }
  .card-links a { color: var(--muted); }
  /* The reading path as one switch; the current step is marked (owner, 04.11.2026). */
  .decision-switch { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1.2fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); }
  .decision-step {
    display: flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 2.75rem; padding: 0 var(--s2);
    border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); font: 500 .8125rem/1.15 var(--sans); text-align: center; text-decoration: none; cursor: pointer;
  }
  .decision-step .icon { width: 1.05rem; height: 1.05rem; flex: none; }
  .decision-step:hover { background: var(--paper); color: var(--ink); }
  .decision-step[aria-current="true"] { background: var(--accent); color: var(--paper); font-weight: 600; cursor: default; }
  a.decision-step[aria-current="true"] { cursor: pointer; }
  .decision-step[aria-current="true"] .icon { color: var(--paper); }
  @container (max-width: 21rem) {
    .decision-step { flex-direction: column; gap: 2px; padding-block: var(--s1); font-size: .75rem; }
  }
  /* Declining is a full answer: two clear buttons, the chosen one marked. */
  .decision-decline { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .decline-step {
    display: flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 2.5rem; padding: 0 var(--s2);
    border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink-2); font: 500 .8125rem/1.15 var(--sans); text-align: center; text-decoration: none;
  }
  .decline-step .icon { width: 1rem; height: 1rem; color: var(--muted); }
  .decline-step:hover { background: var(--paper-2); color: var(--ink); }
  .decline-step[aria-current="true"] { border-color: var(--ink-2); background: var(--paper-2); color: var(--ink); font-weight: 600; }
  .decline-step[aria-current="true"] .icon { color: var(--pink); }
  .badge { display: inline-block; padding: 2px 10px; border-radius: 4px; background: var(--paper-2); border: 1px solid var(--line); color: var(--muted); font: 600 .75rem/1.5 var(--mono); white-space: nowrap; }
  .badge-ready { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
  .badge-ambiguous { border-color: var(--pink); color: var(--ink); }
  .format-tag { display: inline-flex; align-items: center; gap: var(--s1); color: var(--muted); font: 400 .78rem/1.5 var(--mono); }
  .format-tag .icon { width: 1rem; height: 1rem; }

  /* Library */
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: var(--s4) var(--s5); }
  @media (max-width: 40rem) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
  .field-wide { grid-column: 1 / -1; }
  .form-submit { display: flex; }
  .combo input[aria-expanded="true"] { border-color: var(--accent); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .suggestions { border: 1px solid var(--accent); border-top: 0; border-radius: 0 0 6px 6px; background: var(--paper); overflow: hidden; }
  .suggestions li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); cursor: pointer; }
  .suggestions li[aria-selected="true"] { background: var(--accent-soft); }
  .suggestions strong { display: block; font-weight: 600; }
  .suggestions small { color: var(--muted); font-size: .8rem; }
  .combo .hint { margin-top: var(--s2); }
  .thumb { flex: none; display: block; width: 2.6rem; aspect-ratio: 2 / 3; border-radius: 2px 5px 5px 2px; box-shadow: inset 4px 0 #0000002a; }
  .suggestions .thumb { width: 2rem; }
  img.thumb { object-fit: cover; }
  /* A cover without a picture: its title on its colour, as on the shelf (SDNA-0118, C8 A). */
  .thumb-type { overflow: hidden; padding: .3rem .2rem .3rem .4rem; color: #fff; }
  .thumb-title {
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden;
    font: 400 .5rem/1.15 var(--serif); overflow-wrap: anywhere; hyphens: auto;
  }
  .suggestions .thumb-title { -webkit-line-clamp: 4; font-size: .42rem; }
  .library .section-head { margin-bottom: var(--s4); }
  /* An index of a page's parts under its heading (SDNA-0117 B3). */
  /* A page's parts as a book's table of contents (owner, 19.11.2026, SDNA-0117 E1): the part's name in the serif, a
     dotted leader, its count in the typewriter face. The same on the Library and Twój gust. */
  .page-index { display: grid; max-width: 26rem; margin-bottom: var(--s6); padding: var(--s2) 0; border-block: 1px solid var(--line); }
  .page-index a { display: flex; align-items: baseline; gap: var(--s2); min-height: 2.25rem; padding: .3rem 0; color: var(--ink); font: 400 1.0625rem/1.5 var(--serif); text-decoration: none; }
  .page-index a::after { content: ""; order: 1; flex: 1; min-width: 1.5rem; border-bottom: 1.5px dotted var(--field-line); translate: 0 -.3rem; }
  .page-index .count { order: 2; color: var(--muted); font: 400 .8125rem/1 var(--mono); }
  .page-index a:hover { color: var(--accent-ink); }
  /* The reader's shelves above the shown one (SDNA-0117 B2): one line per shelf with its stamp. */
  .shelf-index { margin-bottom: var(--s6); }
  .shelf-index-title { margin-bottom: var(--s2); color: var(--ink-2); font: 600 .875rem/1.4 var(--sans); }
  .shelf-index-list { display: grid; border-top: 1px solid var(--line); }
  .shelf-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .shelf-row-name { font: 500 1.05rem/1.35 var(--serif); }
  a.shelf-row-name { display: inline-block; padding-block: .15rem; color: var(--ink); text-decoration-color: var(--line); }
  a.shelf-row-name:hover { color: var(--accent-ink); }
  .shelf-row-current .shelf-row-name { color: var(--accent-ink); }
  .shelf-row-meta { margin-left: auto; color: var(--muted); font: 400 .78rem/1.5 var(--mono); font-variant-numeric: tabular-nums; }
  .shelf-row-request { flex-basis: 100%; overflow: hidden; color: var(--ink-2); font-size: .8125rem; white-space: nowrap; text-overflow: ellipsis; }
  .shelf-index-more { margin-top: var(--s3); }
  .shelf-index-more > summary { min-height: 1.5rem; }
  .shelf-index-more > .shelf-index-list { margin-top: var(--s2); }
  /* "Więcej ustawień": a folded summary, then two short questions (owner, 04.11.2026). */
  .more-settings { margin-top: var(--s3); }
  .more-settings > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s1); color: var(--ink-2); font-size: .875rem; font-weight: 600; }
  .more-settings > summary::before { content: ""; align-self: center; width: .35rem; height: .35rem; margin-right: var(--s1); border: solid currentColor; border-width: 0 1.5px 1.5px 0; rotate: -45deg; }
  .more-settings[open] > summary::before { rotate: 45deg; }
  .more-settings > summary span { color: var(--muted); font-weight: 400; }
  .more-settings-panel { display: grid; gap: var(--s4); margin-top: var(--s3); padding: var(--s4); border: 1px solid var(--line); border-radius: 10px; background: var(--paper-2); }
  .setting { display: grid; gap: 6px; }
  .setting .segments { flex-wrap: wrap; }
  /* On a phone the longer answers stack, one per row. */
  @media (max-width: 30rem) {
    .setting .segments { grid-template-columns: minmax(0, 1fr); }
    .setting .segments label { justify-content: flex-start; padding-inline: var(--s3); min-height: 2.75rem; }
  }
  .setting-note { color: var(--muted); font-size: .8125rem; line-height: 1.45; max-width: 62ch; }
  .book-lists { margin-block: var(--s6); }
  /* Lists as rows with a fan of covers (owner, 04.11.2026). */
  .book-lists { display: grid; gap: var(--s3); }
  .list-row { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
  .list-row > summary, .list-row-empty { display: grid; grid-template-columns: 5.75rem minmax(0, 1fr) auto; align-items: center; gap: var(--s4); padding: var(--s3) var(--s4); cursor: pointer; }
  .list-row-empty { cursor: default; background: var(--paper-2); }
  .list-row > summary .icon { color: var(--muted); transition: rotate .2s var(--ease); }
  .list-row[open] > summary .icon { rotate: 180deg; }
  .list-fan { position: relative; height: 4.25rem; }
  .list-fan .thumb { position: absolute; bottom: 0; width: 2.75rem; box-shadow: inset 4px 0 #0000002a, 0 8px 14px -10px #1f201c80; }
  .list-fan .thumb:nth-child(1) { left: 0; rotate: -8deg; }
  .list-fan .thumb:nth-child(2) { left: 1.4rem; z-index: 1; }
  .list-fan .thumb:nth-child(3) { left: 2.8rem; rotate: 8deg; }
  .list-fan .thumb:only-child { left: 1.4rem; rotate: 0deg; }
  .list-ghost { position: absolute; bottom: 0; left: 1.4rem; display: grid; place-items: center; width: 2.75rem; aspect-ratio: 2 / 3; border: 1.5px dashed var(--field-line); border-radius: 2px 5px 5px 2px; color: var(--field-line); }
  .list-text { display: grid; gap: 2px; min-width: 0; }
  .list-title { font: 500 1.15rem/1.2 var(--serif); color: var(--ink); }
  .list-count { color: var(--muted); font-size: .875rem; }
  .list-body { display: grid; gap: var(--s3); padding: 0 var(--s4) var(--s4); }
  .library-list { display: grid; border-top: 1px solid var(--line); }
  /* The bin ends the title's row at every width; the catalogue note goes under the text, after the bin in focus order. */
  .library-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "thumb text bin";
    align-items: center; gap: var(--s3) var(--s4); padding: var(--s4) 0; border-bottom: 1px solid var(--line);
  }
  .library-item:has(> .library-state) { grid-template-areas: "thumb text bin" ". state state"; }
  .library-item > .thumb { grid-area: thumb; }
  .library-text { grid-area: text; min-width: 0; display: grid; gap: 2px; }
  .library-text h3 { font: 500 1.2rem/1.25 var(--serif); }
  .library-text .author { margin: 0; }
  .library-meta { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); }
  .library-edit { justify-self: start; margin-top: var(--s1); }
  .my-rating { color: var(--muted); font-size: .8rem; }
  .my-rating strong { color: var(--ink); }
  .library-state { grid-area: state; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
  .library-remove {
    grid-area: bin; align-self: start; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-top: -.6rem;
    border-radius: 50%; color: var(--muted); text-decoration: none;
  }
  .library-remove:hover { background: var(--danger-bg); color: var(--danger-ink); }
  .form-notice.library-notice { margin-bottom: var(--s4); }
  .more-link { margin-top: var(--s5); text-align: center; }

  /* Login. The page clips at the viewport, so nothing scrolls it sideways. */
  .login-page { overflow: clip; }
  .login {
    --login-gutter: clamp(var(--s4), 4vw, 4.5rem);
    position: relative; isolation: isolate;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-rows: auto 1fr auto;
    column-gap: var(--s6); min-height: 100svh; max-width: 90rem; margin: 0 auto;
    padding: var(--s5) var(--login-gutter) var(--s4);
  }
  .login-top { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s5); }
  .login-top > .brand { margin-right: auto; }
  .login-copy { align-self: center; display: grid; gap: var(--s5); padding-block: var(--s6); }
  .login-title { font-size: clamp(3.2rem, 2rem + 4.6vw, 6.2rem); font-weight: 600; line-height: .98; letter-spacing: -.035em; }
  .login-copy .lede { margin-top: calc(-1 * var(--s2)); }
  .pill-form { display: flex; align-items: center; max-width: 34rem; padding: 5px; border: 1px solid var(--field-line); border-radius: 8px; background: var(--paper); }
  .pill-field { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s3); padding-left: var(--s4); color: var(--muted); }
  .pill-field input { border: 0; background: transparent; padding-inline: 0; min-width: 0; }
  .pill-field input:focus-visible { outline: none; }
  .pill-form:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
  .pill-form .btn-cta, .login-copy > p > .btn-cta { border-radius: 5px; }
  .login-copy .caption { margin-top: calc(-1 * var(--s3)); }
  /* Three facts as a plain list: the icon sits in the line, not on a tile. */
  .features { display: grid; gap: var(--s3); max-width: 34rem; }
  .features li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--s3); }
  /* Ruled like the rows of the reader card beside them (SDNA-0117 D1). */
  .features li + li { padding-top: var(--s3); border-top: 1px solid var(--line); }
  .feature-icon { grid-row: span 2; padding-top: 2px; color: var(--accent-ink); }
  .feature-icon .icon { width: 1.25rem; height: 1.25rem; }
  .features strong { font: 600 1rem/1.4 var(--sans); }
  .features span:last-child { color: var(--muted); font-size: .875rem; line-height: 1.45; }
  /* The reader's library card (owner, 19.11.2026, SDNA-0117 D1): the shelf card's language at the page's scale, an
     index tab, typed fields on ruled lines, today's stamp, the lower part slipped into a pocket with a thumb notch. */
  .login-art { position: relative; align-self: center; display: grid; place-items: center; padding-top: 2.75rem; }
  .reader-card {
    --card-pad: clamp(1.5rem, 3vw, 2.75rem);
    --margin-line: linear-gradient(var(--stamp), var(--stamp)) 1.25rem 0 / 1px 100% no-repeat;
    position: relative; display: grid; width: min(100%, 36rem); padding: var(--card-pad) var(--card-pad) 0;
    border: 1px solid var(--line); border-radius: 12px; background: var(--margin-line), var(--paper);
  }
  .reader-card-tab {
    position: absolute; right: 2rem; bottom: 100%; padding: .4rem 1.1rem; border: 1px solid var(--line); border-bottom: 0;
    border-radius: 8px 8px 0 0; background: var(--paper); color: var(--ink); font: 500 1rem/1.4 var(--mono);
  }
  .reader-card-mark { justify-self: end; width: 3.25rem; height: auto; }
  .reader-card-fields { display: grid; margin-top: var(--s4); }
  .reader-card-fields > div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: var(--s3); padding: .7rem 0; border-bottom: 1px solid var(--line); }
  .reader-card-fields dt, .reader-card-fields dd { margin: 0; color: var(--ink); font: 400 1.0625rem/1.45 var(--mono); }
  .reader-card-stamp { justify-self: end; margin-top: var(--s5); }
  .reader-card-stamp .stamp { margin-inline: 0 3px; font-size: .95rem; }
  .reader-card-pocket {
    height: 8rem; margin: var(--s5) calc(-1 * var(--card-pad)) 0; border-radius: 0 0 11px 11px;
    background: var(--margin-line), var(--paper-2);
    mask: radial-gradient(circle 1.6rem at 50% 0, #0000 97%, #000 100%);
  }
  .login-foot { grid-column: 1; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); color: var(--muted); font-size: .78rem; }
  .login-foot a { color: var(--muted); }
  @media (max-width: 64rem) {
    .login { grid-template-columns: minmax(0, 1fr); }
    .login-copy { padding-block: var(--s5) 0; }
    .login-art { padding: calc(var(--s6) + 2.75rem) 0 var(--s5); }
    .reader-card { width: min(100%, 30rem); }
    .reader-card-pocket { height: 5rem; }
    .login-foot { padding-top: var(--s4); }
  }
  @media (max-width: 40rem) {
    .slot { min-height: 0; }
  }
  @media (max-width: 30rem) {
    .pill-form { flex-direction: column; align-items: stretch; gap: var(--s1); border-radius: 10px; }
    .pill-field { padding: 0 var(--s3); }
    .reader-card-fields > div { grid-template-columns: 5.5rem minmax(0, 1fr); }
    .reader-card-fields dt, .reader-card-fields dd { font-size: .9375rem; }
    .reader-card-tab { right: 1.25rem; font-size: .9375rem; }
  }
  /* At 320 px a field's label stands above its value. */
  @media (max-width: 22.5rem) {
    .reader-card-fields > div { grid-template-columns: minmax(0, 1fr); gap: 0; padding: .5rem 0; }
    .reader-card-fields dt { color: var(--muted); font-size: .8125rem; }
  }

  /* Administrator (R7) */
  .admin-section { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .admin-section h2 { font-size: 1.35rem; }
  .table-wrap { overflow-x: auto; }
  .admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
  .admin-table th, .admin-table td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
  .admin-table thead th { color: var(--muted); font-weight: 600; }
  .admin-table .row-failed { background: var(--danger-bg); }
  .admin-table td a { margin-right: var(--s3); }
  .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
  .inline-form input { width: auto; min-width: 7rem; flex: 1 1 7rem; }
  .balance-form { display: grid; gap: var(--s3); }
  .admin-links { display: flex; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s6); }
  .admin-run > summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
  .admin-run h3 { font: 600 1rem var(--sans); margin-top: var(--s3); }
  .admin-run h3 small { color: var(--muted); font-weight: 400; }
  .admin-run-links { display: flex; flex-wrap: wrap; gap: var(--s3); font-size: .85rem; }
  .admin-pre { max-height: 70vh; overflow: auto; margin: 0; padding: var(--s4); border-radius: 6px; background: var(--paper-2); font-size: .8rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

  /* Library (R4) */
  .library-compose > details > summary { display: flex; align-items: center; cursor: pointer; list-style: none; }
  .library-compose > details > summary::-webkit-details-marker { display: none; }
  .library-compose > details > summary h2 { display: flex; align-items: center; gap: var(--s3); font: 600 1.25rem/1.3 var(--serif); letter-spacing: -.01em; }
  .library-compose > details > summary .icon { width: 1.5rem; height: 1.5rem; color: var(--accent); }
  .library-compose > details[open] > summary { margin-bottom: var(--s4); }
  .library-compose .library-readonly, .form-alert { margin: 0; }
  .form-notice { display: flex; align-items: center; gap: var(--s2); margin: 0; padding: var(--s3) var(--s4); border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); font-size: .9rem; }
  .form-notice .icon { flex: none; width: 1.1rem; height: 1.1rem; }
  .suggestions-region { display: grid; }
  .suggestions { max-height: 22rem; overflow-y: auto; }
  .suggestions li { padding: 0; }
  .suggestions label { display: flex; flex: 1; align-items: center; gap: var(--s3); min-width: 0; padding: var(--s2) var(--s4); font-weight: 400; cursor: pointer; }
  .suggestions li.active, .suggestions li:hover { background: var(--accent-soft); }
  .suggestions li[aria-selected="true"] { box-shadow: inset 3px 0 var(--accent); }
  .suggestion-text { display: grid; min-width: 0; overflow-wrap: anywhere; }
  .suggestion-text > span, .suggestion-text small { color: var(--muted); font-size: .8rem; }
  .suggestion-manual { border-top: 1px solid var(--line); }
  [data-enhanced] .suggestions input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
  [data-enhanced][data-expanded="false"] .suggestions { display: none; }
  [data-enhanced] .combo-search { display: none; }
  .combo-search { justify-self: start; margin-top: var(--s2); }
  .combo { display: grid; }
  .combo-busy { display: none; margin-top: var(--s2); }
  .combo:has(#book-title.htmx-request) .combo-busy { display: block; }
  .combo:has(#book-title.htmx-request) #book-title-status { display: none; }
  .library-note { margin: var(--s1) 0 0; color: var(--ink-2); font-size: .875rem; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .library-text h3, .library-text .author { overflow-wrap: anywhere; }
  .library-empty { display: grid; justify-items: center; gap: var(--s2); padding: var(--s6) var(--s4); border: 1px dashed var(--line); border-radius: 10px; text-align: center; color: var(--muted); }
  .library-empty .icon { width: 2rem; height: 2rem; color: var(--accent); }
  .library-empty h3 { color: var(--ink); font: 500 1.2rem/1.3 var(--serif); }
  .identity-dialog { width: min(40rem, calc(100vw - 2 * var(--s4))); max-height: calc(100dvh - 2 * var(--s5)); margin: var(--s5) auto; padding: var(--s5); border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow-lift); }
  .identity-dialog:not(:modal) { position: relative; z-index: 5; }
  .identity-dialog::backdrop { background: var(--backdrop); }
  .identity-dialog > * + * { margin-top: var(--s4); }
  .dialog-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
  .dialog-head h2 { font: 600 1.25rem/1.3 var(--serif); }
  .dialog-lead { color: var(--muted); overflow-wrap: anywhere; }
  .dialog-lead strong { color: var(--ink); }
  .combo-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
  .combo-row input { flex: 1 1 12rem; min-width: 0; margin-top: 0; }
  .match-list { display: grid; gap: var(--s2); }
  .match { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: var(--s3); border: 1px solid var(--line); border-radius: 6px; background: var(--paper-2); color: var(--ink); text-align: left; cursor: pointer; }
  .match:hover:not(:disabled), .match:focus-visible { border-color: var(--accent); }
  .match:disabled { opacity: .6; cursor: not-allowed; }
  .match .suggestion-text { flex: 1; }
  .match-pick { flex: none; color: var(--accent-ink); font-weight: 600; font-size: .85rem; }

  /* Mobile shell: last in the layer so it wins over the base rules above. */
  @media (max-width: 56rem) {
    .rail-foot, .where, .account-name { display: none; }
  }

  /* Error pages */
  .error-page { display: grid; gap: var(--s5); justify-items: start; max-width: 40rem; min-height: 100svh; margin: 0 auto; padding: var(--s6) var(--s4); align-content: center; }
  .error-page .display { font-size: clamp(2.2rem, 1.6rem + 2.4vw, 3.4rem); }
  .error-page code { font-size: .85em; }

  /* Design index */
  .design-index { display: grid; gap: var(--s5); max-width: 44rem; margin: 0 auto; padding: var(--s6) var(--s4); }
  .design-index ul { display: grid; gap: var(--s2); list-style: disc; padding-left: var(--s5); }
}

@layer utilities {
  @media (prefers-reduced-motion: no-preference) {
    .story-book-small, .story-book { animation: rise .24s var(--ease) both; }
    .story-book-2 { animation-delay: 60ms; }
    .story-book { animation-delay: 120ms; }
    .story-book-3 { animation-delay: 90ms; }
    .slot-waiting .slot-lines i {
      background: linear-gradient(90deg, var(--line) 30%, var(--accent-soft) 50%, var(--line) 70%) 0 0 / 300% 100%;
      animation: shimmer 1.4s linear infinite;
    }
    .slot-add, .btn-cta { transition: translate .2s var(--ease), filter .2s; }
    /* The cover slides a little out of its pocket on hover or keyboard focus in the card (SDNA-0117 D1). */
    .card-top > .cover { transition: translate .2s var(--ease); }
    .card:hover .card-top > .cover, .card:has(:focus-visible) .card-top > .cover { translate: 0 -.5rem; }
    .slot-add:hover, .btn-cta:hover:not(:disabled) { translate: 0 -2px; }
    /* Pressed: a slight shrink, so a tap answers before the page does. */
    .btn:active:not(:disabled), button.decision-step:active, a.decision-step:active, a.decline-step:active { scale: .98; }
    .offers::details-content, .more::details-content {
      block-size: 0; overflow: clip;
      transition: block-size .24s var(--ease), content-visibility .24s allow-discrete;
    }
    .offers[open]::details-content, .more[open]::details-content { block-size: auto; }
    .offers > summary::before { transition: rotate .2s var(--ease); }
    /* A light crosses the folded request once on arrival, so a returning reader does not miss it (owner, 17.11.2026;
       once, not three times: owner 19.11.2026). It passes behind the words, which keep AA on its peak; slower than
       other motion on purpose, absent with reduced motion. */
    .request-cue > details > summary::after {
      content: ""; position: absolute; z-index: -1; inset: 0 auto 0 0; width: 45%; pointer-events: none;
      background: linear-gradient(100deg, transparent, color-mix(in srgb, var(--accent) 26%, transparent) 50%, transparent);
      translate: -110% 0; animation: sweep 2.2s var(--ease) .4s 1;
    }
    .request-fold > details > summary .icon { transition: rotate .2s var(--ease); }
  }
  @keyframes sweep { 55%, to { translate: 230% 0; } }
  @keyframes rise { from { translate: 0 18%; opacity: 0; } }
  @keyframes pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
  @keyframes shimmer { to { background-position: -300% 0; } }
}

/* Profile and account (R5) */
@layer components {
  .profile-compose { display: grid; gap: var(--s4); }
  .profile-compose .segmented legend { float: none; }
  .taste-questions { display: grid; gap: var(--s4); }
  .taste-question + .taste-question { padding-top: var(--s4); border-top: 1px dashed var(--dash); }
  .taste-question .form-submit { flex-wrap: wrap; gap: var(--s3); }
  .series-choices, .series-choices form, #interview-series { display: grid; gap: var(--s5); }
  /* The live status stays in the accessibility tree while empty (announced when filled), out of the grid flow. */
  .series-status:empty { position: absolute; }
  /* A series in one row: name and books, then a switch of three short choices (SDNA-0117 B5). */
  .series-legend { display: grid; gap: var(--s1); color: var(--ink-2); font-size: .8125rem; }
  .series-legend dt { display: inline; color: var(--ink); font-weight: 600; }
  .series-legend dt::after { content: " — "; font-weight: 400; }
  .series-legend dd { display: inline; margin: 0; }
  .series-rows { display: grid; gap: var(--s4); padding-top: var(--s3); }
  .series-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2) var(--s4); padding: 0 0 var(--s4); border: 0; border-bottom: 1px solid var(--line); }
  .series-row legend { float: left; display: grid; gap: 2px; max-width: 24rem; padding: 0; }
  .series-row legend small { color: var(--muted); font-size: .8125rem; }
  .series-name { font: 500 1.05rem/1.35 var(--serif); }
  .series-row .segments label { min-height: 2.25rem; font-size: .875rem; line-height: 1.2; text-align: center; }
  .form-error, .form-ok { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: 6px; font-size: .875rem; }
  .form-error { background: var(--danger-bg); color: var(--danger-ink); }
  .form-ok { background: var(--accent-soft); color: var(--ink-2); }
  /* The text sets the baseline, so the link stands on the line of a heading beside it; the icon stays centred. */
  .link-button {
    display: inline-flex; align-items: baseline; gap: var(--s1); padding: var(--s1) 0; border: 0; background: none;
    color: var(--muted); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
  }
  .link-button .icon { align-self: center; width: 1rem; height: 1rem; }
  .link-button:hover:not(:disabled) { color: var(--accent-ink); }
  .link-button:disabled { opacity: .55; cursor: not-allowed; }

  .profile-state { display: grid; gap: var(--s4); margin-bottom: var(--s6); }
  .profile-note { display: grid; gap: var(--s1); padding: var(--s4); border-radius: 8px; background: var(--accent-soft); font-size: .9rem; }
  .profile-note-progress { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: var(--s3); }
  .profile-note-alert { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s3); border-left: 3px solid var(--pink); background: var(--paper-2); }
  @media (max-width: 30rem) { .profile-note-alert { grid-template-columns: minmax(0, 1fr); } }
  .spinner { width: 1.1rem; height: 1.1rem; margin-top: .2rem; border: 2px solid var(--dash); border-top-color: var(--accent); border-radius: 50%; }
  /* A submitted form waits for the service (busy.mjs): its buttons grey out and the sender spins. */
  button[aria-disabled="true"] { opacity: .55; filter: grayscale(.75); box-shadow: none; pointer-events: none; }
  button[data-busy]::after {
    content: ""; display: inline-block; flex: none; width: 1em; height: 1em; vertical-align: -.15em;
    border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  }
  button[data-busy]:not(.btn)::after { margin-inline-start: var(--s2); }

  .taste { display: grid; gap: var(--s3); padding: var(--s5) clamp(var(--s4), 2.5vw, 1.75rem); border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
  .taste-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); }
  .taste-head h3 { font: 500 1.35rem/1.2 var(--serif); }
  .taste-list { display: grid; gap: var(--s3); }
  .taste-more { display: grid; gap: var(--s3); margin-top: var(--s3); }
  .taste-item { display: grid; gap: var(--s2); padding: var(--s4); border-radius: 8px; background: var(--paper-2); border: 1px solid var(--line); }
  .taste-text { font: 400 1.1rem/1.5 var(--serif); overflow-wrap: anywhere; }
  .taste-empty, .profile-empty { padding: var(--s4); border: 1px dashed var(--dash); border-radius: 8px; color: var(--muted); }
  .trait { color: var(--ink-2); font-size: .85rem; overflow-wrap: anywhere; }
  .trait span { margin-right: var(--s1); color: var(--accent-ink); font-weight: 600; }
  .basis > summary { color: var(--muted); font-size: .8rem; font-weight: 600; }
  .basis > summary::after { content: " +"; font-weight: 400; }
  .basis[open] > summary::after { content: " −"; }
  .basis > :not(summary) { margin-top: var(--s2); font-size: .875rem; }
  blockquote { padding-left: var(--s3); border-left: 2px solid var(--accent); color: var(--ink-2); font: italic 400 .95rem/1.55 var(--serif); overflow-wrap: anywhere; }

  .history { border-top: 1px solid var(--line); padding-top: var(--s4); }
  .history > summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font: 500 1.2rem/1.3 var(--serif); }
  .history > .hint { margin-top: var(--s2); }
  .history-note { flex-basis: 100%; color: var(--muted); font: 400 .875rem/1.5 var(--sans); }
  .history-list { display: grid; margin-top: var(--s3); }
  .history-item { display: grid; gap: var(--s2); padding: var(--s4) 0; border-bottom: 1px solid var(--line); }
  .history-item .context-note { overflow-wrap: anywhere; }
  .history-item h3 { font: 500 1.1rem/1.4 var(--serif); overflow-wrap: anywhere; }
  .source-quote { display: grid; gap: var(--s1); }
  .source-quote figcaption { color: var(--muted); font-size: .75rem; }

  .report-form, .report-receipt, .delete-form { display: grid; gap: var(--s4); }
  .report-form h2, .report-receipt h2, .delete-form h2 { font-size: 1.5rem; }
  .report-number { font: 500 .8rem/1.4 ui-monospace, monospace; overflow-wrap: anywhere; }

  .account-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); align-items: start; }
  .account-report { grid-row: span 3; margin-bottom: 0; }
  @media (max-width: 64rem) { .account-grid { grid-template-columns: minmax(0, 1fr); } .account-report { grid-row: auto; } }
  .account-section { display: grid; gap: var(--s3); padding: var(--s5); border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
  .account-section h2 { font-size: 1.4rem; }
  .notify-form { display: grid; gap: var(--s4); }
  .account-danger { border-color: color-mix(in srgb, var(--pink) 45%, var(--line)); }
  .btn-danger { justify-self: start; background: var(--danger-bg); border-color: transparent; color: var(--danger-ink); }
  .btn-danger:hover:not(:disabled) { border-color: var(--danger-ink); }
  .btn-danger:disabled { opacity: .55; cursor: not-allowed; }
  .report-list { display: grid; }
  .report-item { display: grid; gap: 2px; padding: var(--s3) 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  .report-item:last-child { border-bottom: 0; }
}

/* Guided start, shelf rating and questionnaires (SDNA-0057) */
@layer components {
  .start-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
  .start-steps-detailed { grid-template-columns: minmax(0, 1fr); margin: var(--s4) 0 0; }
  .start-steps li { display: flex; align-items: flex-start; gap: var(--s3); color: var(--muted); font-size: .875rem; }
  .start-n {
    display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: 50%;
    background: var(--paper); color: var(--ink-2); font-weight: 600;
  }
  .start-n .icon { width: 1rem; height: 1rem; color: var(--accent); }
  /* The first line centres on the 2rem step circle beside it. */
  .start-text { display: grid; gap: 2px; min-width: 0; padding-top: calc((2rem - 1lh) / 2); overflow-wrap: anywhere; }
  .start-text strong, .start-text a { color: var(--ink); font-weight: 600; }
  .start-text small { font-size: .78rem; }
  .start-hint { color: var(--ink-2); }
  .start-current .start-n { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
  .start-privacy { margin-bottom: var(--s6); }
  /* One line of the guided start on its screens (SDNA-0117). */
  .step-line { display: grid; gap: var(--s2); max-width: 24rem; margin-bottom: var(--s3); color: var(--muted); font-size: .875rem; }
  .step-count { color: var(--accent-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
  .step-bar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--s1); }
  .step-bar i { height: 4px; border-radius: 999px; background: var(--line); }
  .step-bar i.on { background: var(--accent); }
  .first-request .hint { max-width: 60ch; }
  .submit-note { max-width: 60ch; margin-top: var(--s2); }
  .want-status a { font: 500 .8125rem/1.3 var(--sans); white-space: nowrap; }
  /* The guided start's steps (SDNA-0126): one column, a way back above the
     step, a step foot whose edges meet the card's, and the books step's short
     list. Inside the column every block keeps one rhythm. */
  .guided { display: grid; align-content: start; gap: var(--s4); max-width: 44rem; }
  .books-intro { display: grid; gap: var(--s3); }
  .guided .hero { padding-top: 0; }
  .guided .hero-copy { gap: var(--s3); padding-bottom: 0; }
  .guided .step-line { max-width: none; margin-bottom: 0; }
  .guided .request-card { margin-bottom: 0; }
  .guided-form { display: grid; gap: var(--s4); }
  .request-card.interview { display: grid; gap: var(--s5); }
  .request-card.interview .first-request { padding-top: var(--s5); border-top: 1px solid var(--line); }
  .step-back {
    display: inline-flex; align-items: center; gap: var(--s1); justify-self: start; min-height: 1.5rem;
    color: var(--ink-2); font-size: .875rem; text-decoration: none;
  }
  .step-back:hover { color: var(--accent-ink); text-decoration: underline; }
  .step-foot {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s3) var(--s4);
    padding-top: var(--s4); border-top: 1px solid var(--line);
  }
  .step-foot .hint { flex: 1 1 16rem; max-width: 40ch; margin: 0; }
  @media (max-width: 40rem) {
    .step-foot { flex-direction: column; align-items: stretch; justify-content: flex-start; }
    .step-foot .hint { flex: none; max-width: none; }
  }
  .guided .submit-note { margin-top: calc(-1 * var(--s2)); text-align: right; }
  @media (max-width: 40rem) { .guided .submit-note { text-align: left; } }
  .books-added { display: grid; gap: var(--s2); }
  .books-added-title { display: flex; align-items: baseline; gap: var(--s2); font: 500 1.15rem/1.3 var(--serif); }
  .books-added-title .count { font: 400 .875rem/1 var(--mono); color: var(--muted); }
  .books-added-list { display: grid; border-top: 1px solid var(--line); }
  .books-added-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--s3);
    padding: var(--s2) 0; border-bottom: 1px solid var(--line);
  }
  .books-added .thumb { width: 2rem; }
  .books-added-text { display: grid; gap: 2px; margin: 0; }
  .books-added-name { font: 500 1rem/1.3 var(--serif); overflow-wrap: anywhere; }
  .books-added .author { color: var(--muted); font-size: .8125rem; }
  .books-added .my-rating { color: var(--ink-2); font: 400 .8125rem/1 var(--mono); white-space: nowrap; }
  .books-added .library-remove { grid-area: auto; align-self: center; margin-top: 0; }
  .form-more, .optional { display: grid; gap: var(--s3); }
  .form-more > summary, .optional > summary {
    justify-self: start; min-height: 1.5rem; color: var(--accent-ink); font-size: .875rem; font-weight: 500; cursor: pointer;
  }
  .form-more > summary small, .optional > summary small { color: var(--muted); font-weight: 400; }
  .chips-label { margin: 0; color: var(--muted); font-size: .8125rem; }
  .start-insights { display: grid; gap: var(--s2); padding-left: var(--s5); list-style: disc; font: 400 1.05rem/1.5 var(--serif); }
  .start-live { display: grid; gap: var(--s3); }
  .decide { display: grid; gap: var(--s2); margin-bottom: var(--s5); font-size: .9rem; }
  .decide h3 { font: 500 1.15rem/1.3 var(--serif); }
  .decide ul { display: grid; gap: var(--s1); padding-left: var(--s5); list-style: disc; }

  .question { display: grid; gap: var(--s3); padding: 0; border: 0; }
  .question legend { margin-bottom: var(--s2); font: 500 1.15rem/1.35 var(--serif); }
  .question legend small { display: block; color: var(--muted); font: 400 .8125rem/1.4 var(--sans); }
  .chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .chips label {
    display: inline-flex; align-items: center; gap: var(--s2); min-height: 2.75rem; padding: 0 var(--s4);
    border: 1px solid var(--field-line); border-radius: 6px; background: var(--paper); font-weight: 500; cursor: pointer;
  }
  .chips input { margin: 0; accent-color: var(--accent); }
  .chips label:has(:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
  .examples { color: var(--muted); font-size: .8125rem; }

  .scale { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--s2); }
  .scale-wide { grid-template-columns: repeat(auto-fit, minmax(3.25rem, 1fr)); }
  .scale label {
    display: flex; align-items: center; gap: var(--s2); min-height: 2.75rem; padding: var(--s2) var(--s3);
    border: 1px solid var(--field-line); border-radius: 6px; background: var(--paper); font-weight: 500; cursor: pointer;
  }
  .scale-wide label { flex-direction: column; justify-content: center; gap: 2px; padding-inline: var(--s1); text-align: center; }
  .scale input { flex: none; margin: 0; accent-color: var(--accent); }
  .scale label:has(:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
  .scale-n { min-width: 1.25ch; font-weight: 600; font-variant-numeric: tabular-nums; }
  .scale-word { font-size: .875rem; line-height: 1.3; overflow-wrap: break-word; }
  .scale-wide .scale-word { font-size: .72rem; color: var(--muted); }
  /* 0–10 on a phone: two even rows (0–5, 6–10) instead of a lone 10 on a third row. */
  @media (max-width: 30rem) { .scale-wide { grid-template-columns: repeat(6, minmax(0, 1fr)); column-gap: var(--s1); } .scale-wide label { padding-inline: 0; } }

  .rate-shelf { display: grid; gap: var(--s3); margin-top: var(--s5); padding: var(--s5); border: 1px solid var(--line); border-radius: 10px; background: var(--paper); container-type: inline-size; }
  .rate-shelf h3 { font: 500 1.35rem/1.2 var(--serif); }
  .rate-shelf form { display: grid; gap: var(--s3); justify-items: start; }
  /* One scale of words filled up to the choice (owner, 04.11.2026). */
  .rate-scale { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; max-width: 40rem; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-2); }
  .rate-scale::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 0; border-radius: 5px; background: var(--accent); }
  .rate-step { position: relative; display: grid; place-items: center; min-height: 2.75rem; padding: 0 2px; border-radius: 5px; color: var(--ink-2); font: 500 .8125rem/1.15 var(--sans); text-align: center; cursor: pointer; overflow-wrap: anywhere; }
  .rate-step:hover { background: var(--accent-soft); }
  .rate-step:has(input:checked) { font-weight: 600; }
  .rate-step:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
  .rate-scale:has(input[value="1"]:checked)::before { width: calc((100% - 8px) * 1 / 5); }
  .rate-scale:has(input[value="1"]:checked) .rate-step:nth-of-type(-n+1) { color: var(--paper); }
  .rate-scale:has(input[value="2"]:checked)::before { width: calc((100% - 8px) * 2 / 5); }
  .rate-scale:has(input[value="2"]:checked) .rate-step:nth-of-type(-n+2) { color: var(--paper); }
  .rate-scale:has(input[value="3"]:checked)::before { width: calc((100% - 8px) * 3 / 5); }
  .rate-scale:has(input[value="3"]:checked) .rate-step:nth-of-type(-n+3) { color: var(--paper); }
  .rate-scale:has(input[value="4"]:checked)::before { width: calc((100% - 8px) * 4 / 5); }
  .rate-scale:has(input[value="4"]:checked) .rate-step:nth-of-type(-n+4) { color: var(--paper); }
  .rate-scale:has(input[value="5"]:checked)::before { width: calc((100% - 8px) * 5 / 5); }
  .rate-scale:has(input[value="5"]:checked) .rate-step:nth-of-type(-n+5) { color: var(--paper); }
  .rate-scale:has(input:checked) .rate-step:hover { background: transparent; }
  /* A narrow card stacks the words, filled from the top: five words never fit a phone row. */
  @container (max-width: 26rem) {
    .rate-scale { grid-template-columns: minmax(0, 1fr); border-radius: 10px; }
    .rate-scale::before { right: 4px; bottom: auto; border-radius: 8px; }
    .rate-scale:has(input[value="1"]:checked)::before { width: auto; height: calc((100% - 8px) * 1 / 5); }
    .rate-scale:has(input[value="2"]:checked)::before { width: auto; height: calc((100% - 8px) * 2 / 5); }
    .rate-scale:has(input[value="3"]:checked)::before { width: auto; height: calc((100% - 8px) * 3 / 5); }
    .rate-scale:has(input[value="4"]:checked)::before { width: auto; height: calc((100% - 8px) * 4 / 5); }
    .rate-scale:has(input[value="5"]:checked)::before { width: auto; height: calc((100% - 8px) * 5 / 5); }
    .rate-step { min-height: 2.5rem; border-radius: 8px; font-size: .875rem; }
  }
  .rate-form:has(input[data-saved]:checked) .rate-save, .rate-form:not(:has(input:checked)) .rate-save { display: none; }
  .rate-shelf-ask { border-color: var(--accent); background: var(--accent-soft); }
  .survey form { display: grid; gap: var(--s5); }
  .survey .form-submit { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--s3); }
}

@layer utilities {
  [hidden] { display: none; }
  .connection-lost .dot { background: var(--pink); }
  @media (prefers-reduced-motion: no-preference) {
    .spinner, button[data-busy]::after { animation: spin .9s linear infinite; }
  }
  @keyframes spin { to { rotate: 1turn; } }
}

/* SDNA-0117 D2 B′ (owner, 19.11.2026): on phones the shelf's covers stand in one row on a shelf line above the stacked
   cards, each a plain link to its card; where the cards stand side by side they already show the shelf. */
@layer components {
  .cover-row { margin: 0 0 var(--s4); }
  .cover-row ol { display: flex; width: fit-content; max-width: 100%; align-items: flex-end; gap: var(--s3); padding: 0 var(--s3); border-bottom: 2px solid var(--ink-2); }
  .cover-row li { flex: 0 1 2.9rem; min-width: 0; }
  .cover-row a { display: block; border-radius: 2px 4px 4px 2px; text-decoration: none; }
  .cover-row .thumb { width: 100%; height: auto; aspect-ratio: 2 / 3; border-radius: 2px 4px 4px 2px; box-shadow: none; object-fit: cover; }
  .cover-row .thumb-type { padding: .35rem .3rem; }
  .cover-row .thumb-title { font-size: .55rem; -webkit-line-clamp: 4; line-clamp: 4; }
  @media (min-width: 56.01rem) { .cover-row { display: none; } }
  @media (prefers-reduced-motion: no-preference) {
    .cover-row .thumb { transition: translate .2s var(--ease); }
    .cover-row a:hover .thumb, .cover-row a:focus-visible .thumb { translate: 0 -.35rem; }
  }
}
