/* Load LAST, after every page-specific stylesheet. Presentation tokens do not recolour media.
   New shared chrome uses sf-*; retained interiors use paper/ink aliases below. */
/* LIGHT TOKENS */
:root, :root[data-theme="auto"], :root[data-theme="light"], :root[data-theme="dark"] {
  color-scheme: light;
  --theme-ground: #f4f7f8;
  --theme-surface: #ffffff;
  --theme-stage: #dce8ef;
  --theme-soft: #e7eef2;
  --theme-ink: #20272d;
  --theme-secondary: #343e47;
  --theme-muted: #59636d;
  --theme-rule: #bbc7cf;
  --theme-control: #6d7780;
  --theme-link: #852b40;
  --theme-accent: #852b40;
  --theme-focus: #852b40;
  --theme-notice: #edf0dc;
  --theme-notice-ink: #3e482c;
  --theme-error: #9f223d;
  --theme-error-soft: #fce8ed;
  --theme-success: #315f3b;
  --theme-success-soft: #eef3e5;
  --theme-action: #852b40;
  --theme-action-hover: #692033;
  --theme-on-action: #ffffff;
  --theme-lime: #dde56b;
  --theme-on-lime: #20272d;
  --theme-inverse: #20272d;
  --theme-on-inverse: #f4f7f8;
  --theme-inverse-muted: #c9d5de;
  --theme-inverse-link: #b9d3ff;
  --theme-inverse-rule: #91a3af;
  --sf-ground: var(--theme-ground); --sf-stage: var(--theme-stage);
  --sf-ink: var(--theme-ink); --sf-muted: var(--theme-muted);
  --sf-rule: var(--theme-rule); --sf-action: var(--theme-accent);
  --paper: var(--theme-ground); --paper-2: var(--theme-soft); --panel: var(--theme-surface);
  --ink: var(--theme-ink); --ink-2: var(--theme-secondary); --ink-3: var(--theme-muted);
  --line: var(--theme-rule); --line-2: var(--theme-control); --accent: var(--theme-link);
  --accent-soft: var(--theme-soft); --attention: var(--theme-error); --attention-soft: var(--theme-error-soft);
  --ok: var(--theme-success); --inverse: var(--theme-on-inverse);
  --inverse-muted: var(--theme-inverse-muted); --inverse-soft: var(--theme-inverse-muted);
  --inverse-line: var(--theme-inverse-rule); --deep-rule: var(--theme-rule);
}
/* EXPLICIT DARK TOKENS */
:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-ground: #151b21;
  --theme-surface: #202a33;
  --theme-stage: #263b49;
  --theme-soft: #1b2933;
  --theme-ink: #eef2f4;
  --theme-secondary: #d4dde4;
  --theme-muted: #b0bdc8;
  --theme-rule: #657784;
  --theme-control: #91a3af;
  --theme-link: #efb7c6;
  --theme-accent: #efb7c6;
  --theme-focus: #dde56b;
  --theme-notice: #303a25;
  --theme-notice-ink: #e5edc4;
  --theme-error: #ffc0cd;
  --theme-error-soft: #3d2330;
  --theme-success: #c4e0ac;
  --theme-success-soft: #263728;
}
/* SYSTEM DARK TOKENS: auto and a missing/invalid attribute need no JavaScript. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
  --theme-ground: #151b21;
  --theme-surface: #202a33;
  --theme-stage: #263b49;
  --theme-soft: #1b2933;
  --theme-ink: #eef2f4;
  --theme-secondary: #d4dde4;
  --theme-muted: #b0bdc8;
  --theme-rule: #657784;
  --theme-control: #91a3af;
  --theme-link: #efb7c6;
  --theme-accent: #efb7c6;
  --theme-focus: #dde56b;
  --theme-notice: #303a25;
  --theme-notice-ink: #e5edc4;
  --theme-error: #ffc0cd;
  --theme-error-soft: #3d2330;
  --theme-success: #c4e0ac;
  --theme-success-soft: #263728;
  }
}

/* Shared shell and homepage; retain Hanken/Newsreader, geometry and approved artwork. */
html, html body.sf-home, html body.af-page { background:var(--theme-ground); color:var(--theme-ink); }
html :is(.sf-preview,.sf-scene figcaption) { background:var(--theme-soft); color:var(--theme-ink); }
html :is(.sf-submenu,.sf-clothing,.sf-skip) { background:var(--theme-surface); color:var(--theme-ink); }
html .sf-scene { background:var(--theme-stage); }
html .sf-number { background:var(--theme-lime); color:var(--theme-on-lime); }
html :is(.sf-entry,.sf-action), html .sf-moments a[aria-current="true"] { background:var(--theme-action); color:var(--theme-on-action)!important; }
html :is(.sf-entry,.sf-action):hover { background:var(--theme-action-hover); }
/* Header class pair outranks the generic theme CTA selector in folzi-core.css. */
html .sf-header .sf-entry { background:var(--theme-action); color:var(--theme-on-action)!important; }
html .sf-header .sf-entry:hover { background:var(--theme-action-hover); color:var(--theme-on-action)!important; }
html .sf-moments.sf-ind::before { background:var(--theme-action); }
html .sf-moments.sf-ind>a[aria-current="true"] { background:transparent; color:inherit!important; }
html .sf-moments-ink>a { color:var(--theme-on-action)!important; }

