/* --- Base & Theme Variables --- */
:root {
    /* Colour lives here, as "R G B" triplets, because Tailwind's utilities
       are compiled once and reference these variables -- so a theme is a
       swap of thirty-three values rather than a second stylesheet.

       Triplets rather than hex so `rgb(var(--x) / 0.1)` works, which is
       what every bg-primary/10 in the templates compiles to. */
    color-scheme: light;
    --md-sys-color-primary: 103 80 164;
    --md-sys-color-on-primary: 255 255 255;
    --md-sys-color-primary-container: 234 221 255;
    --md-sys-color-on-primary-container: 33 0 93;
    --md-sys-color-secondary: 98 91 113;
    --md-sys-color-on-secondary: 255 255 255;
    --md-sys-color-secondary-container: 232 222 248;
    --md-sys-color-on-secondary-container: 29 25 43;
    --md-sys-color-tertiary: 125 82 96;
    --md-sys-color-on-tertiary: 255 255 255;
    --md-sys-color-tertiary-container: 255 216 228;
    --md-sys-color-on-tertiary-container: 49 17 29;
    --md-sys-color-error: 179 38 30;
    --md-sys-color-on-error: 255 255 255;
    --md-sys-color-error-container: 249 222 220;
    --md-sys-color-on-error-container: 65 14 11;
    --md-sys-color-background: 255 251 254;
    --md-sys-color-on-background: 28 27 31;
    --md-sys-color-surface: 255 251 254;
    --md-sys-color-on-surface: 28 27 31;
    --md-sys-color-surface-variant: 231 224 236;
    --md-sys-color-on-surface-variant: 73 69 79;
    --md-sys-color-surface-bright: 254 247 255;
    --md-sys-color-surface-container-highest: 230 224 233;
    --md-sys-color-surface-container-high: 236 230 240;
    --md-sys-color-surface-container: 243 237 247;
    --md-sys-color-surface-container-low: 247 242 250;
    --md-sys-color-surface-container-lowest: 255 255 255;
    --md-sys-color-outline: 121 116 126;
    --md-sys-color-outline-variant: 202 196 208;
    --md-sys-color-inverse-surface: 49 48 51;
    --md-sys-color-inverse-on-surface: 244 239 244;
    --md-sys-color-inverse-primary: 208 188 255;
    --md-sys-color-feature: 28 27 31;
    --md-sys-color-on-feature: 255 251 254;
    /* The site is light. Browsers that are not told this invent a dark
       version by inverting every colour -- Chrome's auto dark mode -- and
       the result is not a design anybody chose: form fields and shadows
       survive the inversion, hand-written panels do not, and the page
       comes out in two halves. Declaring it is what turns that off. */


    --drawer-width: 280px;
}

