/* ==========================================================================
   FourHeroes design system
   --------------------------------------------------------------------------
   Direction: "logbook after dark". FourHeroes is a private nightly record, so
   the chrome behaves like a bound notebook rather than a dashboard: a quiet
   cool-paper ground, ink text, one deep-teal accent, and a page header that is
   always night. Headings are set in an old-style serif (the voice of a written
   record); every bounded score is set in tabular mono so columns of numbers
   line up.

   Everything below is driven by the tokens in the first two blocks. Change a
   token, not a rule.

   Colour modes
   ------------
   The document always carries an explicit `data-bs-theme` (the inline script in
   base.html sets it before first paint from localStorage, falling back to the
   OS preference), because Bootstrap 5.3 only switches its own components on
   that attribute. The `prefers-color-scheme` block below is the no-JS
   fallback: our own tokens flip, while a handful of Bootstrap's subtle alert
   backgrounds stay light. Keep the two dark blocks in sync.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens — light
   -------------------------------------------------------------------------- */
:root {
    /* Type */
    --fh-font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, "Times New Roman", serif;
    --fh-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
    --fh-font-mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

    /* Spacing scale */
    --fh-sp-1: 0.25rem;
    --fh-sp-2: 0.5rem;
    --fh-sp-3: 0.75rem;
    --fh-sp-4: 1rem;
    --fh-sp-5: 1.5rem;
    --fh-sp-6: 2rem;
    --fh-sp-7: 3rem;
    --fh-sp-8: 4rem;

    /* Radii */
    --fh-r-sm: 8px;
    --fh-r: 12px;
    --fh-r-lg: 18px;
    --fh-r-pill: 999px;

    /* Chrome metrics */
    --fh-nav-h: 64px;
    --fh-card-pad-y: 1.4rem;
    --fh-card-pad-x: 1.5rem;

    /* Surfaces and ink */
    --fh-paper: #e9edf1;
    --fh-surface: #ffffff;
    --fh-surface-2: #f3f6f8;
    --fh-line: #dae1e8;
    --fh-line-strong: #c3cdd7;
    --fh-ink: #131c26;
    --fh-body: #35455a;
    --fh-body-rgb: 53, 69, 90;
    --fh-muted: #62748a;

    /* Brand — "tide". Two tones: a deeper one for fills under white text,
       a text tone for links and icons on paper. */
    --fh-brand: #0b5b60;
    --fh-brand-rgb: 11, 91, 96;
    --fh-brand-fill: #0e6b70;
    --fh-brand-fill-rgb: 14, 107, 112;
    --fh-brand-deep: #084b4f;
    --fh-brand-soft: #dceaea;
    --fh-brand-line: #a7cbcb;
    --fh-focus: rgba(14, 107, 112, 0.25);

    /* Semantic pairs — text tone / fill tone (fills always carry white text) */
    --fh-ok: #157347;
    --fh-ok-rgb: 21, 115, 71;
    --fh-ok-fill-rgb: 21, 115, 71;
    --fh-warn: #b0740c;
    --fh-warn-rgb: 176, 116, 12;
    --fh-warn-fill-rgb: 224, 165, 38;
    --fh-bad: #c42d25;
    --fh-bad-rgb: 196, 45, 37;
    --fh-bad-fill-rgb: 196, 45, 37;
    --fh-info: #12657a;
    --fh-info-rgb: 18, 101, 122;
    --fh-info-fill-rgb: 23, 117, 138;
    --fh-neutral-rgb: 90, 107, 125;
    --fh-neutral-fill-rgb: 90, 107, 125;

    /* Score bands — used by the week strip and any mood-tinted surface */
    --fh-band-ok-bg: #dff1e6;
    --fh-band-ok-line: #a8d8bd;
    --fh-band-ok-ink: #14653c;
    --fh-band-mid-bg: #fbefd6;
    --fh-band-mid-line: #e8d0a0;
    --fh-band-mid-ink: #7a5310;
    --fh-band-low-bg: #fbe2e1;
    --fh-band-low-line: #edb6b2;
    --fh-band-low-ink: #8e241d;

    /* Night — the page header band, dark in both modes */
    --fh-night-1: #0e141c;
    --fh-night-2: #14262d;
    --fh-night-3: #103138;
    --fh-night-glow: rgba(79, 179, 181, 0.28);
    --fh-on-night: rgba(255, 255, 255, 0.78);
    --fh-on-night-dim: rgba(255, 255, 255, 0.58);

    /* Navigation */
    --fh-nav-bg: rgba(255, 255, 255, 0.88);

    /* Elevation */
    --fh-shadow: 0 1px 2px rgba(19, 28, 38, 0.05), 0 10px 24px -14px rgba(19, 28, 38, 0.28);
    --fh-shadow-nav: 0 1px 0 rgba(19, 28, 38, 0.06), 0 8px 24px -18px rgba(19, 28, 38, 0.45);

    /* Charts (read by static/js/app.js) */
    --fh-chart-text: #4a5b70;
    --fh-chart-grid: #e2e8ee;
    --fh-chart-zero: #c3cdd7;
}

