/* Self-hosted fonts: the UI face and all five manuscript faces. The app never loads
   fonts from Google servers. A face downloads only when text uses it.
   See docs/design-system.md section 5. */
@import url('./fonts/fonts.css');

/* =============================================================================
   Ink Familiar design system (repo: writingfriend)
   -----------------------------------------------------------------------------
   Theme: "Familiar". Read docs/design-system.md for the rationale.

   Two rules carry the whole system:
     1. Ink is the writer's. The familiar color is Saga's. The familiar color
        marks everything the AI says or proposes, and nothing else.
        The writer's color is ink blue. The familiar color is violet,
        sampled from the purple Saga sprites.
     2. The familiar sits beside the page, never on it. AI marks go in the
        page margin, not on the words.

   LAYERS
     Primitive palette  --wf-p-*     Raw hex values. Components never use them.
     Semantic tokens    --wf-*       Roles. Themes redefine only these.
     Components         .wf-*        Consume semantic tokens only.

   THEMES (set data-theme on <html>)
     Light family: light (default), cream
     Dark family:  dark (default), navy
     No data-theme: the OS picks light or dark through prefers-color-scheme.
     Light and dark use light-dark() in one block. color-scheme selects the half.

   CONTENTS
     01  Primitive palette
     02  Semantic color tokens: light + dark
     03  Theme: cream
     04  Theme: navy
     05  Type tokens
     06  Manuscript preference tokens
     07  Space, radius, border, elevation, z, motion, layout
     08  Mascot tokens
     09  Reset and base
     10  Type utilities
     11  Buttons            .wf-btn
     12  Fields             .wf-field .wf-input .wf-textarea .wf-select .wf-check .wf-switch
                        .wf-field-meta .wf-field-count .wf-tags .wf-tag .wf-tag-input
     12b Segmented control  .wf-segmented .wf-segment
     12c Menu               .wf-menu .wf-menu-item .wf-menu-label
     13  Tabs               .wf-tabs
     14  Panels and cards   .wf-panel .wf-card
     15  The familiar       .wf-familiar .wf-voice
     16  Chat               .wf-msg .wf-msg-list .wf-chat-scroll
     16b Saga chat          .wf-chat-head .wf-chat-card .wf-chat-tool .wf-passage .wf-cite .wf-chat-attach
     16c Notes              .wf-folder .wf-note-row .wf-backlinks .wf-picker .wf-capture-* .wf-msg-actions .wf-split .wf-template-*
     16d Saga memory        .wf-memory .wf-memory-item .wf-memory-form .wf-details-diff
     16e Saga note writes   .wf-saga-changes .wf-saga-mark .wf-saga-pop .wf-version--held
     16f Tool cards         .wf-tool-card .wf-tool-card-head .wf-tool-card-body .wf-tool-card-foot
     16g Feedback reports   .wf-report-form .wf-report-details
     16h Note images        .wf-note-image
     19  Badges, kbd        .wf-badge .wf-kbd .wf-saved
     19b Banner             .wf-banner
     19c Dialog             .wf-dialog .wf-dialog-section
     19d Drop zone, progress .wf-dropzone .wf-progress
     20  Toasts            .wf-toast .wf-toast-region
     21  Sidebar            .wf-sidebar .wf-brand .wf-brand-mark .wf-sidebar-story .wf-chapter
     21b Activity bar       .wf-activity .wf-activity-btn .wf-activity-badge
     21c Search             .wf-search .wf-search-chip .wf-search-group .wf-search-hit
     22  Manuscript page    .wf-page .wf-ms
     23  App shell          .wf-app .wf-topbar .wf-splitter
     23b Auth pages         .wf-auth .wf-auth-card
     23c Focus save state   .wf-focus-status
     23d Find bar           .wf-findbar
     23e Settings page      .wf-settings .wf-methods .wf-method
     23f History diff       .wf-diff .wf-versions
     23g Import preview     .wf-import-*  .wf-fidelity
     23h Read-only document .wf-doc-preview
     23i Comments           .wf-comment .wf-reply .wf-avatar
     23j Comments tab       .wf-panel-tabs .wf-comments .wf-comment--familiar .wf-comment-hl
     23k Home and stories   .wf-home .wf-story .wf-story-about .wf-sidebar-story-line
     23l Admin              .wf-admin-* (the admin shell and pages)
     23m Structured critique .wf-reader .wf-brief .wf-critic .wf-crit-* .wf-range-* .wf-tpl-save
     24  Motivation         .wf-streak .wf-goal .wf-cal-* .wf-work-fact .wf-sprint
     25  Utilities (.wf-divider .wf-icon .wf-grow .wf-list), accessibility, reduced motion, forced colors
   ============================================================================ */

/* -- 01  Primitive palette ---------------------------------------------------
   Named materials. Only sections 02 to 04 may reference these.
   -------------------------------------------------------------------------- */
:root {
  /* Paper: light neutrals with a faint green-grey cast. Not cream. */
  --wf-p-paper-0: #ffffff;
  --wf-p-paper-50: #fbfbf8;
  --wf-p-paper-100: #f0f0eb;
  --wf-p-paper-150: #eaeae4;
  --wf-p-paper-200: #e6e6e0;
  --wf-p-paper-250: #e4e4de;
  --wf-p-paper-300: #d9d9d2;
  --wf-p-paper-400: #c2c2ba;

  /* Graphite: text and control lines on paper */
  --wf-p-graphite-400: #9a9ca3;
  --wf-p-graphite-500: #7a7c84;
  --wf-p-graphite-600: #5c5f69;
  --wf-p-graphite-700: #474a55;
  --wf-p-graphite-800: #262831;
  --wf-p-graphite-900: #1d1f27;

  /* Dusk: dark surfaces, a cool blue-grey */
  --wf-p-dusk-950: #16181d;
  --wf-p-dusk-925: #181a1f;
  --wf-p-dusk-900: #1c1f25;
  --wf-p-dusk-850: #22252c;
  --wf-p-dusk-800: #2a2e36;
  --wf-p-dusk-750: #30343d;
  --wf-p-dusk-700: #424651;
  --wf-p-dusk-600: #6a6d75;
  --wf-p-dusk-500: #7c818e;

  /* Bone: light text on dusk. Warm, never pure white. */
  --wf-p-bone-100: #e6e2d8;
  --wf-p-bone-200: #dad6cb;
  --wf-p-bone-300: #c0bcb2;
  --wf-p-bone-400: #a5a197;

  /* Iron-gall blue: the writer's ink and the writer's actions */
  --wf-p-ink-50: #e3e7f3;
  --wf-p-ink-100: #dfe4f1;
  --wf-p-ink-200: #cbd5ee;
  --wf-p-ink-300: #b4c3f0;
  --wf-p-ink-350: #aebeee;
  --wf-p-ink-400: #c3d0f5;
  --wf-p-ink-700: #2e3d6b;
  --wf-p-ink-800: #24315a;
  --wf-p-ink-900: #2e3651;
  --wf-p-ink-925: #3a4670;
  --wf-p-ink-950: #161c30;
  /* Comment highlights: the writer's own ink as a tint, never Saga's violet */
  --wf-p-ink-hl-light: #e4e9f6;
  --wf-p-ink-hl-light-strong: #ccd6ee;
  --wf-p-ink-hl-dark: #2c3448;
  --wf-p-ink-hl-dark-strong: #3a4768;
  --wf-p-ink-hl-cream: #e2e1e4;
  --wf-p-ink-hl-cream-strong: #cdd1df;
  --wf-p-ink-hl-navy: #263c69;
  --wf-p-ink-hl-navy-strong: #35508a;

  /* Violet: sampled from the purple Saga sprites (#7048a8 mid, #a080d0,
     #b098e0, #c0a8f0, #c8b0f0 light, #502880 deep). The familiar color. */
  --wf-p-violet-50: #efe9fb;
  --wf-p-violet-75: #ebe4f0;
  --wf-p-violet-200: #c8b0f0;
  --wf-p-violet-250: #c0a8f0;
  --wf-p-violet-300: #b098e0;
  --wf-p-violet-400: #a080d0;
  --wf-p-violet-500: #7048a8;
  --wf-p-violet-600: #5a3490;
  --wf-p-violet-650: #54308a;
  --wf-p-violet-900: #3a3468;
  --wf-p-violet-950: #2d2645;

  /* Madder: concern and danger. A dyer's red, not an alarm red. */
  --wf-p-madder-50: #f7e3df;
  --wf-p-madder-100: #f2dcd2;
  --wf-p-madder-300: #f0a397;
  --wf-p-madder-350: #f4ab9e;
  --wf-p-madder-400: #e07a6d;
  --wf-p-madder-450: #e5877a;
  --wf-p-madder-500: #b4463d;
  --wf-p-madder-550: #ae4438;
  --wf-p-madder-600: #983530;
  --wf-p-madder-650: #943127;
  --wf-p-madder-700: #a12c2c;
  --wf-p-madder-750: #9a2a24;
  --wf-p-madder-800: #eb8272;
  --wf-p-madder-850: #f09080;
  --wf-p-madder-900: #3b2624;
  --wf-p-madder-925: #43304a;
  --wf-p-madder-950: #2a0f0b;

  /* Moss: saved, done, healthy */
  --wf-p-moss-50: #e1ebdb;
  --wf-p-moss-100: #dfe5cc;
  --wf-p-moss-300: #a7d09a;
  --wf-p-moss-350: #b4d6a3;
  --wf-p-moss-700: #38612f;
  --wf-p-moss-750: #375c2e;
  --wf-p-moss-900: #222f20;
  --wf-p-moss-925: #27404a;

  /* Cream and navy: one pair of materials, used inverted by two themes */
  --wf-p-cream-50: #fbf7eb;
  --wf-p-cream-100: #f6f0df;
  --wf-p-cream-150: #f2ecda;
  --wf-p-cream-175: #ede6d2;
  --wf-p-cream-200: #eee6d0;
  --wf-p-cream-250: #eae2cb;
  --wf-p-cream-300: #e8dfc7;
  --wf-p-cream-350: #e4dbc1;
  --wf-p-cream-400: #dcdde0;
  --wf-p-cream-500: #d2cbb8;
  --wf-p-cream-600: #beb8a7;
  --wf-p-cream-line: #ddd3b8;
  --wf-p-cream-line-strong: #c9bd9c;

  --wf-p-navy-300: #8492b5;
  --wf-p-navy-400: #6f7892;
  --wf-p-navy-500: #525d78;
  --wf-p-navy-600: #3d4968;
  --wf-p-navy-650: #2f4474;
  --wf-p-navy-700: #293c68;
  --wf-p-navy-750: #22335c;
  --wf-p-navy-800: #1b2a4e;
  --wf-p-navy-850: #172340;
  --wf-p-navy-900: #131d36;
  --wf-p-navy-950: #121b33;
  --wf-p-navy-line: #2c3e68;
  --wf-p-navy-line-strong: #3b5185;
}

/* -- 02  Semantic color tokens: light + dark -------------------------------
   Each value is light-dark(<light theme>, <dark theme>).
   The family is chosen by color-scheme:
     no data-theme      light dark (the OS decides)
     light, cream       light
     dark, navy         dark
   Components use only the tokens in this block.
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
}
:root[data-theme='light'],
:root[data-theme='cream'] {
  color-scheme: light;
}
:root[data-theme='dark'],
:root[data-theme='navy'] {
  color-scheme: dark;
}

:root {
  /* Surfaces. Nesting order: app > chrome > raised. The page is its own surface. */
  --wf-bg-app: light-dark(var(--wf-p-paper-200), var(--wf-p-dusk-950));
  --wf-bg-chrome: light-dark(var(--wf-p-paper-100), var(--wf-p-dusk-900));
  --wf-bg-page: light-dark(var(--wf-p-paper-50), var(--wf-p-dusk-850));
  --wf-bg-raised: light-dark(var(--wf-p-paper-0), var(--wf-p-dusk-800));
  --wf-bg-sunken: light-dark(var(--wf-p-paper-150), var(--wf-p-dusk-925));
  --wf-bg-hover: light-dark(var(--wf-p-paper-250), var(--wf-p-dusk-750));
  --wf-bg-selected: light-dark(var(--wf-p-ink-100), var(--wf-p-ink-900));
  --wf-bg-scrim: light-dark(rgb(29 31 39 / 0.32), rgb(0 0 0 / 0.55));

  /* Text. text, muted and subtle pass 4.5:1 on every surface above. */
  --wf-text: light-dark(var(--wf-p-graphite-900), var(--wf-p-bone-100));
  --wf-text-muted: light-dark(var(--wf-p-graphite-700), var(--wf-p-bone-300));
  --wf-text-subtle: light-dark(var(--wf-p-graphite-600), var(--wf-p-bone-400));
  --wf-text-disabled: light-dark(var(--wf-p-graphite-400), var(--wf-p-dusk-600));
  --wf-text-page: light-dark(var(--wf-p-graphite-800), var(--wf-p-bone-200));

  /* Lines. Only --wf-line-control may bound a control (3:1). */
  --wf-line: light-dark(var(--wf-p-paper-300), var(--wf-p-dusk-750));
  --wf-line-strong: light-dark(var(--wf-p-paper-400), var(--wf-p-dusk-700));
  --wf-line-control: light-dark(var(--wf-p-graphite-500), var(--wf-p-dusk-500));

  /* Ink: the writer's primary action, links, selection */
  --wf-accent: light-dark(var(--wf-p-ink-700), var(--wf-p-ink-350));
  --wf-accent-hover: light-dark(var(--wf-p-ink-800), var(--wf-p-ink-400));
  --wf-accent-text: light-dark(var(--wf-p-ink-700), var(--wf-p-ink-300));
  --wf-accent-soft: light-dark(var(--wf-p-ink-50), var(--wf-p-ink-900));
  --wf-on-accent: light-dark(var(--wf-p-paper-0), var(--wf-p-ink-950));
  --wf-text-selection: light-dark(var(--wf-p-ink-200), var(--wf-p-ink-925));

  /* Familiar: Saga's color. Use for AI voice, AI marks and AI celebration only. */
  --wf-familiar: light-dark(var(--wf-p-violet-500), var(--wf-p-violet-400));
  --wf-familiar-text: light-dark(var(--wf-p-violet-600), var(--wf-p-violet-250));
  --wf-familiar-soft: light-dark(var(--wf-p-violet-50), var(--wf-p-violet-950));

  /* Madder: a concern (inconsistency) and destructive actions */
  --wf-concern: light-dark(var(--wf-p-madder-500), var(--wf-p-madder-400));
  --wf-concern-text: light-dark(var(--wf-p-madder-600), var(--wf-p-madder-300));
  --wf-concern-soft: light-dark(var(--wf-p-madder-50), var(--wf-p-madder-900));
  --wf-danger: light-dark(var(--wf-p-madder-700), var(--wf-p-madder-800));
  --wf-on-danger: light-dark(var(--wf-p-paper-0), var(--wf-p-madder-950));

  /* Moss: saved, done */
  --wf-ok-text: light-dark(var(--wf-p-moss-700), var(--wf-p-moss-300));
  --wf-ok-soft: light-dark(var(--wf-p-moss-50), var(--wf-p-moss-900));

  /* Charts on the admin page. Views: a quiet navy step. Unique visitors and signups: the
     accent ink. Each mark passes 3:1 on --wf-bg-raised; uniques sit inside views. */
  --wf-chart-views: light-dark(var(--wf-p-navy-300), var(--wf-p-navy-400));
  --wf-chart-uniques: var(--wf-accent);
  --wf-chart-signups: var(--wf-accent);

  /* Comment highlight: the writer's own note on their text */
  --wf-comment-hl: light-dark(var(--wf-p-ink-hl-light), var(--wf-p-ink-hl-dark));
  --wf-comment-hl-strong: light-dark(var(--wf-p-ink-hl-light-strong), var(--wf-p-ink-hl-dark-strong));

  /* Focus: one ring everywhere */
  --wf-focus: var(--wf-accent);

  /* Shadow colors. Shadows in section 07 compose from these. */
  --wf-shadow-c1: light-dark(rgb(29 31 39 / 0.06), rgb(0 0 0 / 0.35));
  --wf-shadow-c2: light-dark(rgb(29 31 39 / 0.12), rgb(0 0 0 / 0.5));
}

/* -- 03  Theme: cream (light family) ----------------------------------------
   Cream paper, navy ink. The inverse of navy.
   -------------------------------------------------------------------------- */
:root[data-theme='cream'] {
  --wf-bg-app: var(--wf-p-cream-300);
  --wf-bg-chrome: var(--wf-p-cream-200);
  --wf-bg-page: var(--wf-p-cream-100);
  --wf-bg-raised: var(--wf-p-cream-50);
  --wf-bg-sunken: var(--wf-p-cream-250);
  --wf-bg-hover: var(--wf-p-cream-350);
  --wf-bg-selected: var(--wf-p-cream-400);
  --wf-bg-scrim: rgb(27 42 78 / 0.3);

  --wf-text: var(--wf-p-navy-800);
  --wf-text-muted: var(--wf-p-navy-600);
  --wf-text-subtle: var(--wf-p-navy-500);
  --wf-text-disabled: var(--wf-p-graphite-400);
  --wf-text-page: var(--wf-p-navy-800);

  --wf-line: var(--wf-p-cream-line);
  --wf-line-strong: var(--wf-p-cream-line-strong);
  --wf-line-control: var(--wf-p-navy-400);

  --wf-accent: var(--wf-p-navy-800);
  --wf-accent-hover: var(--wf-p-navy-700);
  --wf-accent-text: var(--wf-p-navy-800);
  --wf-accent-soft: var(--wf-p-cream-400);
  --wf-on-accent: var(--wf-p-cream-100);
  --wf-text-selection: var(--wf-p-ink-200);

  --wf-familiar: var(--wf-p-violet-500);
  --wf-familiar-text: var(--wf-p-violet-650);
  --wf-familiar-soft: var(--wf-p-violet-75);

  --wf-concern: var(--wf-p-madder-550);
  --wf-concern-text: var(--wf-p-madder-650);
  --wf-concern-soft: var(--wf-p-madder-100);
  --wf-danger: var(--wf-p-madder-750);
  --wf-on-danger: var(--wf-p-cream-50);

  --wf-ok-text: var(--wf-p-moss-750);
  --wf-ok-soft: var(--wf-p-moss-100);
  --wf-chart-views: var(--wf-p-navy-300);
  --wf-comment-hl: var(--wf-p-ink-hl-cream);
  --wf-comment-hl-strong: var(--wf-p-ink-hl-cream-strong);

  --wf-shadow-c1: rgb(27 42 78 / 0.06);
  --wf-shadow-c2: rgb(27 42 78 / 0.12);
}

/* -- 04  Theme: navy (dark family) ------------------------------------------
   Navy paper, cream ink. The inverse of cream.
   -------------------------------------------------------------------------- */
:root[data-theme='navy'] {
  --wf-bg-app: var(--wf-p-navy-900);
  --wf-bg-chrome: var(--wf-p-navy-850);
  --wf-bg-page: var(--wf-p-navy-800);
  --wf-bg-raised: var(--wf-p-navy-750);
  --wf-bg-sunken: var(--wf-p-navy-950);
  --wf-bg-hover: var(--wf-p-navy-700);
  --wf-bg-selected: var(--wf-p-navy-650);
  --wf-bg-scrim: rgb(8 12 24 / 0.6);

  --wf-text: var(--wf-p-cream-150);
  --wf-text-muted: var(--wf-p-cream-500);
  --wf-text-subtle: var(--wf-p-cream-600);
  --wf-text-disabled: var(--wf-p-navy-400);
  --wf-text-page: var(--wf-p-cream-175);

  --wf-line: var(--wf-p-navy-line);
  --wf-line-strong: var(--wf-p-navy-line-strong);
  --wf-line-control: var(--wf-p-navy-300);

  --wf-accent: var(--wf-p-cream-150);
  --wf-accent-hover: var(--wf-p-cream-50);
  --wf-accent-text: var(--wf-p-cream-150);
  --wf-accent-soft: var(--wf-p-navy-650);
  --wf-on-accent: var(--wf-p-navy-800);
  --wf-text-selection: var(--wf-p-navy-650);

  --wf-familiar: var(--wf-p-violet-300);
  --wf-familiar-text: var(--wf-p-violet-200);
  --wf-familiar-soft: var(--wf-p-violet-900);

  --wf-concern: var(--wf-p-madder-450);
  --wf-concern-text: var(--wf-p-madder-350);
  --wf-concern-soft: var(--wf-p-madder-925);
  --wf-danger: var(--wf-p-madder-850);
  --wf-on-danger: var(--wf-p-madder-950);

  --wf-ok-text: var(--wf-p-moss-350);
  --wf-ok-soft: var(--wf-p-moss-925);
  --wf-chart-views: var(--wf-p-navy-300);
  --wf-comment-hl: var(--wf-p-ink-hl-navy);
  --wf-comment-hl-strong: var(--wf-p-ink-hl-navy-strong);

  --wf-shadow-c1: rgb(5 9 20 / 0.35);
  --wf-shadow-c2: rgb(5 9 20 / 0.55);
}

/* -- 05  Type tokens ----------------------------------------------------------
   UI face: Atkinson Hyperlegible Next. Manuscript faces: section 06.
   The UI scale follows the classic typographic scale (Bringhurst):
   11 12 14 16 18 21 24 36 48. Sizes are rem so browser zoom works.
   -------------------------------------------------------------------------- */
:root {
  --wf-font-ui:
    'Atkinson Hyperlegible Next', ui-sans-serif, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Manuscript faces the writer can pick */
  --wf-font-literata: 'Literata', 'Iowan Old Style', Georgia, serif;
  --wf-font-source-serif: 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --wf-font-alegreya: 'Alegreya', 'Palatino Linotype', Palatino, serif;
  --wf-font-atkinson: var(--wf-font-ui);
  --wf-font-courier: 'Courier Prime', 'Courier New', Courier, monospace;
  /* Code and prompt text on the admin page. A system face: the page is for the owner, and
     it shows no manuscript glyph. Courier Prime ships with the app as the last fallback. */
  --wf-font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier Prime', monospace;

  --wf-text-2xs: 0.6875rem; /* 11px: fine print, counts in chips         */
  --wf-text-xs: 0.75rem; /*    12px: meta, badges, captions             */
  --wf-text-sm: 0.875rem; /*   14px: DEFAULT UI text                    */
  --wf-text-md: 1rem; /*       16px: chat and critique prose, inputs   */
  --wf-text-lg: 1.125rem; /*   18px: panel titles, card titles          */
  --wf-text-xl: 1.3125rem; /*  21px: section headings                   */
  --wf-text-2xl: 1.5rem; /*    24px: screen titles                      */
  --wf-text-3xl: 2.25rem; /*   36px: briefing headline                  */
  --wf-text-4xl: 3rem; /*      48px: empty-state display                */

  --wf-weight-regular: 400;
  --wf-weight-medium: 500;
  --wf-weight-semibold: 600;
  --wf-weight-bold: 700;

  --wf-leading-tight: 1.2;
  --wf-leading-snug: 1.35;
  --wf-leading-normal: 1.5;
  --wf-leading-relaxed: 1.6;

  --wf-track-tight: -0.012em;
  --wf-track-normal: 0;
  --wf-track-wide: 0.01em;
}

/* -- 06  Manuscript preference tokens ---------------------------------------
   The writer picks the face and size apart from the theme.
     data-ms-font on <html>: literata (default) | source-serif | alegreya | atkinson | courier
     data-ms-size on <html>: s | m (default) | l | xl
     data-ms-width on <html>: narrow (default) | medium | wide | full
     data-ms-scene on <html>: asterism (default) | stars | dots | dash | fleuron | hash | blank
   A scene separator is an image or a text mark. No separator relies on a system font.
     Image: --wf-ms-scene-image (an SVG mask), --wf-ms-scene-w and --wf-ms-scene-h (in em).
     Text:  --wf-ms-scene-glyph. Use only a glyph that each bundled face has.
   A custom separator sets the three image tokens. It needs no new drawing rule.
   The app may also set --wf-ms-size inline for a free value.
   Each face sets its own leading and measure, because x-height and width differ.
   The width scales the measure of the face. It does not replace it. The page
   limits the column, so the width has no effect on a narrow window.
   -------------------------------------------------------------------------- */
:root {
  --wf-ms-font: var(--wf-font-literata);
  --wf-ms-size-s: 1.0625rem; /*  17px */
  --wf-ms-size-m: 1.1875rem; /*  19px */
  --wf-ms-size-l: 1.3125rem; /*  21px */
  --wf-ms-size-xl: 1.5rem; /*    24px */
  --wf-ms-size: var(--wf-ms-size-m);
  --wf-ms-leading: 1.7;
  --wf-ms-measure-base: 31em; /* about 68 characters of Literata */
  --wf-ms-measure-scale: 1; /* narrow */
  --wf-ms-measure: calc(var(--wf-ms-measure-base) * var(--wf-ms-measure-scale));
  --wf-ms-indent: 1.5em;
  /* The first-line indent of a paragraph. A blockquote keeps --wf-ms-indent. */
  --wf-ms-para-indent: var(--wf-ms-indent);
  /* Lists and tables of a note: the list indent, the table text and the narrowest cell. */
  --wf-ms-indent-list: 1.6em;
  --wf-ms-table-size: 0.9em;
  --wf-ms-cell-min: 6em;
  --wf-ms-para-gap: 0;
  --wf-ms-title-size: 2em;
  --wf-ms-title-weight: 500;
  /* The two drawn glyphs. Vite bundles each SVG as a file (vite.config.ts). */
  --wf-scene-asterism: url('./assets/separators/asterism.svg');
  --wf-scene-fleuron: url('./assets/separators/fleuron.svg');
  /* The default is the asterism. Works for starship and castle alike. */
  --wf-ms-scene-image: var(--wf-scene-asterism);
  --wf-ms-scene-w: 1em;
  --wf-ms-scene-h: 0.92em;
  --wf-ms-scene-glyph: '';
  --wf-ms-scene-rule-w: 3em; /* the short rule of the dash separator */
  --wf-ms-numerals: oldstyle-nums proportional-nums;
}
:root[data-ms-font='source-serif'] {
  --wf-ms-font: var(--wf-font-source-serif);
  --wf-ms-leading: 1.65;
  --wf-ms-measure-base: 32em;
}
:root[data-ms-font='alegreya'] {
  --wf-ms-font: var(--wf-font-alegreya);
  --wf-ms-leading: 1.6;
  --wf-ms-measure-base: 33em;
}
:root[data-ms-font='atkinson'] {
  --wf-ms-font: var(--wf-font-atkinson);
  --wf-ms-leading: 1.6;
  --wf-ms-measure-base: 32em;
  --wf-ms-numerals: lining-nums proportional-nums;
}
:root[data-ms-font='courier'] {
  --wf-ms-font: var(--wf-font-courier);
  --wf-ms-leading: 1.75;
  --wf-ms-measure-base: 62ch;
  --wf-ms-indent: 5ch;
  --wf-ms-title-weight: 700;
  --wf-ms-numerals: normal;
}
:root[data-ms-width='medium'] {
  --wf-ms-measure-scale: 1.25;
}
:root[data-ms-width='wide'] {
  --wf-ms-measure-scale: 1.5;
}
/* No maximum. The column fills the page inside the page padding. */
:root[data-ms-width='full'] {
  --wf-ms-measure: 100%;
}
/* No bundled face has the asterism or the fleuron, so the app draws them as images.
   A preset without an image sets the image to none and the box to zero. */
:root[data-ms-scene='stars'],
:root[data-ms-scene='dots'],
:root[data-ms-scene='dash'],
:root[data-ms-scene='hash'],
:root[data-ms-scene='blank'] {
  --wf-ms-scene-image: none;
  --wf-ms-scene-w: 0;
  --wf-ms-scene-h: 0;
}
:root[data-ms-scene='stars'] {
  --wf-ms-scene-glyph: '*\a0*\a0*';
}
:root[data-ms-scene='dots'] {
  --wf-ms-scene-glyph: '\2022\a0\2022\a0\2022';
}
/* The dash is a drawn rule (.wf-ms hr::after), so its length is the same in each face. */
:root[data-ms-scene='dash'],
:root[data-ms-scene='blank'] {
  --wf-ms-scene-glyph: '';
}
:root[data-ms-scene='fleuron'] {
  --wf-ms-scene-image: var(--wf-scene-fleuron);
  --wf-ms-scene-w: 1.5em;
  --wf-ms-scene-h: 0.94em;
}
:root[data-ms-scene='hash'] {
  --wf-ms-scene-glyph: '#';
}
:root[data-ms-size='s'] {
  --wf-ms-size: var(--wf-ms-size-s);
}
:root[data-ms-size='l'] {
  --wf-ms-size: var(--wf-ms-size-l);
}
:root[data-ms-size='xl'] {
  --wf-ms-size: var(--wf-ms-size-xl);
}
/* A note has block paragraphs unless the writer picks "Indented" (owner, October 14, 2026).
   A chapter always indents. The note page sets .wf-note-page. */
:root:not([data-ms-note-paragraphs='indented']) .wf-note-page {
  --wf-ms-para-indent: 0;
  --wf-ms-para-gap: 0.9em;
}