/* The dark theme. Material Design 3's baseline dark scheme, the counterpart
   of the light one above -- not the light colours darkened, which is what a
   browser does on its own and why it never looks right. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --md-sys-color-primary: 208 188 255;
        --md-sys-color-on-primary: 56 30 114;
        --md-sys-color-primary-container: 79 55 139;
        --md-sys-color-on-primary-container: 234 221 255;
        --md-sys-color-secondary: 204 194 220;
        --md-sys-color-on-secondary: 51 45 65;
        --md-sys-color-secondary-container: 74 68 88;
        --md-sys-color-on-secondary-container: 232 222 248;
        --md-sys-color-tertiary: 239 184 200;
        --md-sys-color-on-tertiary: 73 37 50;
        --md-sys-color-tertiary-container: 99 59 72;
        --md-sys-color-on-tertiary-container: 255 216 228;
        --md-sys-color-error: 242 184 181;
        --md-sys-color-on-error: 96 20 16;
        --md-sys-color-error-container: 140 29 24;
        --md-sys-color-on-error-container: 249 222 220;
        --md-sys-color-background: 20 18 24;
        --md-sys-color-on-background: 230 224 233;
        --md-sys-color-surface: 20 18 24;
        --md-sys-color-on-surface: 230 224 233;
        --md-sys-color-surface-variant: 73 69 79;
        --md-sys-color-on-surface-variant: 202 196 208;
        --md-sys-color-surface-bright: 59 56 62;
        --md-sys-color-surface-container-highest: 54 52 59;
        --md-sys-color-surface-container-high: 43 41 48;
        --md-sys-color-surface-container: 33 31 38;
        --md-sys-color-surface-container-low: 29 27 32;
        --md-sys-color-surface-container-lowest: 15 13 19;
        --md-sys-color-outline: 147 143 153;
        --md-sys-color-outline-variant: 73 69 79;
        --md-sys-color-inverse-surface: 230 224 233;
        --md-sys-color-inverse-on-surface: 50 47 53;
        --md-sys-color-inverse-primary: 103 80 164;
        --md-sys-color-feature: 33 31 38;
        --md-sys-color-on-feature: 230 224 233;
    }
}

/* And the explicit choice, which beats the system preference either way. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --md-sys-color-primary: 208 188 255;
    --md-sys-color-on-primary: 56 30 114;
    --md-sys-color-primary-container: 79 55 139;
    --md-sys-color-on-primary-container: 234 221 255;
    --md-sys-color-secondary: 204 194 220;
    --md-sys-color-on-secondary: 51 45 65;
    --md-sys-color-secondary-container: 74 68 88;
    --md-sys-color-on-secondary-container: 232 222 248;
    --md-sys-color-tertiary: 239 184 200;
    --md-sys-color-on-tertiary: 73 37 50;
    --md-sys-color-tertiary-container: 99 59 72;
    --md-sys-color-on-tertiary-container: 255 216 228;
    --md-sys-color-error: 242 184 181;
    --md-sys-color-on-error: 96 20 16;
    --md-sys-color-error-container: 140 29 24;
    --md-sys-color-on-error-container: 249 222 220;
    --md-sys-color-background: 20 18 24;
    --md-sys-color-on-background: 230 224 233;
    --md-sys-color-surface: 20 18 24;
    --md-sys-color-on-surface: 230 224 233;
    --md-sys-color-surface-variant: 73 69 79;
    --md-sys-color-on-surface-variant: 202 196 208;
    --md-sys-color-surface-bright: 59 56 62;
    --md-sys-color-surface-container-highest: 54 52 59;
    --md-sys-color-surface-container-high: 43 41 48;
    --md-sys-color-surface-container: 33 31 38;
    --md-sys-color-surface-container-low: 29 27 32;
    --md-sys-color-surface-container-lowest: 15 13 19;
    --md-sys-color-outline: 147 143 153;
    --md-sys-color-outline-variant: 73 69 79;
    --md-sys-color-inverse-surface: 230 224 233;
    --md-sys-color-inverse-on-surface: 50 47 53;
    --md-sys-color-inverse-primary: 103 80 164;
    --md-sys-color-feature: 33 31 38;
    --md-sys-color-on-feature: 230 224 233;
}

:root[data-theme="light"] {
    color-scheme: light;
    --md-sys-color-primary: 103 80 164;
    --md-sys-color-on-primary: 255 255 255;
    --md-sys-color-primary-container: 234 221 255;
    --md-sys-color-on-primary-container: 33 0 93;
    --md-sys-color-secondary: 98 91 113;
    --md-sys-color-on-secondary: 255 255 255;
    --md-sys-color-secondary-container: 232 222 248;
    --md-sys-color-on-secondary-container: 29 25 43;
    --md-sys-color-tertiary: 125 82 96;
    --md-sys-color-on-tertiary: 255 255 255;
    --md-sys-color-tertiary-container: 255 216 228;
    --md-sys-color-on-tertiary-container: 49 17 29;
    --md-sys-color-error: 179 38 30;
    --md-sys-color-on-error: 255 255 255;
    --md-sys-color-error-container: 249 222 220;
    --md-sys-color-on-error-container: 65 14 11;
    --md-sys-color-background: 255 251 254;
    --md-sys-color-on-background: 28 27 31;
    --md-sys-color-surface: 255 251 254;
    --md-sys-color-on-surface: 28 27 31;
    --md-sys-color-surface-variant: 231 224 236;
    --md-sys-color-on-surface-variant: 73 69 79;
    --md-sys-color-surface-bright: 254 247 255;
    --md-sys-color-surface-container-highest: 230 224 233;
    --md-sys-color-surface-container-high: 236 230 240;
    --md-sys-color-surface-container: 243 237 247;
    --md-sys-color-surface-container-low: 247 242 250;
    --md-sys-color-surface-container-lowest: 255 255 255;
    --md-sys-color-outline: 121 116 126;
    --md-sys-color-outline-variant: 202 196 208;
    --md-sys-color-inverse-surface: 49 48 51;
    --md-sys-color-inverse-on-surface: 244 239 244;
    --md-sys-color-inverse-primary: 208 188 255;
    --md-sys-color-feature: 28 27 31;
    --md-sys-color-on-feature: 255 251 254;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    background-color: rgb(var(--md-sys-color-background));
    color: rgb(var(--md-sys-color-on-background));
    overflow-x: hidden;
}

/* --- Common Styles --- */
.nav-header {
    display: flex;
    align-items: center;
    padding: 16px 16px 24px 16px;
}

.logo-icon {
    font-size: 24px;
    margin-right: 12px;
    color: rgb(var(--md-sys-color-primary));
}