/* --------------------------------------------------------------------------
   2. Tokens — dark. Two selectors, one palette: keep them in sync.
   -------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-bs-theme="light"]) {
        color-scheme: dark;

        --fh-paper: #0c1219;
        --fh-surface: #141d28;
        --fh-surface-2: #1b2734;
        --fh-line: #26333f;
        --fh-line-strong: #3a4a5a;
        --fh-ink: #eaeff4;
        --fh-body: #bccad8;
        --fh-body-rgb: 188, 202, 216;
        --fh-muted: #8a9bac;

        --fh-brand: #5cc4c5;
        --fh-brand-rgb: 92, 196, 197;
        --fh-brand-fill: #14868c;
        --fh-brand-fill-rgb: 20, 134, 140;
        --fh-brand-deep: #0e6b70;
        --fh-brand-soft: #102e31;
        --fh-brand-line: #1e4b4e;
        --fh-focus: rgba(92, 196, 197, 0.3);

        --fh-ok: #5fc48f;
        --fh-ok-rgb: 95, 196, 143;
        --fh-ok-fill-rgb: 21, 115, 71;
        --fh-warn: #e0a526;
        --fh-warn-rgb: 224, 165, 38;
        --fh-warn-fill-rgb: 224, 165, 38;
        --fh-bad: #f08078;
        --fh-bad-rgb: 240, 128, 120;
        --fh-bad-fill-rgb: 196, 45, 37;
        --fh-info: #58c5db;
        --fh-info-rgb: 88, 197, 219;
        --fh-info-fill-rgb: 23, 117, 138;
        --fh-neutral-rgb: 138, 155, 172;
        --fh-neutral-fill-rgb: 70, 88, 107;

        --fh-band-ok-bg: #102a1d;
        --fh-band-ok-line: #1e4a34;
        --fh-band-ok-ink: #74d2a0;
        --fh-band-mid-bg: #2c2210;
        --fh-band-mid-line: #4c3b18;
        --fh-band-mid-ink: #e5bc63;
        --fh-band-low-bg: #2e1512;
        --fh-band-low-line: #52251f;
        --fh-band-low-ink: #ec9c96;

        --fh-night-1: #080d13;
        --fh-night-2: #101f25;
        --fh-night-3: #0c2a30;
        --fh-night-glow: rgba(79, 179, 181, 0.22);
        --fh-on-night: rgba(255, 255, 255, 0.74);
        --fh-on-night-dim: rgba(255, 255, 255, 0.52);

        --fh-nav-bg: rgba(12, 18, 25, 0.88);

        --fh-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 12px 28px -16px rgba(0, 0, 0, 0.8);
        --fh-shadow-nav: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px -18px rgba(0, 0, 0, 0.9);

        --fh-chart-text: #93a4b5;
        --fh-chart-grid: #232f3b;
        --fh-chart-zero: #3a4a5a;
    }
}

:root[data-bs-theme="dark"] {
    --fh-paper: #0c1219;
    --fh-surface: #141d28;
    --fh-surface-2: #1b2734;
    --fh-line: #26333f;
    --fh-line-strong: #3a4a5a;
    --fh-ink: #eaeff4;
    --fh-body: #bccad8;
    --fh-body-rgb: 188, 202, 216;
    --fh-muted: #8a9bac;

    --fh-brand: #5cc4c5;
    --fh-brand-rgb: 92, 196, 197;
    --fh-brand-fill: #14868c;
    --fh-brand-fill-rgb: 20, 134, 140;
    --fh-brand-deep: #0e6b70;
    --fh-brand-soft: #102e31;
    --fh-brand-line: #1e4b4e;
    --fh-focus: rgba(92, 196, 197, 0.3);

    --fh-ok: #5fc48f;
    --fh-ok-rgb: 95, 196, 143;
    --fh-ok-fill-rgb: 21, 115, 71;
    --fh-warn: #e0a526;
    --fh-warn-rgb: 224, 165, 38;
    --fh-warn-fill-rgb: 224, 165, 38;
    --fh-bad: #f08078;
    --fh-bad-rgb: 240, 128, 120;
    --fh-bad-fill-rgb: 196, 45, 37;
    --fh-info: #58c5db;
    --fh-info-rgb: 88, 197, 219;
    --fh-info-fill-rgb: 23, 117, 138;
    --fh-neutral-rgb: 138, 155, 172;
    --fh-neutral-fill-rgb: 70, 88, 107;

    --fh-band-ok-bg: #102a1d;
    --fh-band-ok-line: #1e4a34;
    --fh-band-ok-ink: #74d2a0;
    --fh-band-mid-bg: #2c2210;
    --fh-band-mid-line: #4c3b18;
    --fh-band-mid-ink: #e5bc63;
    --fh-band-low-bg: #2e1512;
    --fh-band-low-line: #52251f;
    --fh-band-low-ink: #ec9c96;

    --fh-night-1: #080d13;
    --fh-night-2: #101f25;
    --fh-night-3: #0c2a30;
    --fh-night-glow: rgba(79, 179, 181, 0.22);
    --fh-on-night: rgba(255, 255, 255, 0.74);
    --fh-on-night-dim: rgba(255, 255, 255, 0.52);

    --fh-nav-bg: rgba(12, 18, 25, 0.88);

    --fh-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 12px 28px -16px rgba(0, 0, 0, 0.8);
    --fh-shadow-nav: 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 24px -18px rgba(0, 0, 0, 0.9);

    --fh-chart-text: #93a4b5;
    --fh-chart-grid: #232f3b;
    --fh-chart-zero: #3a4a5a;
}

/* --------------------------------------------------------------------------
   3. Bridge — hand the tokens to Bootstrap so its components follow along
      without every template growing an override.
   -------------------------------------------------------------------------- */