/* -- 07  Space, radius, border, elevation, z, motion, layout ---------------- */
:root {
  /* Space: 4px base */
  --wf-space-1: 2px;
  --wf-space-2: 4px;
  --wf-space-3: 8px;
  --wf-space-4: 12px;
  --wf-space-5: 16px;
  --wf-space-6: 24px;
  --wf-space-7: 32px;
  --wf-space-8: 48px;
  --wf-space-9: 64px;
  --wf-space-10: 96px;

  /* Radius: larger containers get larger radii */
  --wf-radius-xs: 3px; /*  entity chips, kbd, checkboxes */
  --wf-radius-sm: 6px; /*  buttons, inputs               */
  --wf-radius-md: 10px; /* cards, popovers, toasts        */
  --wf-radius-lg: 16px; /* phone sheets, dialogs          */
  --wf-radius-full: 999px; /* badges, switches, streak dots */

  /* Borders */
  --wf-border-w: 1px;
  --wf-border-w-strong: 2px;
  --wf-rule-w: 3px; /* the familiar's rule and margin marks */
  --wf-hairline: var(--wf-border-w) solid var(--wf-line);
  --wf-hairline-strong: var(--wf-border-w) solid var(--wf-line-strong);
  --wf-border-control: var(--wf-border-w) solid var(--wf-line-control);

  /* Elevation. The page is level 0 and never has a shadow. */
  --wf-shadow-1: 0 1px 2px var(--wf-shadow-c1);
  --wf-shadow-2: 0 2px 6px -1px var(--wf-shadow-c1), 0 1px 2px var(--wf-shadow-c1);
  --wf-shadow-3: 0 8px 24px -6px var(--wf-shadow-c2), 0 2px 6px var(--wf-shadow-c1);
  --wf-shadow-4: 0 20px 48px -12px var(--wf-shadow-c2), 0 4px 12px var(--wf-shadow-c1);

  /* Z layers. Use only these. */
  --wf-z-base: 0;
  --wf-z-margin-mark: 1;
  --wf-z-sticky: 10;
  --wf-z-sidebar: 20;
  --wf-z-panel: 30;
  --wf-z-popover: 40;
  --wf-z-scrim: 50;
  --wf-z-sheet: 60;
  --wf-z-dialog: 70;
  --wf-z-toast: 80;
  --wf-z-tooltip: 90;

  /* Motion */
  --wf-dur-instant: 80ms; /*  hover, press                         */
  --wf-dur-quick: 140ms; /*   tooltips, chips, small reveals       */
  --wf-dur-gentle: 240ms; /*  panels, sheets, toasts               */
  --wf-dur-slow: 420ms; /*    familiar state changes               */
  --wf-dur-glow: 1200ms; /*   the one familiar glow per idea       */
  --wf-dur-toast: 6000ms; /*  time a toast stays                   */
  --wf-dur-flash: 2000ms; /*  time a passage link tint stays (BLOCK_FLASH_MS) */
  --wf-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --wf-ease-enter: cubic-bezier(0, 0, 0.2, 1);
  --wf-ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --wf-ease-flutter: cubic-bezier(0.34, 1.4, 0.64, 1);

  /* Layout */
  --wf-topbar-h: 48px;
  --wf-sidebar-w: 264px;
  --wf-activity-w: 48px; /* the activity bar, icons only (docs/specs/global-search.md) */
  --wf-activity-w-labels: 72px; /* the activity bar with a label under each icon */
  --wf-search-w: 760px; /* the search modal (.wf-search) */
  --wf-panel-w: 368px;
  /* The splitter of a rail. The app overrides the two rail widths on .wf-app when the
     writer drags a splitter (src/lib/railWidths.ts holds the limits). */
  --wf-splitter-hit: var(--wf-space-3); /* width of the hit area, fine pointer */
  --wf-splitter-inset: var(--wf-space-2); /* part of the hit area that is on the rail */
  --wf-form-w: 400px; /* small standalone forms: sign-in, first-run setup */
  --wf-dialog-w: 480px; /* default dialog width */
  --wf-settings-w: 560px; /* settings page column */
  --wf-home-w: 720px; /* home screen column: the list of stories */
  --wf-admin-nav-w: 220px; /* the left nav of the admin shell */
  --wf-admin-main-w: 1040px; /* the main column of the admin shell */
  --wf-admin-index-w: 13em; /* the side index of the model card */
  --wf-admin-code-max-h: 32rem; /* an open code block scrolls after this height */
  --wf-admin-measure: 70ch; /* the longest line of admin prose */
  --wf-admin-key-w: 14em; /* the key column of a key and value grid */
  --wf-admin-group-min: 26em; /* the narrowest column of the admin group grid */
  --wf-admin-story-w: 28em; /* the story picker of the model card */
  --wf-admin-chart-h: 200px; /* the height of a daily chart on the tab "Landing" */
  --wf-admin-pass-w: 8em; /* the pass bar in a table cell */
  --wf-admin-source-min: 15em; /* the narrowest column of the source tables */
  --wf-admin-tip-w: 17em; /* the widest chart tooltip */
  --wf-admin-stale-opacity: 0.55; /* the old numbers while a new range loads */
  --wf-find-field-min: 8em; /* narrowest find or replace field */
  --wf-doc-preview-max-h: 60vh; /* expanded section preview in the import */
  --wf-avatar-size: 24px;
  --wf-menu-min-w: 14em;
  --wf-menu-max-w: 22em;
  --wf-avatar-size-sm: 20px;
  --wf-page-pad-x: var(--wf-space-8);
  --wf-page-pad-top: var(--wf-space-9);
  --wf-margin-mark-gap: var(--wf-space-5); /* distance from text to a margin mark */
  --wf-hovercard-w: 320px;
  --wf-toast-w: 380px;
  --wf-input-w-sm: 8em; /* a short field: a number of days or words, a time */
  --wf-cal-period-w: 8.5em; /* the week column of the goal calendar */
  --wf-cal-period-w-narrow: 5.5em; /* the same column on a narrow page */
  --wf-cal-period-w-tight: 4em; /* the same column at a large text size on a phone */
  /* Room that a page keeps free at its end while a toast shows: the height of the
     toast region, its distance from the bottom edge, and a gap. The app measures the
     region and sets --wf-toast-h on <html>. The fallback is one toast of two lines. */
  --wf-toast-clear: calc(
    var(--wf-toast-h, var(--wf-space-9)) + var(--wf-space-6) + var(--wf-space-5) + var(--wf-safe-bottom)
  );
  --wf-tooltip-w: 240px;
  --wf-sheet-max-h: 85dvh;

  /* Controls */
  --wf-control-h-sm: 28px;
  --wf-control-h: 36px;
  --wf-control-h-lg: 44px;
  --wf-touch-target: 44px;
  --wf-icon-sm: 16px;
  --wf-icon: 18px;
  --wf-icon-lg: 22px;
  --wf-icon-stroke: 1.5;
  --wf-check-size: 18px;
  /* An image attached to a feedback report, as a thumbnail. */
  --wf-thumb-size: 72px;
  /* The named widths of an image in a note, as a share of the text column. */
  --wf-note-image-small: 33%;
  --wf-note-image-medium: 66%;
  --wf-note-image-full: 100%;
  /* The box of an image that has no bytes to show yet. */
  --wf-note-image-empty-h: 6rem;
  --wf-switch-w: 34px;
  --wf-switch-h: 20px;
  --wf-switch-knob: 14px;
  --wf-disabled-opacity: 0.5; /* a control with aria-disabled, such as the push switch before the iOS install */
  --wf-dot-size: 10px;
  --wf-dot-size-sm: 6px; /* the small dot of the goal calendar: wrote, goal not met */
  --wf-caret-size: 5px;

  /* Mascot sizes */
  --wf-mascot-xs: 16px; /*  glyph only: inline marks, tab icon      */
  --wf-mascot-sm: 24px; /*  chat avatar                             */
  --wf-mascot-md: 40px; /*  panel perch                             */
  --wf-mascot-lg: 96px; /*  empty states, briefing                  */
  --wf-mascot-xl: 160px; /* onboarding, streak milestone            */

  /* Formatting toolbar */
  --wf-tool-size: 32px;
  --wf-tool-sep-h: 20px;
  --wf-dock-h: 48px; /* phone toolbar docked above the keyboard */
  /* Height of the on-screen keyboard. Chrome fills it when the app sets
     navigator.virtualKeyboard.overlaysContent = true. On iOS the app sets
     it from visualViewport in JS. */
  --wf-keyboard-inset: env(keyboard-inset-height, 0px);
  /* Height of the visible area above the keyboard. On Android the keyboard resizes the
     layout (interactive-widget=resizes-content), so 100dvh shrinks. If the keyboard
     overlays the page, the inset takes its height off. On iOS the app sets the value from
     visualViewport in JS (lib/viewport.ts). */
  --wf-visible-h: calc(100dvh - var(--wf-keyboard-inset));

  /* Continuous scroll */
  --wf-chapter-gap: var(--wf-space-10); /* space above each chapter heading */

  /* Focus */
  --wf-focus-w: 2px;
  --wf-focus-offset: 2px;

  /* Device safe areas (PWA on phones) */
  --wf-safe-top: env(safe-area-inset-top, 0px);
  --wf-safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 600px) {
  :root {
    --wf-page-pad-x: var(--wf-space-5);
    --wf-page-pad-top: var(--wf-space-7);
    --wf-ms-size-m: 1.125rem; /* 18px on phones */
    --wf-control-h: var(--wf-touch-target);
    --wf-margin-mark-gap: var(--wf-space-2);
  }
}

/* -- 08  Mascot tokens ---------------------------------------------------------
   Saga is a set of purple PNG sprites in src/assets/saga/. The typed module
   src/assets/saga/index.ts maps each UI state to its sprite URL.
   Sprites have different aspect ratios, so the box is square and the image
   sits on the bottom edge (Saga stands on the panel).
   -------------------------------------------------------------------------- */
:root {
  --wf-mascot-pop: 1.06; /* scale at the top of the idea pop */
  --wf-mascot-bob: 2px; /*  lift while thinking               */
}

/* -- 09  Reset and base ----------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--wf-bg-app);
  color: var(--wf-text);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
  font-weight: var(--wf-weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
blockquote {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
  letter-spacing: var(--wf-track-tight);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--wf-accent-text);
  text-decoration-thickness: var(--wf-border-w);
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration-thickness: var(--wf-border-w-strong);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

img,
svg {
  display: block;
  max-width: 100%;
}

::selection {
  background: var(--wf-text-selection);
  color: var(--wf-text);
}

:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}

hr {
  border: 0;
  border-top: var(--wf-hairline);
  margin: var(--wf-space-5) 0;
}

/* -- 10  Type utilities ----------------------------------------------------- */
.wf-title {
  font-size: var(--wf-text-2xl);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
}
.wf-heading {
  font-size: var(--wf-text-xl);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
}
.wf-subheading {
  font-size: var(--wf-text-lg);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
}
.wf-body {
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
}
.wf-meta {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  line-height: var(--wf-leading-snug);
}
.wf-muted {
  color: var(--wf-text-muted);
}
.wf-num {
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-label {
  display: block;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text);
}

/* -- 11  Buttons ---------------------------------------------------------------
   primary   The writer's one main action in a view. Ink fill.
   secondary Outlined.
   quiet     No box at rest. For toolbars and card actions.
   familiar  Asks the familiar for something (Ask, Riff, Check). Familiar-color outline.
   danger    Permanent loss only, for example "Delete forever". An action that
             the writer can undo, for example "Move to trash", is not danger.
             --danger-quiet is the outlined form, for a row in a list.
   -------------------------------------------------------------------------- */
.wf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--wf-space-2);
  min-height: var(--wf-control-h);
  padding: 0 var(--wf-space-4);
  border: var(--wf-border-w) solid transparent;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
  white-space: nowrap;
  text-decoration: none; /* a link can be a button: <a class="wf-btn"> */
  cursor: pointer;
  transition:
    background-color var(--wf-dur-instant) var(--wf-ease-standard),
    border-color var(--wf-dur-instant) var(--wf-ease-standard),
    color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-btn svg {
  width: var(--wf-icon);
  height: var(--wf-icon);
  flex: none;
}
.wf-btn:disabled,
.wf-btn[aria-disabled='true'] {
  color: var(--wf-text-disabled);
  cursor: not-allowed;
}

.wf-btn--primary {
  background: var(--wf-accent);
  color: var(--wf-on-accent);
}
.wf-btn--primary:hover:not(:disabled) {
  background: var(--wf-accent-hover);
}
.wf-btn--primary:disabled {
  background: var(--wf-bg-hover);
}

.wf-btn--secondary {
  border: var(--wf-border-control);
  background: var(--wf-bg-raised);
}
.wf-btn--secondary:hover:not(:disabled) {
  background: var(--wf-bg-hover);
}

.wf-btn--quiet {
  color: var(--wf-text-muted);
}
.wf-btn--quiet:hover:not(:disabled) {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}

.wf-btn--familiar {
  border: var(--wf-border-w) solid var(--wf-familiar);
  background: var(--wf-familiar-soft);
  color: var(--wf-familiar-text);
}
.wf-btn--familiar:hover:not(:disabled) {
  background: var(--wf-bg-raised);
}

.wf-btn--danger {
  background: var(--wf-danger);
  color: var(--wf-on-danger);
}
.wf-btn--danger-quiet {
  border: var(--wf-border-w) solid var(--wf-concern);
  color: var(--wf-concern-text);
}
.wf-btn--danger-quiet:hover:not(:disabled) {
  background: var(--wf-concern-soft);
}
/* aria-disabled (the offline state of the home screen): the same look as :disabled.
   A primary button drops its fill, so the disabled text is not on the accent color.
   A quiet danger button drops its concern border: it is not a danger while it
   does nothing. Neither reacts to hover. */
.wf-btn--primary[aria-disabled='true'],
.wf-btn--primary[aria-disabled='true']:hover {
  background: var(--wf-bg-hover);
}
.wf-btn--danger-quiet[aria-disabled='true'],
.wf-btn--danger-quiet[aria-disabled='true']:hover {
  border: var(--wf-border-control);
  background: transparent;
}

.wf-btn--sm {
  min-height: var(--wf-control-h-sm);
  padding: 0 var(--wf-space-3);
  font-size: var(--wf-text-xs);
}
.wf-btn--lg {
  min-height: var(--wf-control-h-lg);
  padding: 0 var(--wf-space-5);
  font-size: var(--wf-text-md);
}
.wf-btn--icon {
  width: var(--wf-control-h);
  padding: 0;
}
.wf-btn--icon.wf-btn--sm {
  width: var(--wf-control-h-sm);
}
.wf-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
}
/* A destructive action keeps a distance of --wf-space-5 from the safe action
   before it, so a slip of the finger does not hit it. */
.wf-btn-row > * + .wf-btn--danger,
.wf-btn-row > * + .wf-btn--danger-quiet,
.wf-dialog-foot > * + .wf-btn--danger {
  margin-inline-start: var(--wf-space-4);
}
/* If the row wraps, the distance stays the same. */
.wf-btn-row:has(> .wf-btn--danger, > .wf-btn--danger-quiet),
.wf-dialog-foot:has(> .wf-btn--danger) {
  row-gap: var(--wf-space-5);
}

/* -- 12  Fields --------------------------------------------------------------- */
.wf-field {
  display: grid;
  gap: var(--wf-space-2);
}
.wf-field-hint {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-field-error {
  font-size: var(--wf-text-xs);
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}

.wf-input,
.wf-textarea,
.wf-select {
  width: 100%;
  min-height: var(--wf-control-h);
  padding: var(--wf-space-2) var(--wf-space-4);
  border: var(--wf-border-control);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
  color: var(--wf-text);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-snug);
  transition: border-color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-input::placeholder,
.wf-textarea::placeholder {
  color: var(--wf-text-subtle);
}
.wf-input:hover,
.wf-textarea:hover,
.wf-select:hover {
  border-color: var(--wf-text-muted);
}
.wf-input:focus-visible,
.wf-textarea:focus-visible,
.wf-select:focus-visible {
  outline-offset: 0;
  border-color: var(--wf-focus);
}
.wf-input[aria-invalid='true'] {
  border-color: var(--wf-concern);
}
.wf-textarea {
  min-height: calc(var(--wf-control-h) * 2.5);
  padding-block: var(--wf-space-3);
  resize: vertical;
}
.wf-select {
  appearance: none;
  padding-inline-end: var(--wf-space-7);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--wf-text-muted) 50%),
    linear-gradient(135deg, var(--wf-text-muted) 50%, transparent 50%);
  background-position:
    right var(--wf-space-5) center,
    right var(--wf-space-4) center;
  background-size: var(--wf-caret-size) var(--wf-caret-size);
  background-repeat: no-repeat;
}
/* A short field: a number of days or words, a time. In a .wf-field grid it stays
   at the start. */
.wf-input--short {
  width: var(--wf-input-w-sm);
  justify-self: start;
}
/* A select as wide as its longest option. */
.wf-select--fit {
  width: auto;
  justify-self: start;
}
/* A date field has a wide intrinsic size. min-width lets it shrink in a row. */
.wf-input[type='date'] {
  min-width: 0;
}

.wf-input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.wf-input-group > svg {
  position: absolute;
  inset-inline-start: var(--wf-space-4);
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
  pointer-events: none;
}
.wf-input-group > .wf-input {
  padding-inline-start: var(--wf-space-7);
}

/* The line under a field with a limit: the hint at the start, the count at the end.
   .wf-field-count is "212 of 1,000". [data-full] at the limit: concern text, semibold. */
.wf-field-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--wf-space-1) var(--wf-space-3);
}
.wf-field-count {
  margin-inline-start: auto;
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wf-field-count[data-full] {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}

/* The tag field: the chips and a text field in one control box. Enter or a comma adds
   the text as a chip. The suggestions are a .wf-picker-list in .wf-tag-suggest, inside
   the dialog flow, not a popover: a popover would clip in the scrolling dialog body.
   .wf-tags          A list of tags: on the home card, in the field, in a diff.
   .wf-tag           One tag: a quiet pill with the writer's text. Not a control.
   .wf-tag-remove    The "x" of a chip in the field. It has an aria-label.
   .wf-tag-input     The control box. It shows the focus ring of its text field.
   .wf-tag-input-field The text field after the chips. */
.wf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1);
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-1);
  max-width: 100%;
  min-height: var(--wf-chat-attach-h);
  padding: 0 var(--wf-space-3);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-sunken);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-tight);
}
.wf-tag-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wf-tag-remove {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--wf-icon);
  height: var(--wf-icon);
  margin-inline: 0 calc(-1 * var(--wf-space-2));
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-full);
  background: transparent;
  color: var(--wf-text-muted);
  cursor: pointer;
}
.wf-tag-remove:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-tag-remove > svg {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
.wf-tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-1);
  min-height: var(--wf-control-h);
  padding: var(--wf-space-1) var(--wf-space-2);
  border: var(--wf-border-control);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
  cursor: text;
  transition: border-color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-tag-input:hover {
  border-color: var(--wf-text-muted);
}
.wf-tag-input:has(.wf-tag-input-field:focus-visible) {
  border-color: var(--wf-focus);
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: 0;
}
.wf-tag-input[aria-invalid='true'] {
  border-color: var(--wf-concern);
}
/* In the field, a chip is the writer's current value: the raised surface and the text color. */
.wf-tag-input .wf-tag {
  border: var(--wf-hairline-strong);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
}
.wf-tag-input-field {
  flex: 1 1 var(--wf-tag-field-min-w);
  min-width: var(--wf-tag-field-min-w);
  min-height: var(--wf-chat-attach-h);
  padding: 0 var(--wf-space-2);
  border: 0;
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-snug);
}
.wf-tag-input-field::placeholder {
  color: var(--wf-text-subtle);
}
.wf-tag-input-field:focus-visible {
  outline: none;
}
.wf-tag-suggest {
  padding: var(--wf-space-1);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
  font-size: var(--wf-text-sm);
}
:root {
  --wf-tag-field-min-w: 8em; /* the narrowest text field after the chips */
}

.wf-check {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: var(--wf-control-h-sm);
  cursor: pointer;
}
.wf-check input {
  appearance: none;
  margin: 0;
  width: var(--wf-check-size);
  height: var(--wf-check-size);
  border: var(--wf-border-control);
  border-radius: var(--wf-radius-xs);
  background: var(--wf-bg-sunken);
  display: grid;
  place-content: center;
  flex: none;
}
.wf-check input::after {
  content: '';
  width: calc(var(--wf-check-size) / 2.2);
  height: calc(var(--wf-check-size) / 3.8);
  border-left: var(--wf-border-w-strong) solid var(--wf-on-accent);
  border-bottom: var(--wf-border-w-strong) solid var(--wf-on-accent);
  transform: rotate(-45deg) translate(var(--wf-border-w), calc(-1 * var(--wf-border-w)));
  opacity: 0;
}
.wf-check input:checked {
  background: var(--wf-accent);
  border-color: var(--wf-accent);
}
.wf-check input:checked::after {
  opacity: 1;
}

.wf-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-3);
  cursor: pointer;
}
.wf-switch input {
  appearance: none;
  margin: 0;
  position: relative;
  width: var(--wf-switch-w);
  height: var(--wf-switch-h);
  border: var(--wf-border-control);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-sunken);
  flex: none;
  transition: background-color var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-switch input::after {
  content: '';
  position: absolute;
  top: 50%;
  left: var(--wf-space-1);
  width: var(--wf-switch-knob);
  height: var(--wf-switch-knob);
  border-radius: var(--wf-radius-full);
  background: var(--wf-text-muted);
  transform: translateY(-50%);
  transition:
    left var(--wf-dur-quick) var(--wf-ease-standard),
    background-color var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-switch input:checked {
  background: var(--wf-accent);
  border-color: var(--wf-accent);
}
.wf-switch input:checked::after {
  left: calc(100% - var(--wf-switch-knob) - var(--wf-space-1));
  background: var(--wf-on-accent);
}
/* aria-disabled: the switch stays in the tab order and dims. The label text stays readable;
   a hint next to the switch says why it is off. */
.wf-switch:has(> input[aria-disabled='true']) {
  cursor: not-allowed;
}
.wf-switch > input[aria-disabled='true'] {
  opacity: var(--wf-disabled-opacity);
}

/* -- 12b Segmented control -----------------------------------------------------
   One choice from a few, shown all at once. Built on native radio inputs, so
   arrow keys, the group semantics and the form value come for free.
     <div class="wf-segmented" role="radiogroup" aria-label="...">
       <label class="wf-segment"><input type="radio" name="x" value="a" /><span>A</span></label>
       ...
     </div>
   The selected segment is raised with a control-color border (3:1), so the
   state does not rely on color. A disabled option is dimmed and not clickable.
   --sm is the compact size for list rows. The row wraps if it must.
   -------------------------------------------------------------------------- */
.wf-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1);
  max-width: 100%;
  padding: var(--wf-space-1);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
}
.wf-segment {
  position: relative;
  display: inline-flex;
}
.wf-segment input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.wf-segment span {
  display: inline-flex;
  align-items: center;
  min-height: var(--wf-control-h-sm);
  padding: 0 var(--wf-space-3);
  border: var(--wf-border-w) solid transparent;
  border-radius: calc(var(--wf-radius-sm) - var(--wf-space-1));
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-medium);
  white-space: nowrap;
  transition:
    background-color var(--wf-dur-instant) var(--wf-ease-standard),
    color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-segment input:hover:not(:disabled) + span {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-segment input:checked + span {
  border-color: var(--wf-line-control);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
  box-shadow: var(--wf-shadow-1);
}
.wf-segment input:focus-visible + span {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-segment input:disabled {
  cursor: not-allowed;
}
.wf-segment input:disabled + span {
  color: var(--wf-text-disabled);
  text-decoration: line-through;
  text-decoration-thickness: var(--wf-border-w);
}
.wf-segmented--sm .wf-segment span {
  min-height: calc(var(--wf-control-h-sm) - var(--wf-space-2));
  padding: 0 var(--wf-space-2);
  font-size: var(--wf-text-xs);
}
@media (pointer: coarse) {
  .wf-segment span {
    min-height: var(--wf-touch-target);
  }
}

/* -- 12c Menu --------------------------------------------------------------------
   A small popover list of actions, opened by a button.
     <div class="wf-menu-anchor">
       <button aria-haspopup="menu" aria-expanded="true" aria-controls="m1">...</button>
       <div class="wf-menu" id="m1" role="menu" aria-label="...">
         <button class="wf-menu-item" role="menuitem" tabindex="-1">...</button>
       </div>
     </div>
   The Menu component in components/Menu.tsx owns the keys: arrows and Home/End
   move, Enter or Space picks, Esc and Tab close, focus returns to the button.
   --end aligns the menu to the end edge of the button.
   --up puts the menu above the button. The Menu component adds it if the menu
   has no room below the button.
   -------------------------------------------------------------------------- */
.wf-menu-anchor {
  position: relative;
  display: inline-flex;
}
.wf-menu {
  position: absolute;
  top: calc(100% + var(--wf-space-1));
  inset-inline-start: 0;
  z-index: var(--wf-z-popover);
  display: grid;
  gap: var(--wf-space-1);
  /* Both limits give way to the window, so a menu at 200% text size stays on
     the screen. */
  min-width: min(var(--wf-menu-min-w), calc(100vw - 2 * var(--wf-space-7)));
  max-width: min(var(--wf-menu-max-w), calc(100vw - 2 * var(--wf-space-7)));
  padding: var(--wf-space-1);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
  animation: wf-menu-in var(--wf-dur-quick) var(--wf-ease-enter);
}
.wf-menu--end {
  inset-inline-start: auto;
  inset-inline-end: 0;
}
.wf-menu--up {
  top: auto;
  bottom: calc(100% + var(--wf-space-1));
}
/* A menu in the window, at its trigger (Menu `fixed`): the docked toolbar of the phone
   scrolls sideways and would clip it. The script sets top and left. */
.wf-menu--fixed,
.wf-menu--fixed.wf-menu--up {
  position: fixed;
  bottom: auto;
  inset-inline-end: auto;
}
.wf-menu-item {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  width: 100%;
  min-height: var(--wf-control-h);
  padding: var(--wf-space-1) var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  text-align: start;
  cursor: pointer;
}
.wf-menu-item svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
.wf-menu-item:hover,
.wf-menu-item:focus-visible {
  background: var(--wf-bg-hover);
}
.wf-menu-item:focus-visible {
  outline-offset: calc(-1 * var(--wf-focus-w));
}
.wf-menu-item:disabled {
  color: var(--wf-text-disabled);
  background: transparent;
  cursor: not-allowed;
}
/* A menu item with two lines: a name and a .wf-meta line under it, for example a
   blocked item of the sync state (offline/SyncStatus.tsx). */
.wf-menu-item--stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding-block: var(--wf-space-2);
}
/* A line of text in a menu that is not an action, for example the account
   email above "Settings" and "Sign out". It takes no focus. */
.wf-menu-label {
  padding: var(--wf-space-3) var(--wf-space-3) var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  overflow-wrap: anywhere;
}
.wf-menu-sep {
  height: var(--wf-border-w);
  margin: var(--wf-space-1) 0;
  background: var(--wf-line);
}
@keyframes wf-menu-in {
  from {
    opacity: 0;
    transform: translateY(calc(-1 * var(--wf-space-1)));
  }
}

/* -- 13  Tabs ------------------------------------------------------------------
   Used for the AI panel modes: Chat, Riff, Critique.
   -------------------------------------------------------------------------- */
.wf-tabs {
  display: flex;
  gap: var(--wf-space-1);
  padding: var(--wf-space-1);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
}
.wf-tab {
  flex: 1;
  white-space: nowrap;
  min-height: var(--wf-control-h-sm);
  padding: 0 var(--wf-space-3);
  border: 0;
  border-radius: calc(var(--wf-radius-sm) - var(--wf-space-1));
  background: transparent;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  cursor: pointer;
}
.wf-tab:hover {
  color: var(--wf-text);
}
.wf-tab[aria-selected='true'] {
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  box-shadow: var(--wf-shadow-1);
}

/* -- 14  Panels and cards ------------------------------------------------------
   A panel is a region of chrome: the sidebar, the AI panel, a settings pane.
   A card is one item on a panel. Cards are the only raised thing on chrome.
   -------------------------------------------------------------------------- */
.wf-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--wf-bg-chrome);
  color: var(--wf-text);
}
.wf-panel-head {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: var(--wf-topbar-h);
  padding: 0 var(--wf-space-5);
  border-bottom: var(--wf-hairline);
}
.wf-panel-title {
  flex: 1;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}
/* Positioned, so the body contains and clips its absolutely positioned content
   (.wf-sr-only). Without this, that content makes the window scroll. */
.wf-panel-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--wf-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-4);
}
.wf-panel-foot {
  padding: var(--wf-space-4) var(--wf-space-5);
  border-top: var(--wf-hairline);
}
.wf-panel-empty {
  display: grid;
  justify-items: center;
  gap: var(--wf-space-4);
  padding: var(--wf-space-8) var(--wf-space-5);
  text-align: center;
  color: var(--wf-text-muted);
}

.wf-card {
  padding: var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-1);
}

/* -- 15  The familiar ----------------------------------------------------------
   .wf-voice    Anything the familiar says. Carries the familiar rule on its
                start edge. This rule is the familiar's signature.
   .wf-familiar Saga's sprite box. The app sets data-state and picks the file:
                idle        saga_idle
                thinking    saga_thinking
                idea        saga_exclamation
                celebrating saga_success
                concerned   saga_magnifying_glass
                data-pose overrides the file for single moments.
   .wf-perch    The mascot seat at the top of the AI panel. It hangs on the
                inner edge of the panel, facing the page.
   -------------------------------------------------------------------------- */
.wf-voice {
  position: relative;
  padding-inline-start: var(--wf-space-5);
  border-inline-start: var(--wf-rule-w) solid var(--wf-familiar);
}
.wf-voice-name {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-familiar-text);
}

.wf-familiar {
  display: inline-block;
  flex: none;
  width: var(--wf-mascot-md);
  height: var(--wf-mascot-md);
}
.wf-familiar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  transform-origin: center bottom;
}
.wf-familiar--xs {
  width: var(--wf-mascot-xs);
  height: var(--wf-mascot-xs);
}
.wf-familiar--sm {
  width: var(--wf-mascot-sm);
  height: var(--wf-mascot-sm);
}
.wf-familiar--lg {
  width: var(--wf-mascot-lg);
  height: var(--wf-mascot-lg);
}

/* Motion per state. The sprite carries the pose. CSS adds only a small cue. */
.wf-familiar[data-state='thinking'] img {
  animation: wf-bob var(--wf-dur-glow) var(--wf-ease-standard) infinite alternate;
}
.wf-familiar[data-state='idea'] img,
.wf-familiar[data-state='celebrating'] img,
.wf-familiar[data-state='concerned'] img {
  animation: wf-pop var(--wf-dur-slow) var(--wf-ease-flutter) 1;
}

@keyframes wf-bob {
  to {
    transform: translateY(calc(-1 * var(--wf-mascot-bob)));
  }
}
@keyframes wf-pop {
  50% {
    transform: scale(var(--wf-mascot-pop));
  }
}

.wf-perch {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-4) var(--wf-space-5);
  border-bottom: var(--wf-hairline);
}
.wf-perch-text {
  flex: 1;
  min-width: 0;
}
.wf-perch-status {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}

/* -- 16  Chat ------------------------------------------------------------------
   The writer's messages sit plain. The familiar's messages carry its voice.
   Manuscript quotes inside any message use the manuscript face.
   -------------------------------------------------------------------------- */
.wf-thread {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-5);
}
.wf-msg {
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
}
.wf-msg p + p {
  margin-top: var(--wf-space-3);
}
/* The message that a chip of an earlier chat opened (chatMessageLink.ts): a selection tint
   for 2 s, as the block flash of a passage link. When the class goes, the tint fades out. */
.wf-msg {
  transition:
    background-color var(--wf-dur-slow) var(--wf-ease-exit),
    box-shadow var(--wf-dur-slow) var(--wf-ease-exit);
}
.wf-msg.wf-msg-flash {
  border-radius: var(--wf-radius-xs);
  background-color: var(--wf-text-selection);
  box-shadow: 0 0 0 var(--wf-space-2) var(--wf-text-selection);
}
.wf-msg--writer {
  align-self: flex-end;
  max-width: 88%;
  padding: var(--wf-space-3) var(--wf-space-4);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-hover);
}
.wf-msg--familiar {
  padding-inline-start: var(--wf-space-5);
  border-inline-start: var(--wf-rule-w) solid var(--wf-familiar);
}
/* An answer of Saga in its order (owner, 2026-10-04): each text segment between two tool
   calls is its own ruled block (.wf-msg-segment), with the tool cards between them. */
.wf-msg-segment {
  margin-block: var(--wf-space-2);
}
.wf-composer {
  display: flex;
  align-items: flex-end;
  gap: var(--wf-space-2);
}
.wf-composer .wf-textarea {
  min-height: var(--wf-control-h-lg);
  /* The field grows with its text (Composer.tsx sets the height). No drag handle. */
  max-height: calc(var(--wf-composer-rows-max) * 1lh + 2 * var(--wf-space-3) + 2 * var(--wf-border-w));
  overflow-y: auto;
  font-size: var(--wf-text-md);
  resize: none;
}

/* The Chat tab fills the panel body: the conversation bar, the thread and the message
   field. Only the thread scrolls (.wf-chat-scroll). The bar stays at the top and the
   field stays at the bottom. */
.wf-chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--wf-space-4);
  min-height: 0;
}
.wf-chat-scroll {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--wf-space-4);
  min-height: 0;
  overflow-y: auto;
}
/* An overlay scrollbar takes the clicks on its strip. Without the gap, it covered half of the
   pencil and of "Bad answer" at the right edge (report 01a1342c). */
@media (pointer: fine) {
  .wf-chat-scroll {
    padding-inline-end: var(--wf-space-5);
  }
}
.wf-chat-thread {
  flex: 1;
}
/* "Scroll to the latest message" (ChatTab.tsx): the last child of the thread. It sticks to
   the bottom of the thread while the writer reads above the end. */
.wf-chat-latest {
  position: sticky;
  bottom: 0;
  z-index: var(--wf-z-sticky);
  flex: none;
  align-self: center;
  border-radius: var(--wf-radius-full);
  box-shadow: var(--wf-shadow-2);
}
/* The empty chat fills the panel height. Without align-content the grid stretches its
   rows, and the starter buttons grow to fill the free space. */
.wf-panel-empty.wf-chat-thread {
  align-content: center;
}
.wf-panel-empty.wf-chat-thread > .wf-btn-row {
  justify-content: center;
}
.wf-msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* A list in an answer of Saga (MessageBody.tsx, light markdown). Tight: the items sit
   closer than paragraphs. */