/* Retained interior surfaces with literal light paints in site/evolution/colour-study. */
html body.af-page:not(.af-home) .page-hero,
html body.af-page :is(.af-header,.af-menu-toggle,.af-mobile,.af-nav details>div,.story-collection,.waitlist,.price-card,.journal-masthead,.journal-feature,.journal-recent,.journal-archive,.journal-related,.journal-post,.provenance-console,.provenance-result,.strength-card,.press-wordmark) {
  background:var(--theme-ground); color:var(--theme-ink); border-color:var(--theme-rule);
}
html body.af-page :is(.story-chapter.alt,.role-path,.coverage-request-section,.post-cta,.coverage-directory-controls,.price-card.featured,.price-card:nth-child(2),.journal-prose blockquote,.af-form-notice,.af-form-result,.v2-archive-notice,.v3-measurement-context,.sf-source-strip,.af-draft,.v2-swap-controls button) {
  background:var(--theme-soft); color:var(--theme-secondary)!important; border-color:var(--theme-rule);
}
html body.af-page :is(.af-footer,.af-hero-figure,.story-media,.journal-feature-still,.v2-hero-board,.v2-sample-strip,.v2-look-stage,.tailor-handoff-figure,.editorial-film) {
  background:var(--theme-stage); color:var(--theme-ink); border-color:var(--theme-rule);
}
html body.af-page :is(.af-hero-figure figcaption,.af-story-cover figcaption,.v2-house figcaption,.journal-feature-still figcaption,.v2-campaign figcaption,.outfit-item>span:last-child:not(.piece),.v2-motion-toggle,.lb-prev:after,.lb-next:after) {
  background:var(--theme-surface); color:var(--theme-secondary)!important; border-color:var(--theme-control);
}
html body.af-page:not(.af-home) .lede,
html body.af-page :is(.af-breadcrumb,.af-footer-bottom,.af-page-index a,.af-page-index p,.af-directory-record small,.journal-standfirst,.journal-card-meta,.journal-dept-foot,.journal-crumb,.journal-topics em,.journal-topics a em,.af-journal-filter-status,.meta-line,.v2-small,.v2-media-note,.v2-change-note,.v2-look-stage>p,.v2-three span,.press-wordmark span,.brand-cards button span) {
  color:var(--theme-muted)!important;
}
html body.af-page :is(.journal-dept p,.journal-card p,.story-lede,.af-footer-grid h2,.af-draft a,.provenance-result>p:not(.provenance-badge)) { color:var(--theme-secondary); }
html body.af-page .journal-topics a em { opacity:1; }
html body.af-page :is(.af-page-index a:hover,.v2-research article a,.provenance-action,.photo-candidate-copy button,.photo-result-heading>button,.photo-dialog-top button,.photo-dialog-actions>button:not(.v2-button)) { color:var(--theme-link); }
html body.af-page .v2-future-note { background:var(--theme-notice)!important; color:var(--theme-notice-ink)!important; border-color:var(--theme-control); }