:root {
    --bs-body-font-family: var(--fh-font-body);
    --bs-body-color: var(--fh-body);
    --bs-body-color-rgb: var(--fh-body-rgb);

    /* Bootstrap derives card / form / dropdown / table backgrounds from
       --bs-body-bg, so that token is the *surface*; the page ground is painted
       on <body> below. */
    --bs-body-bg: var(--fh-surface);
    --bs-emphasis-color: var(--fh-ink);
    --bs-heading-color: var(--fh-ink);
    --bs-secondary-color: var(--fh-muted);
    --bs-secondary-bg: var(--fh-surface-2);
    --bs-tertiary-bg: var(--fh-surface-2);
    --bs-tertiary-color: var(--fh-muted);

    --bs-border-color: var(--fh-line);
    --bs-border-color-translucent: var(--fh-line);
    --bs-border-radius: var(--fh-r);
    --bs-border-radius-sm: var(--fh-r-sm);
    --bs-border-radius-lg: var(--fh-r-lg);
    --bs-border-radius-xl: var(--fh-r-lg);

    --bs-primary: var(--fh-brand);
    --bs-primary-rgb: var(--fh-brand-rgb);
    --bs-success: var(--fh-ok);
    --bs-success-rgb: var(--fh-ok-rgb);
    --bs-warning-rgb: var(--fh-warn-rgb);
    --bs-danger: var(--fh-bad);
    --bs-danger-rgb: var(--fh-bad-rgb);
    --bs-info: var(--fh-info);
    --bs-info-rgb: var(--fh-info-rgb);
    --bs-secondary-rgb: var(--fh-neutral-rgb);

    --bs-link-color: var(--fh-brand);
    --bs-link-color-rgb: var(--fh-brand-rgb);
    --bs-link-hover-color: var(--fh-ink);
    --bs-link-hover-color-rgb: var(--fh-body-rgb);

    --bs-focus-ring-color: var(--fh-focus);
    --bs-code-color: var(--fh-brand);
}