.wf-msg-list {
  margin: 0;
  padding-inline-start: var(--wf-space-5);
}
.wf-msg p + .wf-msg-list,
.wf-msg .wf-msg-list + p,
.wf-msg .wf-msg-list + .wf-msg-list {
  margin-top: var(--wf-space-3);
}
.wf-msg-list > li + li {
  margin-top: var(--wf-space-1);
}
/* Inline code in an answer of Saga. */
.wf-msg code {
  padding: 0 var(--wf-space-1);
  border-radius: var(--wf-radius-xs);
  background: var(--wf-bg-sunken);
  font-family: var(--wf-font-courier);
  font-size: var(--wf-text-sm);
}
.wf-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
  margin-bottom: var(--wf-space-2);
}
.wf-chat-foot {
  position: sticky;
  bottom: calc(-1 * var(--wf-space-5));
  display: grid;
  gap: var(--wf-space-2);
  margin-bottom: calc(-1 * var(--wf-space-5));
  padding: var(--wf-space-3) 0 var(--wf-space-5);
  background: var(--wf-bg-chrome);
}
.wf-chat-foot .wf-chat-chips {
  margin-bottom: 0;
}
.wf-chat-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--wf-space-3);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  line-height: var(--wf-leading-snug);
}
.wf-chat-count[data-over='true'] {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-chat-failure {
  display: grid;
  justify-items: start;
  gap: var(--wf-space-2);
  margin-top: var(--wf-space-2);
  color: var(--wf-text-muted);
}
.wf-chat-notice {
  padding: var(--wf-space-3) var(--wf-space-4);
  border-inline-start: var(--wf-rule-w) solid var(--wf-concern);
  background: var(--wf-concern-soft);
  font-size: var(--wf-text-sm);
}

/* A verbatim quote from the manuscript. Code verified it before display. */
.wf-quote {
  margin: var(--wf-space-3) 0;
  padding: var(--wf-space-2) 0 var(--wf-space-2) var(--wf-space-4);
  border-inline-start: var(--wf-border-w-strong) solid var(--wf-line-strong);
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
  color: var(--wf-text-page);
  font-variant-numeric: var(--wf-ms-numerals);
}

/* -- 16b Saga chat -------------------------------------------------------------
   The chat management of the Chat tab and the small pieces in the thread.
   Design note: docs/design-mock/chat-notes.md. Mock: docs/design-mock/pages/chat.html.
   .wf-chat-head       The row above the thread: title, "+", history, "…". It sticks
                       to the top of the panel body. It takes room in the flow, so
                       it never covers the first message.
   .wf-chat-history    The history view: the head row and the list of cards.
   .wf-chat-card       One conversation in the history list.
   .wf-chat-deleted    The "Deleted" section: the trash of the last 30 days.
   .wf-chat-tool       A quiet line for one tool call of Saga.
   .wf-chat-tools-toggle  The summary line of more than 3 tool calls.
   .wf-chat-thinking   The thinking of one model call: "Thinking…" or "Thought".
   .wf-chat-thinking-text  The thinking summary behind the disclosure.
   .wf-msg-segment     One text segment of an answer, between two tool calls.
   .wf-passage         The passage chip: a link to a block of the story.
   .wf-passage--pending  A provisional chip while the answer streams.
   .wf-inexact         The "Inexact" chip after an unverified citation. .wf-inexact-pop is its
                       popover with the sentence of the source (components/InexactChip.tsx).
   .wf-cite            A quote block: a cited snippet on its own line, with a label row
                       (.wf-cite-head, .wf-cite-name, .wf-cite-kind) and the full words
                       (.wf-cite-words). --unfound, --gone and --pending give the states.
                       --link: the box holds the link (.wf-cite-link) and the chip.
   .wf-cite-inline     The note form of the quote block: an inline box. --head (the label, a
                       box around .wf-cite-inline-link) and --words (the note text) are its
                       two parts.
                       .wf-cite-gap hides the quote marks and the white space before the box.
   .wf-passage--chat   A quote chip of the writer's words in this chat: [[chat: "…"]].
                       With a chat title, a chip of an earlier chat: [[chat m3: "…"]].
   .wf-msg-flash       The short highlight of a message that such a chip opened.
   .wf-chat-attach     The attachment chip on a sent message and above the field.
   .wf-chat-attach--quiet  Information above the field, not an attachment: "Chapter 12 changed".
   .wf-msg-time        The quiet time of an answer, at the end of its name line.
   .wf-feedback        The thumbs-up and the thumbs-down at the end of the answer actions.
   .wf-feedback-pop    The popover of a thumb: "What worked?" or "What went wrong?".
   .wf-msg-writer-row  A writer message with its action row (Copy, "Edit and ask again") under it.
   .wf-chat-forked     "Forked from <title>" at the top of a fork, with a link to the parent.
   .wf-chat-editing    "Editing your message" with its X, above the field during "Edit and ask again".
   .wf-chat-card-fork  The small fork mark after the title of a fork in the history list.
   -------------------------------------------------------------------------- */
:root {
  --wf-passage-words-w: 14em; /* the widest part of the first words in a passage chip */
  --wf-chat-attach-h: var(--wf-space-6); /* the height of an attachment chip */
  --wf-composer-rows-max: 10; /* the message field grows to this number of lines, then scrolls */
  --wf-chat-wide-w: 48rem; /* the column of the expanded chat: a line stays easy to read */
}

/* The head row. Negative margins take it to the edges of the panel body. */
.wf-chat-head {
  position: sticky;
  top: calc(-1 * var(--wf-space-5));
  z-index: var(--wf-z-sticky);
  display: flex;
  align-items: center;
  gap: var(--wf-space-1);
  min-height: calc(var(--wf-control-h-sm) + 2 * var(--wf-space-3));
  margin: calc(-1 * var(--wf-space-5)) calc(-1 * var(--wf-space-5)) 0;
  padding: var(--wf-space-3) var(--wf-space-4) var(--wf-space-3) var(--wf-space-5);
  border-bottom: var(--wf-hairline);
  background: var(--wf-bg-chrome);
}
/* The conversation title. A button that starts the rename. One line, with an ellipsis. */
.wf-chat-title {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--wf-control-h-sm);
  margin-inline-start: calc(-1 * var(--wf-space-2));
  padding: 0 var(--wf-space-2);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-control-h-sm);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
/* Hover shows that a click edits the title. */
.wf-chat-title:is(button):hover {
  background: var(--wf-bg-hover);
}
/* A new conversation has no title yet. The placeholder is muted and is not a button. */
.wf-chat-title[data-untitled] {
  color: var(--wf-text-muted);
  font-weight: var(--wf-weight-regular);
  cursor: default;
}
/* The heading of the history view ("Conversations"). */
.wf-chat-head-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
}
/* The rename field, in the head row and in a card. Add it to a .wf-input. */
.wf-chat-rename {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--wf-control-h-sm);
  padding: 0 var(--wf-space-2);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}

/* The history view: the head row, then the list. It takes the place of the thread. */
.wf-chat-history {
  display: grid;
  align-content: start;
  gap: var(--wf-space-4);
  min-height: 100%;
}
/* The list of cards. Add .wf-list. The gap is 12 px (ruling m12). */
.wf-chat-list {
  gap: var(--wf-space-3);
}
/* One conversation: title, date and menu on the first row, the preview on the second. */
.wf-chat-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    'title date menu'
    'preview preview menu';
  align-items: center;
  gap: var(--wf-space-1) var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-2) var(--wf-space-3) var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  transition: background-color var(--wf-dur-instant) var(--wf-ease-standard);
}
/* The whole card is the target of its open button. The hover surface never replaces the
   selected surface of the open card (ruling m2). */
.wf-chat-card:not([aria-current='true']):has(.wf-chat-card-open:hover) {
  background: var(--wf-bg-hover);
}
/* The card shows the focus ring of its open button. */
.wf-chat-card:has(.wf-chat-card-open:focus-visible) {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
/* The open conversation: the selected surface and the "Open" badge, not color alone. */
.wf-chat-card[aria-current='true'] {
  border-color: var(--wf-line-strong);
  background: var(--wf-bg-selected);
}
/* The title line. It holds the open button. */
.wf-chat-card-title {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-width: 0;
  margin: 0;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
}
/* The open button: the title text. Its ::after covers the card. */
.wf-chat-card-open {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.wf-chat-card-open:focus-visible {
  outline: none;
}
.wf-chat-card-open::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
/* The date: relative for 7 days, then the short date. The "Open" badge sits in front of
   it, in the same area (ruling m4). */
.wf-chat-card-date {
  grid-area: date;
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  white-space: nowrap;
}
/* One line of the last message, with an ellipsis. */
.wf-chat-card-preview {
  grid-area: preview;
  min-width: 0;
  margin: 0;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* "You:" or "Saga:" in front of the preview. */
.wf-chat-card-who {
  color: var(--wf-text-subtle);
  font-weight: var(--wf-weight-semibold);
}
/* The menu sits above the covering ::after of the open button. */
.wf-chat-card-menu {
  grid-area: menu;
  position: relative;
  z-index: var(--wf-z-margin-mark);
}
/* An open card menu paints above the cards after it. */
.wf-chat-card:has([aria-expanded='true']) .wf-chat-card-menu {
  z-index: var(--wf-z-popover);
}
/* The "Open" badge has a strong hairline, so it shows on the selected surface (ruling m1). */
.wf-chat-card-date > .wf-badge {
  border: var(--wf-hairline-strong);
}
.wf-chat-card .wf-btn--quiet:hover:not(:disabled) {
  background: var(--wf-bg-selected);
}
/* A card in rename: the field takes the title and the date. The card is not a link.
   The menu area holds "Save" and "Cancel". */
.wf-chat-card--rename {
  grid-template-areas:
    'title title menu'
    'preview preview menu';
}
.wf-chat-card--rename > .wf-chat-card-menu {
  display: flex;
  gap: var(--wf-space-1);
}
/* The rename error takes the line of the preview, and wraps. */
.wf-chat-card--rename > .wf-field-error {
  white-space: normal;
}
/* A conversation with no title yet: the muted placeholder (ruling 2). */
.wf-chat-card-open[data-untitled] {
  color: var(--wf-text-muted);
  font-weight: var(--wf-weight-regular);
}
/* "Show older": the next page of cards (ruling m7). */
.wf-chat-more {
  display: grid;
  justify-items: center;
  gap: var(--wf-space-2);
}
/* The "Deleted" section at the end of the history view: the trash of the last 30 days. */
.wf-chat-deleted {
  display: grid;
  gap: var(--wf-space-2);
  padding-top: var(--wf-space-4);
  border-top: var(--wf-hairline);
}
.wf-chat-section-title {
  margin: 0;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
  color: var(--wf-text-muted);
}
/* A card in the trash: no open button, so no hover surface. "Restore" in the menu area. */
.wf-chat-card--deleted {
  background: transparent;
}
.wf-chat-card--deleted > .wf-chat-card-title {
  display: block;
  color: var(--wf-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tool lines: what Saga looked at. They sit inside the answer, in the order of the calls. */
.wf-chat-tools {
  display: grid;
  gap: var(--wf-space-1);
  margin-block: var(--wf-space-2);
}
/* One tool call: an icon and one short line in the meta size. */
.wf-chat-tool {
  display: flex;
  align-items: flex-start;
  gap: var(--wf-space-2);
  margin: 0;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
}
.wf-chat-tool svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
/* Beats the paragraph gap of .wf-msg. */
.wf-chat-tools > .wf-chat-tool {
  margin: 0;
}
/* A failed call: the muted color and the word "Could not". */
.wf-chat-tool[data-state='failed'] {
  color: var(--wf-text-muted);
}
/* The thinking of one model call: "Thought" with a disclosure for the summary text. */
.wf-chat-thinking {
  display: grid;
  gap: var(--wf-space-1);
}
.wf-chat-thinking-text {
  margin: 0;
  padding-inline-start: calc(var(--wf-icon-sm) + var(--wf-space-2));
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  white-space: pre-wrap;
}
/* More than 3 calls: one summary line, a disclosure for the lines (ruling m11). */
.wf-chat-tools-toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--wf-space-2);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--wf-text-subtle);
  font: inherit;
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  text-align: start;
  cursor: pointer;
}
.wf-chat-tools-toggle svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  transition: transform var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-tool-card--tools > .wf-chat-tools-toggle {
  width: 100%;
}
.wf-chat-tools-summary {
  flex: 1;
  min-width: 0;
}
/* Only the chevron at the end turns. The tool icon at the start stays. */
.wf-chat-tools-toggle > svg:first-child {
  transition: none;
}
.wf-chat-tools-toggle[aria-expanded='true'] > svg:last-child {
  transform: rotate(90deg);
}
.wf-chat-tools-toggle:hover {
  color: var(--wf-text);
}

/* The passage chip (AI stage 3): "Chapter 7" and the stored snippet of the block, inline
   at the place of the marker. A link opens the chapter at the block. The writer's text,
   so ink, not violet. A transparent border shows in forced colors. */
.wf-passage {
  display: inline-flex;
  align-items: baseline;
  gap: var(--wf-space-2);
  max-width: 100%;
  padding: 0 var(--wf-space-2);
  border: var(--wf-border-w) solid transparent;
  border-radius: var(--wf-radius-xs);
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
  text-decoration: none;
  vertical-align: baseline;
  white-space: nowrap;
}
/* The chapter number, in the UI face. */
.wf-passage-ch {
  font-weight: var(--wf-weight-semibold);
}
/* The first words, in the writer's manuscript face. Cut with an ellipsis. */
.wf-passage-words {
  min-width: 0;
  max-width: var(--wf-passage-words-w);
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--wf-ms-font);
}
/* Hover: a stronger ink tint and an ink border. No underline: the owner read an
   underline as a failed citation (2026-09-30). The focus ring stays as it is. */
a.wf-passage,
button.wf-passage {
  transition:
    background-color var(--wf-dur-instant) var(--wf-ease-standard),
    border-color var(--wf-dur-instant) var(--wf-ease-standard);
}
/* The chip of an earlier chat is a button: it opens a conversation, not a URL. */
button.wf-passage {
  font-family: inherit;
  cursor: pointer;
}
a.wf-passage:hover,
button.wf-passage:hover {
  border-color: var(--wf-accent);
  background: var(--wf-text-selection);
}
/* A provisional chip while the answer streams: no link and no mark. The server parts
   take its place when the answer ends, so it keeps the look of a chip. */
.wf-passage--pending {
  cursor: default;
}
/* The block is gone from the story: no link, a dashed border, the subtle color. */
.wf-passage--gone {
  border: var(--wf-border-w) dashed var(--wf-line-strong);
  background: transparent;
  color: var(--wf-text-subtle);
}
.wf-passage--gone .wf-passage-words {
  font-family: var(--wf-font-ui);
}
/* The "Inexact" chip after a citation that the server did not find (owner, October 15, 2026). A
   small concern pill with the warning triangle. A hover, a focus or a tap shows .wf-inexact-pop.
   No user select: a copy of a selection leaves the chip out. On a coarse pointer the hit area
   grows a little up and down. It stays small, so a tap on the words next to it opens the source. */
.wf-inexact {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-1);
  margin-inline-start: var(--wf-space-1);
  padding: 0 var(--wf-space-2);
  border: none;
  border-radius: var(--wf-radius-full);
  background: var(--wf-concern-soft);
  color: var(--wf-concern-text);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-2xs);
  font-style: normal;
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  vertical-align: baseline;
  white-space: nowrap;
  user-select: none;
  cursor: help;
}
.wf-inexact svg {
  flex: none;
  width: var(--wf-text-2xs);
  height: var(--wf-text-2xs);
}
@media (pointer: coarse) {
  .wf-inexact::after {
    content: '';
    position: absolute;
    inset: calc(-1 * var(--wf-space-1)) 0;
  }
}
/* The popover of the chip. It shares its surface with .wf-saga-pop (section 16e). The width is
   max-content: with no set width, the box would shrink at a screen edge instead of a flip. */
.wf-inexact-pop {
  max-width: min(var(--wf-tooltip-w), calc(100vw - 2 * var(--wf-space-4)));
  padding: var(--wf-space-2) var(--wf-space-3);
  color: var(--wf-text);
  font-size: var(--wf-text-xs);
  font-style: normal;
  font-weight: var(--wf-weight-regular);
  line-height: var(--wf-leading-snug);
  white-space: normal;
  text-align: start;
}
/* The popover sits under the chip, from its start edge, to its end edge or across its middle. With
   no room below, it sits above. So it stays on the screen. An engine with no anchor positioning
   keeps the native place of a popover: the middle of the screen. */
@supports (position-area: block-end) {
  .wf-inexact-pop {
    inset: auto;
    margin: var(--wf-space-1) 0 0;
    position-area: block-end span-inline-end;
    position-try-fallbacks: flip-inline, block-end, flip-block, flip-block flip-inline, block-start;
  }
}

/* The quote block (owner, 2026-10-09): a cited snippet of Saga on its own line, in the place
   of the citation. A hairline box on the raised surface. The label row holds the icon, the
   source name in ink and the kind in subtle text. The full snippet follows in the manuscript
   face, with no cut. The whole block is the link. A citation with no snippet stays a chip. */
.wf-cite {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-1);
  margin-block: var(--wf-space-2);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  font-style: normal;
  font-weight: var(--wf-weight-regular);
  text-decoration: none;
  white-space: normal;
  transition: border-color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-cite-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-1) var(--wf-space-2);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
}
.wf-cite-head > svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-accent-text);
}
.wf-cite-name {
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-cite-kind {
  color: var(--wf-text-subtle);
}
.wf-cite-head > .wf-inexact {
  margin-inline-start: 0;
}
/* A block with a link. The box holds the link and the "Inexact" chip, if there is one: a button in a
   link is not valid HTML. The link and the chip share one grid: the chip ends the label row. The
   link has the padding of the block, so the whole box except the chip is the link. The chip has the
   same offset from the edge as the label row. A block that opens a chat message has a button: a
   chat has no URL. */
.wf-cite--link {
  display: grid;
  padding: 0;
  grid-template-columns: 1fr auto;
  align-items: start;
  row-gap: var(--wf-space-1);
}
.wf-cite-link {
  display: grid;
  grid-template: subgrid / subgrid;
  grid-column: 1 / -1;
  grid-row: 1 / span 2;
  padding: var(--wf-space-2) var(--wf-space-3);
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.wf-cite-link > .wf-cite-words {
  grid-column: 1 / -1;
}
.wf-cite--link > .wf-inexact {
  grid-column: 2;
  grid-row: 1;
  margin-block-start: var(--wf-space-2);
  margin-inline: var(--wf-space-2) var(--wf-space-3);
}
.wf-cite--link:has(> .wf-cite-link:hover) {
  border-color: var(--wf-accent);
}
/* The writer's words, in full, in the writer's manuscript face. */
.wf-cite-words {
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-normal);
  overflow-wrap: anywhere;
}
/* Words that the server did not find, or a source that is gone: a dashed edge and the UI
   face. Saga's words never take the manuscript face. */
.wf-cite--unfound {
  border-style: dashed;
  border-color: var(--wf-line-strong);
}
.wf-cite--unfound .wf-cite-words {
  font-family: var(--wf-font-ui);
}
/* A source in the trash or deleted: no link, the subtle color. */
.wf-cite--gone,
.wf-cite--gone .wf-cite-name,
.wf-cite--gone .wf-cite-head > svg {
  color: var(--wf-text-subtle);
}
/* A provisional block while the answer streams: no link and no mark. */
.wf-cite--pending {
  cursor: default;
}
/* The note form of the quote block (owner, October 13, 2026; notes/noteQuotes.ts): an inline box
   that wraps with the text, with the hairline, the raised surface and the radius of .wf-cite. Two
   parts make the box: the label (--head, in the link of the note) and the quoted words (--words,
   note text that the writer can edit). The head has the face of the words, so the two borders line
   up. Its label row takes the UI face. The head covers the left edge of the words, so the join
   shows no line. The quote marks and the white space before the box are hidden (.wf-cite-gap). */
.wf-cite-inline {
  padding: 0 var(--wf-space-2);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  text-indent: 0;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.wf-cite-inline.wf-cite--unfound {
  border-style: dashed;
  border-color: var(--wf-line-strong);
}
/* Two classes: the dashed edge of --unfound must not bring back the right edge of the head. */
.wf-cite-inline.wf-cite-inline--head {
  position: relative;
  margin-inline-end: calc(-1 * var(--wf-border-w));
  padding-inline-end: var(--wf-space-2);
  border-inline-end: none;
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}
.wf-cite-inline--words {
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}
.wf-cite-inline .wf-cite-head {
  display: inline;
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-xs);
  white-space: nowrap;
}
.wf-cite-inline .wf-cite-head > * + * {
  margin-inline-start: var(--wf-space-2);
}
.wf-cite-inline .wf-cite-head > svg {
  display: inline-block;
  vertical-align: text-bottom;
}
.wf-cite-inline .wf-badge {
  vertical-align: baseline;
}
/* The link in the head box: no look of its own. The box holds the link and the chip. */
.wf-cite-inline-link {
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  text-decoration: none;
  vertical-align: baseline;
  cursor: pointer;
}
.wf-cite-inline:has(> .wf-cite-inline-link:hover) {
  border-color: var(--wf-accent);
}
.wf-cite-gap {
  display: none;
}
/* The head carries the mark of a quote that the server did not find. */
.wf-uncited-mark:has(.wf-cite-inline--words)::after {
  content: none;
}
@media (forced-colors: active) {
  .wf-cite--link:has(> .wf-cite-link:hover),
  .wf-cite-inline:has(> .wf-cite-inline-link:hover) {
    border-color: Highlight;
  }
}

/* The attachment chip: what went with a message. On a sent message and above the field.
   The raised surface and a strong line, so it stands out on the writer's bubble. */
.wf-chat-attach {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-1);
  max-width: 100%;
  min-height: var(--wf-chat-attach-h);
  padding: 0 var(--wf-space-3) 0 var(--wf-space-2);
  border: var(--wf-hairline-strong);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
}
.wf-chat-attach > svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-muted);
}
/* The label, with an ellipsis if the rail is narrow. */
.wf-chat-attach-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The quiet chip: information, not a control. The hairline and the muted text keep it
   below the attachment chips. */
.wf-chat-attach--quiet {
  border: var(--wf-hairline);
  background: transparent;
  color: var(--wf-text-muted);
  font-weight: var(--wf-weight-regular);
}
/* The "x" of a chip that the writer can remove before the send. */
.wf-chat-attach-remove {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--wf-icon);
  height: var(--wf-icon);
  margin-inline: var(--wf-space-1) calc(-1 * var(--wf-space-2));
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-full);
  background: transparent;
  color: var(--wf-text-muted);
  cursor: pointer;
}
.wf-chat-attach-remove:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-chat-attach-remove svg {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
/* A larger hit area than the icon. On a coarse pointer it reaches 44 px. */
.wf-chat-attach-remove::after {
  content: '';
  position: absolute;
  inset: calc(-1 * var(--wf-space-2));
}

/* The quiet time of an answer at the end of its name line: "Today 14:32". */
.wf-msg-time {
  margin-inline-start: auto;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-regular);
  font-variant-numeric: tabular-nums;
}
/* The thumbs of an answer (feedback, 2026-09-30): the end of the actions row, the anchor of the popover. */
.wf-feedback {
  position: relative;
  display: inline-flex;
  gap: var(--wf-space-1);
  margin-inline-start: auto;
}
/* A pressed thumb: the icon fills, in the writer's accent, as a pressed tool. */
.wf-feedback-thumb[aria-pressed='true'] {
  color: var(--wf-accent-text);
}
.wf-feedback-thumb[aria-pressed='true'] svg {
  fill: currentColor;
}
/* The popover: a raised surface under the thumbs, aligned to their end edge. */
.wf-feedback-pop {
  position: absolute;
  top: calc(100% + var(--wf-space-1));
  inset-inline-end: 0;
  z-index: var(--wf-z-popover);
  display: grid;
  gap: var(--wf-space-3);
  width: min(var(--wf-menu-max-w), calc(100vw - 2 * var(--wf-space-7)));
  padding: var(--wf-space-3);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
  animation: wf-menu-in var(--wf-dur-quick) var(--wf-ease-enter);
}
/* The popover above the thumbs, when the thread has no room below them. */
.wf-feedback-pop--up {
  top: auto;
  bottom: calc(100% + var(--wf-space-1));
}
/* The question and the "x" on one row. */
.wf-feedback-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-2);
  margin-block: calc(-1 * var(--wf-space-1));
}
/* "What went wrong?". */
.wf-feedback-pop-title {
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text);
}
/* "About: “…”": the text that the writer selected in the answer, on one line. */
.wf-feedback-pop-quote {
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The quick reasons: toggle chips that wrap. */
.wf-feedback-pop-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
}
/* One quick reason. aria-pressed shows the choice in the writer's accent tint. */
.wf-feedback-reason {
  min-height: var(--wf-chat-attach-h);
  padding: 0 var(--wf-space-3);
  border: var(--wf-hairline-strong);
  border-radius: var(--wf-radius-full);
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-tight);
  cursor: pointer;
}
.wf-feedback-reason:hover {
  background: var(--wf-bg-hover);
}
.wf-feedback-reason[aria-pressed='true'] {
  border-color: var(--wf-accent-text);
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
}
/* The one-line field "Anything else?" and "Send" on one row. */
.wf-feedback-pop-form {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-feedback-pop-form > .wf-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--wf-control-h-sm);
  padding-inline: var(--wf-space-3);
  font-size: var(--wf-text-sm);
}
@media (pointer: coarse) {
  .wf-chat-title,
  .wf-chat-rename {
    min-height: var(--wf-touch-target);
    line-height: var(--wf-touch-target);
  }
  .wf-chat-attach-remove::after {
    inset: calc((var(--wf-icon) - var(--wf-touch-target)) / 2);
  }
  .wf-feedback-reason {
    min-height: var(--wf-touch-target);
  }
  /* A touch tablet with the keyboard open: while the message field has the focus, the perch is
     one line, so the thread keeps its room (ruling 5). AppShell sets the class. A phone has no perch. The head row
     of the Chat tab stays sticky. */
  .wf-perch--compact {
    padding-block: var(--wf-space-1);
  }
  .wf-perch--compact .wf-familiar {
    width: var(--wf-mascot-xs);
    height: var(--wf-mascot-xs);
  }
  .wf-perch--compact .wf-perch-text {
    display: flex;
    align-items: baseline;
    gap: var(--wf-space-2);
    white-space: nowrap;
    overflow: hidden;
  }
  .wf-perch--compact .wf-perch-status {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
/* A writer message and its action row (owner, 2026-10-06). The row sits under the bubble,
   at its end, like the row of an answer. The row shows always, as the row of an answer does. */
.wf-msg-writer-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: flex-end;
  min-width: 0;
  max-width: 88%;
}
.wf-msg-writer-row > .wf-msg--writer {
  max-width: 100%;
}
/* "Forked from <title>" at the top of the thread of a fork. The title is a link to the parent. */
.wf-chat-forked {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-width: 0;
  margin: 0;
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
}
.wf-chat-forked > svg,
.wf-chat-card-fork > svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
.wf-chat-forked-link {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--wf-accent-text);
  font: inherit;
  font-weight: var(--wf-weight-semibold);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.wf-chat-forked-link:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--wf-border-w);
}
.wf-chat-forked-link:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
/* "Editing your message" above the field. The X ends the edit. */
.wf-chat-editing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-2);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
}
/* The fork mark of a card: a quiet icon after the title, not color alone. */
.wf-chat-card-fork {
  display: inline-flex;
  flex: none;
  color: var(--wf-text-subtle);
}
@media (forced-colors: active) {
  .wf-chat-card[aria-current='true'] {
    border-color: Highlight;
  }
  .wf-feedback-reason[aria-pressed='true'] {
    border-color: Highlight;
  }
}

/* -- 16c Notes -----------------------------------------------------------------
   The Notes tab, the note page, the link chips, the [[ picker and quick capture.
   Spec: docs/specs/m10-notes.md. Design note: docs/design-mock/notes-notes.md.
   The number 17 is taken (critique cards), so notes take 16c, next to the chips.
   The Inbox is built in: the Notes tab always shows it first, and it has no menu.
   Link chips extend the passage chip family (.wf-passage) of section 16b.
   Capture chips reuse the attachment chip (.wf-chat-attach) and its "x".
   Quick capture: the capture tool in the phone bar of the editor replaces the
   older round phone button (.wf-capture, removed in stage 2).
   -------------------------------------------------------------------------- */
:root {
  /* A note row under its folder: the chevron and its gap. */
  --wf-note-indent: calc(var(--wf-icon-sm) + var(--wf-space-2));
  --wf-picker-w: 20em; /* the [[ picker and its options */
  --wf-drag-ghost-offset: var(--wf-space-4); /* the drag title sits this far below and right of the pointer */
  --wf-picker-max-h: 18em; /* the list of the [[ picker and of the folder dialog before it scrolls */
  --wf-capture-text-h: calc(var(--wf-control-h) * 3.5); /* the capture text area: about six lines */
}

/* The head of the Notes tab: "New note" (secondary) and "Capture" (quiet). */
.wf-notes-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
/* A split button: the main action, and an arrow for more ways to do the same action.
   "New note" and its arrow "New from a template…" (owner, 2026-10-02). The two buttons
   share one outline: the arrow drops its start border and its start corners. */
.wf-split {
  display: inline-flex;
  align-items: stretch;
}
.wf-split > .wf-btn:first-child {
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}
.wf-split > .wf-btn + .wf-btn {
  padding: 0 var(--wf-space-2);
  border-inline-start-width: 0;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}
.wf-split > .wf-btn:focus-visible {
  position: relative;
}
/* The template dialog: three groups ("Plot structures", "Story elements", "My templates").
   Each item is a button with the name, an optional credit line and one line of description.
   An item of "My templates" has a "…" menu (Rename, Delete) at its end. */
.wf-template-groups {
  display: grid;
  gap: var(--wf-space-4);
}
.wf-template-group {
  display: grid;
  gap: var(--wf-space-1);
}
.wf-template-group > .wf-picker-group {
  margin: 0;
}
.wf-template-list {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-template-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-1);
}
.wf-template-option {
  display: grid;
  gap: var(--wf-space-1);
  width: 100%;
  min-height: var(--wf-control-h);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.wf-template-option:hover:not(:disabled) {
  background: var(--wf-bg-hover);
}
.wf-template-option:disabled {
  cursor: progress;
}
.wf-template-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--wf-space-2);
  min-width: 0;
}
.wf-template-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}
.wf-template-credit {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-template-desc {
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text-muted);
}
/* The notes tree: the Inbox first, then the folders and the notes of the top level in the
   writer's order. A folder holds folders and notes in one order too (owner, 2026-10-02).
   The one column may shrink, so a long title ends with an ellipsis and does not widen the rail. */
.wf-folders,
.wf-folder,
.wf-notes {
  grid-template-columns: minmax(0, 1fr);
}
.wf-folders {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
/* One folder: its head and its notes. */
.wf-folder {
  display: grid;
  gap: var(--wf-space-1);
}
/* The head of a folder: the folder button and its "…" menu. The Inbox has no menu. */
.wf-folder-head {
  display: flex;
  align-items: center;
  gap: var(--wf-space-1);
  border-radius: var(--wf-radius-sm);
}
/* The hover surface covers the button and the menu. */
.wf-folder-head:hover {
  background: var(--wf-bg-hover);
}
.wf-folder-head .wf-folder-toggle:hover {
  background: transparent;
}
.wf-folder-head:hover > .wf-note-menu,
.wf-folder-head:focus-within > .wf-note-menu {
  opacity: 1;
}
/* The heading around the folder button. It adds no type of its own. */
.wf-folder-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font: inherit;
}
/* The folder button: the chevron, the icon, the name and the count. aria-expanded opens and closes the folder. */
.wf-folder-toggle {
  display: grid;
  grid-template-columns: var(--wf-icon-sm) var(--wf-icon-sm) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-2);
  width: 100%;
  min-height: var(--wf-control-h-sm);
  padding: var(--wf-space-1) var(--wf-space-3) var(--wf-space-1) var(--wf-space-2);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  text-align: start;
  cursor: pointer;
}
/* The hover surface, as a chapter row has. */
.wf-folder-toggle:hover {
  background: var(--wf-bg-hover);
}
/* The chevron and the folder icon: 16 px, subtle. */
.wf-folder-toggle > svg {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
}
/* The chevron turns with the state. */
.wf-folder-toggle > svg:first-child {
  transition: transform var(--wf-dur-quick) var(--wf-ease-standard);
}
/* A closed folder: the chevron points to the name. */
.wf-folder-toggle[aria-expanded='false'] > svg:first-child {
  transform: rotate(-90deg);
}
/* A closed folder in a right-to-left page: the chevron points the other way. */
.wf-folder-toggle[aria-expanded='false']:dir(rtl) > svg:first-child {
  transform: rotate(90deg);
}
/* The folder name: one line, with an ellipsis. */
.wf-folder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The number of notes in the folder. */
.wf-folder-count {
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-regular);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
}
/* A day in the Inbox: "Today", "Yesterday", then the date. It lines up with the note titles. */
.wf-folder-day {
  margin: var(--wf-space-2) 0 0;
  padding-inline-start: calc(var(--wf-note-indent) + var(--wf-space-3));
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text-subtle);
}
/* One line in a folder with no note: the empty Inbox. */
.wf-folder-empty {
  margin: 0;
  padding: var(--wf-space-1) var(--wf-space-3) var(--wf-space-1)
    calc(var(--wf-note-indent) + var(--wf-space-3));
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
/* The notes of a folder, or of a day. They indent under the folder name. */
.wf-notes {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0 0 0 var(--wf-note-indent);
  list-style: none;
}
/* A list of notes with no folder above it, for example the notes of the Trash tab. No indent. */
.wf-notes--flat {
  padding-inline-start: 0;
}
/* One note: the link and its "…" menu. */
.wf-note-row {
  display: flex;
  align-items: center;
  gap: var(--wf-space-1);
  border-radius: var(--wf-radius-sm);
}
/* The hover surface covers the link and the menu. */
.wf-note-row:hover {
  background: var(--wf-bg-hover);
}
/* The open note: the selected surface, as the current chapter has. */
.wf-note-row:has(> .wf-note-link[aria-current='page']) {
  background: var(--wf-bg-selected);
}
/* The note link: the title, then the time (Inbox) or the word count (other folders). */
.wf-note-link {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  gap: var(--wf-space-3);
  min-width: 0;
  min-height: var(--wf-control-h-sm);
  padding: var(--wf-space-1) var(--wf-space-1) var(--wf-space-1) var(--wf-space-3);
  border-radius: var(--wf-radius-sm);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  text-decoration: none;
}
/* Hover and the open note use the full text color. */
.wf-note-link:hover,
.wf-note-link[aria-current='page'] {
  color: var(--wf-text);
}
/* The open note is semibold, so the state does not rely on the surface only. */
.wf-note-link[aria-current='page'] {
  font-weight: var(--wf-weight-semibold);
}
/* The note title: one line, with an ellipsis. The full title is the tooltip. */
.wf-note-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The time or the word count at the end of the row. */
.wf-note-when {
  flex: none;
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-regular);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
}
/* The "…" menu of a row. It shows on hover, on focus, on the open note and while it is open. */
.wf-note-menu {
  flex: none;
  opacity: 0;
}
.wf-note-row:hover > .wf-note-menu,
.wf-note-row:focus-within > .wf-note-menu,
.wf-note-row:has(> .wf-note-link[aria-current='page']) > .wf-note-menu,
.wf-note-menu:has([aria-expanded='true']) {
  opacity: 1;
}
/* Drag in the notes tree and in the chapter list (components/drag.ts). A row that can move
   keeps the long press for the drag: no text selection and no link preview on a phone. */
