/*
 * PharmRoom design layer: loaded after each page's own styles, so it refines the shared look everywhere
 * (colours, page banners, cards, buttons, form fields, windows, focus rings) without changing layouts.
 * The top bar, footer and cookie banner are styled in js/site-header.js.
 */

/* ---------- Palette: "Dispensary". Prescription-paper neutrals, bottle-green ink, marigold for what needs attention today,
   label red for warnings. Neutrals carry a faint warm tint (never pure grey); green is kept for actions, links and the current place.
   Every colour token is set here in both modes, so a page's own :root values never leak through.
   Contrast (WCAG 2.2): body text 14:1+, secondary text 5.2:1+ on every surface, white on the brand fill 6.5:1 (dark mode 5:1). ---------- */
:root {
    --color-primary: #1f6a50;      /* bottle green: buttons, fills */
    --color-secondary: #6fb594;    /* soft green: logo, decorative */
    --color-accent: #134a38;
    --color-dark: #121a16;
    --color-light: #f6f4ee;        /* page ground: prescription paper */
    --color-white: #ffffff;        /* raised surfaces */
    --color-text: #1b2420;
    --color-gray: #5a635d;
    --color-heading: #121a16;
    --color-link: #1a654c;
    --color-tint: #e5eee8;         /* green wash for the current item and soft buttons */
    --color-border: #e3dfd5;
    --pr-surface-2: #faf8f3;       /* inset areas inside a card */
    --pr-hero: #efece4;
    --shadow-sm: 0 1px 2px rgba(18, 26, 22, 0.04);
    --shadow-md: 0 1px 2px rgba(18, 26, 22, 0.05), 0 8px 20px -12px rgba(18, 26, 22, 0.18);
    --shadow-lg: 0 2px 4px rgba(18, 26, 22, 0.05), 0 20px 40px -16px rgba(18, 26, 22, 0.26);
    --pr-brand: #1f6a50;
    --pr-brand-deep: #134a38;
    --pr-brand-ink: #1a654c;       /* green for text on paper or white */
    --pr-mint: #e5eee8;
    --pr-accent: #f2b134;          /* marigold: what needs attention today (due, streak, highlights) */
    --pr-accent-soft: #fdf1d3;
    --pr-accent-ink: #7f5300;      /* marigold-family text on white (6.7:1) */
    --pr-on-accent: #121a16;
    --pr-danger: #b42318;          /* label red: warnings and destructive actions only */
    --pr-ring: 0 0 0 3px rgba(31, 106, 80, 0.22);
    --pr-radius: 12px;
    --pr-radius-sm: 8px;
}
@media (prefers-color-scheme: dark) {
    :root {
        /* Depth comes from lighter surfaces, not shadows; green is lifted and softened for dark ground */
        --color-primary: #2a7d5f;
        --color-secondary: #6fb594;
        --color-accent: #1f6a50;
        --color-dark: #121a16;
        --color-light: #111613;
        --color-white: #192019;
        --color-text: #e3e8e2;
        --color-gray: #a2aca4;
        --color-heading: #f1f4ef;
        --color-link: #7cc9a5;
        --color-tint: #1d2c24;
        --color-border: #2d3630;
        --pr-surface-2: #212923;
        --pr-hero: #151b17;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 28px -14px rgba(0, 0, 0, 0.65);
        --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 24px 48px -18px rgba(0, 0, 0, 0.75);
        --pr-brand: #2a7d5f;
        --pr-brand-deep: #1f6a50;
        --pr-brand-ink: #7cc9a5;
        --pr-mint: #1d2c24;
        --pr-accent: #f5bd4b;
        --pr-accent-soft: rgba(245, 189, 75, 0.14);
        --pr-accent-ink: #f7c96a;
        --pr-danger: #f28b82;
        --pr-ring: 0 0 0 3px rgba(124, 201, 165, 0.28);
    }
}

/* ---------- Typeface: Atkinson Hyperlegible Next, self-hosted (SIL OFL, /assets/fonts/OFL.txt).
   Drawn by the Braille Institute for legibility; distinct letterforms keep look-alike drug names apart. ---------- */
@font-face {
    font-family: 'Atkinson Hyperlegible Next';
    src: url('/assets/fonts/ahn-normal.woff2') format('woff2');
    font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Atkinson Hyperlegible Next';
    src: url('/assets/fonts/ahn-italic.woff2') format('woff2');
    font-weight: 200 800; font-style: italic; font-display: swap;
}
/* Source Serif 4 (SIL OFL, /assets/fonts/SourceSerif-LICENSE.md) for page and section headings: the voice of a
   textbook or the BNF, set against Atkinson for everything you read and use */
@font-face {
    font-family: 'Source Serif 4';
    src: url('/assets/fonts/ss4-latin.woff2') format('woff2');
    font-weight: 400 700; font-style: normal; font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Source Serif 4';
    src: url('/assets/fonts/ss4-latin-ext.woff2') format('woff2');
    font-weight: 400 700; font-style: normal; font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
    --pr-font: 'Atkinson Hyperlegible Next', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --pr-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}