/* `.text-*` wants the readable tone; `.bg-*` wants the fill tone that carries
   white text. Re-pointing the variable the utility already reads keeps this
   free of `!important`. */
.bg-primary { --bs-primary-rgb: var(--fh-brand-fill-rgb); }
.bg-success { --bs-success-rgb: var(--fh-ok-fill-rgb); }
.bg-warning { --bs-warning-rgb: var(--fh-warn-fill-rgb); }
.bg-danger { --bs-danger-rgb: var(--fh-bad-fill-rgb); }
.bg-info { --bs-info-rgb: var(--fh-info-fill-rgb); }
.bg-secondary { --bs-secondary-rgb: var(--fh-neutral-fill-rgb); }

/* --------------------------------------------------------------------------
   4. Base
   -------------------------------------------------------------------------- */
body {
    background-color: var(--fh-paper);
    color: var(--fh-body);
    font-family: var(--fh-font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.card-title {
    font-family: var(--fh-font-display);
    font-weight: 600;
    letter-spacing: -0.006em;
}

.lead { font-weight: 400; }

a { text-underline-offset: 0.15em; }

hr {
    border-top-color: var(--fh-line);
    opacity: 1;
}

code {
    font-family: var(--fh-font-mono);
    background: var(--fh-brand-soft);
    padding: 0.1em 0.35em;
    border-radius: 5px;
}

:focus-visible {
    outline: 2px solid var(--fh-brand);
    outline-offset: 2px;
}

/* An eyebrow: a small letterspaced label above a value or a section. */
.eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--fh-muted);
}

/* Every bounded score in the app is set here: tabular mono so columns of
   numbers line up down a card or a strip. */
.stat-value {
    font-family: var(--fh-font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-size: clamp(1.55rem, 4vw, 1.95rem);
    line-height: 1.1;
    margin-bottom: 0.2rem;
}

.badge { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   5. Navigation
   -------------------------------------------------------------------------- */
.site-nav {
    min-height: var(--fh-nav-h);
    padding-block: 0.55rem;
    background-color: var(--fh-nav-bg);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--fh-line);
    box-shadow: var(--fh-shadow-nav);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--fh-font-display);
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: -0.015em;
    color: var(--fh-ink);
}

.navbar-brand:hover,
.navbar-brand:focus { color: var(--fh-ink); }

.brand-mark {
    display: grid;
    place-items: center;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 0.6rem;
    background: linear-gradient(145deg, var(--fh-brand-fill), var(--fh-brand-deep));
    color: #fff;
    font-size: 0.78rem;
    flex: none;
}

.site-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.7rem;
    border-radius: var(--fh-r-sm);
    font-size: 0.925rem;
    font-weight: 500;
    color: var(--fh-muted);
    transition: color 0.12s ease, background-color 0.12s ease;
}

.site-nav .nav-link:hover,
.site-nav .nav-link:focus-visible {
    color: var(--fh-ink);
    background-color: var(--fh-surface-2);
}