.wf-drag-row {
  -webkit-touch-callout: none;
  user-select: none;
}
/* The row in the hand: it lifts to elevation 3, as a dragged chapter does. */
.wf-note-row.is-dragging,
.wf-folder-head.is-dragging {
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
}
/* A folder under the pointer: the drop goes into it, at its end. The ink ring and the ink tint. */
.wf-folder-head.is-drop-target {
  background: var(--wf-accent-soft);
  box-shadow: inset 0 0 0 var(--wf-border-w-strong) var(--wf-accent);
}
/* The title of the row in the hand. It follows the pointer, so the finger does not hide what moves. */
.wf-drag-ghost {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: var(--wf-z-tooltip);
  max-width: var(--wf-picker-w);
  padding: var(--wf-space-1) var(--wf-space-3);
  overflow: hidden;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  /* --wf-drag-x and --wf-drag-y: the pointer position, set by the component. */
  transform: translate(
    calc(var(--wf-drag-x, 0px) + var(--wf-drag-ghost-offset)),
    calc(var(--wf-drag-y, 0px) + var(--wf-drag-ghost-offset))
  );
}
/* During a drag: the grab cursor everywhere and no text selection. */
.wf-is-dragging,
.wf-is-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}
/* An option of the folder picker at its level in the tree. --wf-tree-depth is 0 for "Top level". */
/* Two classes: the base rule of .wf-picker-option comes later and has a padding shorthand. */
.wf-picker-option.wf-picker-option--tree {
  padding-inline-start: calc(var(--wf-space-3) + var(--wf-tree-depth, 0) * var(--wf-note-indent));
}
/* An option that the item cannot go to: the item itself, its folders, or a place too deep. */
.wf-picker-option[aria-disabled='true'] {
  color: var(--wf-text-subtle);
  cursor: default;
}
.wf-picker-option[aria-disabled='true']:hover {
  background: transparent;
}

/* A group heading in the Trash tab: "Chapters", "Notes". */
.wf-trash-group {
  margin: var(--wf-space-2) 0 0;
  padding-inline-start: var(--wf-space-3);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-subtle);
}

/* The note title on the note page: an input with the type of the chapter title. Add it to .wf-chapter-title-input. */
.wf-note-title-input:not(:hover, :focus-visible) {
  background: none;
  box-shadow: none;
}
/* The meta line of a note: "Note · Characters · 184 words · Saved". The UI face. */
.wf-note-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-1) var(--wf-space-3);
  margin: 0;
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
}
/* The dot between two parts of the meta line. */
.wf-note-meta > :not(:last-child)::after {
  content: '·';
  margin-inline-start: var(--wf-space-3);
}
/* "Saved from a chat with Saga": a link in ink (notes stage 5). */
.wf-note-meta > a {
  color: var(--wf-accent-text);
  text-decoration: none;
}
.wf-note-meta > a:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--wf-border-w);
}
/* "Referenced by" at the end of a note: the notes that link to it. Chrome, in the UI face. */
.wf-backlinks {
  display: grid;
  gap: var(--wf-space-3);
  margin-top: var(--wf-space-8);
  padding-top: var(--wf-space-5);
  border-top: var(--wf-hairline);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
}
/* The heading "Referenced by". */
.wf-backlinks-title {
  margin: 0;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-muted);
}
/* One note that links here: the title link, then its folder. */
.wf-backlink {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--wf-space-1) var(--wf-space-3);
}
/* The title link of a backlink, in ink. */
.wf-backlink > a {
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
  text-decoration: none;
}
.wf-backlink > a:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--wf-border-w);
}
/* The folder of a backlink. */
.wf-backlink-folder {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}

/* The icon of a note chip (FileText). */
.wf-passage > svg {
  flex: none;
  align-self: center;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
/* The chapter title in a chapter chip: the UI face, regular, with an ellipsis. */
.wf-passage-name {
  min-width: 0;
  max-width: var(--wf-passage-words-w);
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The word state of a chip that is not a link: "In the trash" or "Deleted". */
.wf-passage-state {
  font-size: var(--wf-text-xs);
  font-style: italic;
}
/* In a note, a chip sits in a manuscript line: the UI face and no paragraph indent. */
.wf-ms .wf-passage {
  font-family: var(--wf-font-ui);
  text-indent: 0;
}

/* The [[ picker: a listbox under the caret with notes and chapters. */
.wf-picker {
  position: absolute;
  z-index: var(--wf-z-popover);
  display: grid;
  width: min(var(--wf-picker-w), calc(100vw - 2 * var(--wf-space-5)));
  padding: var(--wf-space-1);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
  color: var(--wf-text);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  text-indent: 0;
  animation: wf-menu-in var(--wf-dur-quick) var(--wf-ease-enter);
}
/* The options. The list scrolls after about eight options. */
.wf-picker-list {
  display: grid;
  gap: var(--wf-space-1);
  max-height: var(--wf-picker-max-h);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
/* A group label or a status line: "Notes", "Chapters", "2 notes match. Pick one." */
.wf-picker-group {
  padding: var(--wf-space-2) var(--wf-space-3) var(--wf-space-1);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-subtle);
}
/* One target: an icon, the title and a quiet line (the folder or the chapter number). */
.wf-picker-option {
  display: grid;
  grid-template-columns: var(--wf-icon-sm) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: var(--wf-control-h);
  padding: var(--wf-space-1) var(--wf-space-3);
  border-radius: var(--wf-radius-sm);
  cursor: pointer;
}
/* The icon of an option: 16 px, subtle. */
.wf-picker-option > svg {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
}
/* The hover surface. */
.wf-picker-option:hover {
  background: var(--wf-bg-hover);
}
/* The active option (aria-activedescendant): the selected surface and semibold. */
.wf-picker-option[aria-selected='true'] {
  background: var(--wf-bg-selected);
  font-weight: var(--wf-weight-semibold);
}
/* The title of an option: one line, with an ellipsis. */
.wf-picker-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The quiet line of an option: the folder, "Chapter 6", or "Current". */
.wf-picker-meta {
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-regular);
  color: var(--wf-text-subtle);
  white-space: nowrap;
}
/* "Create note “…”" or "New folder “…”": the option that makes a new target. Ink. */
.wf-picker-option--create,
.wf-picker-option--create > svg {
  color: var(--wf-accent-text);
}
/* The key hint at the end of the picker. */
.wf-picker-hint {
  margin-top: var(--wf-space-1);
  padding: var(--wf-space-2) var(--wf-space-3);
  border-top: var(--wf-hairline);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
/* The text after [[ in the note while the picker is open. The ink tint shows what the picker reads. */
.wf-link-query {
  border-radius: var(--wf-radius-xs);
  background: var(--wf-accent-soft);
}
/* The folder list inside the "Move to folder…" dialog: the picker options in a box, not a popover. */
.wf-folder-options {
  padding: var(--wf-space-1);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
  font-size: var(--wf-text-sm);
}

/* The capture text area. The UI face: a thought, not manuscript. About six lines. Add it to .wf-textarea. */
.wf-capture-text {
  min-height: var(--wf-capture-text-h);
}
/* The link chips of a capture. They use .wf-chat-attach and .wf-chat-attach-remove. */
.wf-capture-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
/* The line under the text: where the note goes, and the count near the limit. */
.wf-capture-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--wf-space-1) var(--wf-space-3);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text-subtle);
}
/* The count at the limit: the concern text, semibold. "Save" is off. */
.wf-capture-count[data-over='true'] {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}
/* The /capture page: the capture field on a full page, in the home frame. */
.wf-capture-page {
  display: grid;
  gap: var(--wf-space-5);
  width: 100%;
  max-width: var(--wf-form-w);
  margin-inline: auto;
}
/* The saved state of the /capture page: a check, the sentence and two actions. */
.wf-capture-done {
  display: grid;
  justify-items: center;
  gap: var(--wf-space-4);
  text-align: center;
}
/* The check of the saved state: moss, the "saved" color. */
.wf-capture-done > svg {
  width: var(--wf-space-8);
  height: var(--wf-space-8);
  color: var(--wf-ok-text);
}
/* At 600 px and below the capture dialog is a bottom sheet on the keyboard. Add it to .wf-dialog. */
@media (max-width: 600px) {
  .wf-dialog.wf-dialog--sheet {
    width: 100vw;
    max-height: calc(100dvh - var(--wf-keyboard-inset) - var(--wf-safe-top) - var(--wf-space-7));
    margin: auto 0 var(--wf-keyboard-inset);
    padding-bottom: var(--wf-safe-bottom);
    border-inline: 0;
    border-bottom: 0;
    border-radius: var(--wf-radius-lg) var(--wf-radius-lg) 0 0;
  }
  .wf-dialog.wf-dialog--sheet[open] {
    animation: wf-sheet-in var(--wf-dur-gentle) var(--wf-ease-enter);
  }
  /* The two buttons of the sheet share the row in equal parts. */
  .wf-dialog--sheet .wf-dialog-foot > .wf-btn {
    flex: 1 1 0;
  }
}
@keyframes wf-sheet-in {
  from {
    transform: translateY(100%);
  }
}
/* The "Capture" button of the home screen. On a phone it takes its own row, under the title. */
@container wf-home (max-width: 37.5em) {
  .wf-home-head > .wf-home-capture {
    grid-column: 1 / -1;
  }
}

/* The actions under a complete answer of Saga: "Copy", then the rating. Quiet buttons. */
.wf-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1);
  margin-top: var(--wf-space-2);
  margin-inline-start: calc(-1 * var(--wf-space-3));
}
/* Under a writer bubble the row lines up with the right edge of the bubble. */
.wf-msg-actions--writer {
  justify-content: flex-end;
  margin-inline-start: 0;
}

@media (pointer: coarse) {
  .wf-note-menu {
    opacity: 1;
  }
  .wf-note-link,
  .wf-folder-head,
  .wf-folder-toggle,
  .wf-picker-option {
    min-height: var(--wf-touch-target);
  }
}
@media (forced-colors: active) {
  .wf-picker-option[aria-selected='true'],
  .wf-note-row:has(> .wf-note-link[aria-current='page']) {
    outline: var(--wf-border-w) solid Highlight;
  }
  .wf-folder-head.is-drop-target {
    outline: var(--wf-border-w-strong) solid Highlight;
  }
}

/* -- 16d Saga memory -----------------------------------------------------------
   docs/research/2026-10-02-saga-memory.md and docs/design-mock/pages/memory.html.
   Memory holds how Saga works with the writer. It holds nothing about the story.
   Saga changes memory directly (owner, 2026-10-02). The writer can edit or undo.

   .wf-memory             The page "What Saga remembers" in the home frame.
   .wf-memory-section     One level: "All stories", or one story. A count shows the cap.
   .wf-memory-count       "12 of 30". [data-full] at the cap: concern text and the word "full".
   .wf-memory-list        The items of a section.
   .wf-memory-item        One item: the text, the date (with "Added by Saga" for an item of
                          Saga) and the "…" menu.
   .wf-memory-form        The field to add or edit an item: the text, the count, the scope.
   -------------------------------------------------------------------------- */
/* A change of the story details by Saga (set_story_details). .wf-details-diff shows the old and the new description, the tags added and removed.
   A removed tag and the old description are struck. */
.wf-details-diff {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--wf-space-2) var(--wf-space-3);
  margin: var(--wf-space-2) 0 0;
  padding: var(--wf-space-3);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
}
.wf-details-diff > dt {
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-subtle);
}
.wf-details-diff > dd {
  margin: 0;
  color: var(--wf-text);
  white-space: pre-wrap;
}
.wf-details-diff [data-old] {
  color: var(--wf-text-subtle);
  text-decoration: line-through;
  text-decoration-thickness: var(--wf-border-w);
}
.wf-details-diff [data-empty] {
  color: var(--wf-text-subtle);
  font-style: italic;
}
.wf-memory {
  display: grid;
  gap: var(--wf-space-6);
}
.wf-memory-intro {
  display: grid;
  gap: var(--wf-space-3);
}
.wf-memory-section {
  display: grid;
  gap: var(--wf-space-3);
  padding-top: var(--wf-space-5);
  border-top: var(--wf-hairline);
  scroll-margin-top: var(--wf-space-5);
}
.wf-memory-section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--wf-space-2) var(--wf-space-3);
}
.wf-memory-section-head .wf-subheading {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.wf-memory-count {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
}
.wf-memory-count[data-full] {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-memory-list {
  display: grid;
  gap: var(--wf-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-memory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--wf-space-1) var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-2) var(--wf-space-3) var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-memory-item-text {
  margin: 0;
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text);
  overflow-wrap: anywhere;
}
.wf-memory-item-date {
  grid-column: 1;
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-memory-item > .wf-menu-anchor {
  grid-column: 2;
  grid-row: 1 / span 2;
}
.wf-memory-empty {
  margin: 0;
  font-size: var(--wf-text-sm);
  color: var(--wf-text-subtle);
}
.wf-memory-form {
  display: grid;
  gap: var(--wf-space-3);
  padding: var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-memory-form-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--wf-space-2) var(--wf-space-3);
}

/* -- 16e Saga note writes -------------------------------------------------------
   docs/research/2026-10-02-saga-notes-and-riffs.md, sections 2.2, 2.7 to 2.9. The mock:
   docs/design-mock/pages/saga-notes.html.

   .wf-saga-changes        The actions of one answer, grouped by note. The "Show"
                           modal and the permission card use it.
   .wf-saga-changes-note-open  The note title as a button: it opens the note.
   .wf-saga-change         One action as a disclosure button (aria-expanded). A click
                           expands the action in place. The chevron turns down.
                           [data-skipped]: the writer kept that paragraph.
   .wf-saga-change-created A created note: the line and a snippet of its start. Not a
                           button, no chevron.
   .wf-saga-change-snippet The start of the new text: two lines at most, then "…", muted.
   .wf-saga-change-panel   The expanded action: the whole text, then "Show in note".
   .wf-saga-change-full    The whole text of the change in the manuscript face, as
                           plain text. [data-removed]: the old text, muted.
   .wf-saga-changes--plain In the permission card: the lines are text, not buttons.
   .wf-saga-mark           Saga's words in a note: a dotted familiar underline. No
                           tint, no text color. [data-active='true']: the popover is
                           open for this span.
   .wf-uncited-mark        A quote in Saga's note text that the server did not find in
                           its source. A quiet note after it, as in the chat:
                           "Not in the source."
   .wf-saga-pop            The popover on a click in Saga's words.
   .wf-version--held       The note history entry "Saga's change, not applied".
   ---------------------------------------------------------------------------- */

.wf-saga-changes {
  display: grid;
  gap: var(--wf-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-saga-changes-group {
  display: grid;
  gap: var(--wf-space-1);
}
/* The note: the note icon, the title and the folder in a quiet tail. */
.wf-saga-changes-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--wf-space-1) var(--wf-space-2);
  margin: 0;
  padding-inline: var(--wf-space-3);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text);
}
.wf-saga-changes-note svg {
  align-self: center;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
}
/* The title opens the note: a link in look, with the focus ring. */
.wf-saga-changes-note-open {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-xs);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.wf-saga-changes-note-open:hover {
  color: var(--wf-accent-text);
  text-decoration: underline;
  text-decoration-thickness: var(--wf-border-w);
}
.wf-saga-changes-note-open:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-saga-changes-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}
/* One action: the line in plain words, and an arrow at the end edge. */
.wf-saga-change {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--wf-icon-sm);
  align-items: center;
  gap: var(--wf-space-3);
  width: 100%;
  min-height: var(--wf-control-h);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font: inherit;
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  text-align: start;
  cursor: pointer;
}
.wf-saga-change:hover {
  background: var(--wf-bg-hover);
}
.wf-saga-change > svg {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
  transition: transform var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-saga-change[aria-expanded='true'] > svg {
  transform: rotate(90deg);
}
/* A created note: the line, then the start of its text. The note title above opens the note. */
.wf-saga-change-created {
  display: grid;
  gap: var(--wf-space-1);
  padding: var(--wf-space-2) var(--wf-space-3);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text);
}
.wf-saga-change-snippet {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  margin: 0;
  overflow: hidden;
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-relaxed);
  color: var(--wf-text-muted);
}
/* The expanded action: the whole text, then "Show in note". */
.wf-saga-change-panel {
  display: grid;
  justify-items: start;
  gap: var(--wf-space-3);
  padding: var(--wf-space-1) var(--wf-space-3) var(--wf-space-3);
}
/* The whole text as the note reads: the manuscript face, plain text, not a diff. */
.wf-saga-change-full {
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
  color: var(--wf-text-page);
  font-variant-numeric: var(--wf-ms-numerals);
}
.wf-saga-change-full > p {
  margin: 0;
}
.wf-saga-change-full > p + p {
  margin-top: var(--wf-space-2);
}
/* A removed paragraph: the old text, quiet. */
.wf-saga-change-full[data-removed] {
  color: var(--wf-text-muted);
}
/* "Skipped: you were editing this paragraph." under a skipped action. */
.wf-saga-change-skip {
  display: block;
  margin-top: var(--wf-space-1);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
.wf-saga-change[data-skipped] .wf-saga-change-text {
  color: var(--wf-text-muted);
}
/* In the permission card the lines are text. The card has "Show" for the detail. */
.wf-saga-changes--plain {
  gap: var(--wf-space-2);
}
.wf-saga-changes--plain .wf-saga-changes-note {
  padding-inline: 0;
}
.wf-saga-changes--plain .wf-saga-changes-list {
  gap: var(--wf-space-1);
  padding-inline-start: var(--wf-space-5);
  list-style: disc;
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text);
}

/* Saga's words in a note. A dotted familiar underline, 2 px, set low. No tint and no
   text color, so the writer reads the words as page text. It differs from a comment
   (ink tint and a solid ink line), a find hit (the selection tint), a link (a chip)
   and an entity mention (a 1 px dotted control line, chapters only). */
.wf-saga-mark {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--wf-familiar);
  text-decoration-thickness: var(--wf-border-w-strong);
  text-underline-offset: 0.35em;
  text-decoration-skip-ink: none;
}
/* The span of the open popover: the familiar tint. */
.wf-saga-mark[data-active='true'] {
  border-radius: var(--wf-radius-xs);
  background: var(--wf-familiar-soft);
}
/* A link that Saga added. A text underline does not reach an inline chip. */
.wf-saga-mark .wf-passage {
  border-block-end: var(--wf-border-w-strong) dotted var(--wf-familiar);
}
.wf-app.is-focus .wf-saga-mark {
  text-decoration: none;
}
@media (forced-colors: active) {
  .wf-saga-mark {
    text-decoration-color: Highlight;
  }
  .wf-saga-mark .wf-passage {
    border-block-end-color: Highlight;
  }
}

/* A quote in Saga's note text that the server did not find in its source (owner,
   2026-10-04). The words stay as they are. A quiet note follows them. The note is not text:
   a copy leaves it out. */
.wf-uncited-mark::after {
  content: 'Not in the source.';
  margin-inline-start: var(--wf-space-1);
  color: var(--wf-concern-text);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-xs);
  font-style: italic;
}
.wf-app.is-focus .wf-uncited-mark::after {
  content: none;
}

/* The surface of the popover on Saga's words and of the popover of the "Inexact" chip. */
.wf-saga-pop,
.wf-inexact-pop {
  width: max-content;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
  font-family: var(--wf-font-ui);
}
/* The popover on a click in Saga's words. The code sets top and left, under the span. */
.wf-saga-pop {
  position: absolute;
  z-index: var(--wf-z-popover);
  display: grid;
  gap: var(--wf-space-2);
  max-width: min(var(--wf-menu-max-w), calc(100vw - 2 * var(--wf-space-7)));
  padding: var(--wf-space-3);
  animation: wf-menu-in var(--wf-dur-quick) var(--wf-ease-enter);
}
/* "Saga wrote this in “…”.": the Saga glyph and one quiet line. */
.wf-saga-pop-meta {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  margin: 0;
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text-muted);
}
.wf-saga-pop-meta > svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-familiar);
}
.wf-saga-pop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
}

/* The note history: the held change of Saga. The familiar rule on the start edge, as on
   anything Saga proposes. The row has "Compare" only. */
.wf-version--held {
  padding-inline-start: var(--wf-space-3);
  border-inline-start: var(--wf-rule-w) solid var(--wf-familiar);
}

/* -- 16f Tool cards -------------------------------------------------------------
   Owner request of 2026-10-04. Each tool action of Saga in the chat is one card, so it
   does not blend into the text of the answer. The grouped tool lines use the same look,
   so all tool UI in the chat is one family. The component: apps/web/src/saga/ToolCard.tsx.

   .wf-tool-card          The card: a hairline box on the raised surface.
                          [data-asks]: the card waits for the writer's decision ("Allow",
                          "Deny"). It gets the familiar border, because Saga asks.
                          [data-settled]: the writer decided or undid the action. The card
                          stays, with no surface and quiet text.
   .wf-tool-card-head     The head row: the tool icon and the short title, in the familiar
                          text color.
   .wf-tool-card-body     The proposed or changed content.
   .wf-tool-card-text     One line of content. [data-struck]: undone or denied content.
   .wf-tool-card-note     A second, muted line: "1 change skipped: …".
   .wf-tool-card-foot     The action buttons. A settled card shows its state here.
   .wf-tool-card-state    The settled state: "Undone.", "Allowed.". Quiet text.
   .wf-tool-card-instructions  "Show instructions" on the critique launch card: a disclosure
                          with the full critic instructions.
   .wf-tool-card--tools   The compact card of the tool lines (.wf-chat-tools).
   The old line classes (.wf-memory-line, .wf-saga-hold) are in docs/design-mock/mock.css.
   -------------------------------------------------------------------------- */
.wf-tool-card {
  display: grid;
  gap: var(--wf-space-3);
  margin-top: var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-1);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
  overflow-wrap: anywhere;
}
/* Beats the paragraph gap of .wf-msg: the grid gap sets the space. */
.wf-msg .wf-tool-card-body > p {
  margin: 0;
}
.wf-tool-card[data-asks] {
  border: var(--wf-border-w) solid var(--wf-familiar);
}
.wf-tool-card[data-settled] {
  background: transparent;
  box-shadow: none;
}
.wf-tool-card-head {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-width: 0;
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  color: var(--wf-familiar-text);
}
.wf-tool-card-head svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
.wf-tool-card[data-settled] .wf-tool-card-head {
  color: var(--wf-text-subtle);
}
.wf-tool-card-body {
  display: grid;
  gap: var(--wf-space-2);
  min-width: 0;
}
.wf-tool-card-text {
  color: var(--wf-text);
}
.wf-tool-card[data-settled] .wf-tool-card-text {
  color: var(--wf-text-muted);
}
.wf-tool-card-text[data-struck] {
  text-decoration: line-through;
  text-decoration-thickness: var(--wf-border-w);
}
.wf-tool-card-note {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
.wf-tool-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
/* "Show" and "See the change" open a menu when the card holds two notes or more. */
.wf-tool-card-foot .wf-menu-anchor {
  display: inline-flex;
}
.wf-tool-card-state {
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-subtle);
}
.wf-tool-card .wf-memory-form {
  padding: var(--wf-space-3);
}
.wf-tool-card .wf-details-diff {
  margin: 0;
}
.wf-tool-card-instructions > summary {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
  cursor: pointer;
}
.wf-tool-card-instructions > p {
  margin: var(--wf-space-2) 0 0;
  font-size: var(--wf-text-xs);
  color: var(--wf-text);
  white-space: pre-wrap;
}
/* The compact card of the tool lines: less padding, the lines close together. */
.wf-tool-card--tools {
  gap: var(--wf-space-1);
  margin-block: var(--wf-space-2);
  padding: var(--wf-space-2) var(--wf-space-3);
}

/* -- 16g Feedback reports ------------------------------------------------------
   .wf-report-form        The form of a bug report or a feature request, in the dialog
                          "Send feedback" and in the report card of Saga.
   .wf-report-details     A disclosure with the metadata as JSON, in the admin tab "Feedback".
   .wf-report-text        A text of the writer in the admin tab "Feedback".
   .wf-report-images      The thumbnails of the images on a report, in the form and in the
                          admin tab. Each .wf-report-image holds an <img> and a remove button
                          or a link to the full image.
   docs/specs/feedback-reports.md.
   -------------------------------------------------------------------------- */
.wf-report-form {
  display: grid;
  gap: var(--wf-space-3);
}
.wf-report-images {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-report-image {
  position: relative;
}
.wf-report-image img {
  display: block;
  width: var(--wf-thumb-size);
  height: var(--wf-thumb-size);
  object-fit: cover;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
}
.wf-report-image > .wf-btn {
  position: absolute;
  inset-block-start: calc(-1 * var(--wf-space-2));
  inset-inline-end: calc(-1 * var(--wf-space-2));
}
.wf-report-attach {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
}
/* The file input is hidden in its label, so the label shows the focus. */
.wf-report-attach > label:has(:focus-visible) {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-report-details > summary {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
  cursor: pointer;
}
.wf-report-details > pre {
  max-height: 16rem;
  margin: var(--wf-space-2) 0 0;
  padding: var(--wf-space-2);
  overflow: auto;
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
  font-family: var(--wf-font-mono);
  font-size: var(--wf-text-xs);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The admin tab "Feedback": the text of the writer keeps its lines. The row link is a button. */
.wf-report-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
button.wf-admin-row-link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

/* -- 16h Note images ------------------------------------------------------------
   .wf-note-image          An image in a note (docs/specs/m10-notes.md, "Images"): a <figure>
                           with data-size small, medium or full. It holds the <img>, or
                           .wf-note-image-empty with the state, and the caption.
   .wf-note-image-state    The state over an image: "Not uploaded yet", "did not upload".
   .wf-note-image-caption  The description field and the size choice. The size choice shows
                           while the image is selected or a field of it has the focus. With
                           no alt, Saga's generated description is the placeholder, with a
                           .wf-badge--familiar tag and a "Make it mine" button.
   -------------------------------------------------------------------------- */
.wf-ms .wf-note-image {
  position: relative;
  width: var(--wf-note-image-medium);
  margin: var(--wf-space-5) 0;
  text-indent: 0;
}
.wf-ms .wf-note-image[data-size='small'] {
  width: var(--wf-note-image-small);
}
.wf-ms .wf-note-image[data-size='full'] {
  width: var(--wf-note-image-full);
}
.wf-note-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--wf-radius-sm);
}
.wf-note-image[data-selected] img,
.wf-note-image[data-selected] .wf-note-image-empty {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-note-image-empty {
  display: grid;
  place-items: center;
  min-height: var(--wf-note-image-empty-h);
  padding: var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
  color: var(--wf-text-muted);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
}
.wf-note-image-state {
  position: absolute;
  inset-block-start: var(--wf-space-3);
  inset-inline-start: var(--wf-space-3);
  padding: var(--wf-space-1) var(--wf-space-3);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-raised);
  color: var(--wf-text-muted);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-xs);
}
.wf-note-image-caption {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  margin-block-start: var(--wf-space-2);
  color: var(--wf-text-muted);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
}
.wf-note-image-alt {
  flex: 1;
  min-width: 0;
  padding: var(--wf-space-1) 0;
  border: 0;
  border-block-end: var(--wf-hairline);
  background: none;
  color: inherit;
  font: inherit;
}
/* Saga's generated description in the empty field: the placeholder, quieter than the writer's text. */
.wf-note-image-alt[data-generated]::placeholder {
  color: var(--wf-text-muted);
  font-style: italic;
}
.wf-note-image-alt:focus-visible {
  outline: none;
  border-block-end: var(--wf-border-control);
}
.wf-note-image-size {
  display: none;
  font: inherit;
}
.wf-note-image[data-selected] .wf-note-image-size,
.wf-note-image:focus-within .wf-note-image-size {
  display: block;
}

/* -- 19  Badges, kbd, saved state -------------------------------------------- */
.wf-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-1);
  min-height: calc(var(--wf-text-xs) * 1.8);
  padding: 0 var(--wf-space-3);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-hover);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  white-space: nowrap;
}
.wf-badge--concern {
  background: var(--wf-concern-soft);
  color: var(--wf-concern-text);
}
.wf-badge--ok {
  background: var(--wf-ok-soft);
  color: var(--wf-ok-text);
}
.wf-badge--ink {
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
}

.wf-kbd {
  display: inline-block;
  min-width: calc(var(--wf-text-xs) * 1.8);
  padding: 0 var(--wf-space-2);
  border: var(--wf-hairline-strong);
  border-bottom-width: var(--wf-border-w-strong);
  border-radius: var(--wf-radius-xs);
  background: var(--wf-bg-raised);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-normal);
  text-align: center;
}

.wf-saved {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-saved::before {
  content: '';
  width: var(--wf-space-3);
  height: var(--wf-space-3);
  border-radius: var(--wf-radius-full);
  background: var(--wf-ok-text);
}
.wf-saved[data-state='saving']::before {
  background: transparent;
  border: var(--wf-border-w-strong) solid var(--wf-text-subtle);
}
.wf-saved[data-state='offline']::before {
  /* Saved on this device, not yet on the server. Not an error: a hollow ring
     in the moss color says "safe here, waiting". */
  background: transparent;
  border: var(--wf-border-w-strong) solid var(--wf-ok-text);
}
.wf-saved[data-state='error'] {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-saved[data-state='error']::before {
  background: var(--wf-concern);
}

/* -- 19b Banner ----------------------------------------------------------------
   A non-modal notice, inline above the page text. Use it when the writer must
   choose before work continues (a save conflict), but the page stays usable.
   Neutral by default. --concern for problems that need a decision.
   -------------------------------------------------------------------------- */
.wf-banner {
  display: grid;
  gap: var(--wf-space-3);
  margin-bottom: var(--wf-space-6);
  padding: var(--wf-space-4) var(--wf-space-5);
  border-inline-start: var(--wf-rule-w) solid var(--wf-line-strong);
  border-radius: 0 var(--wf-radius-sm) var(--wf-radius-sm) 0;
  background: var(--wf-bg-sunken);
  color: var(--wf-text);
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
}
.wf-banner--concern {
  border-inline-start-color: var(--wf-concern);
  background: var(--wf-concern-soft);
}
.wf-banner-title {
  font-weight: var(--wf-weight-semibold);
}
.wf-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
}

/* -- 19c Dialog ----------------------------------------------------------------
   For the native <dialog>. showModal() puts it in the top layer, so it needs
   no z-index. Width comes from --wf-dialog-w; --form uses the small form width.
   -------------------------------------------------------------------------- */
.wf-dialog {
  width: min(var(--wf-dialog-w), calc(100vw - 2 * var(--wf-space-5)));
  max-width: none;
  max-height: calc(100dvh - 2 * var(--wf-space-7));
  margin: auto;
  padding: 0;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-lg);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  /* The text styles of <body>. A dialog in a row, a banner or a page does not inherit theirs. */
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
  box-shadow: var(--wf-shadow-4);
  overflow: hidden;
}
/* Only while open: a closed <dialog> must stay hidden. */
.wf-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: wf-dialog-in var(--wf-dur-gentle) var(--wf-ease-enter);
}
.wf-dialog--form {
  --wf-dialog-w: var(--wf-form-w);
}
.wf-dialog::backdrop {
  background: var(--wf-bg-scrim);
}
/* Head: pinned. The title and a close button that never scrolls away. */
.wf-dialog-head {
  display: flex;
  flex: none;
  align-items: flex-start;
  gap: var(--wf-space-3);
  padding: var(--wf-space-5) var(--wf-space-4) var(--wf-space-4) var(--wf-space-6);
  border-bottom: var(--wf-hairline);
}
.wf-dialog-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding-top: var(--wf-space-1);
  font-size: var(--wf-text-xl);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
  overflow-wrap: anywhere;
}
.wf-dialog-close {
  flex: none;
}
/* A form that spans the body and the footer */
.wf-dialog-frame {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
/* Body: the only part that scrolls */
.wf-dialog-body {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: var(--wf-space-4);
  min-height: 0;
  padding: var(--wf-space-5) var(--wf-space-6);
  overflow-y: auto;
  overscroll-behavior: contain;
}
/* Footer: pinned actions */
.wf-dialog-foot {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--wf-space-2);
  padding: var(--wf-space-4) var(--wf-space-6);
  border-top: var(--wf-hairline);
}
.wf-dialog-foot > .wf-banner {
  flex: 1 1 100%;
  margin: 0;
}
/* A short line under the buttons, at the end edge: "You can extend your pause
   later." Link it to its button with aria-describedby. */
.wf-dialog-foot > .wf-meta {
  flex: 1 1 100%;
  margin: 0;
  text-align: end;
}
/* At a large text size on a narrow screen a label wraps. */
.wf-dialog-body .wf-btn,
.wf-dialog-foot .wf-btn {
  padding-block: var(--wf-space-1);
  white-space: normal;
  text-align: center;
}
@media (max-width: 600px) {
  .wf-dialog {
    width: calc(100vw - 2 * var(--wf-space-4));
    max-height: calc(100dvh - 2 * var(--wf-space-4) - var(--wf-safe-top) - var(--wf-safe-bottom));
  }
  .wf-dialog-head {
    padding-inline-start: var(--wf-space-5);
  }
  .wf-dialog-body,
  .wf-dialog-foot {
    padding-inline: var(--wf-space-5);
  }
}
@keyframes wf-dialog-in {
  from {
    opacity: 0;
    transform: translateY(var(--wf-space-3));
  }
}
/* A titled part of a dialog body. Sections after the first get a hairline. */
.wf-dialog-section {
  display: grid;
  gap: var(--wf-space-3);
}
.wf-dialog-section + .wf-dialog-section {
  padding-top: var(--wf-space-5);
  border-top: var(--wf-hairline);
}
.wf-dialog-section-title {
  margin: 0;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  color: var(--wf-text);
}

/* -- 19d Drop zone and progress --------------------------------------------------
   .wf-dropzone   A place to drop a file. It always holds a "Choose a file"
                  button too, so it works without drag and drop.
                  [data-dragging="true"] while a file is over it.
   .wf-progress   The native <progress>. Without a value it is indeterminate.
   -------------------------------------------------------------------------- */