.app-name {
    font-size: 1.5rem;
    font-weight: 500;
    color: rgb(var(--md-sys-color-on-surface));
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.nav-menu li {
    margin-bottom: 4px;
}

.nav-menu a {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 24px;
    border-radius: 28px;
    text-decoration: none;
    color: rgb(var(--md-sys-color-on-surface-variant));
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-menu a:hover {
    background-color: rgba(29, 25, 43, 0.08);
    color: rgb(var(--md-sys-color-on-surface));
}

.nav-menu a.active {
    background-color: rgb(var(--md-sys-color-secondary-container));
    color: rgb(var(--md-sys-color-on-secondary-container));
}

.nav-menu a .material-symbols-rounded {
    margin-right: 12px;
    font-size: 24px;
}

.divider {
    height: 1px;
    background-color: rgb(var(--md-sys-color-outline));
    margin: 12px 16px;
    opacity: 0.2;
}

.page-title {
    font-size: 1.375rem;
    font-weight: 400;
    margin: 0;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 500;
}

.content-wrapper {
    padding: 24px;
    background-color: rgb(var(--md-sys-color-background));
}

/* --- Form Elements --- */
.form-input-styled {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
    border-radius: 8px;
    background-color: rgb(var(--md-sys-color-surface-bright));
    color: rgb(var(--md-sys-color-on-surface));
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input-styled:focus {
    outline: none;
    border-color: rgb(var(--md-sys-color-primary));
    box-shadow: 0 0 0 2px rgb(var(--md-sys-color-primary-container));
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgb(var(--md-sys-color-outline));
    border-radius: 4px;
    background-color: rgb(var(--md-sys-color-surface));
    color: rgb(var(--md-sys-color-on-surface));
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: rgb(var(--md-sys-color-primary));
    box-shadow: 0 0 0 2px rgb(var(--md-sys-color-primary-container));
}

.form-textarea {
    resize: vertical;
}

/* --- Toast Notifications ---------------------------------------------------
 *
 * Plain CSS rather than Tailwind classes: these are built by JavaScript at
 * runtime, and Tailwind only compiles the classes it can see in a template at
 * build time -- so a class used only from JS silently does nothing.
 *
 * The container sits clear of the support launcher, which is a 56px circle at
 * bottom-right with a z-index near the maximum. Toasts used to render
 * underneath it, so a message like "Confirmation email sent" was cut off by
 * the chat bubble at exactly the moment it mattered.
 */
#toast-container {
    position: fixed;
    /* Above the support launcher (56px) plus its 20px inset, plus breathing
     * room, so the two never overlap. */
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    right: 1.25rem;
    left: 1.25rem;
    z-index: 2147483001;   /* one above the support launcher */
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    pointer-events: none;  /* the gaps between toasts must not eat clicks */
}

.toast-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    max-width: 24rem;
    padding: 0.875rem 1rem;
    border-radius: 0.875rem;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.12), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    background-color: rgb(var(--md-sys-color-inverse-surface));
    color: rgb(var(--md-sys-color-inverse-on-surface));
    font-size: 0.9375rem;
    line-height: 1.4;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

/* Added on the next frame, so the transition has a start state to run from. */
.toast-message.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-message.is-leaving {
    opacity: 0;
    transform: translateY(0.5rem);
}

.toast-message .toast-text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;   /* a long word must wrap, not overflow the card */
}

.toast-message .icon {
    flex: 0 0 auto;
    font-size: 1.25rem;
    line-height: 1.4;
}

.toast-message .toast-close {
    flex: 0 0 auto;
    margin: -0.25rem -0.25rem -0.25rem 0;
    padding: 0.25rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
    font-size: 1.125rem;
    line-height: 1;
}
.toast-message .toast-close:hover,
.toast-message .toast-close:focus-visible {
    opacity: 1;
    background: rgb(255 255 255 / 0.15);
}

/* Colours carry meaning, so each also gets its own icon in the markup --
 * colour alone is not available to everybody. */