.site-nav .nav-link.is-current {
    color: var(--fh-brand);
    background-color: var(--fh-brand-soft);
}

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.3rem;
    height: 2.3rem;
    padding: 0;
    border: 1px solid var(--fh-line);
    border-radius: var(--fh-r-sm);
    background-color: transparent;
    color: var(--fh-muted);
    transition: color 0.12s ease, border-color 0.12s ease;
}

.theme-toggle:hover {
    color: var(--fh-ink);
    border-color: var(--fh-line-strong);
}

/* Moon by default (click for dark); sun once dark is on. */
.theme-toggle__icon--light { display: none; }
[data-bs-theme="dark"] .theme-toggle__icon--light { display: inline; }
[data-bs-theme="dark"] .theme-toggle__icon--dark { display: none; }

/* Bootstrap's toggler focus ring is currentColor, which reads as a hard black
   halo on paper. */
.site-nav .navbar-toggler:focus { box-shadow: 0 0 0 0.2rem var(--fh-focus); }

@media (max-width: 991.98px) {
    .site-nav .navbar-collapse {
        margin-top: 0.6rem;
        padding-top: 0.6rem;
        border-top: 1px solid var(--fh-line);
    }

    /* The open menu sits over the page, so it needs its own ground rather than
       the translucent bar's. */
    .site-nav .navbar-collapse.show,
    .site-nav .navbar-collapse.collapsing {
        background-color: var(--fh-nav-bg);
    }
}

/* --------------------------------------------------------------------------
   6. Page shell and header band
   -------------------------------------------------------------------------- */
.site-main {
    padding-top: calc(var(--fh-nav-h) + var(--fh-sp-5));
    padding-bottom: var(--fh-sp-8);
}

/* The page header is always night: it keeps the `text-white` utilities the
   templates already use working, and gives every page the same masthead
   instead of each hero styling itself. */
.hero-section {
    position: relative;
    padding: clamp(1.6rem, 4vw, 2.75rem) clamp(1.25rem, 4vw, 2.5rem);
    margin: 0 0 var(--fh-sp-6);
    border-radius: var(--fh-r-lg);
    background:
        radial-gradient(125% 95% at 88% -25%, var(--fh-night-glow), transparent 62%),
        linear-gradient(148deg, var(--fh-night-1) 0%, var(--fh-night-2) 58%, var(--fh-night-3) 100%);
    color: var(--fh-on-night);
    box-shadow: var(--fh-shadow);
    --bs-heading-color: #fff;
    --bs-secondary-color: var(--fh-on-night-dim);
}

.hero-section h1 {
    font-size: clamp(1.55rem, 3.4vw, 2.3rem);
    line-height: 1.15;
    margin-bottom: 0.6rem;
}

.hero-section .lead {
    color: var(--fh-on-night);
    font-size: 1.02rem;
    max-width: 58ch;
    margin-inline: auto;
    margin-bottom: 0;
}

.hero-section .text-white-50 { color: var(--fh-on-night-dim) !important; }

/* --------------------------------------------------------------------------
   7. Cards
   -------------------------------------------------------------------------- */
.card {
    --bs-card-bg: var(--fh-surface);
    --bs-card-border-color: var(--fh-line);
    --bs-card-border-radius: var(--fh-r);
    --bs-card-inner-border-radius: calc(var(--fh-r) - 1px);
    --bs-card-spacer-y: var(--fh-card-pad-y);
    --bs-card-spacer-x: var(--fh-card-pad-x);
    --bs-card-cap-padding-y: 0.85rem;
    --bs-card-cap-padding-x: var(--fh-card-pad-x);
    --bs-card-cap-bg: var(--fh-surface-2);
    --bs-card-cap-color: var(--fh-ink);
    --bs-card-title-spacer-y: 0.75rem;
    box-shadow: var(--fh-shadow);
}

.card > .card-body { --bs-card-title-color: var(--fh-ink); }

/* Titles inside a tinted header take the header's colour, not the ink token. */
.card-header { --bs-heading-color: inherit; }