.wf-dropzone {
  display: grid;
  justify-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-6) var(--wf-space-5);
  border: var(--wf-border-w-strong) dashed var(--wf-line-control);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-sunken);
  text-align: center;
  transition:
    background-color var(--wf-dur-quick) var(--wf-ease-standard),
    border-color var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-dropzone > p {
  margin: 0;
}
.wf-dropzone[data-dragging='true'] {
  border-style: solid;
  border-color: var(--wf-accent);
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
}
.wf-dropzone[aria-disabled='true'] {
  border-color: var(--wf-line-strong);
  color: var(--wf-text-disabled);
}

.wf-progress {
  display: block;
  width: 100%;
  height: var(--wf-space-2);
  border: 0;
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-hover);
  box-shadow: inset 0 0 0 var(--wf-border-w) var(--wf-line-control);
  color: var(--wf-accent);
  overflow: hidden;
  appearance: none;
}
/* The control line around the track shows where the bar ends (3:1). The value
   covers it. */
.wf-progress::-webkit-progress-bar {
  background: var(--wf-bg-hover);
  box-shadow: inset 0 0 0 var(--wf-border-w) var(--wf-line-control);
  border-radius: var(--wf-radius-full);
}
.wf-progress::-webkit-progress-value {
  background: var(--wf-accent);
  border-radius: var(--wf-radius-full);
  transition: width var(--wf-dur-gentle) var(--wf-ease-standard);
}
.wf-progress::-moz-progress-bar {
  background: var(--wf-accent);
  border-radius: var(--wf-radius-full);
}
/* No value: indeterminate. A short bar slides across. */
.wf-progress:indeterminate {
  background-image: linear-gradient(to right, var(--wf-accent) 0 30%, transparent 30%);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  animation: wf-progress-slide var(--wf-dur-glow) var(--wf-ease-standard) infinite;
}
.wf-progress:indeterminate::-webkit-progress-bar {
  background: transparent;
}
.wf-progress:indeterminate::-moz-progress-bar {
  background: transparent;
}
@keyframes wf-progress-slide {
  from {
    background-position: 130% 0;
  }
  to {
    background-position: -70% 0;
  }
}

/* -- 20  Toasts ----------------------------------------------------------------
   .wf-toast-region  One region for each page, with role="status". It is in the
                     page from the first render and it is empty. The app inserts
                     only the toast. It is a child of <body> or of the app root,
                     never of a size container: a container would make it fixed
                     to the page and not to the window.
   .wf-toast         One sentence, then an optional action, then "Close".
                     A toast with an action has no timer.
   -------------------------------------------------------------------------- */
.wf-toast-region {
  position: fixed;
  inset-inline-start: 50%;
  bottom: calc(var(--wf-space-6) + var(--wf-safe-bottom));
  z-index: var(--wf-z-toast);
  display: grid;
  gap: var(--wf-space-3);
  width: min(var(--wf-toast-w), calc(100vw - var(--wf-space-6)));
  transform: translateX(-50%);
}
.wf-toast {
  display: flex;
  align-items: center;
  gap: var(--wf-space-4);
  padding: var(--wf-space-3) var(--wf-space-3) var(--wf-space-3) var(--wf-space-5);
  /* Forced colors remove the background. The border then shows the edge. */
  border: var(--wf-border-w) solid transparent;
  border-radius: var(--wf-radius-md);
  background: var(--wf-text);
  color: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-4);
  font-size: var(--wf-text-sm);
  animation: wf-toast-in var(--wf-dur-gentle) var(--wf-ease-enter);
}
.wf-toast-msg {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
/* The toast has inverted colors, so the focus ring inverts too. */
.wf-toast :focus-visible {
  outline-color: var(--wf-bg-raised);
}
/* While a toast shows, the page scrolls far enough to clear it. */
:root:has(.wf-toast-region > .wf-toast) {
  scroll-padding-bottom: var(--wf-toast-clear);
}
.wf-toast .wf-btn--quiet {
  color: var(--wf-bg-raised);
}
.wf-toast .wf-btn--quiet:hover {
  background: var(--wf-text-muted);
  color: var(--wf-bg-raised);
}
@keyframes wf-toast-in {
  from {
    opacity: 0;
    transform: translateY(var(--wf-space-3));
  }
}
/* A toast with a question: the message on the first row, the actions on a
   second row (.wf-toast-actions). Saga's streak messages and the sprint result
   use it. The actions line up with the message. The main action inverts to the
   raised surface. */
.wf-toast--stack {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'saga msg close'
    'actions actions actions';
  align-items: start;
  gap: var(--wf-space-2) var(--wf-space-3);
}
.wf-toast--stack > .wf-familiar {
  grid-area: saga;
}
.wf-toast--stack > .wf-toast-msg {
  grid-area: msg;
  padding-block: var(--wf-space-1);
}
.wf-toast--stack > .wf-btn--icon {
  grid-area: close;
}
.wf-toast-actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2);
}
.wf-toast--stack:has(> .wf-familiar) > .wf-toast-actions {
  padding-inline-start: calc(var(--wf-mascot-sm) + var(--wf-space-3));
}
.wf-toast--stack:not(:has(> .wf-familiar)) {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'msg close'
    'actions actions';
}
.wf-toast .wf-btn--primary {
  background: var(--wf-bg-raised);
  color: var(--wf-text);
}
.wf-toast .wf-btn--primary:hover:not(:disabled) {
  background: var(--wf-bg-hover);
}

/* -- 21  Sidebar ---------------------------------------------------------------
   Chapters and scenes. Drag to reorder.
   -------------------------------------------------------------------------- */
.wf-sidebar {
  width: var(--wf-sidebar-w);
  border-inline-end: var(--wf-hairline);
}
/* The app name in the sidebar head: the app mark, then "Ink Familiar". It is quieter
   than .wf-book-title, because the story title is the writer's work. As a link it
   opens the home screen. The home bar has a louder variant (section 23k). */
.wf-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-width: 0;
  min-height: var(--wf-control-h);
  border-radius: var(--wf-radius-sm);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  text-decoration: none;
  white-space: nowrap;
}
a.wf-brand:hover {
  color: var(--wf-text);
}
/* The app mark: the PWA icon at the size of the small sprite (components/BrandMark.tsx). */
.wf-brand-mark {
  display: block;
  flex: none;
  width: var(--wf-mascot-sm);
  height: var(--wf-mascot-sm);
  border-radius: var(--wf-radius-xs);
}
/* The sidebar head with the way home: the brand at the start, the "Stories"
   link at the end. */
.wf-panel-head > .wf-brand {
  margin-inline-end: auto;
}
/* The rail can be narrow (lib/railWidths.ts). If the brand and the "Stories"
   link do not fit in one row, the link wraps below the brand. */
.wf-sidebar > .wf-panel-head {
  flex-wrap: wrap;
  row-gap: 0;
}
/* The story in the sidebar: the first item of the sidebar body, above the
   chapter tabs. The row holds the story title and the story menu. A long title
   wraps. */
.wf-sidebar-story {
  display: grid;
  gap: var(--wf-space-1);
}
.wf-sidebar-story-row {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-sidebar-story-row > .wf-book-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.wf-book-title {
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
}
.wf-chapters {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--wf-space-1);
}
.wf-chapter {
  display: grid;
  grid-template-columns: var(--wf-icon-sm) 1fr auto;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: var(--wf-control-h);
  padding: var(--wf-space-2) var(--wf-space-3);
  border-radius: var(--wf-radius-sm);
  color: var(--wf-text-muted);
  text-decoration: none;
  cursor: pointer;
}
.wf-chapter:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-chapter[aria-current='page'] {
  background: var(--wf-bg-selected);
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-chapter-grip {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
  opacity: 0;
  cursor: grab;
}
.wf-chapter:hover .wf-chapter-grip,
.wf-chapter:focus-within .wf-chapter-grip {
  opacity: 1;
}
.wf-chapter-count {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
  font-weight: var(--wf-weight-regular);
}
.wf-scenes {
  list-style: none;
  margin: 0 0 var(--wf-space-2);
  padding: 0 0 0 calc(var(--wf-icon-sm) + var(--wf-space-5));
  display: grid;
}
.wf-scene {
  padding: var(--wf-space-1) var(--wf-space-3);
  border-inline-start: var(--wf-hairline);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-scene[aria-current='true'] {
  border-inline-start-color: var(--wf-accent);
  color: var(--wf-text);
}
/* Scene jump link: a button that scrolls the page to the scene. One line,
   truncated. It inherits the scene's color, so the current scene reads darker. */
.wf-scene-link {
  display: block;
  width: 100%;
  padding: var(--wf-space-1) var(--wf-space-2);
  border: 0;
  border-radius: var(--wf-radius-xs);
  background: transparent;
  color: inherit;
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.wf-scene-link:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-scene:has(.wf-scene-link) {
  padding-block: 0;
  padding-inline-end: 0;
}
.wf-chapter.is-dragging {
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-3);
}
.wf-dropline {
  height: var(--wf-border-w-strong);
  background: var(--wf-accent);
  border-radius: var(--wf-radius-full);
}
/* The sidebar footer: the streak row (.wf-streak, section 24) takes the spare
   room, and the account button stays at the end. Without the streak row (before
   the first read, or offline) the account button stays at the end
   too, so its menu (aligned to the end edge) stays on the screen. */
.wf-sidebar > .wf-panel-foot {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
}
.wf-sidebar > .wf-panel-foot > :last-child {
  margin-inline-start: auto;
}

/* -- 21b Activity bar ----------------------------------------------------------
   docs/specs/global-search.md, sections 1 and 2.
   .wf-activity--column  The column at the far left of the shell (desktop).
   .wf-activity--labels  The column with a label under each icon (a setting).
   .wf-activity--row     The row at the top of the drawer. 44 px targets, no labels.
   .wf-activity-btn      One icon: a button (a view or Search) or a link. A view
                         that shows has aria-pressed="true", a page aria-current.
   .wf-activity-badge    A count on the icon: new critiques, chapters in the trash.
   -------------------------------------------------------------------------- */
.wf-activity {
  display: flex;
  align-items: center;
  gap: var(--wf-space-1);
  background: var(--wf-bg-app);
}
.wf-activity--column {
  flex-direction: column;
  padding: var(--wf-space-3) 0;
  border-inline-end: var(--wf-hairline);
}
.wf-activity--row {
  padding: var(--wf-space-2) var(--wf-space-3);
  border-bottom: var(--wf-hairline);
}
.wf-activity-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  align-content: center;
  gap: var(--wf-space-1);
  width: var(--wf-control-h-lg);
  height: var(--wf-control-h-lg);
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text-subtle);
  text-decoration: none;
  cursor: pointer;
}
.wf-activity-btn svg {
  width: var(--wf-icon-lg);
  height: var(--wf-icon-lg);
}
.wf-activity-btn:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-activity-btn[aria-pressed='true'],
.wf-activity-btn[aria-current='page'] {
  background: var(--wf-bg-selected);
  color: var(--wf-accent-text);
}
.wf-activity--labels .wf-activity-btn {
  width: calc(var(--wf-activity-w-labels) - var(--wf-space-3));
  height: auto;
  padding-block: var(--wf-space-2);
}
.wf-activity-label {
  font-size: var(--wf-text-2xs);
  line-height: var(--wf-leading-tight);
}
.wf-activity-btn[aria-pressed='true'] > .wf-activity-label {
  font-weight: var(--wf-weight-semibold);
}
.wf-activity-badge {
  position: absolute;
  inset-block-start: var(--wf-space-1);
  inset-inline-end: var(--wf-space-1);
  min-width: var(--wf-icon-sm);
  padding: 0 var(--wf-space-1);
  border-radius: var(--wf-radius-full);
  background: var(--wf-accent);
  color: var(--wf-on-accent);
  font-size: var(--wf-text-2xs);
  font-weight: var(--wf-weight-bold);
  line-height: var(--wf-icon-sm);
  text-align: center;
}
.wf-activity--column > .wf-menu-anchor {
  margin-top: var(--wf-space-2);
}
.wf-sidebar > .wf-panel-foot > .wf-activity-btn {
  margin-inline-start: auto;
}
.wf-sidebar > .wf-panel-foot > .wf-activity-btn + :last-child {
  margin-inline-start: 0;
}

/* -- 21c Search ------------------------------------------------------------------
   docs/specs/global-search.md, section 4. A dialog (.wf-dialog.wf-search): a
   centered modal on the desktop, a full-screen sheet on a phone.
   .wf-search-bar      The field and the "Match case" and "Whole word" toggles.
   .wf-search-filters  The kind chips and the mode.
   .wf-search-chip     One kind: Notes, Chapters or Chat, with its count.
   .wf-search-row      A recent search, a title hit or a "Jump to" item.
   .wf-search-group    The hits of one source: a head that collapses, then snippets.
   .wf-search-hit      One snippet. The match is a mark (.wf-find-hit).
   -------------------------------------------------------------------------- */
.wf-search {
  --wf-dialog-w: var(--wf-search-w);
}
.wf-search .wf-dialog-body {
  gap: var(--wf-space-3);
}
.wf-search-bar,
.wf-search-filters,
.wf-search-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-search-input {
  flex: 1 1 auto;
  min-width: 0;
}
.wf-search-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-height: var(--wf-control-h-sm);
  padding: 0 var(--wf-space-4);
  border: var(--wf-border-w) solid var(--wf-line-control);
  border-radius: var(--wf-radius-full);
  background: transparent;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  cursor: pointer;
}
.wf-search-chip[aria-pressed='true'] {
  border-color: var(--wf-accent);
  background: var(--wf-accent);
  color: var(--wf-on-accent);
  font-weight: var(--wf-weight-semibold);
}
.wf-search-section,
.wf-search-group {
  display: grid;
  gap: var(--wf-space-1);
}
.wf-search-section-head {
  justify-content: space-between;
}
.wf-search-list {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-search-recent {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-search-row,
.wf-search-group-head,
.wf-search-hit {
  display: grid;
  width: 100%;
  min-width: 0;
  padding: var(--wf-space-2) var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.wf-search-row:hover,
.wf-search-group-head:hover,
.wf-search-hit:hover {
  background: var(--wf-bg-hover);
}
.wf-search-row small,
.wf-search-group-head small {
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
}
.wf-search-row--icon {
  grid-template-columns: var(--wf-icon-sm) auto minmax(0, 1fr);
  align-items: baseline;
  gap: var(--wf-space-3);
}
.wf-search-group-head {
  grid-template-columns: var(--wf-icon-sm) var(--wf-icon-sm) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-2);
  font-weight: var(--wf-weight-semibold);
}
.wf-search-group-head svg,
.wf-search-row--icon svg {
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  color: var(--wf-text-subtle);
}
.wf-search-group-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wf-search-hit {
  /* Inline text with marks: not a grid of runs. */
  display: block;
  padding-inline-start: calc(var(--wf-icon-sm) * 2 + var(--wf-space-5));
  color: var(--wf-text-muted);
  font-family: var(--wf-ms-font);
  line-height: var(--wf-leading-normal);
}
.wf-search-hit--chat {
  border-inline-start: var(--wf-border-w-strong) solid var(--wf-familiar);
  border-radius: 0;
  font-family: var(--wf-font-ui);
  font-size: var(--wf-text-sm);
}
.wf-search .wf-search-list > li > .wf-btn--quiet {
  margin-inline-start: calc(var(--wf-icon-sm) * 2 + var(--wf-space-3));
}
@media (max-width: 600px) {
  .wf-dialog.wf-search {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding-top: var(--wf-safe-top);
    padding-bottom: var(--wf-safe-bottom);
    border: 0;
    border-radius: 0;
  }
}

/* -- 22  Manuscript page -------------------------------------------------------
   The most important surface. Flat, no shadow, no border, no texture.
   Book conventions: indented paragraphs, no indent after a heading or a scene
   break, old-style numerals, ragged right.
   The familiar marks a paragraph from the margin. It never tints the words.
   -------------------------------------------------------------------------- */
.wf-page {
  min-height: 100%;
  background: var(--wf-bg-page);
  padding: var(--wf-page-pad-top) var(--wf-page-pad-x) var(--wf-space-10);
}
.wf-ms {
  max-width: var(--wf-ms-measure);
  margin: 0 auto;
  font-family: var(--wf-ms-font);
  font-size: var(--wf-ms-size);
  line-height: var(--wf-ms-leading);
  color: var(--wf-text-page);
  font-variant-numeric: var(--wf-ms-numerals);
  font-optical-sizing: auto;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  hanging-punctuation: first;
  hyphens: manual;
  caret-color: var(--wf-accent);
}
.wf-ms:focus {
  outline: none;
}
/* Headings inside a chapter. The chapter title is not here: it is chrome
   (.wf-chapter-head), outside the chapter's document. */
.wf-ms h2,
.wf-ms h3 {
  font-family: var(--wf-ms-font);
  font-weight: var(--wf-ms-title-weight);
  line-height: var(--wf-leading-tight);
  letter-spacing: var(--wf-track-tight);
  color: var(--wf-text-page);
  text-wrap: balance;
}
.wf-ms h2 {
  margin: 2em 0 0.75em;
  font-size: 1.45em;
}
.wf-ms h3 {
  margin: 1.75em 0 0.6em;
  font-size: 1.15em;
  font-style: italic;
}
.wf-ms > :first-child {
  margin-top: 0;
}
.wf-ms blockquote {
  margin: 1em 0;
  padding-inline-start: var(--wf-ms-indent);
  border-inline-start: var(--wf-border-w-strong) solid var(--wf-line-strong);
  font-style: italic;
}
.wf-ms blockquote p {
  text-indent: 0;
}
.wf-ms u {
  text-decoration-thickness: var(--wf-border-w);
  text-underline-offset: 0.2em;
}
.wf-ms s {
  text-decoration-thickness: var(--wf-border-w);
  color: var(--wf-text-muted);
}
.wf-ms p {
  position: relative;
  margin: 0;
  text-indent: var(--wf-ms-para-indent);
  text-wrap: pretty;
}
/* While the writer types, pretty wrap moves the word before a short last word down and back up
   (reports 01a138b1, 01a138bc). Read-only text keeps it. */
.wf-ms[contenteditable='true'] p {
  text-wrap: wrap;
}
.wf-ms p + p {
  margin-top: var(--wf-ms-para-gap);
}
.wf-ms h2 + p,
.wf-ms h3 + p,
.wf-ms blockquote + p,
.wf-ms hr + p,
.wf-ms p:first-child {
  text-indent: 0;
}
.wf-ms em {
  font-style: italic;
}
.wf-ms strong {
  font-weight: var(--wf-weight-semibold);
}
/* Scene break: centered mark, a full blank line above and below.
   data-ms-scene picks the mark. The document stores no glyph.
   ::before draws an image separator. ::after draws a text separator or the dash. */
.wf-ms hr {
  border: 0;
  margin: calc(var(--wf-ms-leading) * 1em) 0;
  text-align: center;
  overflow: visible;
  height: calc(var(--wf-ms-leading) * 1em);
}
/* The one drawing rule for each image separator. The image is a mask, so the mark
   takes the text color of the theme. The box is in em, so it scales with the text.
   A mask adds no text for a screen reader. */
.wf-ms hr::before,
.wf-scene-icon {
  content: '';
  display: inline-block;
  width: var(--wf-ms-scene-w);
  height: var(--wf-ms-scene-h);
  max-width: 100%;
  vertical-align: middle;
  background-color: currentColor;
  -webkit-mask: var(--wf-ms-scene-image) center / contain no-repeat;
  mask: var(--wf-ms-scene-image) center / contain no-repeat;
  print-color-adjust: exact;
}
.wf-ms hr::before {
  color: var(--wf-text-subtle);
}
/* The scene break tool shows the asterism always. It does not follow the setting. */
.wf-scene-icon {
  --wf-ms-scene-image: var(--wf-scene-asterism);
  --wf-ms-scene-w: 1em;
  --wf-ms-scene-h: 0.92em;
}
.wf-ms hr::after {
  content: var(--wf-ms-scene-glyph);
  color: var(--wf-text-subtle);
  font-size: 1em;
  line-height: var(--wf-ms-leading);
}
:root[data-ms-scene='dash'] .wf-ms hr::after {
  display: inline-block;
  width: var(--wf-ms-scene-rule-w);
  max-width: 100%;
  border-top: var(--wf-border-w) solid currentColor;
  vertical-align: middle;
}
/* Settings: a small preview of the chosen separator, on the page color. */
.wf-scene-preview {
  max-width: none;
  margin: 0;
  border: var(--wf-border-w) solid var(--wf-line);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-page);
}
.wf-scene-preview hr {
  margin: var(--wf-space-2) 0;
}
/* The blank separator has no glyph. The space of the scene break stays, and
   the selected scene break shows an outline, so the writer can find and delete it. */
:root[data-ms-scene='blank'] .wf-ms hr.ProseMirror-selectednode {
  outline: var(--wf-border-w) dashed var(--wf-line-control);
  outline-offset: var(--wf-focus-offset);
}

/* Margin mark: the familiar points at a paragraph from the start margin */
.wf-ms p[data-mark]::before {
  content: '';
  position: absolute;
  top: 0.3em;
  bottom: 0.3em;
  inset-inline-start: calc(-1 * var(--wf-margin-mark-gap) - var(--wf-rule-w));
  width: var(--wf-rule-w);
  border-radius: var(--wf-radius-full);
  background: var(--wf-familiar);
  z-index: var(--wf-z-margin-mark);
}
.wf-ms p[data-mark='concern']::before {
  background: var(--wf-concern);
}
.wf-ms p[data-mark][data-mark-active]::before {
  inset-inline-start: calc(-1 * var(--wf-margin-mark-gap) - var(--wf-rule-w) * 2);
  width: calc(var(--wf-rule-w) * 2);
}

/* Lists and tables in a note (the note profile; docs/research/2026-10-02-notes-first-class.md,
   section 1.2). A chapter never holds them. Items and cells take no paragraph indent.
   A table scrolls sideways inside its own box (.tableWrapper of TipTap), so the page never
   scrolls sideways on a phone. */
.wf-ms ul,
.wf-ms ol {
  margin: var(--wf-space-3) 0;
  padding-inline-start: var(--wf-ms-indent-list);
}
.wf-ms li > ul,
.wf-ms li > ol {
  margin: var(--wf-space-1) 0 0;
}
.wf-ms li + li {
  margin-top: var(--wf-space-1);
}
.wf-ms li::marker {
  color: var(--wf-text-muted);
}
.wf-ms li p,
.wf-ms td p,
.wf-ms th p {
  text-indent: 0;
}
.wf-ms ul + p,
.wf-ms ol + p,
.wf-ms .tableWrapper + p {
  text-indent: 0;
}
.wf-ms .tableWrapper {
  margin: var(--wf-space-5) 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.wf-ms table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--wf-ms-table-size);
  line-height: var(--wf-leading-tight);
}
.wf-ms td,
.wf-ms th {
  position: relative;
  min-width: var(--wf-ms-cell-min);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: var(--wf-border-w) solid var(--wf-line-strong);
  vertical-align: top;
  text-align: start;
  overflow-wrap: anywhere;
}
.wf-ms th {
  background: var(--wf-bg-sunken);
  font-weight: var(--wf-ms-title-weight);
}
.wf-ms td p + p,
.wf-ms th p + p {
  margin-top: var(--wf-space-2);
}
/* A cell selection of the table plugin (prosemirror-tables). */
.wf-ms .selectedCell {
  background: var(--wf-text-selection);
}

/* The block of a passage link of Saga (blockTarget.ts): a selection tint for 2 s. When
   the class goes, the tint fades out. Reduced motion: the tint goes at once. */
.wf-ms > *,
.wf-ms blockquote > * {
  transition:
    background-color var(--wf-dur-slow) var(--wf-ease-exit),
    box-shadow var(--wf-dur-slow) var(--wf-ease-exit);
}
.wf-ms .wf-block-flash {
  border-radius: var(--wf-radius-xs);
  background-color: var(--wf-text-selection);
  box-shadow: 0 0 0 var(--wf-space-2) var(--wf-text-selection);
}
/* The words of a passage link with a quote (report 01a12439). The span goes at the end of
   the flash, so the tint fades out before it: the fade ends at --wf-dur-flash. */
.wf-ms .wf-quote-flash {
  border-radius: var(--wf-radius-xs);
  animation: wf-quote-flash-out var(--wf-dur-slow) var(--wf-ease-exit) calc(var(--wf-dur-flash) - var(--wf-dur-slow)) both;
}
@keyframes wf-quote-flash-out {
  from {
    background-color: var(--wf-text-selection);
  }
  to {
    background-color: transparent;
  }
}

/* Find and replace hits */
.wf-ms mark,
.wf-find-hit {
  background: var(--wf-text-selection);
  color: inherit;
  border-radius: var(--wf-radius-xs);
}
/* The selection that went to Saga's chat, drawn while the writer types in the chat field (askSaga.ts). */
.wf-kept-selection {
  background: var(--wf-text-selection);
}
/* The current hit inverts to the accent pair, so it stands out from the other hits. */
.wf-find-hit[aria-current='true'] {
  background: var(--wf-accent);
  color: var(--wf-on-accent);
  outline: var(--wf-border-w-strong) solid var(--wf-accent);
}

/* -- 22b Chapter on the page: chapter heading ----------------------------------
   One chapter per page, with its title as chrome above the editor.
   .wf-page-chapter  One chapter: a heading plus an editor.
   .wf-chapter-head   Chrome, not manuscript text. It is not in either
                      chapter's document and the caret cannot enter it.
   .wf-chapter-title-btn    The title as a button: a click starts the rename.
                            A quiet fill on hover and on keyboard focus is the
                            only hint. It has no icon.
   .wf-chapter-title-input  The title in edit mode. It takes the type of the
                            heading and has no box, so the text does not move.
   -------------------------------------------------------------------------- */
.wf-page-chapter {
  max-width: var(--wf-ms-measure);
  margin: 0 auto;
  font-size: var(--wf-ms-size);
}
.wf-page-chapter + .wf-page-chapter {
  margin-top: var(--wf-chapter-gap);
}
.wf-page-chapter .wf-ms {
  font-size: 1em;
}
.wf-chapter-head {
  position: relative;
  display: grid;
  gap: var(--wf-space-2);
  margin-bottom: 1.5em;
  padding-top: var(--wf-space-6);
  border-top: var(--wf-hairline);
  user-select: none;
  overflow-anchor: none;
}
.wf-page-chapter:first-child .wf-chapter-head {
  border-top: 0;
  padding-top: 0;
}
.wf-chapter-title {
  font-family: var(--wf-ms-font);
  font-size: var(--wf-ms-title-size);
  font-weight: var(--wf-ms-title-weight);
  line-height: var(--wf-leading-tight);
  letter-spacing: var(--wf-track-tight);
  color: var(--wf-text-page);
  text-wrap: balance;
}
.wf-chapter-title-btn,
.wf-chapter-title-input {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-xs);
  background: none;
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  text-align: start;
}
.wf-chapter-title-btn {
  display: inline;
  text-wrap: inherit;
  cursor: text;
  transition:
    background-color var(--wf-dur-quick) var(--wf-ease-standard),
    box-shadow var(--wf-dur-quick) var(--wf-ease-standard);
}
/* The fill grows past the text with a shadow, so the text keeps its place. */
.wf-chapter-title-btn:hover,
.wf-chapter-title-btn:focus-visible,
.wf-chapter-title-input {
  background: var(--wf-bg-hover);
  box-shadow: 0 0 0 var(--wf-space-1) var(--wf-bg-hover);
}
.wf-chapter-title-input {
  display: block;
  width: 100%;
  user-select: text;
  caret-color: var(--wf-accent);
}
.wf-chapter-title-input::placeholder {
  color: var(--wf-text-subtle);
}
.wf-chapter-title-input:focus-visible {
  outline-offset: var(--wf-space-1);
}

/* -- 22c Formatting toolbar ----------------------------------------------------
   A slim row of quiet tools, not a ribbon. It acts on the chapter that holds
   the caret. aria-pressed shows the mark at the caret. Focus mode hides it.
   .wf-formatbar         The row. Sits in the top bar on desktop.
   .wf-formatbar--dock   Phone: fixed above the on-screen keyboard.
   .wf-tool              One toggle or action. Icon only, with a tooltip.
   .wf-tool-sep          A short divider between groups.
   .wf-block-select      Block style: Body, Heading 2, Heading 3, Quote.
   -------------------------------------------------------------------------- */
.wf-formatbar {
  display: flex;
  align-items: center;
  gap: var(--wf-space-1);
  min-width: 0;
}
.wf-tool {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--wf-tool-size);
  height: var(--wf-tool-size);
  padding: 0;
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text-muted);
  font-family: var(--wf-font-ui);
  cursor: pointer;
  transition:
    background-color var(--wf-dur-instant) var(--wf-ease-standard),
    color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-tool svg {
  width: var(--wf-icon);
  height: var(--wf-icon);
}
.wf-tool:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-tool[aria-pressed='true'] {
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
}
.wf-tool:disabled {
  color: var(--wf-text-disabled);
  background: transparent;
  cursor: not-allowed;
}
.wf-tool--glyph {
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-lg);
  line-height: var(--wf-leading-tight);
}
.wf-tool-sep {
  flex: none;
  width: var(--wf-border-w);
  height: var(--wf-tool-sep-h);
  margin: 0 var(--wf-space-2);
  background: var(--wf-line);
}
.wf-block-select {
  flex: none;
  min-height: var(--wf-tool-size);
  padding: 0 var(--wf-space-6) 0 var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background-color: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--wf-text-muted) 50%),
    linear-gradient(135deg, var(--wf-text-muted) 50%, transparent 50%);
  background-position:
    right var(--wf-space-4) center,
    right var(--wf-space-3) center;
  background-size: var(--wf-caret-size) var(--wf-caret-size);
  background-repeat: no-repeat;
  cursor: pointer;
}
.wf-block-select:hover {
  background-color: var(--wf-bg-hover);
}

.wf-formatbar--dock {
  position: fixed;
  inset-inline: 0;
  bottom: var(--wf-keyboard-inset);
  z-index: var(--wf-z-sticky);
  height: var(--wf-dock-h);
  padding: 0 var(--wf-space-2);
  gap: 0;
  background: var(--wf-bg-chrome);
  border-top: var(--wf-hairline);
  overflow-x: auto;
  scrollbar-width: none;
}
.wf-formatbar--dock .wf-tool {
  width: var(--wf-touch-target);
  height: var(--wf-touch-target);
}
.wf-formatbar--dock .wf-block-select {
  min-height: var(--wf-touch-target);
}
.wf-formatbar--dock .wf-tool-sep {
  margin: 0 var(--wf-space-1);
}

/* -- 23  App shell -------------------------------------------------------------
   Desktop: sidebar | page | AI panel. The page takes all spare width.
   Under 1180px the AI panel overlays the page. Under 860px the sidebar becomes
   a drawer. Under 600px both become bottom or side sheets.

   .wf-splitter           The grab line on the inner edge of a docked rail. The
                          writer drags it to change the width of the rail.
   .wf-splitter--sidebar  On the end edge of the sidebar.
   .wf-splitter--panel    On the start edge of the AI panel.
   .wf-is-resizing        On <html> during a drag.
   -------------------------------------------------------------------------- */
.wf-app {
  --wf-act-w: var(--wf-activity-w);
  --wf-side-w: var(--wf-sidebar-w);
  display: grid;
  grid-template-columns: var(--wf-act-w) var(--wf-side-w) minmax(0, 1fr) var(--wf-panel-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    'act side top panel'
    'act side page panel';
  height: 100dvh;
  background: var(--wf-bg-app);
}
.wf-app > .wf-sidebar {
  grid-area: side;
}
.wf-app > .wf-activity {
  grid-area: act;
}
.wf-app:has(> .wf-activity--labels) {
  --wf-act-w: var(--wf-activity-w-labels);
}
/* A click on the icon of the shown view collapses the sidebar. The bar stays. */
.wf-app.is-sidebar-collapsed {
  --wf-side-w: 0px;
}
.wf-app.is-sidebar-collapsed > .wf-sidebar,
.wf-app.is-sidebar-collapsed > .wf-splitter--sidebar {
  display: none;
}
.wf-app > .wf-topbar {
  grid-area: top;
}
/* The scroll container is positioned, so it contains and clips its absolutely positioned
   content, for example .wf-sr-only. Without this, that content makes the window scroll. */
.wf-app > .wf-page-scroll {
  grid-area: page;
  position: relative;
  overflow-y: auto;
  background: var(--wf-bg-page);
}
.wf-app > .wf-ai {
  grid-area: panel;
}
.wf-app.is-panel-closed {
  grid-template-columns: var(--wf-act-w) var(--wf-side-w) minmax(0, 1fr) 0;
}
.wf-app.is-focus {
  grid-template-columns: 0 0 minmax(0, 1fr) 0;
}
.wf-app.is-focus > .wf-sidebar,
.wf-app.is-focus > .wf-activity,
.wf-app.is-focus > .wf-ai {
  visibility: hidden;
}
/* Focus mode hides the toolbar. The top bar fades out. The save state never
   hides: .wf-focus-status shows it in the corner, with the button that exits
   focus mode at its end. Esc also exits. */
.wf-app.is-focus .wf-formatbar,
.wf-app.is-focus .wf-topbar-status {
  visibility: hidden;
}
.wf-app.is-focus > .wf-topbar {
  opacity: 0;
  transition: opacity var(--wf-dur-gentle) var(--wf-ease-standard);
}
.wf-app.is-focus > .wf-topbar:hover,
.wf-app.is-focus > .wf-topbar:focus-within {
  opacity: 1;
}

.wf-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
  min-height: var(--wf-topbar-h);
  padding: var(--wf-space-2) var(--wf-space-5);
  background: var(--wf-bg-page);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}