.toast-message.success { background-color: #1B5E20; color: #FFFFFF; }
.toast-message.error   { background-color: #8C1D18; color: #FFFFFF; }
.toast-message.warning { background-color: #6D4C00; color: #FFFFFF; }
.toast-message.info    { background-color: #0B4A6F; color: #FFFFFF; }

@media (prefers-reduced-motion: reduce) {
    .toast-message {
        transition: opacity 0.01ms;
        transform: none;
    }
    .toast-message.is-visible,
    .toast-message.is-leaving { transform: none; }
}

@media (max-width: 767px) {
    #toast-container {
        /* Above the mobile bottom navigation bar (64px) and the launcher. */
        bottom: calc(150px + env(safe-area-inset-bottom, 0px));
        align-items: stretch;
    }
    .toast-message { max-width: none; }
}

.pb-safe {
    padding-bottom: env(safe-area-inset-bottom);
}

/* =========================================
   MOBILE FIRST STYLES (Default)
   ========================================= */
.app-container {
    display: block !important; /* Force block on mobile */
    min-height: 100vh;
}

/* Hide desktop sidebar on mobile */
.desktop-sidebar, .desktop-sidebar-nav {
    display: none !important;
}

/* Ensure old class is also hidden if cached HTML is used */
.navigation-drawer {
    display: none !important;
}

.top-app-bar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background-color: rgb(var(--md-sys-color-surface));
    border-bottom: 1px solid rgb(var(--md-sys-color-outline-variant));
    position: sticky;
    top: 0;
    z-index: 90;
    /* Both groups are flex items with `min-width: auto`, so neither can
       shrink below its content and the bar simply grew past the window.
       Signed in there is more in the right-hand group -- support, the
       language switcher, the theme toggle, notifications, the avatar --
       and every signed-in page scrolled sideways on a phone: 407px of bar
       in a 390px window, and 422 in Spanish, where the page title is
       longer again.

       The controls on the right are all needed and are already as small
       as they go, so the title is what gives way. It shrinks and
       ellipsises; nothing else moves. */
    gap: 8px;
}

.top-app-bar > :first-child {
    min-width: 0;
    flex: 0 1 auto;
}

.top-app-bar > :last-child {
    flex: 0 0 auto;
}

.top-app-bar .page-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A strip that scrolls sideways without showing it.
   Used on the home page's section nav, which is a fixed-height pill: a
   horizontal scrollbar inside it eats the height the links need and
   Chrome then paints a *vertical* one too, so the pill arrives with two
   scrollbars across it. `overflow-y: hidden` is what stops the second.

   The class was already on the element and had never been defined
   anywhere, so it did nothing at all. */
.no-scrollbar {
    overflow-y: hidden;
    scrollbar-width: none;            /* Firefox */
    -ms-overflow-style: none;         /* old Edge */
}

.no-scrollbar::-webkit-scrollbar {
    display: none;                    /* Chrome, Safari */
}

/* The home page's section nav.
   On a phone it is a strip you swipe. On anything wider it should simply
   fit, so it hugs its links rather than staying pinned to the 42rem
   `max-w-2xl` the utilities give it -- five Spanish labels need 804px,
   and in a 672px pill two of them were reachable only by dragging a strip
   whose scrollbar is hidden on purpose. */
@media (min-width: 768px) {
    .section-nav {
        width: auto;
        max-width: min(56rem, calc(100% - 2rem));
        justify-content: center;
    }
}

.content-area {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* A grid item's min-width is `auto`, so its track grows to its
       min-content width instead of honouring the 1fr it was given. On the
       home page that pushed the 1fr column to 1120px next to the 280px
       sidebar -- 1400px of layout in a 1280px window, and 120px of
       sideways scroll on every page, in every language. */
    min-width: 0;
}

.content-wrapper {
    padding: 16px;
    padding-bottom: 80px; /* Space for bottom nav */
}

.page-title {
    font-size: 1.25rem;
}

/* Material Symbols filled state for active icons */
.material-symbols-rounded.filled {
    font-variation-settings: 'FILL' 1;
}

/* =========================================
   DESKTOP STYLES (min-width: 768px)
   ========================================= */
@media (min-width: 768px) {
    .app-container {
        display: grid !important;
        grid-template-columns: var(--drawer-width) 1fr;
    }

    .desktop-sidebar, .desktop-sidebar-nav {
        display: flex !important; /* Visible on desktop */
        background-color: rgb(var(--md-sys-color-surface));
        border-right: 1px solid rgb(var(--md-sys-color-outline-variant));
        padding: 12px;
        position: sticky;
        top: 0;
        height: 100vh;
        box-sizing: border-box;
        flex-direction: column;
        z-index: 100;
    }

    /* Reset old class for desktop if needed */
    .navigation-drawer {
        display: flex !important;
    }

    .top-app-bar {
        padding: 0 24px;
    }

    .content-wrapper {
        padding: 24px;
        padding-bottom: 24px; /* Reset padding */
    }

    .page-title {
        font-size: 1.375rem;
    }

}

/* ---------------------------------------------------------------------------
   Tap targets
   ---------------------------------------------------------------------------
   Apple's minimum is 44x44 CSS pixels and Google's is 48x48; 48 is used here
   because it satisfies both and because a control that is exactly at the limit
   is still one people miss.

   Written by hand rather than as Tailwind classes: the arbitrary-value classes
   this needs are not in the compiled stylesheet, and a class Tailwind never
   built is inert -- no error, no warning, the attribute simply does nothing.

   `min-height` and `min-width` rather than fixed sizes, so a control that is
   already comfortable is left alone and only the small ones grow. The flex
   centring keeps the label where it was: the target gets bigger, the design
   does not move.
   --------------------------------------------------------------------------- */
.tap-target {
    min-height: 48px;
    min-width: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* For a link sitting in a row of links, where a minimum width would space
   them out oddly. Height alone is what makes these hittable. */
.tap-target-y {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
}

/* ---------------------------------------------------------------------------
   allauth's own pages
   ---------------------------------------------------------------------------
   Signup, password reset, email confirmation and the rest use allauth's
   templates rather than ones written here, and allauth ships them with no
   classes at all -- browser-default buttons and inputs, small and grey, well
   under a thumb's width on a phone.

   The classes below are applied by overriding two allauth "elements"
   (templates/allauth/elements/), which is its documented extension point and
   themes every one of those pages at once, including ones a future version
   adds.
   --------------------------------------------------------------------------- */
.pt-auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 24px;
    border: 0;
    border-radius: 999px;
    background: rgb(var(--md-sys-color-primary));
    color: rgb(var(--md-sys-color-on-primary));
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.pt-auth-btn:hover { filter: brightness(1.08); }

.pt-auth-btn--quiet {
    background: transparent;
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
    color: rgb(var(--md-sys-color-on-surface));
}

.pt-auth-field { margin: 0 0 16px 0; }

.pt-auth-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(var(--md-sys-color-on-surface-variant));
}

.pt-auth-label--inline {
    display: inline;
    margin: 0 0 0 8px;
    font-weight: 400;
}

.pt-auth-input {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
    border-radius: 16px;
    background: rgb(var(--md-sys-color-surface));
    color: rgb(var(--md-sys-color-on-surface));
    /* 16px or larger. Below that, iOS Safari zooms the whole page the moment
       somebody taps the field, and they have to pinch back out to find the
       button -- on the signup form, of all places. */
    font-size: 1rem;
}

textarea.pt-auth-input { padding: 12px 16px; min-height: 120px; }

.pt-auth-input:focus {
    outline: 2px solid rgb(var(--md-sys-color-primary));
    outline-offset: 1px;
}

/* A checkbox is a tap target too, and the browser default is 13px square. */
.pt-auth-check { width: 20px; height: 20px; }

.pt-auth-help {
    display: block;
    margin-top: 6px;
    font-size: 0.8125rem;
    color: rgb(var(--md-sys-color-on-surface-variant));
}

.errorlist {
    margin: 0 0 8px 0;
    padding: 0;
    list-style: none;
    color: rgb(var(--md-sys-color-error));
    font-size: 0.875rem;
}

/* --- reCAPTCHA v3 badge -----------------------------------------------------
 *
 * v3 asks the visitor nothing; it leaves a small badge pinned to the bottom
 * right of every page that carries one of the protected forms. That is the
 * same corner as the support launcher, so by default the two sit on top of
 * each other -- and on a phone the bottom navigation is under both.
 *
 * Only `bottom` is changed. The badge collapses itself by sliding off the
 * right edge (`right: -186px`) and slides back on hover, so overriding
 * `right` would leave it permanently expanded.
 *
 * Moved, not hidden: Google's terms allow hiding the badge only if the
 * "protected by reCAPTCHA" notice appears in the form instead, and a notice
 * nobody adds is a term nobody keeps.
 */
.grecaptcha-badge {
    /* Clear of the support launcher: 56px circle on a 20px inset. */
    bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    /* Under the toasts and the launcher, above ordinary page content. */
    z-index: 2147482000 !important;
}

@media (max-width: 767px) {
    .grecaptcha-badge {
        /* Above the bottom navigation (64px) and the launcher as well. */
        bottom: calc(150px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* --- Buttons that are working ------------------------------------------- *
 *
 * See static/js/pending.js. The button keeps its own colours; only the
 * spinner and a slightly dimmed label say that something is happening.
 */
.pending-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-inline-end: 0.5em;
    vertical-align: -0.125em;
    border: 2px solid currentColor;
    /* The gap is what makes it read as spinning rather than pulsing. */
    border-top-color: transparent;
    border-radius: 50%;
    animation: pending-spin 0.6s linear infinite;
    flex-shrink: 0;
}

@keyframes pending-spin { to { transform: rotate(360deg); } }

.is-pending {
    /* Not `disabled`: a disabled submit button is not a successful control,
     * so the browser leaves its name and value out of the request. Every
     * view that branches on which button was pressed would stop working. */
    cursor: progress;
    opacity: 0.85;
    /* The click has already been taken. Further ones are noise. */
    pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
    .pending-spinner {
        /* Still visible, still says "working", just not moving. */
        animation: none;
        border-top-color: currentColor;
        opacity: 0.5;
    }
}

/* --- Changing theme -----------------------------------------------------
 *
 * A theme switch repaints every colour on the page at once. Without a
 * transition that is a hard cut, which reads as a flicker or a glitch
 * rather than as something the person just did.
 *
 * The transition is applied only WHILE switching, by a class the script
 * adds and removes. Left on permanently it would put a 220ms fade on every
 * hover and every focus ring on the site, which makes the whole interface
 * feel laggy -- the usual mistake when this is done with a bare
 * `* { transition: background-color ... }`.
 */
.theme-changing,
.theme-changing *,
.theme-changing *::before,
.theme-changing *::after {
    transition: background-color 220ms ease,
                border-color 220ms ease,
                color 220ms ease,
                fill 220ms ease,
                stroke 220ms ease,
                box-shadow 220ms ease !important;
}

/* The icon itself turns over, so the button acknowledges the press even
   on a page that happens to be mostly one flat colour. */
[data-theme-toggle] .material-symbols-rounded {
    transition: transform 320ms cubic-bezier(0.2, 0, 0, 1);
}
[data-theme-toggle].is-turning .material-symbols-rounded {
    transform: rotate(180deg) scale(0.85);
}

@media (prefers-reduced-motion: reduce) {
    .theme-changing,
    .theme-changing *,
    .theme-changing *::before,
    .theme-changing *::after {
        transition: none !important;
    }
    [data-theme-toggle] .material-symbols-rounded,
    [data-theme-toggle].is-turning .material-symbols-rounded {
        transition: none;
        transform: none;
    }
}

/* --- The page shell -----------------------------------------------------
 *
 * One set of primitives every page uses, because the alternative is what
 * this site had: FAQ at max-w-3xl with a centred bold title, About at
 * max-w-4xl inside a card with a coloured banner, Learn at max-w-4xl with
 * a left-aligned medium title, the blog at 68rem in a serif. Four pages,
 * four different widths, three heading sizes, two fonts. Each looked
 * considered on its own and nothing looked like the same website.
 *
 * Anything a page needs that is not here should be added here, not
 * invented in the template.
 */
.page {
    background: rgb(var(--md-sys-color-surface-container));
    min-height: 100dvh;
    padding: 2.5rem 1rem 4rem;
}
@media (min-width: 768px) { .page { padding: 3.5rem 1.5rem 5rem; } }

/* One column width for everything, so the eye does not have to re-find
   the left edge on every navigation. */
.page-inner { max-width: 64rem; margin-inline: auto; }
/* Entry pages -- sign in, register, the password-reset steps. One card,
   vertically centred. There were ten of these and between them they used
   min-h-[calc(100vh-200px)], min-h-[calc(100vh-128px)], min-h-screen and
   nothing at all, with four different card paddings. Same shell, one
   modifier. */
.page.is-centred {
    display: grid;
    place-items: center;
    padding-block: 3rem;
}
.page.is-centred > .page-inner { width: 100%; max-width: 28rem; }

/* For pages that are mostly prose. 44rem is about 75 characters, which is
   where a line stops being comfortable to read. */
.page-inner.is-reading { max-width: 44rem; }

.page-head { margin-bottom: 2.5rem; }
/* `page-heading`, not `page-title`: base.html has used .page-title for the
   top app bar since long before this shell existed, and taking the name
   turned every app-bar title into a 48px headline. */
.page-heading {
    /* One scale, fluid, instead of a different pair of breakpoint classes
       on every page. */
    font-size: clamp(2rem, 1.3rem + 2.6vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 500;
    color: rgb(var(--md-sys-color-on-surface));
    margin: 0;
}
.page-lede {
    margin-top: 0.75rem;
    font-size: 1.125rem;
    line-height: 1.6;
    color: rgb(var(--md-sys-color-on-surface-variant));
    max-width: 60ch;
}
.page-back {
    display: inline-flex; align-items: center; gap: 0.25rem;
    margin-bottom: 1rem;
    font-size: 0.875rem; font-weight: 500;
    color: rgb(var(--md-sys-color-primary));
    text-decoration: none;
}
.page-back:hover { text-decoration: underline; }

/* A surface sitting on the page background. */
.panel {
    background: rgb(var(--md-sys-color-surface-bright));
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
    border-radius: 24px;
}

.page-section { margin-top: 3.5rem; }
.page-section-title {
    font-size: 1.25rem; font-weight: 500; margin: 0 0 0.25rem;
    color: rgb(var(--md-sys-color-on-surface));
}

/* --- Long-form copy -----------------------------------------------------
 *
 * For anything stored as text and rendered to HTML: the About page, a
 * landing page. Without this a stored document renders as one undivided
 * wall, which is what the About page was -- every paragraph the same
 * weight, headings indistinguishable from body text.
 */
.copy { color: rgb(var(--md-sys-color-on-surface)); font-size: 1.0625rem; line-height: 1.7; }
.copy > * + * { margin-top: 1.1rem; }
.copy h2 {
    font-size: 1.5rem; font-weight: 500; line-height: 1.25;
    margin-top: 2.5rem; letter-spacing: -0.01em;
}
.copy h3 { font-size: 1.1875rem; font-weight: 500; margin-top: 1.75rem; }
.copy ul, .copy ol { padding-inline-start: 1.25rem; }
.copy ul { list-style: disc; }
.copy ol { list-style: decimal; }
.copy li + li { margin-top: 0.4rem; }
.copy a { color: rgb(var(--md-sys-color-primary)); text-decoration: underline; text-underline-offset: 2px; }
.copy strong { font-weight: 600; }

/* --- Section headings ---------------------------------------------------
 *
 * The home page alone had five treatments: text-3xl/4xl bold, 4xl/5xl
 * medium, 4xl/6xl black, 3xl/5xl bold, 4xl/5xl black. Each was chosen
 * once and never compared with the others, which is how a page ends up
 * looking like five pages.
 *
 * One size, one weight, one rhythm. `is-centred` where a section is
 * centred; nothing else varies.
 */
.section-head { margin-bottom: 2.5rem; }
.section-head.is-centred { text-align: center; }
.section-head.is-centred .section-lede { margin-inline: auto; }

.section-title {
    font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 500;
    color: rgb(var(--md-sys-color-on-surface));
    margin: 0;
}
.section-lede {
    margin-top: 0.75rem;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: rgb(var(--md-sys-color-on-surface-variant));
    max-width: 58ch;
}

/* A step or card heading inside a section -- one level down, same family. */
.subsection-title {
    font-size: clamp(1.25rem, 1.05rem + 0.8vw, 1.625rem);
    line-height: 1.25;
    font-weight: 500;
    color: rgb(var(--md-sys-color-on-surface));
    margin: 0;
}

/* --- FAQ rows -----------------------------------------------------------
 *
 * <details>, not Alpine. The open state belongs to the element, so it
 * works before any script has run, it is announced correctly, and the
 * browser's own find-in-page can open a closed answer.
 */
.faq-row > .faq-summary {
    display: flex; align-items: center; gap: 1rem;
    padding: 1.125rem 1.25rem;
    cursor: pointer; list-style: none;
    transition: background-color 140ms ease;
}
.faq-row > .faq-summary::-webkit-details-marker { display: none; }
.faq-row > .faq-summary:hover { background: rgb(var(--md-sys-color-on-surface) / 0.04); }
.faq-row > .faq-summary:focus-visible {
    outline: 2px solid rgb(var(--md-sys-color-primary));
    outline-offset: -2px;
}
.faq-question {
    flex: 1; font-size: 1rem; font-weight: 500;
    color: rgb(var(--md-sys-color-on-surface));
}
.faq-chevron {
    flex: none; color: rgb(var(--md-sys-color-on-surface-variant));
    transition: transform 180ms cubic-bezier(0.2, 0, 0, 1);
}
.faq-row[open] > .faq-summary > .faq-chevron { transform: rotate(180deg); }
.faq-answer {
    padding: 0 1.25rem 1.25rem;
    font-size: 0.9375rem;
    color: rgb(var(--md-sys-color-on-surface-variant));
}
.faq-answer p { margin: 0 0 0.75rem; }
.faq-answer p:last-child { margin-bottom: 0; }

@media (prefers-reduced-motion: reduce) {
    .faq-chevron, .faq-row > .faq-summary { transition: none; }
}

/* --- About, and any page built from blocks rather than prose -----------*/
.about-art { display: block; width: 100%; height: auto; border-radius: 24px; }

.feature-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .feature-grid { grid-template-columns: repeat(3, 1fr); } }

.feature {
    padding: 1.5rem;
    border-radius: 20px;
    background: rgb(var(--md-sys-color-surface-bright));
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
}
.feature-icon {
    display: grid; place-items: center;
    width: 44px; height: 44px; margin-bottom: 1rem;
    border-radius: 14px;
    background: rgb(var(--md-sys-color-primary) / 0.12);
    color: rgb(var(--md-sys-color-primary));
}
.feature h3 {
    font-size: 1.0625rem; font-weight: 500; margin: 0 0 0.4rem;
    color: rgb(var(--md-sys-color-on-surface));
}
.feature p {
    margin: 0; font-size: 0.9375rem; line-height: 1.6;
    color: rgb(var(--md-sys-color-on-surface-variant));
}

/* A row of short facts. Deliberately not numbers nobody can verify --
   these are statements about how the thing works. */
.fact-list { display: grid; gap: 0.875rem; margin: 0; padding: 0; list-style: none; }
@media (min-width: 720px) { .fact-list { grid-template-columns: 1fr 1fr; gap: 1rem 2rem; } }
.fact-list li { display: flex; gap: 0.75rem; align-items: flex-start; }
.fact-list .material-symbols-rounded {
    flex: none; font-size: 22px; color: rgb(var(--md-sys-color-primary));
}
.fact-list span:last-child {
    font-size: 0.9375rem; line-height: 1.6;
    color: rgb(var(--md-sys-color-on-surface-variant));
}

/* --- Page mastheads -----------------------------------------------------
 *
 * A page title and a sentence under it, set as plain text, is what every
 * one of these pages had. It is not wrong, and it reads as a document
 * somebody forgot to design -- the heading and the body copy differ only
 * in size, there is no entry point, and the eye has nothing to catch on.
 *
 * So the header becomes a band: a tinted panel, a small eyebrow label to
 * say what kind of page this is, the title, and the lede. Tinted rather
 * than coloured, because a saturated banner on every page is the other
 * failure -- a site that shouts the same note eight times.
 */
.page-hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 2.5rem;
    padding: 2.25rem 1.5rem;
    border-radius: 28px;
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
    background:
        radial-gradient(90% 140% at 0% 0%,
            rgb(var(--md-sys-color-primary) / 0.14), transparent 62%),
        radial-gradient(70% 120% at 100% 0%,
            rgb(var(--md-sys-color-tertiary) / 0.10), transparent 58%),
        rgb(var(--md-sys-color-surface-bright));
}
@media (min-width: 768px) {
    .page-hero { padding: 3rem 2.5rem; }
}

/* The label above the title. Lets a page say what it is without spending
   a sentence on it. */
.page-eyebrow {
    display: inline-flex; align-items: center; gap: 0.4rem;
    margin-bottom: 0.875rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    background: rgb(var(--md-sys-color-primary) / 0.12);
    color: rgb(var(--md-sys-color-primary));
    font-size: 0.75rem; font-weight: 600;
    letter-spacing: 0.06em; text-transform: uppercase;
}
.page-eyebrow .material-symbols-rounded { font-size: 16px; }

.page-hero .page-heading { max-width: 20ch; }
.page-hero .page-lede { margin-top: 0.875rem; }

/* Anything the page wants under the lede: buttons, a search box, counts. */
.page-hero-actions {
    display: flex; flex-wrap: wrap; gap: 0.75rem;
    margin-top: 1.5rem;
}

@media (prefers-reduced-motion: no-preference) {
    .page-hero > * { animation: page-hero-in 460ms cubic-bezier(0.2, 0, 0, 1) both; }
    .page-hero > *:nth-child(2) { animation-delay: 60ms; }
    .page-hero > *:nth-child(3) { animation-delay: 110ms; }
    .page-hero > *:nth-child(4) { animation-delay: 150ms; }
}
@keyframes page-hero-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------------------
 * Staff panel form controls.
 *
 * Django renders these widgets, so they cannot be given utility classes
 * one by one in a template -- the class goes on in forms.py and the look
 * is defined once, here.
 *
 * `min-height: 44px` is not decoration. A control smaller than that is
 * hard to hit accurately on a phone, and this panel is used on one more
 * often than its desktop layout suggests.
 * ------------------------------------------------------------------ */
.staff-input {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 0.625rem 0.875rem;
    border-radius: 0.75rem;
    border: 1px solid rgb(var(--md-sys-color-outline-variant));
    background: rgb(var(--md-sys-color-surface-container-low));
    color: rgb(var(--md-sys-color-on-surface));
    font-size: 0.875rem;
    line-height: 1.5;
}

textarea.staff-input { min-height: 6rem; resize: vertical; }

.staff-input:focus {
    outline: 2px solid rgb(var(--md-sys-color-primary));
    outline-offset: -1px;
    border-color: rgb(var(--md-sys-color-primary));
}

/* The field is wrong: say so with a border as well as the message, so
 * it is not colour alone carrying the meaning. */
.staff-field--invalid .staff-input {
    border-color: rgb(var(--md-sys-color-error));
    border-width: 2px;
}

.staff-input[disabled],
.staff-input[readonly] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------------------------------------------------------------------
 * The post preview in the staff editor.
 *
 * The published article is styled by the blog's own templates, which the
 * panel does not load -- so without this the preview is a column of
 * undifferentiated text where the real page has headings, quotes and
 * lists. A preview that does not look like the page is a preview nobody
 * trusts, and the thing it is wrong about is exactly the formatting it
 * exists to show.
 *
 * Deliberately not a copy of the blog's typography. It is close enough
 * to read structure from and plainly part of the panel, so nobody
 * mistakes it for the finished page.
 * ------------------------------------------------------------------ */
.prose-staff { line-height: 1.7; }
.prose-staff > * + * { margin-top: 1em; }
.prose-staff h2 {
    font-size: 1.375rem;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 1.6em;
}
.prose-staff h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-top: 1.4em;
}
.prose-staff ul, .prose-staff ol { padding-inline-start: 1.5rem; }
.prose-staff ul { list-style: disc; }
.prose-staff ol { list-style: decimal; }
.prose-staff li + li { margin-top: 0.35em; }
.prose-staff a {
    color: rgb(var(--md-sys-color-primary));
    text-decoration: underline;
}
.prose-staff blockquote {
    border-inline-start: 3px solid rgb(var(--md-sys-color-outline-variant));
    padding-inline-start: 1rem;
    color: rgb(var(--md-sys-color-on-surface-variant));
}
.prose-staff pre {
    background: rgb(var(--md-sys-color-surface-container-highest));
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    font-size: 0.8125rem;
}
.prose-staff code {
    background: rgb(var(--md-sys-color-surface-container-highest));
    border-radius: 0.25rem;
    padding: 0.1em 0.35em;
    font-size: 0.875em;
}
.prose-staff pre code { background: none; padding: 0; }
.prose-staff img { max-width: 100%; height: auto; border-radius: 0.75rem; }
.prose-staff figure { margin-top: 1.5em; }
.prose-staff hr {
    border: 0;
    border-top: 1px solid rgb(var(--md-sys-color-outline-variant));
}