html, body { font-family: var(--pr-font); }
button, input, select, textarea { font-family: inherit; }

/* ---------- Base ---------- */
body {
    background-color: var(--color-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
/* Short pages (sign-in prompts, empty lists): the footer rests at the bottom of the window instead of floating mid-screen */
body { min-height: 100vh; min-height: 100dvh; }
#site-footer { position: sticky; top: 100vh; top: 100dvh; }
h1, h2, h3 { letter-spacing: -0.01em; }
h1 { font-weight: 800; }
/* Any link a page hasn't styled takes the brand ink (zero specificity, so every styled link keeps its own colour) */
:where(a) { color: var(--color-link); }
/* Links inside running text: a thin underline set clear of the letters */
p a, li a, dd a, td a { text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
p a:hover, li a:hover, dd a:hover, td a:hover { text-decoration-thickness: 2px; }
::selection { background: rgba(242, 177, 52, 0.35); color: inherit; }
html { scrollbar-color: #ccc9c2 transparent; accent-color: var(--pr-brand); }
@media (prefers-color-scheme: dark) { html { scrollbar-color: #494741 transparent; } }
:focus-visible { outline: 2px solid var(--pr-brand); outline-offset: 2px; }
@media (prefers-color-scheme: dark) { :focus-visible { outline-color: #8fd3b3; } }

/* ---------- Page banners: a sheet of ruled paper, one step darker than the page, with a serif title ---------- */
.page-hero, body > .hero, section.hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    color: var(--color-heading);
    background-color: var(--pr-hero);
    background-image: none;
    border-bottom: 1px solid var(--color-border);
}
.page-hero h1, .page-hero p, section.hero h1, body > .hero h1 { color: var(--color-heading); }
.page-hero p, section.hero > p, body > .hero > p { color: var(--color-gray); opacity: 1; }
.page-hero h1, section.hero h1, body > .hero h1 {
    font-family: var(--pr-serif); font-weight: 600; letter-spacing: -0.015em; text-wrap: balance;
    font-optical-sizing: auto;
}
/* Faint ruled lines that fade in from the left, plus a margin rule: revision paper, not decoration for its own sake */
.page-hero::before, body > .hero::before, section.hero::before {
    content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(18, 26, 22, 0.06) 31px 32px);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 55%); mask-image: linear-gradient(to right, transparent 0%, #000 55%);
}
@media (prefers-color-scheme: dark) {
    .page-hero::before, body > .hero::before, section.hero::before {
        background-image: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(255, 255, 255, 0.04) 31px 32px);
    }
}
.page-hero p, section.hero p { text-wrap: balance; }
/* Section headings on long pages share the serif, so the reading voice is consistent */
.section-head h2, .pillars-head h2, .about-head h2, .faq-head h2, .newsletter-copy h2, .contact-info h2, .section > .container > h2 {
    font-family: var(--pr-serif); font-weight: 600; letter-spacing: -0.015em; font-optical-sizing: auto;
}

/* Reference pages (Medicines, Tools, Resources): a compact, left-aligned header in line with the content column,
   so search and tools come first. Pages set --page-w to their content width. */
.page-hero.compact {
    text-align: left;
    padding: 2rem max(1.25rem, calc((100% - var(--page-w, 1100px)) / 2 + var(--page-pad, 2rem))) 2.25rem;
}
.page-hero.compact h1 { font-size: clamp(1.7rem, 3vw, 2.1rem); line-height: 1.15; margin: 0 0 0.35rem; }
.page-hero.compact p { font-size: 1rem; margin: 0; max-width: 60ch; opacity: 0.92; }
.page-hero.compact ~ .container { margin-top: 1.5rem; }
@media (max-width: 640px) { .page-hero.compact { padding: 1.5rem 1rem 1.75rem; } }

/* ---------- Tabs: one design everywhere (text tabs, teal underline on the current one) ---------- */
.pr-tabs.pr-tabs {
    display: flex; justify-content: flex-start; align-items: stretch; gap: 0.25rem; width: auto; max-width: none; margin: 0 0 1.5rem; padding: 0;
    background: none; box-shadow: none; border-radius: 0; border-bottom: 1px solid var(--color-border);
    overflow-x: auto; scrollbar-width: none;
}
.pr-tabs.pr-tabs::-webkit-scrollbar { display: none; }
.pr-tabs .pr-tab {
    flex: 0 0 auto; padding: 0.8rem 1.1rem; margin: 0 0 -1px; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
    background: none; color: var(--color-gray); font: inherit; font-weight: 650; font-size: 0.95rem; text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.pr-tabs .pr-tab:hover { color: var(--color-heading, var(--color-text)); background: none; }
.pr-tabs .pr-tab.active, .pr-tabs .pr-tab.on, .pr-tabs .pr-tab[aria-selected="true"] { color: var(--color-link, #1a654c); border-bottom-color: var(--pr-brand); background: none; }
@media (prefers-color-scheme: dark) { .pr-tabs .pr-tab.active, .pr-tabs .pr-tab.on, .pr-tabs .pr-tab[aria-selected="true"] { border-bottom-color: #8fd3b3; } }

/* ---------- Surfaces: flat white sheets on the paper ground, a hairline edge and almost no shadow.
   Shadows are kept for things that genuinely float (menus, windows, sticky notes) and for hover on links. ---------- */
.card, .feature-card, .deck-card, .stat-card, .stats-card, .study-panel, .doc, .browse-table, .stat-tiles .tile, .value-card, .faq details {
    border-radius: var(--pr-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}
.stat-card, .feature-card, .deck-card { box-shadow: var(--shadow-sm); }
.feature-card, .deck-card, a.card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.feature-card:hover, a.card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(31, 106, 80, 0.35);
}
.deck-card:hover { box-shadow: var(--shadow-md); }

/* ---------- Buttons: 8px corners, no gloss; one solid green action per view ---------- */
.btn, .btn-auth, .btn-reveal, .btn-rating, .icon-tool, .icon-btn {
    border-radius: var(--pr-radius-sm);
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.btn, .btn-auth { font-weight: 650; }
.btn-primary, .btn-auth {
    background: var(--pr-brand);
    color: #fff;
    border: 1px solid var(--pr-brand);
    box-shadow: none;
}
.btn-primary:hover:not(:disabled), .btn-auth:hover:not(:disabled) {
    background: var(--pr-brand-deep);
    border-color: var(--pr-brand-deep);
}
.btn-primary:active:not(:disabled), .btn-auth:active:not(:disabled), .btn-secondary:active:not(:disabled), .btn:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary {
    background: var(--color-white);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: none;
}
.btn-secondary:hover:not(:disabled) {
    border-color: rgba(31, 106, 80, 0.45);
    color: var(--color-heading, var(--color-text));
    background: var(--pr-surface-2);
}
.btn-danger { box-shadow: none; }
/* Soft action for buttons repeated down a list (Study, Download, Join): the page's one main action stays solid */
.btn-tint { background: var(--color-tint); color: var(--color-link); border: 1px solid transparent; font-weight: 700; }
.btn-tint:hover:not(:disabled) { background: var(--pr-brand); border-color: var(--pr-brand); color: #fff; }

/* ---------- Form fields ---------- */
.input, .select, .textarea,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
.form-group select, .form-group textarea,
.contact-form input, .contact-form textarea, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
    border-radius: var(--pr-radius-sm);
    border: 1px solid var(--color-border);
    background-color: var(--color-white);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:hover:not(:focus), .select:hover:not(:focus), .textarea:hover:not(:focus) { border-color: #cfc9bc; }
@media (prefers-color-scheme: dark) { .input:hover:not(:focus), .select:hover:not(:focus), .textarea:hover:not(:focus) { border-color: #3d4740; } }
.input:focus, .select:focus, .textarea:focus,
.form-group input:focus, .form-group select:focus, .form-group textarea:focus,
.contact-form input:focus, .contact-form textarea:focus, .field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--pr-brand);
    box-shadow: var(--pr-ring);
}
@media (prefers-color-scheme: dark) {
    .input:focus, .select:focus, .textarea:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus,
    .contact-form input:focus, .contact-form textarea:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: #8fd3b3; }
}
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--pr-brand); }

/* ---------- Windows ---------- */
.modal, .auth-modal {
    background-color: rgba(27, 25, 20, 0.5);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.modal-content, .auth-modal-content {
    border-radius: 16px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
}
.modal.active .modal-content, .modal:not([hidden]) .modal-content, .auth-modal[style*="block"] .auth-modal-content { animation: pr-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.modal.active, .modal:not([hidden]) { animation: pr-fade 0.18s ease-out; }
@keyframes pr-pop { from { opacity: 0.4; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pr-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Loading: the PharmRoom capsule, gently shaken. It only fades in if loading takes more than
   a moment, so quick loads never flash it. ---------- */
.pr-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.65rem; min-height: 200px; padding: 1.5rem;
    color: var(--color-gray, #5a635d); font-size: 0.92rem; opacity: 0; animation: pr-loader-in 0.2s ease-out 0.2s forwards; }
.pr-loader.sm { min-height: 64px; flex-direction: row; gap: 0.55rem; padding: 0.75rem; font-size: 0.88rem; }
.pr-loader-pill { width: 46px; height: 46px; transform: rotate(-35deg); animation: pr-shake 0.9s ease-in-out infinite; }
.pr-loader.sm .pr-loader-pill { width: 26px; height: 26px; }
@keyframes pr-loader-in { to { opacity: 1; } }
@keyframes pr-shake { 0%, 100% { transform: rotate(-35deg); } 50% { transform: rotate(-8deg) translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .pr-loader { animation: none; opacity: 1; } .pr-loader-pill { animation: none; } }
td > .pr-loader.sm { justify-content: flex-start; }

/* ---------- Switching tabs: the new content settles in instead of jumping ---------- */
.tab-content.active, .panel.active { animation: pr-settle 0.2s ease-out; }
@keyframes pr-settle { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Opening and closing sections (FAQs, law guides): height eases where the browser can ---------- */
@supports (interpolate-size: allow-keywords) {
    :root { interpolate-size: allow-keywords; }
    details::details-content { height: 0; overflow: clip; transition: height 0.25s ease-out, content-visibility 0.25s allow-discrete; }
    details[open]::details-content { height: auto; }
}

/* ---------- Tabs and pills ---------- */
.tabs { border-bottom-color: var(--color-border); }
.tab { transition: color 0.15s ease, border-color 0.15s ease; }
.pill, .badge { letter-spacing: 0.01em; }

/* ---------- Skeleton placeholders: a gentle shimmer ---------- */
.skeleton { border: 1px solid var(--color-border); border-radius: var(--pr-radius); }

/* ---------- Motion: respect people who've asked for less ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
    details::details-content { transition: none !important; }
    .feature-card:hover, a.card:hover, .btn-primary:hover, .btn-auth:hover { transform: none; }
}


/* ═══ Introduction for signed-out visitors (and search engines) on members-only pages ═══ */
.guest-intro { max-width: var(--page-w, 1100px); margin: 0 auto 3.5rem; padding: 0 var(--page-pad, 1.5rem); }
.guest-intro .gi-inner { border-top: 1px solid var(--color-border); padding-top: 2.25rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1.25rem 3rem; }
.guest-intro h2 { font-size: 1.35rem; line-height: 1.3; color: var(--color-heading); margin: 0 0 0.75rem; text-wrap: balance; }
.guest-intro p { color: var(--color-text); line-height: 1.65; margin: 0 0 0.85rem; max-width: 62ch; }
.guest-intro .gi-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.85rem; }
.guest-intro .gi-points li { position: relative; padding-left: 1.15rem; line-height: 1.6; color: var(--color-text); }
.guest-intro .gi-points li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--pr-brand, #1f6a50); }
.guest-intro .gi-points strong { color: var(--color-heading); }
.guest-intro .gi-related { display: block; grid-column: 1 / -1; font-size: 0.92rem; color: var(--color-gray); padding: 0.25rem 0 0; margin: 0; max-width: none; }
.guest-intro .gi-related a { color: var(--color-link); }
.ph-member .guest-intro { display: none; }
@media (max-width: 760px) { .guest-intro .gi-inner { grid-template-columns: minmax(0, 1fr); gap: 1rem; } }

/* Plain links in the footer slot until the shared footer replaces them (seen by search engines and without scripts) */
nav.ph-static-footer { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-size: 0.9rem; border-top: 1px solid var(--color-border); }
.ph-static-footer a { color: var(--color-link); }

/* ═══ Revision-desk notes: a marigold sticky note for what matters today (due cards, streak, a deadline).
   Only ever holds real, current information for the person looking at it. ═══ */
.pr-note {
    display: inline-flex; flex-direction: column; gap: 0.1rem;
    padding: 0.75rem 0.95rem 0.8rem; min-width: 10rem; max-width: 18rem;
    background: #fff3d6; color: #4a3500; border-radius: 3px 3px 10px 3px;
    box-shadow: 0 1px 1px rgba(18, 26, 22, 0.08), 0 10px 18px -12px rgba(18, 26, 22, 0.35);
    transform: rotate(-1.2deg); font-size: 0.88rem; line-height: 1.35; text-decoration: none;
}
.pr-note strong { font-size: 1.35rem; line-height: 1.1; color: #2e2100; font-weight: 800; }
.pr-note small { color: #6b5208; font-size: 0.8rem; }
a.pr-note:hover { transform: rotate(0deg); }
@media (prefers-color-scheme: dark) {
    .pr-note { background: #f0c35e; color: #3b2a00; box-shadow: 0 12px 20px -12px rgba(0, 0, 0, 0.85); }
    .pr-note strong { color: #2a1d00; }
    .pr-note small { color: #4f3a05; }
}
@media (prefers-reduced-motion: reduce) { .pr-note, a.pr-note:hover { transform: none; } }

/* ═══ Site notices (Admin → Notices), in the style of current product sites (Stripe, Notion, Supabase):
   - the bar: one slim centred strip, the link inline with an arrow, a small × at the far right;
   - the pop-up: a compact card floating in the corner. It doesn't dim or block the page, so people can ignore it
     and carry on (NN/g: non-modal over modal for anything that isn't urgent).
   Tones follow the colour rules: deep green for news, marigold for something to do now, label red for problems.
   Problems carry a warning icon and every notice has a spoken label, so meaning never rests on colour alone. ═══ */
.pr-vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ── Bar ── a tone-coloured icon tile, the title set off by a thin rule, and the link as a small pill */
/* Out of the way during a flashcard study session */
body.studying .pr-notice-bar { display: none; }
.pr-notice-bar { --nb-bg: #134a38; --nb-text: rgba(255, 255, 255, 0.82); --nb-strong: #ffffff; --nb-ico: #bfe6d3; --nb-edge: transparent; --nb-hover: rgba(255, 255, 255, 0.12);
    --nb-tile: rgba(255, 255, 255, 0.12); --nb-tile-edge: rgba(255, 255, 255, 0.16); --nb-pill: rgba(255, 255, 255, 0.1); --nb-pill-edge: rgba(255, 255, 255, 0.28); --nb-pill-hover: rgba(255, 255, 255, 0.2);
    background: var(--nb-bg); color: var(--nb-text); border-bottom: 1px solid var(--nb-edge); font-family: var(--pr-font); position: relative; z-index: 501;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.pr-notice-bar.tone-today { --nb-bg: #fdf1d3; --nb-text: #5c430c; --nb-strong: #121a16; --nb-ico: #7f5300; --nb-edge: rgba(127, 83, 0, 0.18); --nb-hover: rgba(127, 83, 0, 0.1);
    --nb-tile: #ffffff; --nb-tile-edge: rgba(127, 83, 0, 0.2); --nb-pill: #ffffff; --nb-pill-edge: rgba(127, 83, 0, 0.24); --nb-pill-hover: #fff9ea; }
.pr-notice-bar.tone-warning { --nb-bg: #fdecea; --nb-text: #7a2219; --nb-strong: #4a0f0a; --nb-ico: #b42318; --nb-edge: rgba(180, 35, 24, 0.2); --nb-hover: rgba(180, 35, 24, 0.09);
    --nb-tile: #ffffff; --nb-tile-edge: rgba(180, 35, 24, 0.2); --nb-pill: #ffffff; --nb-pill-edge: rgba(180, 35, 24, 0.24); --nb-pill-hover: #fff6f5; }
.pr-notice-bar-inner { position: relative; max-width: 1200px; margin: 0 auto; min-height: 44px; padding: calc(0.5rem + 2px) 3.25rem calc(0.5rem - 2px); display: flex; align-items: center; justify-content: center; text-align: center; }
.pr-notice-text { margin: 0; font-size: 0.875rem; line-height: 1.55; text-wrap: balance; }
.pr-notice-text strong { color: var(--nb-strong); font-weight: 650; }
.pr-notice-text strong::after { content: ''; display: inline-block; width: 1px; height: 0.95em; margin: 0 0.65em; vertical-align: -0.12em; background: currentColor; opacity: 0.3; }
.pr-notice-text .pr-notice-ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-right: 0.6em; vertical-align: -0.42em; position: relative; top: -0.24em;
    border-radius: 6px; background: var(--nb-tile); box-shadow: inset 0 0 0 1px var(--nb-tile-edge); color: var(--nb-ico); }
.pr-notice-link { display: inline-flex; align-items: center; gap: 0.25em; margin-left: 0.7em; padding: 0.08rem 0.65rem; border-radius: 999px; line-height: 1.45;
    background: var(--nb-pill); box-shadow: inset 0 0 0 1px var(--nb-pill-edge); color: var(--nb-strong); font-weight: 650; white-space: nowrap; text-decoration: none; transition: background 0.15s ease; }
.pr-notice-link:hover { background: var(--nb-pill-hover); }
.pr-notice-link svg { transition: transform 0.15s ease; }
.pr-notice-link:hover svg { transform: translateX(2px); }
.pr-notice-close { position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 8px; background: none; color: var(--nb-strong); opacity: 0.7; cursor: pointer; }
.pr-notice-close:hover { background: var(--nb-hover); opacity: 1; }
.pr-notice-bar a:focus-visible, .pr-notice-close:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
    .pr-notice-bar { --nb-bg: #173a2f; --nb-text: rgba(236, 244, 239, 0.8); --nb-edge: rgba(143, 211, 179, 0.12); --nb-ico: #8fd3b3; }
    .pr-notice-bar.tone-today { --nb-bg: #2b2513; --nb-text: #ead9b0; --nb-strong: #fff6e0; --nb-ico: #f5bd4b; --nb-edge: rgba(245, 189, 75, 0.2); --nb-hover: rgba(245, 189, 75, 0.12);
        --nb-tile: rgba(245, 189, 75, 0.12); --nb-tile-edge: rgba(245, 189, 75, 0.22); --nb-pill: rgba(245, 189, 75, 0.1); --nb-pill-edge: rgba(245, 189, 75, 0.3); --nb-pill-hover: rgba(245, 189, 75, 0.2); }
    .pr-notice-bar.tone-warning { --nb-bg: #361c19; --nb-text: #f3cdc8; --nb-strong: #ffe7e4; --nb-ico: #f28b82; --nb-edge: rgba(248, 113, 113, 0.24); --nb-hover: rgba(248, 113, 113, 0.12);
        --nb-tile: rgba(248, 113, 113, 0.12); --nb-tile-edge: rgba(248, 113, 113, 0.24); --nb-pill: rgba(248, 113, 113, 0.1); --nb-pill-edge: rgba(248, 113, 113, 0.32); --nb-pill-hover: rgba(248, 113, 113, 0.2); }
}
@media (max-width: 640px) {
    .pr-notice-bar-inner { justify-content: flex-start; text-align: left; padding: calc(0.6rem + 2px) 2.9rem calc(0.6rem - 2px) 1rem; }
    .pr-notice-text { font-size: 0.84rem; text-wrap: pretty; }
    .pr-notice-close { right: 0.4rem; width: 40px; height: 40px; }
}

/* ── Pop-up: a floating card, bottom right (lifted above the cookie bar while that's showing).
   Its heading sits on a strip of tinted ruled paper, the same motif as the page banners, in the tone's colour. ── */
.pr-notice-card { --nc-tint: #e6efe9; --nc-line: rgba(19, 74, 56, 0.09); --nc-edge: rgba(19, 74, 56, 0.12); --nc-ico: #1a654c; --nc-x-hover: rgba(19, 74, 56, 0.1);
    position: fixed; z-index: 890; right: 1.25rem; bottom: var(--pr-card-bottom, 1.25rem); width: min(380px, calc(100vw - 2rem));
    background: var(--color-white, #fff); color: var(--color-text, #1b2420); font-family: var(--pr-font);
    border: 1px solid var(--color-border, #e3dfd5); border-radius: 16px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(16, 40, 44, 0.06), 0 22px 44px -18px rgba(16, 40, 44, 0.34);
    transition: bottom 0.2s ease; animation: pr-card-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.pr-notice-card.tone-today { --nc-tint: #fdf1d3; --nc-line: rgba(127, 83, 0, 0.1); --nc-edge: rgba(127, 83, 0, 0.16); --nc-ico: #7f5300; --nc-x-hover: rgba(127, 83, 0, 0.1); }
.pr-notice-card.tone-warning { --nc-tint: #fdecea; --nc-line: rgba(180, 35, 24, 0.08); --nc-edge: rgba(180, 35, 24, 0.16); --nc-ico: #b42318; --nc-x-hover: rgba(180, 35, 24, 0.09);
    border-color: rgba(180, 35, 24, 0.3); }
.pr-notice-card.leaving { animation: pr-card-out 0.16s ease-in forwards; }
@keyframes pr-card-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes pr-card-out { to { opacity: 0; transform: translateY(6px); } }
.pr-notice-card-head { position: relative; isolation: isolate; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 0.75rem; align-items: center;
    padding: 0.85rem 0.6rem 0.85rem 0.95rem; background: var(--nc-tint); border-bottom: 1px solid var(--nc-edge); }
.pr-notice-card-head:last-child { border-bottom: 0; }
/* Ruled lines that fade in from the left, as on the page banners */
.pr-notice-card-head::before { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image: repeating-linear-gradient(to bottom, transparent 0 19px, var(--nc-line) 19px 20px);
    -webkit-mask-image: linear-gradient(to right, transparent 10%, #000 70%); mask-image: linear-gradient(to right, transparent 10%, #000 70%); }
.pr-notice-card .pr-notice-ico { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 11px;
    background: var(--color-white, #fff); color: var(--nc-ico); border: 1px solid var(--nc-edge); box-shadow: 0 1px 2px rgba(16, 40, 44, 0.07); }
.pr-notice-card .pr-notice-ico svg { width: 20px; height: 20px; }
.pr-notice-card h2 { margin: 0; font-family: var(--pr-serif); font-size: 1.14rem; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; color: var(--color-heading, #121a16);
    font-optical-sizing: auto; text-wrap: balance; }
.pr-notice-x { align-self: start; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: none;
    color: var(--color-gray, #5a635d); cursor: pointer; }
.pr-notice-x:hover { background: var(--nc-x-hover); color: var(--color-heading, #121a16); }
.pr-notice-card .pr-notice-copy { padding: 0.85rem 1.1rem 0; }
.pr-notice-card .pr-notice-copy:last-child { padding-bottom: 1rem; }
.pr-notice-card .pr-notice-copy p { margin: 0 0 0.45rem; font-size: 0.9rem; line-height: 1.55; color: var(--color-text, #1b2420); text-wrap: pretty; }
.pr-notice-card .pr-notice-copy p:last-child { margin-bottom: 0; }
.pr-notice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; padding: 0.95rem 1.1rem 1.05rem; }
.pr-notice-btn { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 38px; padding: 0 1rem; border-radius: 9px; border: 1px solid var(--pr-brand, #1f6a50);
    background: var(--pr-brand, #1f6a50); color: #fff; font: inherit; font-size: 0.875rem; font-weight: 700; text-decoration: none; cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 40, 44, 0.12); }
.pr-notice-btn:hover { background: var(--pr-brand-deep, #134a38); border-color: var(--pr-brand-deep, #134a38); }
.pr-notice-btn svg { transition: transform 0.15s ease; }
.pr-notice-btn:hover svg { transform: translateX(2px); }
.pr-notice-later { min-height: 38px; padding: 0; border: 0; background: none; font: inherit; font-size: 0.875rem; font-weight: 600; color: var(--color-gray, #5a635d); cursor: pointer; white-space: nowrap; }
.pr-notice-later:hover { color: var(--color-heading, #121a16); text-decoration: underline; text-underline-offset: 0.2em; }
.pr-notice-btn:focus-visible, .pr-notice-later:focus-visible, .pr-notice-x:focus-visible { outline: 2px solid var(--pr-brand, #1f6a50); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
    .pr-notice-card { --nc-tint: #173a2f; --nc-line: rgba(255, 255, 255, 0.05); --nc-edge: rgba(143, 211, 179, 0.16); --nc-ico: #8fd3b3; --nc-x-hover: rgba(255, 255, 255, 0.08);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 22px 44px -16px rgba(0, 0, 0, 0.85); }
    .pr-notice-card.tone-today { --nc-tint: #2b2513; --nc-line: rgba(245, 189, 75, 0.07); --nc-edge: rgba(245, 189, 75, 0.2); --nc-ico: #f5bd4b; --nc-x-hover: rgba(245, 189, 75, 0.12); }
    .pr-notice-card.tone-warning { --nc-tint: #361c19; --nc-line: rgba(248, 113, 113, 0.07); --nc-edge: rgba(248, 113, 113, 0.24); --nc-ico: #f28b82; --nc-x-hover: rgba(248, 113, 113, 0.12);
        border-color: rgba(242, 139, 130, 0.4); }
    .pr-notice-card .pr-notice-ico { box-shadow: none; }
    .pr-notice-btn:focus-visible, .pr-notice-later:focus-visible, .pr-notice-x:focus-visible { outline-color: #8fd3b3; }
}
@media (max-width: 560px) {
    .pr-notice-card { left: 0.75rem; right: 0.75rem; width: auto; bottom: calc(var(--pr-card-bottom, 0.75rem) + env(safe-area-inset-bottom)); }
    .pr-notice-x { width: 40px; height: 40px; margin: -0.3rem -0.2rem -0.3rem 0; align-self: center; }
    .pr-notice-btn, .pr-notice-later { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .pr-notice-card, .pr-notice-card.leaving { animation: none; transition: none; } .pr-notice-link svg, .pr-notice-btn svg { transition: none; } }
@media print { .pr-notice-bar, .pr-notice-card { display: none !important; } }

/* ---------- Switching between light and dark mode ---------- */
/* With the View Transitions API: the new theme spreads out in a circle from the toggle button */
html.ph-theme-reveal::view-transition-old(root), html.ph-theme-reveal::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.ph-theme-reveal::view-transition-new(root) { animation: ph-theme-reveal 0.55s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes ph-theme-reveal {
    from { clip-path: circle(0 at var(--ph-vt-x, 50%) var(--ph-vt-y, 0)); }
    to { clip-path: circle(var(--ph-vt-r, 150%) at var(--ph-vt-x, 50%) var(--ph-vt-y, 0)); }
}
/* Without it (and when the device itself switches): a short colour fade */
html.ph-theme-fade, html.ph-theme-fade *, html.ph-theme-fade *::before, html.ph-theme-fade *::after {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, fill 0.35s ease, stroke 0.35s ease, box-shadow 0.35s ease, outline-color 0.35s ease !important;
}

/* ---------- Metallic badges with a sheen: Pro (silver) and Admin (gold) by default, and any role or plan tag set to
   "Metallic" in Admin (badge-metal, colour in --metal). Built from one colour, so any colour works. Beats older per-page styles. ---------- */
:root .badge-pro, :root .ph-badge-pro { --metal: #aeb8c1; color: #1a2027; }
:root .badge-admin, :root .ph-badge-admin { --metal: #d4a020; color: #2b1d00; }
:root .badge-metal, :root .badge-pro, :root .ph-badge-pro, :root .badge-admin, :root .ph-badge-admin {
    background-color: var(--metal);
    background-image:
        linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.8) 46%, rgba(255, 255, 255, 0.2) 54%, transparent 64%),
        linear-gradient(180deg,
            color-mix(in srgb, var(--metal) 40%, #fff) 0%,
            color-mix(in srgb, var(--metal) 78%, #fff) 16%,
            color-mix(in srgb, var(--metal) 52%, #fff) 32%,
            var(--metal) 50%,
            color-mix(in srgb, var(--metal) 84%, #fff) 66%,
            color-mix(in srgb, var(--metal) 70%, #000) 86%,
            color-mix(in srgb, var(--metal) 90%, #fff) 100%);
    background-size: 260% 100%, 100% 100%;
    background-position: 85% 0, 0 0;
    background-repeat: no-repeat;
    border: 1px solid color-mix(in srgb, var(--metal) 60%, #000);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.3);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
    letter-spacing: 0.04em;
    transition: background-position 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Dark metal colours carry white text: shadow it the other way so it stays crisp */
:root .badge-metal.metal-ink-light { text-shadow: 0 1px 1px rgba(0, 0, 0, 0.55); }
:root .badge-metal svg, :root .badge-admin svg, :root .ph-badge-admin svg { filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45)); }
:root .badge-metal:hover, :root .badge-pro:hover, :root .ph-badge-pro:hover, :root .badge-admin:hover, :root .ph-badge-admin:hover { background-position: -15% 0, 0 0; }
@media (prefers-color-scheme: dark) {
    :root .badge-metal, :root .badge-pro, :root .ph-badge-pro, :root .badge-admin, :root .ph-badge-admin {
        border-color: color-mix(in srgb, var(--metal) 55%, #fff);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.55);
    }
}
@media (prefers-reduced-motion: reduce) { :root .badge-metal, :root .badge-pro, :root .ph-badge-pro, :root .badge-admin, :root .ph-badge-admin { transition: none; } }

/* ---------- Galaxy badges (finish "Galaxy" in Admin): a nebula tinted by the tag colour (--metal), twinkling stars and a slow drift ---------- */
:root .badge-galaxy {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    color: #fff;
    background-color: #0d0a24;
    background-image:
        radial-gradient(ellipse 55% 130% at 18% 35%, color-mix(in srgb, var(--metal) 90%, transparent), transparent 70%),
        radial-gradient(ellipse 50% 120% at 82% 65%, color-mix(in srgb, color-mix(in srgb, var(--metal) 45%, #ff4fd8) 75%, transparent), transparent 72%),
        radial-gradient(ellipse 40% 90% at 55% 15%, color-mix(in srgb, color-mix(in srgb, var(--metal) 50%, #38bdf8) 55%, transparent), transparent 70%),
        linear-gradient(115deg, #07051a 0%, color-mix(in srgb, var(--metal) 30%, #0d0a24) 50%, #05030f 100%);
    background-size: 220% 100%, 220% 100%, 200% 100%, 100% 100%;
    background-position: 0% 0, 100% 0, 50% 0, 0 0;
    background-repeat: no-repeat;
    border: 1px solid color-mix(in srgb, var(--metal) 55%, #fff);
    box-shadow: 0 0 7px color-mix(in srgb, var(--metal) 55%, transparent), inset 0 0 6px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
    text-shadow: 0 0 5px color-mix(in srgb, var(--metal) 60%, #fff), 0 1px 1px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.04em;
    animation: ph-galaxy-drift 9s ease-in-out infinite alternate;
}
/* The stars: a layer behind the text that twinkles */
:root .badge-galaxy::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 9% 28%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 22% 74%, rgba(255, 255, 255, 0.85) 50%, transparent 51%),
        radial-gradient(1.4px 1.4px at 37% 20%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 51% 80%, rgba(255, 255, 255, 0.75) 50%, transparent 51%),
        radial-gradient(1px 1px at 64% 34%, #fff 50%, transparent 51%),
        radial-gradient(1.4px 1.4px at 78% 70%, rgba(255, 255, 255, 0.9) 50%, transparent 51%),
        radial-gradient(1px 1px at 90% 22%, #fff 50%, transparent 51%),
        radial-gradient(1px 1px at 96% 86%, rgba(255, 255, 255, 0.7) 50%, transparent 51%);
    animation: ph-galaxy-twinkle 3.2s ease-in-out infinite alternate;
}
:root .badge-galaxy svg { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--metal) 60%, #fff)); }
:root .badge-galaxy:hover { box-shadow: 0 0 12px color-mix(in srgb, var(--metal) 75%, transparent), inset 0 0 6px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
@keyframes ph-galaxy-drift {
    from { background-position: 0% 0, 100% 0, 50% 0, 0 0; }
    to { background-position: 100% 0, 0% 0, 20% 0, 0 0; }
}
@keyframes ph-galaxy-twinkle { from { opacity: 0.55; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { :root .badge-galaxy, :root .badge-galaxy::before { animation: none; } }

/* ---------- Moving between pages ----------
   Pages fade into each other instead of flashing white. (Don't give #site-header a view-transition-name:
   it creates a stacking context and traps the dropdown menus under the page.)
   (Speculation rules in site-header.js load the next page while the pointer rests on a link.) */
@media (prefers-reduced-motion: no-preference) {
    @view-transition { navigation: auto; }
    ::view-transition-old(root) { animation: 0.14s ease-in both ph-page-out; }
    ::view-transition-new(root) { animation: 0.24s cubic-bezier(0.16, 1, 0.3, 1) both ph-page-in; }
}
@keyframes ph-page-out { to { opacity: 0; } }
@keyframes ph-page-in { from { opacity: 0; transform: translateY(6px); } }
/* Hold the header's space before its script draws it, so the page doesn't jump */
#site-header:empty { min-height: 68px; }
@media (max-width: 960px) { #site-header:empty { min-height: 60px; } }
/* Notice links are tap targets too: at least 24px tall */
.pr-notice-link { min-height: 24px; }

/* ---------- Moving within a page ----------
   Links to a section glide there, and the section you land on glows briefly so the eye finds it. */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
    :is(h2, h3, section, li)[id]:target { animation: ph-arrive 1.8s cubic-bezier(0.16, 1, 0.3, 1); border-radius: 6px; }
}
@keyframes ph-arrive { from { background-color: color-mix(in srgb, #6fb594 30%, transparent); } to { background-color: transparent; } }