.wf-topbar-spacer {
  flex: 1;
}
.wf-wordcount {
  display: inline-flex;
  white-space: nowrap;
  gap: var(--wf-space-4);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
}
.wf-wordcount b {
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}

.wf-ai {
  border-inline-start: var(--wf-hairline);
  width: var(--wf-panel-w);
}

@media (max-width: 1180px) {
  .wf-app,
  .wf-app.is-panel-closed {
    grid-template-columns: var(--wf-act-w) var(--wf-side-w) minmax(0, 1fr);
    grid-template-areas:
      'act side top'
      'act side page';
  }
  /* The panel sits on the on-screen keyboard, so the message field stays in view. */
  .wf-app > .wf-ai {
    position: fixed;
    inset-block: 0 var(--wf-keyboard-inset);
    inset-inline-end: 0;
    z-index: var(--wf-z-panel);
    box-shadow: var(--wf-shadow-4);
  }
  .wf-app.is-panel-closed > .wf-ai {
    display: none;
  }
  .wf-app.is-focus {
    grid-template-columns: 0 0 minmax(0, 1fr);
  }
}
@media (max-width: 860px) {
  .wf-app,
  .wf-app.is-panel-closed,
  .wf-app.is-focus {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'top'
      'page';
  }
  .wf-app > .wf-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: var(--wf-z-sidebar);
    box-shadow: var(--wf-shadow-4);
  }
  .wf-app:not(.is-sidebar-open) > .wf-sidebar {
    display: none;
  }
}
@media (max-width: 600px) {
  .wf-wordcount > span:not(:first-child) {
    display: none;
  }
  /* The chat and the comments fill the screen (docs/specs/phone-chat-and-comments.md). The
     screen rises with the keyboard and fits in the visible area, so the thread above the
     message field stays in view. The keyboard covers the home indicator: the safe area
     padding drops while it shows. */
  .wf-app > .wf-ai {
    inset-block: auto var(--wf-keyboard-inset);
    inset-inline: 0;
    width: 100%;
    height: calc(var(--wf-visible-h) - var(--wf-safe-top));
    border-inline-start: 0;
    padding-bottom: max(0px, calc(var(--wf-safe-bottom) - var(--wf-keyboard-inset)));
    z-index: var(--wf-z-sheet);
  }
}

/* The expanded chat (.is-chat-wide on .wf-app). The panel covers the top bar, the page and
   its own column, beside the sidebar. The page keeps its layout below it, so the editor does
   not reflow. Under 860 px the sidebar is a drawer, and the chat fills the width. A phone has
   no expanded chat: the chat fills the screen there. The thread, the notices and the field keep a readable
   column in the middle. */
.wf-app.is-chat-wide > .wf-ai {
  position: fixed;
  inset-block: 0 var(--wf-keyboard-inset);
  inset-inline: calc(var(--wf-act-w) + var(--wf-side-w)) 0;
  z-index: var(--wf-z-panel);
  width: auto;
  box-shadow: none;
}
.wf-app.is-chat-wide .wf-chat,
.wf-app.is-chat-wide .wf-chat-history {
  width: 100%;
  max-width: var(--wf-chat-wide-w);
  margin-inline: auto;
}
@media (max-width: 860px) {
  .wf-app.is-chat-wide > .wf-ai {
    inset-inline: 0;
    border-inline-start: 0;
  }
}

/* Rail splitters. The shell fills the window, so a fixed position from the window edge
   is the edge of the rail. The hit area is wider than the line and lies mostly on the
   page side, so it does not cover the controls of the rail. The line lies on the
   hairline of the rail. The app renders a splitter only for a docked rail. The rules
   below hide it in the other layouts too. */
.wf-splitter {
  position: fixed;
  inset-block: 0;
  z-index: var(--wf-z-sticky);
  width: var(--wf-splitter-hit);
  cursor: col-resize;
  touch-action: none;
  /* The line is the focus indicator: --wf-focus-w of --wf-focus. An outline around the
     hit area is a bar on the page. */
  outline: none;
}
.wf-splitter--sidebar {
  inset-inline-start: calc(var(--wf-act-w) + var(--wf-sidebar-w) - var(--wf-splitter-inset));
}
.wf-splitter--panel {
  inset-inline-end: calc(var(--wf-panel-w) - var(--wf-splitter-inset));
}
.wf-splitter::before {
  content: '';
  position: absolute;
  inset-block: 0;
  border-inline-start: var(--wf-hairline);
  transition: border-color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-splitter--sidebar::before {
  inset-inline-end: calc(100% - var(--wf-splitter-inset));
}
.wf-splitter--panel::before {
  inset-inline-start: calc(100% - var(--wf-splitter-inset));
}
.wf-splitter:hover::before,
.wf-splitter[data-dragging]::before {
  border-inline-start-color: var(--wf-accent);
  border-inline-start-width: var(--wf-focus-w);
}
.wf-splitter:focus-visible::before {
  border-inline-start-color: var(--wf-focus);
  border-inline-start-width: var(--wf-focus-w);
}
.wf-app.is-focus > .wf-splitter,
.wf-app.is-panel-closed > .wf-splitter--panel,
.wf-app.is-chat-wide > .wf-splitter--panel {
  display: none;
}
@media (max-width: 1180px) {
  .wf-splitter--panel {
    display: none;
  }
}
@media (max-width: 860px) {
  .wf-splitter--sidebar {
    display: none;
  }
}
@media (pointer: coarse) {
  .wf-splitter {
    --wf-splitter-hit: var(--wf-touch-target);
  }
}
/* During a drag: the resize cursor everywhere, no text selection, and the page and the
   rails get no pointer events. The splitter has the pointer capture. */
.wf-is-resizing,
.wf-is-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
.wf-is-resizing .wf-app > :not(.wf-splitter) {
  pointer-events: none;
}

/* -- 23b Auth pages ----------------------------------------------------------
   Sign-in and other standalone forms. Full viewport height, one centered
   card, a side gutter at phone width. The card fills the width up to
   --wf-form-w.
   -------------------------------------------------------------------------- */
.wf-auth {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: calc(var(--wf-space-5) + var(--wf-safe-top)) var(--wf-space-5)
    calc(var(--wf-space-5) + var(--wf-safe-bottom));
  background: var(--wf-bg-app);
}
.wf-auth-card {
  width: 100%;
  max-width: var(--wf-form-w);
}
/* The sign-in and link pages (docs/design-mock/pages/auth.html, sections 1 and 2).
   .wf-auth-providers  The provider buttons, one under the other, at full width.
   .wf-auth-foot       The "invite only" line at the end of the login card. */
.wf-auth-card > .wf-title {
  text-align: center;
}
.wf-auth-card > .wf-banner {
  margin: 0;
}
.wf-auth-card > .wf-body,
.wf-auth-card > .wf-field-error {
  margin: 0;
  text-align: center;
}
.wf-auth-providers {
  display: grid;
  gap: var(--wf-space-3);
}
.wf-auth-providers > .wf-btn,
.wf-auth-card > .wf-btn {
  width: 100%;
}
.wf-auth-foot {
  margin: 0;
  text-align: center;
}
/* The code of a shell sign-in on the courier page (docs/specs/m15-desktop-shell.md, section 2.3).
   .wf-handoff-code      "482 195", large and in the mono face, so each digit reads clearly.
   .wf-handoff-code-row  The code and its copy button, centered on one line. */
.wf-handoff-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--wf-space-2);
}
.wf-handoff-code {
  margin: 0;
  font-family: var(--wf-font-mono);
  font-size: var(--wf-text-2xl);
  font-variant-numeric: tabular-nums;
  text-align: center;
  user-select: all;
}
/* The invite page and Admin › Invites (docs/design-mock/pages/auth.html, sections 3 and 5).
   .wf-auth-note           The note from the team on the invite page.
   .wf-invite-form         The invite form. It keeps the form width.
   .wf-admin-invites       The invite list. .wf-admin-col-wide ("Invited") hides at 600 px
                           and below. .wf-admin-row-narrow then shows the date under the email.
   .wf-invite-actions-row  The row under an open invite. It holds .wf-invite-actions:
                           "Resend", "Copy link" and "Revoke". */
.wf-auth-note {
  display: grid;
  gap: var(--wf-space-2);
  margin: 0;
  padding: var(--wf-space-3) var(--wf-space-4);
  border-inline-start: var(--wf-rule-w) solid var(--wf-line-strong);
  background: var(--wf-bg-sunken);
}
.wf-auth-note > blockquote {
  margin: 0;
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.wf-invite-form {
  max-width: var(--wf-form-w);
}
.wf-invite-form > .wf-btn {
  justify-self: start;
}
.wf-admin-invites th[scope='row'] {
  min-width: 11em;
  overflow-wrap: anywhere;
}
.wf-admin-invites tr:has(+ .wf-invite-actions-row) > * {
  border-bottom: 0;
}
.wf-admin-invites .wf-invite-actions-row > td {
  padding-top: 0;
}
.wf-invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1) var(--wf-space-2);
}
.wf-admin-invites .wf-field-error {
  margin: var(--wf-space-1) 0 0;
}
@media (max-width: 600px) {
  .wf-admin-invites .wf-admin-col-wide {
    display: none;
  }
  .wf-admin-invites .wf-admin-row-narrow {
    display: block;
  }
}

/* -- 23c Focus-mode save state -------------------------------------------------
   The save state stays visible in focus mode (spec: editor requirement 10).
   It sits in the top end corner with no box and no shadow, in subtle text,
   so "Saved" is barely there. Offline and error states carry their own
   color and draw the eye only when something needs attention.
   -------------------------------------------------------------------------- */
.wf-focus-status {
  position: fixed;
  top: calc(var(--wf-space-4) + var(--wf-safe-top));
  inset-inline-end: var(--wf-space-5);
  z-index: var(--wf-z-sticky);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--wf-space-3);
  max-width: calc(100vw - 2 * var(--wf-space-5));
  padding: var(--wf-space-1) var(--wf-space-1) var(--wf-space-1) var(--wf-space-3);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-page);
}
/* The exit button keeps its size at the end of the row. A long save state
   shrinks first, so nothing covers the button. */
.wf-focus-status > .wf-btn {
  flex: none;
}
.wf-focus-status > .wf-saved {
  min-width: 0;
}

/* -- 23d Find bar ----------------------------------------------------------------
   Replaces the formatting tools in the top bar while it is open.
   Order: find field, match case, whole word, count, previous, next,
   [replace field, Replace, Replace all], show-replace or close.
   Two groups. When the top bar is too narrow for both (about 860-1180 px with
   the sidebar open), the replace group wraps to a second row.
   -------------------------------------------------------------------------- */
.wf-findbar {
  display: flex;
  /* Grow into the spare room, but ask for at least one full find row, so the
     top bar wraps the status and chapter tools before the find row breaks. */
  flex: 1 1 0;
  min-width: min(100%, 26em);
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
}
.wf-findbar-group {
  display: flex;
  flex: 1 1 22em;
  align-items: center;
  gap: var(--wf-space-1);
  min-width: 0;
}
.wf-findbar-group--replace {
  flex-basis: 20em;
}
.wf-findbar-field {
  flex: 1 1 auto;
  width: auto;
  min-width: var(--wf-find-field-min);
  min-height: var(--wf-tool-size);
  padding-block: 0;
  font-size: var(--wf-text-sm);
}
.wf-findbar-count {
  flex: none;
  min-width: 7ch;
  padding-inline: var(--wf-space-2);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.wf-findbar-count[data-empty='true'] {
  color: var(--wf-concern-text);
}

/* -- 23e Settings page ---------------------------------------------------------- */
.wf-settings {
  display: grid;
  gap: var(--wf-space-7);
  width: 100%;
  max-width: var(--wf-settings-w);
  margin-inline: auto;
  padding-block: var(--wf-space-7) var(--wf-space-9);
}
.wf-settings-section {
  display: grid;
  gap: var(--wf-space-4);
  padding-top: var(--wf-space-6);
  border-top: var(--wf-hairline);
}
/* Settings > Sign-in methods (docs/design-mock/pages/auth.html, section 4).
   .wf-methods        The list of methods.
   .wf-method         One method: the name, the account, a meta line and "Remove".
   .wf-method-links   "Link Google" and "Link Discord". */
.wf-settings .wf-stack > .wf-banner {
  margin: 0;
}
.wf-methods {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--wf-hairline);
}
.wf-method {
  display: flex;
  align-items: center;
  gap: var(--wf-space-4);
  padding-block: var(--wf-space-3);
  border-bottom: var(--wf-hairline);
}
.wf-method-main {
  display: grid;
  gap: var(--wf-space-1);
  flex: 1;
  min-width: 0;
}
.wf-method-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
  font-weight: var(--wf-weight-semibold);
}
.wf-method-name > svg {
  width: var(--wf-icon);
  height: var(--wf-icon);
  flex: none;
}
.wf-method-account {
  overflow-wrap: anywhere;
}
.wf-method-links {
  flex-wrap: wrap;
}

/* -- 23f History diff ----------------------------------------------------------
   Compares a snapshot with the chapter now. Words: <ins class="wf-diff-ins">
   is only in the chapter now, <del class="wf-diff-del"> is only in the old
   version. Each color pairs with a line style, so the diff reads without
   color. Blocks: .wf-diff-row[data-status] with a rule on the start edge.
     changed  ink rule        added, split   moss rule
     removed, merged  madder rule   moved   dashed subtle rule
   -------------------------------------------------------------------------- */
.wf-diff {
  display: grid;
  gap: var(--wf-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-diff-row {
  display: grid;
  gap: var(--wf-space-2);
  padding-inline-start: var(--wf-space-4);
  border-inline-start: var(--wf-rule-w) solid var(--wf-line-strong);
}
.wf-diff-row[data-status='changed'] {
  border-inline-start-color: var(--wf-accent);
}
.wf-diff-row[data-status='added'],
.wf-diff-row[data-status='split'] {
  border-inline-start-color: var(--wf-ok-text);
}
.wf-diff-row[data-status='removed'],
.wf-diff-row[data-status='merged'] {
  border-inline-start-color: var(--wf-concern);
}
.wf-diff-row[data-status='moved'] {
  border-inline-start-style: dashed;
  border-inline-start-color: var(--wf-text-subtle);
}
.wf-diff-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-diff-text {
  margin: 0;
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
  color: var(--wf-text-page);
  font-variant-numeric: var(--wf-ms-numerals);
}
.wf-diff-ins {
  background: var(--wf-ok-soft);
  color: var(--wf-ok-text);
  text-decoration: underline;
  text-decoration-thickness: var(--wf-border-w);
  text-underline-offset: 0.2em;
  border-radius: var(--wf-radius-xs);
}
.wf-diff-del {
  background: var(--wf-concern-soft);
  color: var(--wf-concern-text);
  text-decoration: line-through;
  text-decoration-thickness: var(--wf-border-w);
  border-radius: var(--wf-radius-xs);
}
.wf-diff-same {
  padding: var(--wf-space-1) var(--wf-space-4);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
/* Snapshot list in the history dialog */
.wf-versions {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-version {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3) 0;
  border-bottom: var(--wf-hairline);
}

/* -- 23g Import preview ------------------------------------------------------
   The writer's first hour: a Google Doc becomes a book. Calm and scannable.
   One row per section. A row that becomes a chapter is a raised card. A row
   that does not (note, merge, skip) recedes onto the chrome surface, so the
   chapters stand out when the writer scans down the list.
   -------------------------------------------------------------------------- */
.wf-import-tab {
  display: flex;
  align-items: baseline;
  gap: var(--wf-space-3);
  padding-bottom: var(--wf-space-2);
  border-bottom: var(--wf-hairline);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-muted);
}
.wf-import-row {
  container-type: inline-size;
  display: grid;
  gap: var(--wf-space-3);
  padding: var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-1);
}
.wf-import-row:not([data-action='chapter']) {
  background: var(--wf-bg-chrome);
  box-shadow: none;
}
.wf-import-row-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-3);
}
.wf-import-title {
  min-height: var(--wf-control-h-sm);
  padding-block: 0;
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-semibold);
}
/* A title that cannot change (merge, skip) reads as plain text, not a field. */
.wf-import-title:disabled {
  border-color: transparent;
  background: transparent;
  color: var(--wf-text-muted);
  padding-inline: 0;
}
.wf-import-words {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wf-import-row-body {
  display: grid;
  gap: var(--wf-space-3);
  /* Aligns with the title: the head's first column is a small icon button.
     The button is wider on a coarse pointer (section 25). */
  padding-inline-start: calc(var(--wf-import-menu-w, var(--wf-control-h-sm)) + var(--wf-space-3));
}
/* The first line in the writer's manuscript face: they recognize their own words. */
.wf-import-firstline {
  margin: 0;
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-normal);
  color: var(--wf-text-muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.wf-import-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
  font-size: var(--wf-text-sm);
}
.wf-import-action .wf-select,
.wf-import-subrow .wf-select {
  width: auto;
  min-height: var(--wf-control-h-sm);
  padding-block: 0;
  font-size: var(--wf-text-sm);
}
.wf-import-warnings {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
.wf-import-warnings li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-import-subrows {
  padding-inline-start: var(--wf-space-4);
  border-inline-start: var(--wf-hairline);
}
/* A deeper heading level: its list sits in the parent's list and indents again. */
.wf-import-subrows .wf-import-subrows {
  margin-top: var(--wf-space-1);
  padding-inline-start: var(--wf-space-3);
}
.wf-import-subrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--wf-space-3);
  font-size: var(--wf-text-sm);
}
.wf-import-subrow[data-action='skip'] > :first-child {
  color: var(--wf-text-subtle);
}
/* The four-option control needs room. When the row is narrow (always at the
   settings width, and on phones), the title and word count share one line and
   the control goes below. */
@container (max-width: 44em) {
  .wf-import-subrow {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: var(--wf-space-2);
  }
  .wf-import-subrow > .wf-segmented {
    grid-column: 1 / -1;
    justify-self: start;
  }
}
/* Phone width: no indent, and each segmented control fills the row with equal
   segments, so the four options wrap as a block instead of one ragged line. */
@container (max-width: 30em) {
  .wf-import-row-body {
    padding-inline-start: 0;
  }
  .wf-import-row .wf-segmented {
    display: flex;
    width: 100%;
  }
  .wf-import-row .wf-segment {
    flex: 1 1 auto;
  }
  .wf-import-row .wf-segment span {
    justify-content: center;
    width: 100%;
  }
  .wf-import-subrow > .wf-segmented {
    justify-self: stretch;
  }
}
.wf-import-row-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-2) var(--wf-space-4);
}
/* The text check: the imported text matches the Google Doc, or it does not. */
.wf-fidelity {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  font-size: var(--wf-text-xs);
  color: var(--wf-ok-text);
}
.wf-fidelity::before {
  content: '';
  width: var(--wf-space-3);
  height: var(--wf-space-3);
  flex: none;
  border-radius: var(--wf-radius-full);
  background: var(--wf-ok-text);
}
.wf-fidelity[data-pass='false'] {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-fidelity[data-pass='false']::before {
  background: var(--wf-concern);
}
/* Totals and the Import button stay in view at the bottom while the writer scrolls. */
.wf-import-footer {
  position: sticky;
  bottom: 0;
  z-index: var(--wf-z-sticky);
  display: grid;
  gap: var(--wf-space-3);
  padding: var(--wf-space-4) 0 calc(var(--wf-space-4) + var(--wf-safe-bottom));
  border-top: var(--wf-hairline);
  background: var(--wf-bg-page);
}
.wf-import-totals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1) var(--wf-space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--wf-text-sm);
  font-variant-numeric: tabular-nums;
}
.wf-import-totals b {
  font-weight: var(--wf-weight-semibold);
}

/* -- 23h Read-only document ----------------------------------------------------
   Manuscript text shown for reading only: an expanded import section, a note.
   It keeps the manuscript face and conventions at a smaller size, on the page
   surface, inside a hairline box so it never looks like the live editor.
   --scroll caps the height for previews inside a list.
   -------------------------------------------------------------------------- */
.wf-doc-preview {
  --wf-ms-size: var(--wf-text-md);
  padding: var(--wf-space-5) var(--wf-space-6);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-page);
}
.wf-doc-preview .wf-ms {
  max-width: none;
  caret-color: transparent;
}
.wf-doc-preview--scroll {
  max-height: var(--wf-doc-preview-max-h);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* -- 23i Comments --------------------------------------------------------------
   Comments from people (imported from Google Docs, later from beta readers).
   They must never look like Saga. Saga's words carry the familiar rule and
   color. A person's comment has no rule and no familiar color: it has an
   initial avatar and a name, like a note left in the margin by a colleague.
   States: data-state="resolved" recedes; "orphaned" has lost its text.
   The read-only note list and the mock still style "ambiguous" and
   "unanchored". The Comments tab does not use them (owner decision 2026-09-30).
   -------------------------------------------------------------------------- */
.wf-comment {
  display: grid;
  /* One track that may shrink: a long citation chip (nowrap) cuts with an ellipsis, not past the card. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--wf-space-3);
  padding: var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-comment[data-state='resolved'] {
  background: var(--wf-bg-chrome);
}
.wf-comment[data-state='resolved'] .wf-comment-body {
  color: var(--wf-text-muted);
}
.wf-comment-head {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-width: 0;
}
.wf-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--wf-avatar-size);
  height: var(--wf-avatar-size);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-hover);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-2xs);
  font-weight: var(--wf-weight-bold);
  line-height: 1;
  text-transform: uppercase;
}
.wf-avatar--sm {
  width: var(--wf-avatar-size-sm);
  height: var(--wf-avatar-size-sm);
}
.wf-comment-author {
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  min-width: 0;
  overflow-wrap: anywhere;
}
.wf-comment-date {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  white-space: nowrap;
}
.wf-comment-head .wf-badge {
  margin-inline-start: auto;
}
.wf-comment .wf-quote {
  margin: 0;
}
/* The passage above a thread's first comment: one line, cut to about 8 words by the
   card, and by an ellipsis if it is still too wide. The hover title has all of it. */
.wf-comment .wf-comment-quote {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wf-comment-body {
  margin: 0;
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
}
/* Where the quote landed, when it did not land on one place */
.wf-comment-place {
  margin: 0;
  padding-top: var(--wf-space-2);
  border-top: var(--wf-hairline);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
.wf-comment[aria-current='true'] {
  border-color: var(--wf-accent);
  box-shadow:
    0 0 0 var(--wf-border-w) var(--wf-accent),
    var(--wf-shadow-2);
}
/* The anchor text is gone: the card keeps its words but loses its place. */
.wf-comment[data-state='orphaned'] {
  border-style: dashed;
  border-color: var(--wf-line-control);
  background: var(--wf-bg-chrome);
}
.wf-comment-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1);
}
/* A row of quiet buttons lines its first label up with the text above. */
.wf-comment-actions:has(> .wf-btn--quiet:first-child) {
  margin-inline-start: calc(-1 * var(--wf-space-3));
}
.wf-comment-replies {
  display: grid;
  gap: var(--wf-space-3);
  margin: 0;
  padding: 0 0 0 var(--wf-space-4);
  border-inline-start: var(--wf-hairline);
  list-style: none;
}
.wf-reply {
  display: grid;
  gap: var(--wf-space-1);
}
.wf-reply .wf-comment-body {
  font-size: var(--wf-text-sm);
}

/* -- 23j Comments tab ----------------------------------------------------------
   Comments live in the side panel, in the Comments tab (milestone 2.5, addendum A).
   The panel (.wf-ai) is: the perch, the tab strip (.wf-panel-tabs) and the body.
   The body is the tab's own scroll. The cards list in document order; nothing
   aligns them with their text.
   .wf-comments          the tab content: tools, list, groups
   .wf-comments-tools    "Add comment", author filter, count and resolved toggle. It sticks to
                         the top of the panel body while the list scrolls.
   .wf-comment--familiar Saga's comment: the same card with the familiar rule.
   Highlights use the writer's ink, never Saga's violet.
   -------------------------------------------------------------------------- */
.wf-panel-tabs {
  padding: var(--wf-space-3) var(--wf-space-5) 0;
}
.wf-comments {
  display: grid;
  align-content: start;
  gap: var(--wf-space-5);
  min-width: 0;
}
.wf-comments-tools {
  position: sticky;
  top: calc(-1 * var(--wf-space-5));
  z-index: var(--wf-z-sticky);
  display: grid;
  gap: var(--wf-space-3);
  margin: calc(-1 * var(--wf-space-5)) calc(-1 * var(--wf-space-5)) 0;
  padding: var(--wf-space-5) var(--wf-space-5) var(--wf-space-3);
  border-bottom: var(--wf-hairline);
  background: var(--wf-bg-chrome);
}
.wf-comments-tools .wf-segmented {
  width: 100%;
}
.wf-comments-tools .wf-segment {
  flex: 1;
}
.wf-comments-list {
  display: grid;
  gap: var(--wf-space-3);
}
.wf-comments-empty {
  margin: 0;
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
}

/* Saga's comment: the one comment card, with the familiar's signature. The rule
   sits on the start edge, as on every word of the familiar. The sprite takes the
   avatar's place. The name uses the familiar text color. */
.wf-comment--familiar {
  border-inline-start: var(--wf-rule-w) solid var(--wf-familiar);
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}
.wf-comment--familiar[aria-current='true'] {
  border-inline-start-color: var(--wf-familiar);
}
.wf-comment--familiar > .wf-comment-head .wf-comment-author,
.wf-reply[data-author-kind='saga'] .wf-comment-author {
  color: var(--wf-familiar-text);
}

/* Groups: "Chapter" at the top of the list (comments with no passage), and
   "No longer in the text" at the end. */
.wf-comment-group {
  display: grid;
  gap: var(--wf-space-3);
  padding-top: var(--wf-space-4);
  border-top: var(--wf-hairline);
}
.wf-comment-group--chapter {
  padding-top: 0;
  padding-bottom: var(--wf-space-4);
  border-top: 0;
  border-bottom: var(--wf-hairline);
}
.wf-comment-group-title {
  margin: 0;
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-muted);
}

/* Highlights in the text. Rest: a tint and a thin underline. Focused: a stronger
   tint and a thick underline, so it differs by more than color. Draft: dashed.
   Resolved (shown only when the writer asks): no tint, a dotted line. */
.wf-comment-hl {
  background: var(--wf-comment-hl);
  text-decoration: underline solid var(--wf-accent);
  text-decoration-thickness: var(--wf-border-w);
  text-underline-offset: 0.2em;
  text-decoration-skip-ink: none;
  border-radius: var(--wf-radius-xs);
  cursor: pointer;
}
.wf-comment-hl .wf-comment-hl {
  background: var(--wf-comment-hl-strong);
}
.wf-comment-hl[data-focused='true'] {
  background: var(--wf-comment-hl-strong);
  text-decoration-thickness: var(--wf-rule-w);
}
.wf-comment-hl[data-draft='true'] {
  text-decoration-style: dashed;
}
.wf-comment-hl[data-resolved='true'] {
  background: transparent;
  text-decoration-style: dotted;
  text-decoration-color: var(--wf-line-control);
}
/* Focus mode: no panel, no highlights. The text reads as plain text. */
.wf-app.is-focus .wf-comment-hl {
  background: transparent;
  text-decoration: none;
  cursor: auto;
}

/* The "Comment" button beside a selection. The code sets top and left. */
.wf-comment-add {
  position: fixed;
  z-index: var(--wf-z-popover);
  transform: translate(var(--wf-space-3), calc(-1 * var(--wf-space-1)));
  box-shadow: var(--wf-shadow-3);
  background: var(--wf-bg-raised);
}
/* "Comment" and "Ask Saga" in one floating control beside a selection (chat stage 4). */
.wf-selection-actions {
  display: flex;
  gap: var(--wf-space-1);
  padding: var(--wf-space-1);
  border: var(--wf-hairline-strong);
  border-radius: var(--wf-radius-md);
}

/* -- 23k Home and stories ------------------------------------------------------
   The home screen lists the writer's stories. It is a standalone page, not
   the editor shell: a bar with the brand, then one centered column.
   .wf-home           The page. It is a size container, so the layout follows
                      the width of the page, not the window.
   .wf-home-bar       The bar: the brand at the start, the account menu at
                      the end. The brand here is louder than in the sidebar.
   .wf-home-main      The column, --wf-home-w wide.
   .wf-home-head      The screen title, the "Trash" link and the actions
                      "New story" and "Import".
   .wf-home-empty     The empty state: Saga, a title, one line, two actions.
   .wf-home-page      The column of Settings and of the import pages.
   .wf-home-back      The "Back" link above the title of such a page.
   .wf-story          One story: title, counts, last edit, story menu. The
                      list is a .wf-list.
     --current        The story the writer edited last: the large card.
     --trash          A story in the trash. It has no link.
     --loading        A placeholder while the list loads. Quiet bars, no shimmer.
   .wf-story-link     The title link. The whole card or row is its target.
                      The story menu and "Add story details" stay above it.
   The story title uses the manuscript face: it is the writer's own words.
   -------------------------------------------------------------------------- */
.wf-home {
  container: wf-home / inline-size;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--wf-bg-app);
  color: var(--wf-text);
}
.wf-home-bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: calc(var(--wf-topbar-h) + var(--wf-safe-top));
  padding: var(--wf-safe-top) var(--wf-space-6) 0;
  border-bottom: var(--wf-hairline);
  background: var(--wf-bg-chrome);
}
.wf-home-bar > .wf-brand {
  margin-inline-end: auto;
  color: var(--wf-text);
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-bold);
  letter-spacing: var(--wf-track-tight);
}
.wf-home-main {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: var(--wf-space-7);
  width: 100%;
  max-width: calc(var(--wf-home-w) + 2 * var(--wf-space-6));
  margin-inline: auto;
  padding: var(--wf-space-8) var(--wf-space-6) calc(var(--wf-space-9) + var(--wf-safe-bottom));
}
/* While a toast shows, the last control of the page stays clear of it. */
.wf-home:has(+ .wf-toast-region > .wf-toast) .wf-home-main {
  padding-bottom: max(calc(var(--wf-space-9) + var(--wf-safe-bottom)), var(--wf-toast-clear));
}
.wf-home-main > .wf-banner {
  margin-bottom: 0;
}
.wf-home-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-3);
}
.wf-home-head > .wf-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.wf-home-empty {
  display: grid;
  justify-items: center;
  align-self: center;
  gap: var(--wf-space-5);
  max-width: var(--wf-form-w);
  margin-inline: auto;
  padding-block: var(--wf-space-7);
  text-align: center;
}
.wf-home-empty > .wf-btn-row {
  justify-content: center;
  gap: var(--wf-space-3);
}

.wf-story {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'title menu'
    'meta menu';
  align-items: center;
  gap: var(--wf-space-1) var(--wf-space-4);
  padding: var(--wf-space-4) var(--wf-space-4) var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  transition: background-color var(--wf-dur-instant) var(--wf-ease-standard);
}
.wf-story:has(.wf-story-link:hover) {
  background: var(--wf-bg-hover);
}
/* A card or a row shows the focus ring of its title link. */
.wf-story:has(.wf-story-link:focus-visible) {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
/* The menu button keeps a visible hover on a row that has the hover surface. A dialog of the row keeps its own hover. */
.wf-story .wf-btn--quiet:hover:not(:disabled):not(.wf-dialog *) {
  background: var(--wf-bg-selected);
}
.wf-story-title {
  grid-area: title;
  min-width: 0;
  margin: 0;
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-lg);
  font-weight: var(--wf-ms-title-weight);
  line-height: var(--wf-leading-snug);
  letter-spacing: var(--wf-track-normal);
  overflow-wrap: anywhere;
}
.wf-story-link {
  border-radius: var(--wf-radius-xs);
  color: inherit;
  text-decoration: none;
}
.wf-story .wf-story-link:focus-visible {
  outline: none;
}
.wf-story .wf-story-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
/* aria-disabled (the offline state): the title stays readable, in the muted color of
   a title that is not a link (a story in the trash). No hover surface. */
.wf-story-link[aria-disabled='true'] {
  color: var(--wf-text-muted);
  cursor: not-allowed;
}
.wf-story:has(.wf-story-link[aria-disabled='true']:hover) {
  background: var(--wf-bg-raised);
}
.wf-story-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--wf-space-3);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
}
/* The dot comes after an item, so a line that wraps never starts with a dot. */
.wf-story-meta > span:not(.wf-badge):not(:last-child)::after {
  content: '\00b7';
  margin-inline-start: var(--wf-space-3);
}
/* The dates of a story in the trash: a second meta line. */
.wf-story-dates {
  grid-area: dates;
}
.wf-story-menu {
  grid-area: menu;
  align-self: start;
}
.wf-story-last {
  grid-area: last;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
}
/* Add .wf-btn-row in the markup. */
.wf-story-actions {
  grid-area: actions;
}
/* At a large text size a label wraps. It does not leave the screen. */
.wf-home .wf-btn:not(.wf-dialog *) {
  padding-block: var(--wf-space-1);
  white-space: normal;
  text-align: center;
}