/* Inputs, secondary/selected controls and source-state messages. No form behavior changes. */
html body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]),select,textarea) {
  background:var(--theme-surface); color:var(--theme-ink); border-color:var(--theme-control); caret-color:var(--theme-ink);
}
html body :is(input,textarea)::placeholder { color:var(--theme-muted); opacity:1; }
html body :is(input[type="checkbox"],input[type="radio"],input[type="range"]) { accent-color:var(--theme-accent); }
html body.af-page :is(.button,.v2-button,.af-open) { background:var(--theme-action); border-color:var(--theme-action); color:var(--theme-on-action)!important; }
html body.af-page :is(.button,.v2-button,.af-open):hover { background:var(--theme-action-hover); }
html body.af-page main :is(.button.secondary,.state-switcher button,.brand-cards button,.delete-choice-tabs button,.coverage-filter-buttons button,.studio-presets button) {
  background:var(--theme-surface); color:var(--theme-ink)!important; border-color:var(--theme-control);
}
html body.af-page main :is(.button.secondary,.v2-swap-controls button):hover { background:var(--theme-stage); color:var(--theme-ink)!important; }
html body.af-page main :is([aria-pressed="true"],[role="tab"][aria-selected="true"]),
html body.af-page .brand-cards button[aria-pressed="true"] span { background:var(--theme-action); color:var(--theme-on-action)!important; border-color:var(--theme-action); }
html body.af-page main .v2-piece-button[aria-pressed="true"] { background:var(--theme-stage); color:var(--theme-ink)!important; border-color:var(--theme-accent); }
html body :is(input,select,textarea)[aria-invalid="true"] { border-color:var(--theme-error); }
html body :is(.form-error,[data-form-error],[role="alert"]) { color:var(--theme-error); }
html body :is(.af-form-notice,.af-form-result) [role="alert"] { color:var(--theme-error); }
html .sf-theme-control { color:var(--theme-secondary); }
html .sf-theme-control select { min-height:44px; max-width:100%; padding:8px 30px 8px 10px; border:1px solid var(--theme-control); font:inherit; }
html .sf-theme-control select:disabled { opacity:.7; cursor:not-allowed; }

/* Deep reading overrides mirror its stronger page-scoped selectors, including !important paints. */
html body.af-page main[data-deep-reading] { --deep-rule:var(--theme-rule); }
html body.af-page main[data-deep-reading] :is(.deep-example-values,.deep-measurement-scope,.deep-sample-stage,.coverage-hub-strip,.coverage-directory-controls) { background:var(--theme-soft); color:var(--theme-ink); }
html body.af-page main[data-deep-reading] :is(.provenance-stage,.provenance-grid) { background:var(--theme-stage); color:var(--theme-ink); }
html body.af-page main[data-deep-reading] :is(.provenance-result,.strength-card,.deep-example-values .chip,.deep-example-values .hero-measure-popover) { background:var(--theme-surface)!important; color:var(--theme-ink)!important; border-color:var(--theme-control)!important; }
html body.af-page main[data-deep-reading] :is(.provenance-zone-caption,.provenance-zone-caption b,.provenance-result p) { color:var(--theme-ink)!important; }
html body.af-page main[data-deep-reading] :is(.deep-boundary,.deep-sample-note,.deep-sample-stage p,.deep-sample-stage span) { color:var(--theme-muted)!important; }
html body.af-page main[data-deep-reading] .provenance-badge { background:var(--theme-inverse)!important; color:var(--theme-on-inverse)!important; }
html body.af-coverage main[data-deep-reading] :is(input,select) { background:var(--theme-surface)!important; color:var(--theme-ink); border-color:var(--theme-control)!important; }