.card-title { font-size: 1.08rem; }

h4.card-title { font-size: 1.2rem; }

/* --------------------------------------------------------------------------
   8. Buttons, forms, tables
   -------------------------------------------------------------------------- */
.btn {
    --bs-btn-border-radius: var(--fh-r-sm);
    --bs-btn-font-weight: 500;
    --bs-btn-padding-x: 1rem;
    --bs-btn-padding-y: 0.45rem;
}

.btn-lg {
    --bs-btn-padding-x: 1.4rem;
    --bs-btn-padding-y: 0.65rem;
    --bs-btn-font-size: 1.02rem;
}

.btn-primary {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--fh-brand-fill);
    --bs-btn-border-color: var(--fh-brand-fill);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--fh-brand-deep);
    --bs-btn-hover-border-color: var(--fh-brand-deep);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--fh-brand-deep);
    --bs-btn-active-border-color: var(--fh-brand-deep);
    --bs-btn-disabled-bg: var(--fh-brand-fill);
    --bs-btn-disabled-border-color: var(--fh-brand-fill);
}

.btn-outline-primary {
    --bs-btn-color: var(--fh-brand);
    --bs-btn-border-color: var(--fh-brand-line);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--fh-brand-fill);
    --bs-btn-hover-border-color: var(--fh-brand-fill);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--fh-brand-deep);
    --bs-btn-active-border-color: var(--fh-brand-deep);
    --bs-btn-disabled-color: var(--fh-brand);
    --bs-btn-disabled-border-color: var(--fh-brand-line);
}

.btn-outline-secondary {
    --bs-btn-color: var(--fh-body);
    --bs-btn-border-color: var(--fh-line-strong);
    --bs-btn-hover-color: var(--fh-ink);
    --bs-btn-hover-bg: var(--fh-surface-2);
    --bs-btn-hover-border-color: var(--fh-line-strong);
    --bs-btn-active-color: var(--fh-ink);
    --bs-btn-active-bg: var(--fh-surface-2);
    --bs-btn-active-border-color: var(--fh-line-strong);
    --bs-btn-disabled-color: var(--fh-muted);
    --bs-btn-disabled-border-color: var(--fh-line);
}

/* Bootstrap's amber outline is 2.2:1 on paper; use the readable warn tone. */
.btn-outline-warning {
    --bs-btn-color: var(--fh-band-mid-ink);
    --bs-btn-border-color: var(--fh-band-mid-line);
    --bs-btn-hover-color: var(--fh-band-mid-ink);
    --bs-btn-hover-bg: var(--fh-band-mid-bg);
    --bs-btn-hover-border-color: var(--fh-band-mid-ink);
    --bs-btn-active-color: var(--fh-band-mid-ink);
    --bs-btn-active-bg: var(--fh-band-mid-bg);
    --bs-btn-active-border-color: var(--fh-band-mid-ink);
    --bs-btn-disabled-color: var(--fh-band-mid-ink);
    --bs-btn-disabled-border-color: var(--fh-band-mid-line);
}

.btn-danger {
    --bs-btn-bg: rgb(var(--fh-bad-fill-rgb));
    --bs-btn-border-color: rgb(var(--fh-bad-fill-rgb));
    --bs-btn-hover-bg: #a52620;
    --bs-btn-hover-border-color: #a52620;
    --bs-btn-active-bg: #a52620;
    --bs-btn-active-border-color: #a52620;
}

.form-control,
.form-select {
    border-radius: var(--fh-r-sm);
    padding: 0.6rem 0.8rem;
    background-color: var(--fh-surface);
    border-color: var(--fh-line-strong);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--fh-brand);
    box-shadow: 0 0 0 0.2rem var(--fh-focus);
}

/* The auth forms render Django's bare widgets, which never picked up
   `.form-control` and so fell through to the browser default. */