.wf-story--current {
  grid-template-areas:
    'title menu'
    'meta menu'
    'last last';
  padding: var(--wf-space-6) var(--wf-space-5) var(--wf-space-6) var(--wf-space-6);
  box-shadow: var(--wf-shadow-1);
}
.wf-story--current > .wf-story-title {
  font-size: var(--wf-text-2xl);
  line-height: var(--wf-leading-tight);
  letter-spacing: var(--wf-track-tight);
}
.wf-story--current > .wf-story-last {
  margin-top: var(--wf-space-3);
}
.wf-story--trash {
  grid-template-areas:
    'title actions'
    'meta actions'
    'dates actions';
  padding-inline-end: var(--wf-space-5);
  background: var(--wf-bg-chrome);
}
.wf-story--trash > .wf-story-title {
  color: var(--wf-text-muted);
}
.wf-story--trash > .wf-story-actions {
  align-self: center;
  align-items: center;
  /* If the row wraps, "Delete forever" also keeps its distance from "Restore". */
  row-gap: var(--wf-space-5);
}

/* Placeholder rows while the list loads. The bars stand for the title and the
   meta line. They do not move. */
.wf-story--loading {
  grid-template-areas:
    'title'
    'meta';
  grid-template-columns: minmax(0, 1fr);
  gap: var(--wf-space-3);
}
.wf-story--loading::before,
.wf-story--loading::after {
  content: '';
  height: var(--wf-space-4);
  border-radius: var(--wf-radius-xs);
  background: var(--wf-bg-hover);
}
.wf-story--loading::before {
  width: min(100%, 16em);
  height: var(--wf-space-5);
}
.wf-story--loading::after {
  width: min(100%, 24em);
}
.wf-story--loading.wf-story--current {
  min-height: calc(var(--wf-space-10) + var(--wf-space-9));
  align-content: start;
}

/* Narrow page (a phone): the actions take a full row and grow to touch size. */
@container wf-home (max-width: 37.5em) {
  .wf-home-bar {
    padding-inline: var(--wf-space-5);
  }
  .wf-home-main {
    gap: var(--wf-space-6);
    padding: var(--wf-space-6) var(--wf-space-5) calc(var(--wf-space-8) + var(--wf-safe-bottom));
  }
  /* The title and the "Trash" link share the first row. The two actions
     share the second row in equal parts. */
  .wf-home-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .wf-home-head > .wf-title:last-child,
  .wf-home-head > .wf-title:has(+ .wf-btn--secondary) {
    grid-column: 1 / -1;
  }
  .wf-home-head > .wf-btn--quiet {
    justify-self: end;
  }
  .wf-home-empty > .wf-btn-row {
    flex-direction: column;
    align-self: stretch;
    width: 100%;
  }
  .wf-home .wf-btn:not(.wf-dialog *),
  .wf-home .wf-brand,
  .wf-home .wf-menu-item:not(.wf-dialog *) {
    min-height: var(--wf-touch-target);
  }
  .wf-home .wf-btn--icon:not(.wf-dialog *) {
    min-width: var(--wf-touch-target);
  }
  .wf-story {
    padding: var(--wf-space-4) var(--wf-space-3) var(--wf-space-4) var(--wf-space-5);
  }
  .wf-story--current {
    padding: var(--wf-space-5) var(--wf-space-3) var(--wf-space-5) var(--wf-space-5);
  }
  .wf-story--trash {
    grid-template-areas:
      'title title'
      'meta meta'
      'dates dates'
      'actions actions';
    padding-inline-end: var(--wf-space-5);
  }
  .wf-story--trash > .wf-story-actions {
    margin-top: var(--wf-space-3);
  }
  /* "Delete forever" goes to the end edge, far from "Restore". */
  .wf-story--trash > .wf-story-actions > .wf-btn--danger-quiet {
    margin-inline-start: auto;
  }
  /* The row menu of the trash sits near the start edge. It opens to the end. */
  .wf-story--trash .wf-menu--end {
    inset-inline: 0 auto;
  }
  /* Each date takes its own line, without a separator dot. */
  .wf-story-meta > .wf-story-when {
    flex-basis: 100%;
  }
  .wf-story-meta > span.wf-story-when:not(.wf-badge)::after,
  .wf-story-meta > span:not(.wf-badge):has(+ .wf-story-when)::after {
    content: none;
  }
}

/* A page in the home frame that is not the home screen: Settings and the two
   import pages.
   .wf-home-page   The column of the page, --wf-settings-w wide. It holds the
                   "Back" link and the page (.wf-settings). .wf-home-main has
                   the padding, so the page adds none. It is a size container
                   named wf-page: the goal page follows the column width.
   .wf-home-back   The "Back" link, a quiet button. Its icon starts at the
                   start edge of the page title. */
.wf-home-page {
  container: wf-page / inline-size;
  display: grid;
  gap: var(--wf-space-4);
  width: 100%;
  max-width: var(--wf-settings-w);
  margin-inline: auto;
}
.wf-home-page > .wf-settings {
  padding-block: 0;
}
.wf-home-back {
  justify-self: start;
  margin-inline-start: calc(-1 * var(--wf-space-4));
}

/* The story details on a story (docs/design-mock/pages/home.html, "Story details").
   .wf-story-about    The description and the tags, under the meta line. The
                      description is the writer's text: the manuscript face, clamped
                      to three lines on the card and two lines in a row.
   .wf-story-desc     The description.
   .wf-story-add      "Add story details" on the current card with no details.
   .wf-sidebar-story-line  The quiet line under the title in the editor sidebar: the stage and the tags. */
.wf-story-about {
  grid-area: about;
  display: grid;
  gap: var(--wf-space-2);
  min-width: 0;
}
.wf-story-desc {
  margin: 0;
  font-family: var(--wf-ms-font);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-normal);
  color: var(--wf-text-muted);
  white-space: pre-line;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.wf-story--current .wf-story-desc {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}
.wf-story-add {
  /* Above the target of the title link. */
  position: relative;
  justify-self: start;
}
.wf-story:has(> .wf-story-about) {
  grid-template-areas:
    'title menu'
    'meta menu'
    'about about';
}
.wf-story--current:has(> .wf-story-about) {
  grid-template-areas:
    'title menu'
    'meta menu'
    'about about'
    'last last';
}
.wf-story--current > .wf-story-about {
  margin-top: var(--wf-space-2);
}
.wf-sidebar-story-line {
  margin: 0;
}

/* -- 23l Admin -------------------------------------------------------------------
   The admin page /admin. Only a user with the admin flag sees it. Desktop first.
   Below 860 px the side index becomes a row above the section.
   The shell (docs/design-mock/admin-notes.md), at the end of this section:
   .wf-admin-shell      The left nav (--wf-admin-nav-w) and the main column, under the home bar.
                        At 860 px and narrower (container wf-home), the nav is a strip.
   .wf-admin-nav        The nav: .wf-admin-nav-group, .wf-admin-nav-label, .wf-admin-nav-item.
                        .wf-admin-nav-item[aria-current] takes the ink. .wf-admin-nav-count.
   .wf-admin-main       The main column (--wf-admin-main-w).
   .wf-admin-page-head  The title, a count and the actions (.wf-admin-page-actions).
   .wf-admin-page-meta  The meta line under the title.
   .wf-admin-stats      The stat grid: four columns, two at 860 px, equal heights. Every stat
                        grid uses it. .wf-admin-stat is a card (StatCard, parts.tsx): a link
                        or a div. .wf-admin-tile-label and .wf-admin-tile-value are its text.
   .wf-admin-pass       A pass count ("60 of 64") with the pass bar, in a table cell.
   .wf-admin-source     A source reference of the model card. Hidden until "Show sources"
                        (.wf-admin-card[data-sources]).
   .wf-admin-invites-layout  The invite form and the invite list side by side.
   .wf-admin-list       A short list in a card. .wf-admin-list-link is a row link,
                        [data-done] a quiet row. .wf-admin-recent-link is a row of "Recent".
   .wf-admin-tag        A quiet badge with a divider line.
   .wf-admin-detail-head  The head of a detail page: title and badges, then the status.
   .wf-admin-raw        A disclosure (details) whose summary is a quiet link with a chevron.
   .wf-admin-card       The tab "Model card": the bar, the agent switcher, the layout.
   .wf-admin-card-bar   The story picker and the rendered time.
   .wf-admin-layout     The side index and the open section, side by side.
   .wf-admin-index      The side index. .wf-admin-index-item[aria-current] is open.
   .wf-admin-section    The open section.
   .wf-admin-groups     A grid of groups (.wf-admin-group), two columns when wide.
   .wf-admin-kv         Key and value rows. A code value is monospace (.wf-admin-value).
   .wf-admin-parts      The parts of a request, in order. .wf-admin-part is one part.
   .wf-admin-breakpoint A cache breakpoint between two parts.
   .wf-admin-code       A collapsible code block with a "Copy" button.
   .wf-admin-pre        Monospace text. Long lines wrap.
   .wf-admin-slot       A parameter slot in a template. It says its origin in words,
                        so the color is not the only signal.
   .wf-admin-table      A plain table. .wf-admin-table-wrap scrolls it on a phone.
                        .wf-admin-table-num aligns a number column to the end.
                        tr[data-flag] marks a row that needs the owner.
   Tab "Landing":
   .wf-admin-landing    The tab: the range bar, the tiles, the charts, the tables.
                        [data-stale] dims it while a new range loads.
   .wf-admin-chart-card A chart with its head (.wf-admin-chart-head) and legend.
   .wf-admin-chart      A daily column chart (DailyChart.tsx). Plain SVG, no library.
                        .wf-admin-chart-mark[data-series] takes the series color.
   .wf-admin-chart-tip  The tooltip of one day. Values lead, labels follow.
   .wf-admin-sources    The source tables in a grid.
   .wf-admin-kv-row[data-flag]  A key and value row that needs the owner.
   Tab "Evals":
   .wf-admin-table--rows  A table whose rows open a view. .wf-admin-row is a row and
                        .wf-admin-row-link, the link in its first cell, covers the row.
   .wf-admin-view-head  The heading of a view and a link at its end.
   .wf-admin-back       The visible "Back to ..." link of a detail view.
   Tab "Users":
   .wf-admin-users      The user list. .wf-admin-col-wide hides at 860 px and below,
                        .wf-admin-col-mid at 600 px and below. .wf-admin-row-narrow, a line
                        under the email, shows those values at 600 px and below.
   .wf-admin-badges     The "Admin" and "Suspended" badges of a user.
   .wf-admin-filter     The email filter field.
   .wf-admin-user-title The heading of the page of a user: the email and the badges.
   .wf-admin-case       One case: .wf-admin-case-head, .wf-admin-case-status.
   .wf-admin-checks     The checks of a run, the failed checks first (.wf-admin-check).
   .wf-admin-chat       The writer's message and Saga's answer (.wf-admin-msg), same weight.
   .wf-admin-code-body  The open body of a collapsible section that is not code.
   -------------------------------------------------------------------------- */
.wf-admin-card {
  display: grid;
  gap: var(--wf-space-5);
  min-width: 0;
}
.wf-admin-card:not([data-sources='true']) .wf-admin-source {
  display: none;
}
.wf-admin-card > .wf-segmented {
  justify-self: start;
}
.wf-admin-card-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--wf-space-3) var(--wf-space-6);
}
.wf-admin-card-bar > .wf-meta {
  margin: 0;
}
.wf-admin-story {
  flex: 0 1 var(--wf-admin-story-w);
  min-width: 0;
}
.wf-admin-layout {
  display: grid;
  grid-template-columns: var(--wf-admin-index-w) minmax(0, 1fr);
  align-items: start;
  gap: var(--wf-space-6);
}
.wf-admin-index {
  position: sticky;
  top: var(--wf-space-5);
  padding: var(--wf-space-2);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-chrome);
}
.wf-admin-index-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-3);
  width: 100%;
  min-height: var(--wf-control-h-sm);
  padding: 0 var(--wf-space-3);
  border: 0;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-medium);
  text-align: start;
  cursor: pointer;
}
.wf-admin-index-item:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
/* The open section: the selected surface and a start rule, not color alone. */
.wf-admin-index-item[aria-current='true'] {
  box-shadow: inset var(--wf-rule-w) 0 0 var(--wf-accent);
  background: var(--wf-bg-selected);
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-index-item:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-admin-section {
  display: grid;
  gap: var(--wf-space-5);
  min-width: 0;
}
.wf-admin-section > .wf-heading {
  margin: 0;
}
.wf-admin-prose {
  max-width: var(--wf-admin-measure);
  margin: 0;
  line-height: var(--wf-leading-normal);
}
.wf-admin-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--wf-admin-group-min)), 1fr));
  gap: var(--wf-space-5);
}
.wf-admin-group {
  display: grid;
  align-content: start;
  gap: var(--wf-space-3);
  min-width: 0;
}
.wf-admin-group > .wf-subheading {
  margin: 0;
}
.wf-admin-kv {
  display: grid;
  margin: 0;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-admin-kv-row {
  display: grid;
  grid-template-columns: minmax(0, var(--wf-admin-key-w)) minmax(0, 1fr);
  gap: var(--wf-space-1) var(--wf-space-4);
  padding: var(--wf-space-3) var(--wf-space-4);
}
.wf-admin-kv-row + .wf-admin-kv-row {
  border-top: var(--wf-hairline);
}
.wf-admin-kv-row > dt {
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}
.wf-admin-kv-row > dd {
  display: grid;
  gap: var(--wf-space-1);
  min-width: 0;
  margin: 0;
  font-size: var(--wf-text-sm);
}
.wf-admin-kv-note {
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
}
.wf-admin-value {
  font-family: var(--wf-font-mono);
  font-size: var(--wf-text-xs);
  overflow-wrap: anywhere;
}
.wf-admin-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-admin-parts,
.wf-admin-cards {
  display: grid;
  gap: var(--wf-space-4);
  margin: 0;
  padding: 0;
}
.wf-admin-part {
  display: grid;
  gap: var(--wf-space-3);
  padding: var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-admin-part-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
}
.wf-admin-part-title {
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-semibold);
  overflow-wrap: anywhere;
}
code.wf-admin-part-title {
  font-family: var(--wf-font-mono);
  font-size: var(--wf-text-sm);
}
.wf-admin-step {
  display: inline-grid;
  place-items: center;
  min-width: var(--wf-control-h-sm);
  min-height: var(--wf-control-h-sm);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-sunken);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-breakpoint {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-breakpoint::before,
.wf-admin-breakpoint::after {
  content: '';
  flex: 1;
  border-top: var(--wf-border-w-strong) dashed var(--wf-line-strong);
}
.wf-admin-tool {
  display: grid;
  gap: var(--wf-space-3);
  min-width: 0;
}
.wf-admin-code {
  min-width: 0;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
}
.wf-admin-code-head {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
  padding-inline-end: var(--wf-space-2);
}
.wf-admin-code-toggle {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-1) var(--wf-space-3);
  min-width: 0;
  min-height: var(--wf-control-h);
  padding: 0 var(--wf-space-3);
  border: 0;
  background: transparent;
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
  text-align: start;
  cursor: pointer;
}
.wf-admin-code-toggle:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: calc(-1 * var(--wf-focus-w));
}
.wf-admin-code-toggle svg {
  flex: none;
  width: var(--wf-text-md);
  height: var(--wf-text-md);
  transition: transform var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-admin-code[data-open='true'] > .wf-admin-code-head > .wf-admin-code-toggle svg {
  transform: rotate(90deg);
}
.wf-admin-code-title {
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-pre {
  max-height: var(--wf-admin-code-max-h);
  margin: 0;
  overflow: auto;
  padding: var(--wf-space-3) var(--wf-space-4);
  border-top: var(--wf-hairline);
  color: var(--wf-text);
  font-family: var(--wf-font-mono);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.wf-admin-tool > .wf-admin-pre {
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
}
.wf-admin-slot {
  padding: 0 var(--wf-space-1);
  border: var(--wf-border-w) dashed var(--wf-line-control);
  border-radius: var(--wf-radius-xs);
  background: var(--wf-bg-hover);
  color: var(--wf-text);
  font-family: var(--wf-font-mono);
  font-size: var(--wf-text-xs);
  font-style: italic;
}
.wf-admin-slot[data-origin='story'],
.wf-admin-slot[data-origin='writer'] {
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
}
.wf-admin-facts {
  display: grid;
  gap: var(--wf-space-3);
  max-width: var(--wf-admin-measure);
  line-height: var(--wf-leading-normal);
}
.wf-admin-result {
  display: grid;
  gap: var(--wf-space-1);
  padding-inline-start: var(--wf-space-4);
  border-inline-start: var(--wf-rule-w) solid var(--wf-line-strong);
  font-size: var(--wf-text-sm);
}
.wf-admin-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
.wf-admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--wf-text-sm);
}
.wf-admin-table th,
.wf-admin-table td {
  padding: var(--wf-space-2) var(--wf-space-3);
  border-bottom: var(--wf-hairline);
  text-align: start;
  vertical-align: top;
}
.wf-admin-table thead th {
  color: var(--wf-text-muted);
  font-weight: var(--wf-weight-semibold);
}
/* The tab "Landing" */
.wf-admin-landing {
  display: grid;
  gap: var(--wf-space-6);
  min-width: 0;
  transition: opacity var(--wf-dur-quick) var(--wf-ease-standard);
}
.wf-admin-landing[data-stale='true'] {
  opacity: var(--wf-admin-stale-opacity);
}
.wf-admin-landing > .wf-banner {
  margin: 0;
}
.wf-admin-problems {
  margin: 0;
  padding-inline-start: var(--wf-space-5);
}
.wf-admin-group-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
  margin: 0;
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-section > .wf-subheading,
.wf-admin-section > .wf-meta {
  margin: 0;
}
/* A long path in a meta line breaks, so it does not widen the page on a phone. */
.wf-admin-section > .wf-meta {
  overflow-wrap: anywhere;
}
.wf-admin-tile-label {
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}
/* A large standalone number: proportional figures (dataviz rule). */
.wf-admin-tile-value {
  color: var(--wf-text);
  font-size: var(--wf-text-2xl);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
}
.wf-admin-chart-card {
  display: grid;
  gap: var(--wf-space-3);
  min-width: 0;
  padding: var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-admin-chart-card > .wf-meta {
  margin: 0;
}
.wf-admin-chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--wf-space-2) var(--wf-space-5);
}
.wf-admin-chart-head > .wf-subheading {
  margin: 0;
}
.wf-admin-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2) var(--wf-space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
}
.wf-admin-chart-legend > li {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-admin-chart-swatch {
  width: var(--wf-space-3);
  height: var(--wf-space-3);
  border-radius: var(--wf-radius-xs);
  background: var(--wf-chart-views);
}
.wf-admin-chart {
  position: relative;
  height: var(--wf-admin-chart-h);
  min-width: 0;
  border-radius: var(--wf-radius-sm);
}
.wf-admin-chart:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-admin-chart-svg {
  display: block;
  overflow: visible;
}
.wf-admin-chart-grid,
.wf-admin-chart-base {
  stroke: var(--wf-line);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.wf-admin-chart-base {
  stroke: var(--wf-line-strong);
}
.wf-admin-chart-tick {
  fill: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  font-variant-numeric: tabular-nums;
}
.wf-admin-chart-hover {
  fill: var(--wf-bg-hover);
}
.wf-admin-chart-mark,
.wf-admin-chart-swatch[data-series='views'] {
  fill: var(--wf-chart-views);
  background: var(--wf-chart-views);
}
.wf-admin-chart-mark[data-series='uniques'],
.wf-admin-chart-swatch[data-series='uniques'] {
  fill: var(--wf-chart-uniques);
  background: var(--wf-chart-uniques);
}
.wf-admin-chart-mark[data-series='signups'] {
  fill: var(--wf-chart-signups);
}
/* The page of a user: one quiet series, or cache reads (base) and writes (top) stacked. */
.wf-admin-chart-swatch[data-series='cache-read'] {
  background: var(--wf-chart-views);
}
.wf-admin-chart-mark[data-series='cache-write'],
.wf-admin-chart-swatch[data-series='cache-write'] {
  fill: var(--wf-chart-uniques);
  background: var(--wf-chart-uniques);
}
.wf-admin-chart-tip {
  position: absolute;
  top: 0;
  z-index: var(--wf-z-tooltip);
  display: grid;
  gap: var(--wf-space-1);
  width: max-content;
  max-width: var(--wf-admin-tip-w);
  padding: var(--wf-space-2) var(--wf-space-3);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-2);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  line-height: var(--wf-leading-snug);
  pointer-events: none;
  transform: translateX(var(--wf-space-3));
}
.wf-admin-chart-tip[data-flip='true'] {
  transform: translateX(calc(-100% - var(--wf-space-3)));
}
.wf-admin-chart-tip-day {
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-chart-tip-row {
  display: grid;
  grid-template-columns: var(--wf-space-3) auto 1fr;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-admin-chart-tip-row > b {
  color: var(--wf-text);
  font-size: var(--wf-text-sm);
}
/* A line key, not a box. No series: an empty slot keeps the columns. */
.wf-admin-chart-key[data-series] {
  height: var(--wf-border-w-strong);
  border-radius: var(--wf-radius-full);
  background: var(--wf-chart-views);
}
.wf-admin-chart-key[data-series='uniques'] {
  background: var(--wf-chart-uniques);
}
.wf-admin-chart-key[data-series='signups'] {
  background: var(--wf-chart-signups);
}
.wf-admin-chart-key[data-series='cache-write'] {
  background: var(--wf-chart-uniques);
}
.wf-admin-daily-wrap {
  max-height: var(--wf-admin-code-max-h);
  overflow: auto;
  border-top: var(--wf-hairline);
}
.wf-admin-table-num {
  text-align: end;
}
.wf-admin-table th.wf-admin-table-num,
.wf-admin-table td.wf-admin-table-num {
  text-align: end;
}
.wf-admin-table th[scope='row'] {
  font-weight: var(--wf-weight-regular);
}
/* A table whose rows open a view. The link in the first cell covers the whole row. */
.wf-admin-table--rows .wf-admin-row {
  position: relative;
  cursor: pointer;
}
.wf-admin-table--rows .wf-admin-row:hover {
  background: var(--wf-bg-hover);
}
.wf-admin-table--rows .wf-admin-row:focus-within {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: calc(-1 * var(--wf-focus-w));
}
/* A date cell keeps one line on a wide screen. */
@media (min-width: 600px) {
  .wf-admin-table-date {
    white-space: nowrap;
  }
}
.wf-admin-row-link {
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.wf-admin-row-link::after {
  content: '';
  position: absolute;
  inset: 0;
}
.wf-admin-row-link:focus-visible {
  outline: none;
}
.wf-admin-row:hover .wf-admin-row-link {
  text-decoration: underline;
}
/* The tab "Users": the list collapses its columns, so it never scrolls sideways. */
.wf-admin-filter {
  max-width: var(--wf-form-w);
}
.wf-admin-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--wf-space-1);
  vertical-align: middle;
}
.wf-admin-row-narrow {
  display: none;
  margin: var(--wf-space-1) 0 0;
}
@media (max-width: 860px) {
  .wf-admin-users .wf-admin-col-wide {
    display: none;
  }
}
@media (max-width: 600px) {
  .wf-admin-users .wf-admin-col-mid {
    display: none;
  }
  .wf-admin-users .wf-admin-row-narrow {
    display: block;
  }
}
.wf-admin-user-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
  min-width: 0;
}
/* The tab "Evals": the head of a view, the back link, a case, its checks and its chat. */
.wf-admin-view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--wf-space-3);
}
.wf-admin-view-head > .wf-heading {
  margin: 0;
}
.wf-admin-back {
  justify-self: start;
  text-decoration: none;
}
.wf-admin-case-head {
  display: grid;
  gap: var(--wf-space-2);
}
.wf-admin-case-head > * {
  margin: 0;
}
.wf-admin-case-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2);
  margin: 0;
  font-size: var(--wf-text-sm);
}
.wf-admin-run {
  padding-top: var(--wf-space-4);
  border-top: var(--wf-hairline);
}
.wf-admin-checks {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: var(--wf-hairline);
  font-size: var(--wf-text-sm);
}
.wf-admin-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--wf-space-3);
  padding: var(--wf-space-2) 0;
  border-bottom: var(--wf-hairline);
}
.wf-admin-check-text {
  display: grid;
  gap: var(--wf-space-1);
  min-width: 0;
  overflow-wrap: anywhere;
}
.wf-admin-check-detail {
  margin: 0;
  color: var(--wf-text-muted);
  line-height: var(--wf-leading-normal);
  white-space: pre-wrap;
}
.wf-admin-code-body {
  display: grid;
  gap: var(--wf-space-3);
  min-width: 0;
  padding: var(--wf-space-3) var(--wf-space-4);
  border-top: var(--wf-hairline);
}
.wf-admin-code-body > .wf-meta {
  margin: 0;
}
.wf-admin-pre--flat {
  padding: 0;
  border-top: 0;
}
.wf-admin-chat {
  display: grid;
  gap: var(--wf-space-3);
  min-width: 0;
}
.wf-admin-chat > .wf-meta {
  margin: 0;
}
.wf-admin-msg {
  display: grid;
  gap: var(--wf-space-1);
  min-width: 0;
  padding: var(--wf-space-3) var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-admin-msg-text {
  margin: 0;
  max-width: var(--wf-admin-measure);
  font-size: var(--wf-text-sm);
  line-height: var(--wf-leading-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* A row that needs the owner: a madder start rule and the concern tint, plus a word. */
.wf-admin-table tr[data-flag='true'] > :first-child {
  box-shadow: inset var(--wf-rule-w) 0 0 var(--wf-concern);
}
.wf-admin-table tr[data-flag='true'] {
  background: var(--wf-concern-soft);
}
.wf-admin-kv-row[data-flag='true'] {
  box-shadow: inset var(--wf-rule-w) 0 0 var(--wf-concern);
  background: var(--wf-concern-soft);
}
.wf-admin-kv-row[data-flag='true'] > dd {
  color: var(--wf-concern-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-sources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--wf-admin-source-min)), 1fr));
  gap: var(--wf-space-5);
}
@media (max-width: 860px) {
  .wf-admin-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .wf-admin-index {
    position: static;
  }
  .wf-admin-index > .wf-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--wf-space-1);
  }
  .wf-admin-index-item {
    width: auto;
  }
}
@media (max-width: 600px) {
  .wf-admin-kv-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .wf-admin-index-item {
    min-height: var(--wf-touch-target);
  }
}

/* The admin shell (docs/design-mock/admin-notes.md). These classes moved here from mock.css.
   One shell for /admin: the home bar, a left nav with groups and one main column. The nav
   becomes a strip that scrolls sideways when the frame is 860 px or narrower. The query is on
   the .wf-home container, so the mock's phone frame and a phone window both get it. */
.wf-admin-shell {
  display: grid;
  grid-template-columns: var(--wf-admin-nav-w) minmax(0, 1fr);
  flex: 1 1 auto;
  min-width: 0;
}
.wf-admin-nav {
  display: grid;
  align-content: start;
  gap: var(--wf-space-5);
  padding: var(--wf-space-6) var(--wf-space-4);
  border-inline-end: var(--wf-hairline);
  background: var(--wf-bg-chrome);
}
.wf-admin-nav-group > ul {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-admin-nav-label {
  margin: 0 0 var(--wf-space-2);
  padding-inline: var(--wf-space-3);
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
}
/* The look of .wf-chapter. The current item takes the writer's ink, not the familiar color. */
.wf-admin-nav-item {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  min-height: var(--wf-control-h);
  padding: var(--wf-space-2) var(--wf-space-3);
  border-radius: var(--wf-radius-sm);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  text-decoration: none;
  white-space: nowrap;
}
.wf-admin-nav-item:hover {
  background: var(--wf-bg-hover);
  color: var(--wf-text);
}
.wf-admin-nav-item[aria-current='page'] {
  background: var(--wf-bg-selected);
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-admin-nav-item:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-admin-nav-count {
  margin-inline-start: auto;
}
.wf-admin-main {
  display: grid;
  align-content: start;
  gap: var(--wf-space-6);
  width: 100%;
  max-width: calc(var(--wf-admin-main-w) + 2 * var(--wf-space-7));
  min-width: 0;
  padding: var(--wf-space-7) var(--wf-space-7) var(--wf-space-9);
}
/* The page head: the title, a quiet count, and the actions at the end of the same row. */
.wf-admin-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-3);
}
.wf-admin-page-head > .wf-title {
  margin: 0;
}
.wf-admin-page-actions {
  margin-inline-start: auto;
}
/* The meta line sits under the title, so the gap above it is small. */
.wf-admin-main > .wf-admin-page-meta {
  margin: calc(var(--wf-space-4) - var(--wf-space-6)) 0 0;
  font-size: var(--wf-text-sm);
}
/* The stat grid: always four columns, equal height. Each card is a link. */
.wf-admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--wf-space-4);
}
.wf-admin-stat {
  display: flex;
  flex-direction: column;
  gap: var(--wf-space-2);
  padding: var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  color: var(--wf-text);
  text-decoration: none;
}
a.wf-admin-stat:hover {
  border-color: var(--wf-line-control);
}
.wf-admin-stat:focus-visible {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
.wf-admin-stat > .wf-meta {
  margin-top: auto;
}
.wf-admin-stat-unit {
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-regular);
}
.wf-admin-stat-bar {
  height: var(--wf-space-2);
}
/* A pass count in a table cell: the count, then the bar under it. */
.wf-admin-pass {
  display: grid;
  gap: var(--wf-space-1);
  max-width: var(--wf-admin-pass-w);
}
/* The invites: the form (one third) and the list side by side. They stack at 860 px. */
.wf-admin-invites-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  align-items: start;
  gap: var(--wf-space-7);
}
/* A short list in a card: one row per item, hairlines between rows. */
.wf-admin-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  font-size: var(--wf-text-sm);
}
.wf-admin-list > li {
  display: grid;
  gap: var(--wf-space-1);
  padding: var(--wf-space-3) var(--wf-space-4);
}
.wf-admin-list > li + li {
  border-top: var(--wf-hairline);
}
.wf-admin-list > li:has(> .wf-admin-list-link) {
  padding: 0;
}
.wf-admin-list-link {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-4);
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
  text-decoration: none;
}
.wf-admin-list-link:hover {
  background: var(--wf-bg-hover);
  text-decoration: underline;
}
.wf-admin-list-link[data-done='true'] {
  color: var(--wf-text-subtle);
  font-weight: var(--wf-weight-regular);
}
.wf-admin-list-link > svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
.wf-admin-list-go {
  margin-inline-start: auto;
  color: var(--wf-text-subtle);
}
.wf-admin-list-done {
  color: var(--wf-ok-text);
}
/* A row of the list "Recent": the text is a link that keeps the text color. */
.wf-admin-recent-link {
  color: var(--wf-text);
  text-decoration: none;
}
.wf-admin-recent-link:hover {
  color: var(--wf-accent-text);
  text-decoration: underline;
}
/* A quiet badge on the app background: a neutral badge with a divider line, so it shows in light themes too. */
.wf-admin-tag {
  box-shadow: inset 0 0 0 var(--wf-border-w) var(--wf-line);
}
/* A report row: the kind badge before the title. */
.wf-admin-report-title {
  display: flex;
  align-items: center;
  gap: var(--wf-space-2);
}
/* The detail head: the title and the meta on the left, the status or the actions on the right. */
.wf-admin-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--wf-space-4);
}
.wf-admin-detail-title {
  display: grid;
  gap: var(--wf-space-2);
  min-width: 0;
}
.wf-admin-detail-title > * {
  margin: 0;
}
.wf-admin-detail-title > .wf-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-3);
  overflow-wrap: anywhere;
}
.wf-admin-detail-title > .wf-meta {
  font-size: var(--wf-text-sm);
}
.wf-admin-main > .wf-report-text {
  margin: 0;
}
/* A disclosure is a link, not a box: the summary is quiet accent text with the chevron marker. */
.wf-admin-raw > summary {
  justify-self: start;
  width: fit-content;
  color: var(--wf-accent-text);
  font-size: var(--wf-text-sm);
  cursor: pointer;
}
.wf-admin-raw > summary:hover {
  text-decoration: underline;
}
.wf-admin-raw > .wf-admin-table-wrap {
  margin-top: var(--wf-space-2);
}
@container wf-home (max-width: 860px) {
  .wf-admin-shell {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }
  .wf-admin-nav {
    display: flex;
    gap: var(--wf-space-1);
    padding: var(--wf-space-2) var(--wf-space-4);
    overflow-x: auto;
    border-inline-end: 0;
    border-bottom: var(--wf-hairline);
  }
  .wf-admin-nav-group,
  .wf-admin-nav-group > ul {
    display: contents;
  }
  .wf-admin-nav-label {
    display: none;
  }
  .wf-admin-nav-count {
    margin-inline-start: 0;
  }
  .wf-admin-main {
    padding: var(--wf-space-6) var(--wf-space-5) var(--wf-space-9);
  }
  .wf-admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .wf-admin-invites-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -- 23m Structured critique --------------------------------------------------
   docs/specs/m11-critique.md, section 6. The approved mock is
   docs/design-mock/pages/critique.html. These classes moved here from mock.css.
   They use only semantic tokens.
   .wf-reader          The critique viewer: a bar, the page in one continuous scroll and
                       the comments panel. The reader and the writer use the same layout.
   .wf-reader-bar      The bar above the page and the panel.
   .wf-reader-title    The title block in the bar: a name and a meta line.
   .wf-reader-progress The reader's "Chapter 3 of 6" with the bar.
   .wf-reader-settings The reader's settings popover: a .wf-menu with form fields.
   .wf-page-column   The column of the brief and the summary: the width of the chapter text.
   .wf-brief         The writer's brief at the top of the page, above chapter 1.
                       It is not manuscript: the UI face on the chrome surface.
   .wf-crit-summary  The Saga summary on the page, under the brief.
   .wf-crit-pinned   The same summary, a disclosure above the comments of the panel.
   .wf-crit-pinned-title  The "Summary" toggle of the disclosure.
   .wf-critic          One critic in the request form and in the critiques list.
     --familiar        Saga: the familiar rule on the start edge.
   .wf-critic-line     The progress line or the state of one critic.
   .wf-crit-request    One request in the critiques list: a card with its critics.
   .wf-crit-toggles    The per-critique checks in the Comments tab.
   .wf-crit-dock       The phone: the bar at the end of the reader page. It replaces the
                       panel column, and [data-panel-open] shows the panel as a sheet.
   -------------------------------------------------------------------------- */
.wf-reader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--wf-panel-w);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    'bar bar'
    'page panel';
  height: 100dvh;
  background: var(--wf-bg-app);
}
.wf-reader > .wf-reader-bar {
  grid-area: bar;
}
.wf-reader > .wf-page-scroll {
  grid-area: page;
  position: relative;
  overflow-y: auto;
  background: var(--wf-bg-page);
}
.wf-reader > .wf-panel {
  grid-area: panel;
  border-inline-start: var(--wf-hairline);
}
.wf-reader > .wf-crit-dock {
  display: none;
}
/* The splitter of the comments panel (section 23). It is a grid item in the panel area, so
   it does not cover the bar. Its line lies on the start edge of the panel. The layout
   renders it only while the panel is a column. */