/* Photo review and Studio controls are themed, while photos/canvas/garment artwork stay intact. */
html body.af-page :is(.photo-stage,.photo-scene,.photo-candidates,.photo-empty,.photo-intro-note,.photo-scene>button,.photo-reveal,.photo-approved-card,.studio-toolbar,.studio-inspector,.studio-look-summary) { background:var(--theme-soft); color:var(--theme-ink); border-color:var(--theme-control); }
html body.af-page :is(.studio-world,.studio-world-label,.studio-flat-art) { background:var(--theme-stage); color:var(--theme-muted); }
html body.af-page .photo-main dialog { background:var(--theme-surface); color:var(--theme-ink); }
html body.af-page :is(.photo-caption,.photo-small,.photo-reveal-note,.studio-camera>span,.studio-material-note,.studio-piece-list small,#studio-status,#photo-empty) { color:var(--theme-muted)!important; border-color:var(--theme-control); }
html body.af-page .studio-piece-list>button { background:var(--theme-surface); color:var(--theme-ink); }
html body.af-page .studio-piece-list>button:is(:hover,[aria-pressed="true"]) { background:var(--theme-stage); color:var(--theme-ink)!important; box-shadow:inset 0 -3px var(--theme-accent); }

/* Intentional inverse panels retain paired dark ink/surfaces in BOTH themes. */
html body.af-page :is(.section.dark,.honesty,.measured-for,.story-chapter.dark,.story-wide,.security-report,.quote-section,.error-copy) {
  --ink:var(--theme-on-inverse); --ink-2:var(--theme-inverse-muted); --ink-3:var(--theme-inverse-muted);
  --accent:var(--theme-inverse-link); --paper:var(--theme-inverse); --panel:var(--theme-inverse);
  color:var(--theme-on-inverse); background:var(--theme-inverse); border-color:var(--theme-inverse-rule);
}
html body.af-page :is(.section.dark,.honesty,.measured-for,.story-chapter.dark,.security-report,.quote-section,.error-copy) :is(h1,h2,h3,p,li,.eyebrow,.meta-line,.quote-label,.copy-status,.story-num,.story-sign,.story-sign span) { color:var(--theme-inverse-muted)!important; }
html body.af-page :is(.error-copy,.security-report,.quote-section) :is(h1,h2,h3) { color:var(--theme-on-inverse)!important; }
html body.af-page :is(.section.dark,.honesty,.story-chapter.dark,.security-report,.quote-section,.error-copy) a:not(.button) { color:var(--theme-inverse-link); }
html body.af-page .quote-grid { background:var(--theme-inverse-rule); border-color:var(--theme-inverse-rule); }
html body.af-page :is(.quote-grid article,.dark .card) { background:var(--theme-inverse); border-color:var(--theme-inverse-rule); }
html body.af-page :is(.quote-grid blockquote,.quote-grid button) { color:var(--theme-on-inverse); }
html body.af-page .quote-grid button { background:var(--theme-inverse); border-color:var(--theme-inverse-rule); }
html body.af-page :is(.error-copy,.section.dark) .button.secondary { background:var(--theme-inverse); color:var(--theme-on-inverse)!important; border-color:var(--theme-inverse-rule); }
html body.af-page :is(.error-copy,.section.dark) .button.secondary:hover,
html body.af-page .quote-grid button:hover { background:var(--theme-on-inverse); color:var(--theme-inverse)!important; }
/* The security opening is deliberately a normal page surface in the retained blue palette. */
html body.af-page .security-hero { --ink-2:var(--theme-secondary); --ink-3:var(--theme-muted); background:var(--theme-ground); color:var(--theme-ink); }
html body.af-page .security-hero h1 { color:var(--theme-ink); }
html body.af-page .security-hero :is(.eyebrow,.lede) { color:var(--theme-muted)!important; }

/* One visible keyboard ring; inverse sections use the lime family accent. */
html body :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible { outline:3px solid var(--theme-focus); outline-offset:4px; }
html body.af-page :is(.section.dark,.honesty,.story-chapter.dark,.security-report,.quote-section,.error-copy) :focus-visible { outline-color:var(--theme-lime); }
::selection { background:var(--theme-lime); color:var(--theme-on-lime); }
@media (forced-colors:active) {
  html body :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible { outline:3px solid Highlight; }
  html body :is(input,select,textarea,button,.button) { border-color:ButtonText; }
}

/* Existing illustrated device screens intentionally remain light, with their own paired tokens. */
html body.af-page :is(.phone-screen,.ph-screen) { --paper:#ffffff; --paper-2:#f4f7f8; --panel:#ffffff; --ink:#20272d; --ink-2:#343e47; --ink-3:#59636d; background:#ffffff; color:#20272d; }
html body.af-page main[data-deep-reading] :is(summary,a,button,input,select):focus-visible { outline:3px solid var(--theme-focus); outline-offset:4px; }

@media print {
  :root, :root[data-theme], :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme:light;
  --theme-ground: #f4f7f8;
  --theme-surface: #ffffff;
  --theme-stage: #dce8ef;
  --theme-soft: #e7eef2;
  --theme-ink: #20272d;
  --theme-secondary: #343e47;
  --theme-muted: #59636d;
  --theme-rule: #bbc7cf;
  --theme-control: #6d7780;
  --theme-link: #852b40;
  --theme-accent: #852b40;
  --theme-focus: #852b40;
  --theme-notice: #edf0dc;
  --theme-notice-ink: #3e482c;
  --theme-error: #9f223d;
  --theme-error-soft: #fce8ed;
  --theme-success: #315f3b;
  --theme-success-soft: #eef3e5;
  }
}