input[type="text"]:not([class]),
input[type="password"]:not([class]),
input[type="email"]:not([class]) {
    display: block;
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--fh-body);
    background-color: var(--fh-surface);
    border: 1px solid var(--fh-line-strong);
    border-radius: var(--fh-r-sm);
}

input[type="text"]:not([class]):focus,
input[type="password"]:not([class]):focus,
input[type="email"]:not([class]):focus {
    outline: none;
    border-color: var(--fh-brand);
    box-shadow: 0 0 0 0.2rem var(--fh-focus);
}

.form-label {
    font-weight: 600;
    color: var(--fh-ink);
    margin-bottom: 0.4rem;
}

.form-check-input:checked {
    background-color: var(--fh-brand-fill);
    border-color: var(--fh-brand-fill);
}

.form-check-input:focus {
    border-color: var(--fh-brand);
    box-shadow: 0 0 0 0.2rem var(--fh-focus);
}

.table {
    --bs-table-border-color: var(--fh-line);
    --bs-table-hover-bg: var(--fh-surface-2);
    --bs-table-hover-color: var(--fh-ink);
}

.table > thead th {
    font-family: var(--fh-font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fh-muted);
    border-bottom-color: var(--fh-line-strong);
}

.table > tbody td { vertical-align: middle; }

.alert { border-radius: var(--fh-r-sm); }

.progress {
    background-color: rgba(255, 255, 255, 0.18);
    border-radius: var(--fh-r-pill);
}

.progress-bar {
    background: linear-gradient(90deg, var(--fh-brand-fill), #4fb3b5);
    border-radius: var(--fh-r-pill);
}

/* --------------------------------------------------------------------------
   9. The week strip — the signature element.
      Seven nights, one tile each: the weekday, then that day's mood score in
      tabular mono, tinted by its band. Days with nothing logged are dashed and
      offer a "+". Today carries the brand ring.
   -------------------------------------------------------------------------- */
.day-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.day-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    min-width: 3.1rem;
    padding: 0.45rem 0.35rem 0.5rem;
    border: 1px solid var(--fh-line);
    border-radius: var(--fh-r-sm);
    background-color: var(--fh-surface-2);
    color: var(--fh-muted);
    text-decoration: none;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.day-chip:hover,
.day-chip:focus-visible {
    transform: translateY(-1px);
    border-color: var(--fh-brand);
    color: var(--fh-muted);
}

.day-chip__dow {
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.day-chip__val {
    font-family: var(--fh-font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    color: var(--fh-ink);
}

.day-chip--ok { background-color: var(--fh-band-ok-bg); border-color: var(--fh-band-ok-line); }
.day-chip--ok .day-chip__val { color: var(--fh-band-ok-ink); }
.day-chip--mid { background-color: var(--fh-band-mid-bg); border-color: var(--fh-band-mid-line); }
.day-chip--mid .day-chip__val { color: var(--fh-band-mid-ink); }
.day-chip--low { background-color: var(--fh-band-low-bg); border-color: var(--fh-band-low-line); }
.day-chip--low .day-chip__val { color: var(--fh-band-low-ink); }

.day-chip--empty {
    border-style: dashed;
    background-color: transparent;
}

.day-chip--empty .day-chip__val {
    color: var(--fh-muted);
    font-weight: 400;
}

.day-chip--today {
    border-color: transparent;
    box-shadow: 0 0 0 2px var(--fh-brand);
}

/* --------------------------------------------------------------------------
   10. Charts — the plot draws on the card, so the paper shows through.
   -------------------------------------------------------------------------- */
.js-plot { width: 100%; }

.js-plot .modebar { filter: none; }

/* --------------------------------------------------------------------------
   11. Narrow viewports
   -------------------------------------------------------------------------- */
@media (max-width: 575.98px) {
    :root {
        --fh-nav-h: 58px;
        --fh-card-pad-y: 1.1rem;
        --fh-card-pad-x: 1.1rem;
    }

    .hero-section { border-radius: var(--fh-r); }

    .day-chip { min-width: 2.7rem; }
}