.wf-reader > .wf-splitter {
  display: block;
  position: relative;
  grid-area: panel;
  justify-self: start;
  inset: auto;
  margin-inline-start: calc(var(--wf-splitter-inset) - var(--wf-splitter-hit));
}
.wf-is-resizing .wf-reader > :not(.wf-splitter) {
  pointer-events: none;
}
.wf-reader-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-3) var(--wf-space-5);
  min-height: var(--wf-topbar-h);
  padding: var(--wf-space-3) var(--wf-space-5);
  border-bottom: var(--wf-hairline);
  background: var(--wf-bg-chrome);
}
.wf-reader-title {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
}
.wf-reader-title > b {
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-semibold);
  overflow-wrap: anywhere;
}
.wf-reader-title > span {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-reader-progress {
  display: grid;
  gap: var(--wf-space-1);
  width: calc(var(--wf-space-10) * 1.6);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
/* The reader's settings popover (ReaderSettings): the menu surface with form fields. */
.wf-reader-settings {
  gap: var(--wf-space-3);
  padding: var(--wf-space-3);
}
/* The brief and the summary above chapter 1 sit in the column of the chapter text. The
   measure is in em, so the column takes the font size of the manuscript, as
   .wf-page-chapter does. It follows the width setting of the writer or the reader. */
.wf-page-column {
  max-width: var(--wf-ms-measure);
  margin: 0 auto;
  font-size: var(--wf-ms-size);
}
.wf-page-column + .wf-page-chapter .wf-chapter-head {
  padding-top: 0;
  border-top: 0;
}
.wf-brief {
  display: grid;
  gap: var(--wf-space-2);
  margin: 0 0 var(--wf-space-8);
  padding: var(--wf-space-4) var(--wf-space-5);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-chrome);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
}
.wf-brief > summary {
  cursor: pointer;
}
.wf-brief-title {
  margin: 0;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}
.wf-brief p {
  margin: 0;
  white-space: pre-wrap;
}
.wf-critic {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
}
.wf-critic--familiar {
  border-inline-start: var(--wf-rule-w) solid var(--wf-familiar);
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}
/* A second row: the link, the critic instructions or the progress bar. It spans the row. */
.wf-critic > .wf-critic-more {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--wf-space-3);
  min-width: 0;
}
.wf-critic-name {
  display: grid;
  min-width: 0;
}
.wf-critic-name > b {
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}
.wf-critic--familiar .wf-critic-name > b {
  color: var(--wf-familiar-text);
}
.wf-critic-line {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
.wf-critic-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: end;
  gap: var(--wf-space-3);
}
.wf-critic[data-state='revoked'] {
  background: var(--wf-bg-chrome);
}
.wf-critic[data-state='revoked'] .wf-critic-name > b {
  color: var(--wf-text-muted);
  text-decoration: line-through;
  text-decoration-thickness: var(--wf-border-w);
}
.wf-crit-request {
  display: grid;
  gap: var(--wf-space-4);
}
.wf-crit-request-head {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: var(--wf-space-2) var(--wf-space-3);
}
.wf-crit-request-brief {
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--wf-text-muted);
  font-size: var(--wf-text-sm);
}
.wf-crit-toggles {
  display: grid;
  gap: var(--wf-space-1);
  margin: 0;
  padding: 0;
  border: 0;
}
.wf-crit-toggles > legend {
  margin-bottom: var(--wf-space-1);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-muted);
}
.wf-crit-toggles .wf-check {
  font-size: var(--wf-text-sm);
}
.wf-crit-toggles .wf-check small {
  color: var(--wf-text-subtle);
  font-size: var(--wf-text-xs);
}
/* The snapshot quote of an orphaned comment: the words as the critic read them. */
.wf-comment-snapshot {
  margin: 0;
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
}
/* A badge with an icon: "Sent to Hal". */
.wf-badge > svg {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
}
.wf-crit-dock {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-4);
  border-top: var(--wf-hairline);
  background: var(--wf-bg-chrome);
}

/* Feedback round 1: the chapter range and the template name.
   .wf-range-row     The one row of the form: "All chapters (1 to 8)" and "Change".
   .wf-range-inputs  The modal: "All", "From" and "To".
   .wf-range-grid    The modal: one cell per chapter number. It scrolls for a long book.
   .wf-range-cell    One chapter. [data-in-range] is in the range. [data-edge] is the
                     first or the last chapter. The edges differ by fill and weight.
   .wf-range-hover   The title of the chapter under the pointer or the focus.
   .wf-tpl-save      The inline name field of "Save as template". */
.wf-range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-3);
  padding: var(--wf-space-3) var(--wf-space-4);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  font-size: var(--wf-text-md);
}
.wf-range-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-3) var(--wf-space-5);
}
.wf-range-inputs .wf-input {
  width: calc(var(--wf-space-10) * 0.9);
}
.wf-range-grid {
  display: grid;
  /* Each cell is at least the touch target wide, so a phone keeps 44 px cells. */
  grid-template-columns: repeat(auto-fill, minmax(var(--wf-touch-target), 1fr));
  gap: var(--wf-space-1);
  max-height: calc(var(--wf-space-10) * 2.6);
  overflow-y: auto;
  padding: var(--wf-space-2);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-sunken);
}
.wf-range-cell {
  min-height: var(--wf-control-h-sm);
  padding: 0;
  border: var(--wf-border-w) solid transparent;
  border-radius: var(--wf-radius-sm);
  background: transparent;
  color: var(--wf-text);
  font: inherit;
  font-size: var(--wf-text-sm);
  cursor: pointer;
}
.wf-range-cell:hover {
  background: var(--wf-bg-hover);
}
.wf-range-cell[data-in-range] {
  background: var(--wf-accent-soft);
  color: var(--wf-accent-text);
}
.wf-range-cell[data-edge] {
  background: var(--wf-accent);
  color: var(--wf-on-accent);
  font-weight: var(--wf-weight-bold);
}
.wf-range-cell:focus-visible,
.wf-range-cell[data-focus] {
  outline: var(--wf-focus-w) solid var(--wf-focus);
  outline-offset: var(--wf-focus-offset);
}
@media (pointer: coarse) {
  .wf-range-cell {
    min-height: var(--wf-touch-target);
  }
}
.wf-range-hover {
  margin: 0;
  min-height: 1.5em;
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
}
.wf-tpl-save {
  display: grid;
  gap: var(--wf-space-2);
  padding: var(--wf-space-3);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-sm);
  background: var(--wf-bg-chrome);
}

/* The build: the frame of the critique pages and the lazy chapters.
   .wf-badge--familiar  A badge in the familiar color: Saga's tag chips and "Summary".
   .wf-crit-page        The column of the critiques list (the home width).
   .wf-crit-fieldset    A fieldset of the request form with no box.
   .wf-crit-form-foot   The end of the request form: the hint and the two buttons.
   .wf-crit-name-row    A field and its buttons in one row ("Template name").
   .wf-crit-sent        The "Sent" block of the reader panel.
   .wf-crit-placeholder A chapter that is not mounted yet. Its height follows its
                        text length (--wf-crit-lines), so the scroll stays close. */
.wf-badge--familiar {
  background: var(--wf-familiar-soft);
  color: var(--wf-familiar-text);
}
.wf-crit-page {
  max-width: var(--wf-home-w);
}
.wf-crit-fieldset {
  display: grid;
  gap: var(--wf-space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.wf-crit-fieldset > legend {
  margin-bottom: var(--wf-space-3);
  padding: 0;
}
.wf-crit-form-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
  padding-top: var(--wf-space-4);
  border-top: var(--wf-hairline);
}
.wf-crit-form-foot > .wf-field-hint {
  flex-basis: 100%;
}
.wf-crit-name-row > .wf-input {
  flex: 1;
  min-width: 0;
}
.wf-crit-name-row > .wf-btn {
  flex: none;
}
.wf-crit-sent {
  padding-block: var(--wf-space-5);
  border-bottom: var(--wf-hairline);
}
.wf-crit-sent > p {
  margin: 0;
}
/* The Saga summary of the critique view: wide on the page under the brief, and a disclosure
   above the comments of the panel. The disclosure scrolls with the comments. A rule and space
   separate it from the first chapter group. */
.wf-crit-summary {
  margin: 0 0 var(--wf-space-8);
  font-size: var(--wf-text-md);
}
.wf-crit-pinned {
  flex: none;
  display: grid;
  gap: var(--wf-space-3);
  padding-bottom: var(--wf-space-5);
  margin-bottom: var(--wf-space-2);
  border-bottom: var(--wf-hairline);
}
.wf-crit-pinned-title {
  cursor: pointer;
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}
.wf-crit-placeholder {
  min-height: calc(var(--wf-crit-lines, 20) * var(--wf-ms-size) * var(--wf-ms-leading));
}
/* Under 860 px the comments panel goes under the page, at most a sheet high. */
@media (max-width: 860px) {
  .wf-reader {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'bar'
      'page'
      'panel';
  }
  .wf-reader > .wf-panel {
    max-height: var(--wf-sheet-max-h);
    border-inline-start: 0;
    border-top: var(--wf-hairline);
  }
  .wf-reader > .wf-splitter {
    display: none;
  }
}
/* The phone, on a page with a dock: no panel row. "N comments" in the dock opens the
   panel as a sheet. */
@media (max-width: 600px) {
  .wf-reader:has(> .wf-crit-dock) {
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'bar'
      'page'
      'dock';
  }
  .wf-reader > .wf-crit-dock {
    display: flex;
    grid-area: dock;
  }
  .wf-reader:has(> .wf-crit-dock) > .wf-panel {
    display: none;
  }
  .wf-reader[data-panel-open]:has(> .wf-crit-dock) > .wf-panel {
    display: flex;
    position: fixed;
    inset: var(--wf-topbar-h) 0 0;
    z-index: var(--wf-z-sheet);
    max-height: none;
    box-shadow: var(--wf-shadow-3);
  }
  .wf-reader:has(> .wf-crit-dock) > .wf-reader-bar > .wf-brand,
  .wf-reader:has(> .wf-crit-dock) > .wf-reader-bar > .wf-btn {
    display: none;
  }
  .wf-reader-progress {
    width: 100%;
  }
}

/* -- 24  Motivation ------------------------------------------------------------
   A streak counts the goal periods that the writer met, in a row. It forgives:
   a period that the writer did not meet is "at risk" for a grace period, any
   writing in that time recovers it, and a pause connects the streak. The
   display is honest. Each kind of day and each kind of period has its own
   mark and its own word.
   Design note: docs/design-mock/motivation-notes.md.

   .wf-streak       The row in the sidebar footer: the count and one line of
                    state. It is a link to the goal page. It shares the footer
                    with the account button (section 21).
   .wf-goal         The head of the goal page: the count, the state line, the
                    best streak and the days written, the progress of the
                    period, one fact, Saga's note, and the goal line.
     --compact      The streak and goal card on the home screen: the count,
                    the progress of the period and one fact, in three lines.
   .wf-cal-table    The period calendar, in a .wf-settings-section. One row per
                    week, one mark per day, and the result of the period in
                    the last column.
   .wf-work-fact    One fact about the writer's work, in one line.
   .wf-sprint       The sprint timer in the top bar and in focus mode.
   The goal page is in .wf-home-page, a size container named wf-page
   (section 23k). The card and the calendar follow the width of that column.
   -------------------------------------------------------------------------- */
/* Motivation design, revision 2: start */

/* The sidebar footer row. The count is the strongest text. The state line says
   what the period needs, in plain words. At risk uses the writer's ink: the
   writer must act. It is not a warning color. The row takes the spare room of
   the footer and shortens each line with an ellipsis; its name keeps the full
   text. It has no Saga: the brand in the sidebar head is the one Saga there. */
.wf-streak {
  display: grid;
  flex: 1 1 auto;
  align-content: center;
  min-width: 0;
  min-height: var(--wf-control-h);
  padding: var(--wf-space-2) var(--wf-space-3);
  margin-block: calc(-1 * var(--wf-space-2));
  margin-inline-start: calc(-1 * var(--wf-space-3));
  border-radius: var(--wf-radius-sm);
  color: var(--wf-text);
  text-decoration: none;
}
a.wf-streak:hover {
  background: var(--wf-bg-hover);
}
.wf-streak-count,
.wf-streak-state {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: var(--wf-leading-snug);
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-streak-count {
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
}
.wf-streak-state {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-streak[data-state='risk'] .wf-streak-state {
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
}

/* The goal card. The count on the start side, the two numbers that never go
   down on the end side. Under them the progress of the current period, one
   fact, Saga's note and the goal line. data-state: normal | risk | paused |
   fresh | met | words. */
.wf-goal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'count stats'
    'state stats'
    'progress progress'
    'fact fact'
    'note note'
    'meta meta';
  gap: var(--wf-space-2) var(--wf-space-6);
  padding: var(--wf-space-6);
  border: var(--wf-hairline);
  border-radius: var(--wf-radius-md);
  background: var(--wf-bg-raised);
  box-shadow: var(--wf-shadow-1);
}
.wf-goal-count {
  grid-area: count;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--wf-space-1) var(--wf-space-3);
  margin: 0;
  font-size: var(--wf-text-3xl);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-tight);
  letter-spacing: var(--wf-track-tight);
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-goal-count > small {
  font-size: var(--wf-text-md);
  font-weight: var(--wf-weight-regular);
  letter-spacing: var(--wf-track-normal);
  color: var(--wf-text-muted);
}
.wf-goal-state {
  grid-area: state;
  margin: 0;
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-goal[data-state='risk'] .wf-goal-state {
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-goal-stats {
  grid-area: stats;
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-3) var(--wf-space-6);
  align-self: start;
  margin: 0;
}
.wf-goal-stats > div {
  display: grid;
  gap: var(--wf-space-1);
}
.wf-goal-stats dt {
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-goal-stats dd {
  margin: 0;
  font-size: var(--wf-text-lg);
  font-weight: var(--wf-weight-semibold);
  line-height: var(--wf-leading-snug);
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-goal-progress {
  grid-area: progress;
  display: grid;
  gap: var(--wf-space-2);
  margin-top: var(--wf-space-4);
}
.wf-goal-progress-text {
  display: flex;
  justify-content: space-between;
  gap: var(--wf-space-3);
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}
/* The number in a line of text is strong: the progress and the fact. */
.wf-goal-progress-text > b,
.wf-work-fact b {
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}
/* A met period: the bar takes the familiar color, because Saga celebrates it. */
.wf-goal[data-state='met'] .wf-progress {
  color: var(--wf-familiar);
}
.wf-goal[data-state='met'] .wf-progress::-webkit-progress-value {
  background: var(--wf-familiar);
}
.wf-goal[data-state='met'] .wf-progress::-moz-progress-bar {
  background: var(--wf-familiar);
}
.wf-goal > .wf-work-fact {
  grid-area: fact;
  margin-top: var(--wf-space-3);
}
/* Saga's note: the sprite at 40 px beside Saga's words. The words carry the
   familiar rule. One sentence, and its actions. */
.wf-goal-note {
  grid-area: note;
  display: flex;
  align-items: center;
  gap: var(--wf-space-4);
  margin-top: var(--wf-space-4);
}
.wf-goal-note > .wf-voice {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: var(--wf-space-3);
  font-size: var(--wf-text-md);
  line-height: var(--wf-leading-relaxed);
}
.wf-goal-note > .wf-voice > p {
  margin: 0;
}
.wf-goal-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wf-space-2) var(--wf-space-3);
  margin-top: var(--wf-space-4);
  padding-top: var(--wf-space-4);
  border-top: var(--wf-hairline);
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
}
.wf-goal-meta > span {
  flex: 1 1 auto;
  min-width: 0;
}

/* Motivation design, revision 4: start */
/* The compact card on the home screen. The streak and the goal belong to the
   writer, not to a story, so the card sits under the head of the home screen,
   above the story list. Three lines at most. The first line is the count and
   the link "Goal and streak" (.wf-goal-link). The lines under it take the full
   width, in source order: the progress of the period (.wf-goal-state) and one
   fact (.wf-work-fact), or a .wf-goal-meta. At risk, the .wf-goal-meta is the
   way out in ink and "Pause for 7 days". No stats, no Saga, no calendar. No
   shadow: the current story below holds the one primary action. */
.wf-goal--compact {
  grid-template-areas: none;
  align-items: center;
  gap: var(--wf-space-1) var(--wf-space-4);
  padding: var(--wf-space-4) var(--wf-space-5);
  box-shadow: none;
}
.wf-goal--compact > .wf-goal-count {
  grid-area: 1 / 1;
  font-size: var(--wf-text-xl);
}
.wf-goal--compact > .wf-goal-count > small {
  font-size: var(--wf-text-sm);
}
.wf-goal-link {
  grid-area: 1 / 2;
  justify-self: end;
  margin-inline-end: calc(-1 * var(--wf-space-3));
}
.wf-goal--compact > .wf-goal-state,
.wf-goal--compact > .wf-work-fact,
.wf-goal--compact > .wf-goal-meta {
  grid-area: auto / 1 / auto / -1;
  margin: 0;
  padding: 0;
  border: 0;
}
.wf-goal--compact > .wf-goal-state b {
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}
/* A met period: the number takes the familiar color, as the bar does on the
   goal page. The word "Met" says it too. */
.wf-goal--compact[data-state='met'] > .wf-goal-state b {
  color: var(--wf-familiar-text);
}
.wf-goal--compact[data-state='risk'] > .wf-goal-meta > span {
  color: var(--wf-accent-text);
  font-weight: var(--wf-weight-semibold);
}
/* Motivation design, revision 4: end */

/* The period calendar. A table keeps the semantics of rows and columns for a
   screen reader. The day number is text. The mark under it is the state of
   the day. The last column is the result of the period. A column head holds
   the short name (.wf-cal-dow), a one-letter name for a narrow page
   (.wf-cal-dow--short) and the full name as hidden text. The first day of a
   month adds the month (.wf-cal-month): "Oct 1".
   Day marks (.wf-cal-mark[data-state]):
     done       a filled familiar dot. A day with activity; for a daily goal,
                a met day. Saga celebrates it.
     wrote      a small familiar dot. A daily words goal only: writing under
                the target.
     recovered  a familiar ring, half filled. Activity in the grace period
                recovered the day.
     paused     a short bar. Time away that the writer set.
     risk       a dashed ink ring. A daily goal in its grace period only.
     missed     a hollow ring in the control-line color. A completed day with
                no writing.
     today      no mark: today has no activity yet.
     future     no mark.
   Period results (.wf-cal-week[data-period]): met, recovered, paused, risk,
   missed ("Not met"), open ("So far"). Each result is a word. Color is the
   second signal. */
.wf-cal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.wf-cal-table th {
  padding: 0 0 var(--wf-space-2);
  font-size: var(--wf-text-xs);
  font-weight: var(--wf-weight-regular);
  color: var(--wf-text-subtle);
  text-align: center;
}
.wf-cal-dow--short {
  display: none;
}
.wf-cal-table:has(.wf-cal-period) th:last-child,
.wf-cal-period {
  width: var(--wf-cal-period-w);
  padding-inline-start: var(--wf-space-3);
  text-align: start;
}
.wf-cal-day {
  padding: var(--wf-space-1) 0 var(--wf-space-2);
  text-align: center;
  vertical-align: top;
}
.wf-cal-num {
  display: inline-block;
  min-width: calc(var(--wf-text-xs) * 2);
  min-height: calc(var(--wf-text-xs) * 2);
  margin-bottom: var(--wf-space-1);
  padding-inline: var(--wf-space-1);
  line-height: calc(var(--wf-text-xs) * 2);
  text-align: center;
  white-space: nowrap;
  border-radius: var(--wf-radius-full);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-muted);
  font-variant-numeric: tabular-nums lining-nums;
}
/* Today: the selected surface, a control line around it (3:1; a divider line
   is under 3:1 here) and the semibold number. The
   legend sample uses data-today, because aria-current belongs to the day cell
   only. */
.wf-cal-day[aria-current='date'] .wf-cal-num,
.wf-cal-num[data-today] {
  background: var(--wf-bg-selected);
  box-shadow: inset 0 0 0 var(--wf-border-w) var(--wf-line-control);
  color: var(--wf-text);
  font-weight: var(--wf-weight-semibold);
}
.wf-cal-mark {
  display: block;
  width: var(--wf-dot-size);
  height: var(--wf-dot-size);
  margin: 0 auto;
  border: var(--wf-border-w) solid var(--wf-line-control);
  border-radius: var(--wf-radius-full);
}
.wf-cal-mark[data-state='done'] {
  background: var(--wf-familiar);
  border-color: var(--wf-familiar);
}
.wf-cal-mark[data-state='wrote'] {
  width: var(--wf-dot-size-sm);
  height: var(--wf-dot-size-sm);
  margin-block: calc((var(--wf-dot-size) - var(--wf-dot-size-sm)) / 2);
  background: var(--wf-familiar);
  border-color: var(--wf-familiar);
}
/* Half filled, so it differs from the hollow "no writing" ring by shape. */
.wf-cal-mark[data-state='recovered'] {
  border: var(--wf-border-w-strong) solid var(--wf-familiar);
  background: linear-gradient(90deg, var(--wf-familiar) 50%, transparent 0);
}
.wf-cal-mark[data-state='paused'] {
  height: var(--wf-border-w-strong);
  margin-block: calc((var(--wf-dot-size) - var(--wf-border-w-strong)) / 2);
  border: 0;
  border-radius: var(--wf-radius-full);
  background: var(--wf-text-subtle);
}
.wf-cal-mark[data-state='risk'] {
  border: var(--wf-border-w-strong) dashed var(--wf-accent);
}
.wf-cal-mark[data-state='today'],
.wf-cal-mark[data-state='future'] {
  visibility: hidden;
}
.wf-cal-period {
  padding-top: var(--wf-space-1);
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
  line-height: var(--wf-leading-snug);
  vertical-align: top;
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-cal-period > b {
  display: block;
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text-muted);
}
.wf-cal-week[data-period='met'] .wf-cal-period > b,
.wf-cal-week[data-period='recovered'] .wf-cal-period > b {
  color: var(--wf-familiar-text);
}
.wf-cal-week[data-period='risk'] .wf-cal-period > b {
  color: var(--wf-accent-text);
}
.wf-cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wf-space-2) var(--wf-space-5);
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-cal-legend > li {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
}
.wf-cal-legend .wf-cal-mark {
  flex: none;
  margin: 0;
}

/* One fact about the writer's work. Code picks it and fixed texts show it.
   The number is strong (see the rule for b above). It is not Saga's speech,
   so it has no familiar rule. */
.wf-work-fact {
  margin: 0;
  font-size: var(--wf-text-sm);
  color: var(--wf-text-muted);
  line-height: var(--wf-leading-normal);
  font-variant-numeric: tabular-nums lining-nums;
}

/* The sprint timer. A quiet pill in the top bar: a thin ring that fills, the
   time left, the words so far and a square "Stop" button. It never covers the
   text. In focus mode it loses its box and sits in the save-state pill
   (.wf-focus-status), as a sibling of .wf-saved, never a child: .wf-saved is a
   live region. --wf-sprint-done is the part of the sprint that has passed,
   0 to 100. The app sets it inline. data-state="break" shows the break
   timer. */
.wf-sprint {
  display: inline-flex;
  align-items: center;
  gap: var(--wf-space-2);
  min-height: var(--wf-tool-size);
  padding: 0 var(--wf-space-1) 0 var(--wf-space-3);
  border-radius: var(--wf-radius-full);
  background: var(--wf-bg-sunken);
  color: var(--wf-text-muted);
  font-size: var(--wf-text-xs);
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
}
.wf-sprint-ring {
  flex: none;
  width: var(--wf-icon-sm);
  height: var(--wf-icon-sm);
  border-radius: var(--wf-radius-full);
  background: conic-gradient(
    var(--wf-accent) calc(var(--wf-sprint-done, 0) * 1%),
    var(--wf-line-control) 0
  );
  -webkit-mask: radial-gradient(
    farthest-side,
    transparent calc(100% - var(--wf-border-w-strong)),
    currentColor 0
  );
  mask: radial-gradient(
    farthest-side,
    transparent calc(100% - var(--wf-border-w-strong)),
    currentColor 0
  );
}
.wf-sprint[data-state='break'] .wf-sprint-ring {
  background: conic-gradient(
    var(--wf-text-subtle) calc(var(--wf-sprint-done, 0) * 1%),
    var(--wf-line-control) 0
  );
}
.wf-sprint-time {
  font-size: var(--wf-text-sm);
  font-weight: var(--wf-weight-semibold);
  color: var(--wf-text);
}
.wf-sprint-words {
  color: var(--wf-text-subtle);
}
/* While a sprint runs, the pill carries the words. The session and chapter
   counts hide, so the top bar does not grow a second row. A break shows the
   counts again. */
.wf-topbar:has(.wf-sprint:not([data-state='break'])) .wf-wordcount {
  display: none;
}
/* The save state of the open chapter or note already says "Offline". The
   top bar hides the "Offline" pill of the sync state (m13). */
.wf-topbar:has(.wf-saved[data-state='offline']:not(.wf-sync-pill)) .wf-sync-pill[data-state='offline'] {
  display: none;
}
/* Focus mode: plain text in the pill, no box and no "Stop". Esc leaves focus
   mode; the sprint continues and "Stop" is back in the top bar. */
.wf-focus-status > .wf-sprint {
  min-height: 0;
  padding: 0;
  background: transparent;
}
.wf-focus-status > .wf-sprint > .wf-btn {
  display: none;
}
/* Under 1180 px the words hide; the name of the timer keeps them. */
@media (max-width: 1180px) {
  .wf-sprint-words {
    display: none;
  }
}
/* A narrow bar at a large text size: the ring hides too. The time and "Stop"
   stay. The query is in em, so it follows the text size of the browser. */
@media (max-width: 22.5em) {
  .wf-sprint-ring {
    display: none;
  }
}

/* A narrow page column (a phone, or a large text size): the goal card stacks,
   and the calendar uses one-letter column heads and no side padding. */
@container wf-page (max-width: 34em) {
  .wf-goal {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'count'
      'state'
      'stats'
      'progress'
      'fact'
      'note'
      'meta';
    padding: var(--wf-space-5);
  }
  .wf-goal-stats {
    margin-top: var(--wf-space-3);
  }
  .wf-goal-note {
    align-items: flex-start;
  }
  .wf-cal-dow {
    display: none;
  }
  .wf-cal-dow--short {
    display: inline;
  }
  .wf-cal-table th,
  .wf-cal-table td {
    padding-inline: 0;
    overflow-wrap: anywhere;
  }
  .wf-cal-num {
    min-width: 0;
  }
  .wf-cal-table:has(.wf-cal-period) th:last-child,
  .wf-cal-period {
    width: var(--wf-cal-period-w-narrow);
    padding-inline-start: var(--wf-space-2);
  }
}
/* A very narrow column (a phone at a large text size): the first day of a month
   shows its number only. The hidden text of the cell keeps the full date. */
@container wf-page (max-width: 20em) {
  .wf-cal-month {
    display: none;
  }
  /* The week column keeps its word ("Met", "Paused") and drops the line of
     days from view, so the day numbers keep their room. The marks show the
     days. */
  .wf-cal-table:has(.wf-cal-period) th:last-child,
  .wf-cal-period {
    width: var(--wf-cal-period-w-tight);
  }
  /* Hidden as .wf-sr-only is: a screen reader still reads the line. */
  .wf-cal-period > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
/* Motivation design, revision 2: end */

/* -- 25  Utilities, accessibility, reduced motion, forced colors ------------- */

/* Divider with an optional centered label, for example "or" between two
   sign-in methods. Without a label it is a plain hairline. */
.wf-divider {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
  margin: 0;
  font-size: var(--wf-text-xs);
  color: var(--wf-text-subtle);
}
.wf-divider::before,
.wf-divider::after {
  content: '';
  flex: 1;
  border-top: var(--wf-hairline);
}
.wf-divider:empty {
  gap: 0;
}

/* Lucide icons: the design-system stroke width */
.wf-icon {
  stroke-width: var(--wf-icon-stroke);
}

/* A plain list: no markers, no indent, even gaps. --flush has no gap. */
.wf-list {
  display: grid;
  gap: var(--wf-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-list--flush {
  gap: 0;
}

/* A flex child that takes the spare room and may shrink, and that breaks a
   long word (an email, a long title) instead of overflowing. */
.wf-grow {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.wf-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.wf-stack {
  display: grid;
  gap: var(--wf-space-4);
}
.wf-row {
  display: flex;
  align-items: center;
  gap: var(--wf-space-3);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--wf-line-strong) transparent;
}

@media (pointer: coarse) {
  .wf-btn,
  .wf-brand,
  .wf-chapter,
  .wf-tab {
    min-height: var(--wf-touch-target);
  }
  .wf-btn--icon,
  .wf-dialog-close {
    min-width: var(--wf-touch-target);
  }
  /* The import row body lines up with the title, after the wider menu button. */
  .wf-import-row {
    --wf-import-menu-w: var(--wf-touch-target);
  }
  .wf-chapter-grip {
    opacity: 1;
  }
  .wf-streak {
    min-height: var(--wf-touch-target);
  }
  /* A tool in the top bar, for example the sprint tool on a phone. */
  .wf-tool {
    width: var(--wf-touch-target);
    height: var(--wf-touch-target);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media (forced-colors: active) {
  .wf-voice,
  .wf-msg--familiar,
  .wf-comment--familiar {
    border-inline-start-color: Highlight;
  }
  .wf-ms p[data-mark]::before,
  .wf-cal-mark[data-state='done'],
  .wf-cal-mark[data-state='wrote'] {
    background: Highlight;
  }
  .wf-cal-mark[data-state='wrote'] {
    border-color: Highlight;
  }
  /* Forced colors remove a gradient. Keep the half fill in system colors. */
  .wf-cal-mark[data-state='recovered'] {
    forced-color-adjust: none;
    border-color: Highlight;
    background: linear-gradient(90deg, Highlight 50%, Canvas 0);
  }
  .wf-cal-mark[data-state='paused'] {
    background: CanvasText;
  }
  /* Forced colors remove the surface and the shadow of today. A border shows it. */
  .wf-cal-day[aria-current='date'] .wf-cal-num,
  .wf-cal-num[data-today] {
    border: var(--wf-border-w) solid CanvasText;
  }
  /* Forced colors paint the track, the bar and the value in Canvas. Keep them. */
  .wf-progress {
    forced-color-adjust: none;
    border: var(--wf-border-w) solid CanvasText;
    background: Canvas;
  }
  .wf-progress::-webkit-progress-bar {
    background: Canvas;
  }
  .wf-progress::-webkit-progress-value,
  .wf-goal[data-state='met'] .wf-progress::-webkit-progress-value {
    background: Highlight;
  }
  .wf-progress::-moz-progress-bar,
  .wf-goal[data-state='met'] .wf-progress::-moz-progress-bar {
    background: Highlight;
  }
  .wf-sprint-ring {
    forced-color-adjust: none;
    background: conic-gradient(Highlight calc(var(--wf-sprint-done, 0) * 1%), GrayText 0);
  }
  /* Forced colors replace a background color. Keep the mask and paint it as text. */
  .wf-ms hr::before,
  .wf-scene-icon {
    forced-color-adjust: none;
    background-color: CanvasText;
  }
  .wf-tool:disabled .wf-scene-icon {
    background-color: GrayText;
  }
  .wf-btn--primary,
  .wf-btn--danger {
    border-color: ButtonText;
  }
  .wf-splitter::before {
    border-inline-start-color: CanvasText;
  }
  .wf-splitter:hover::before,
  .wf-splitter:focus-visible::before,
  .wf-splitter[data-dragging]::before {
    border-inline-start-color: Highlight;
  }
}
