/*
  SPDX-FileCopyrightText: 2026 Lukas Körber
  SPDX-License-Identifier: AGPL-3.0-only
*/

/* StudyAtrium — Design System */
/* Self-hosted DM Sans / DM Mono (SIL Open Font License 1.1, see fonts/OFL.txt). Replaces the
   former Google Fonts @import: an @import is invisible to the browser's preload scanner, so it
   serialized base.css -> fonts.googleapis.com CSS -> fonts.gstatic.com woff2 (two extra origins,
   DNS+TLS each) before the first paint. Same subsets Google served (latin + latin-ext, split by
   unicode-range so a German page downloads latin only), DM Sans as one variable file per subset
   covering weights 300-500. */
@font-face {
    font-family: 'DM Mono';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/dmmono-400-italic-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'DM Mono';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/dmmono-400-italic-latin.woff2') format('woff2');
    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: 'DM Mono';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/dmmono-300-normal-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/dmmono-300-normal-latin.woff2') format('woff2');
    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: 'DM Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/dmmono-400-normal-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/dmmono-400-normal-latin.woff2') format('woff2');
    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: 'DM Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/dmmono-500-normal-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'DM Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/dmmono-500-normal-latin.woff2') format('woff2');
    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: 'DM Sans';
    font-style: italic;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/dmsans-300-italic-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'DM Sans';
    font-style: italic;
    font-weight: 300;
    font-display: swap;
    src: url('../fonts/dmsans-300-italic-latin.woff2') format('woff2');
    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: 'DM Sans';
    font-style: normal;
    font-weight: 300 500;
    font-display: swap;
    src: url('../fonts/dmsans-normal-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 300 500;
    font-display: swap;
    src: url('../fonts/dmsans-normal-latin.woff2') format('woff2');
    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;
}

:root {
    /* Tells the browser this page manages its own light/dark appearance - without this,
       Android Chrome's "Auto Dark Theme" force-inverts page colors at the rendering layer
       for any site that doesn't declare it, completely ignoring the data-theme CSS below. */
    color-scheme: dark light;
    /* Latin from the bundled faces, CJK from the device: a Chinese page must not wait for a
       web font that does not even contain the glyphs (Quiet Focus uses the system CJK face). */
    --font: 'DM Sans', -apple-system, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
    --font-mono: 'DM Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;

    /* === Colour tokens ===
       This file is the only place that holds colour values. Components reference the role tokens
       below and never a raw hex value for these roles. tools/check-contrast.py reads this file and
       asserts the ratios for every accent preset in both themes (and under prefers-contrast: more),
       so a value that stops meeting its target fails CI.

       Surfaces and text (dark values here; the light theme overrides them further down):
         --bg, --bg2, --bg3        page, card, inset surface
         --text, --text2, --text3  body, secondary, tertiary text (all >= 4.5:1 on every surface)
       Roles (each >= the ratio named, on every surface of its theme):
         --accent                  the preset colour as a FILL (buttons, active chips, bars)
         --accent-fill             the --accent shade for solid fills that carry text (buttons, FAB,
                                   active chips, own chat bubble), darker so --on-accent reaches 4.5:1
         --on-accent               white text on an --accent-fill, >= 4.5:1
         --accent-text             the accent as link or text colour, >= 4.5:1
         --accent-tint-text        the accent as text on a tinted chip, >= 4.5:1
         --success/--warning/--danger   status text and icons, >= 4.5:1; each has a -bg tint
         --control-border          boundary of inputs, selects, toggles, secondary buttons, >= 3:1
         --focus-ring              keyboard focus outline, >= 3:1
       Muted states carry meaning through a colour, never through opacity (opacity lowers the
       contrast of everything inside the element):
         --muted-text              text of a past, done or completed item, >= 4.5:1 (an alias of --text2)
         --disabled-text           text of a locked or dimmed item, >= 4.5:1 (an alias of --text3: the
                                   item still tells the user what it is, so it is not exempt)
       Course colours are user data. They are never used as text colour; they tint a surface and the
       text on it stays --text (see .on-tint in shared.css):
         --tint, --tint-muted      share of the course colour in that tint (normal, past or done);
                                   tools/check-contrast.py proves --text stays >= 4.5:1
                                   on it for black, white and the course palette on every surface,
                                   and that the share is the highest one that does (per theme
                                   and contrast mode, see the --tint-* values above)
       Wrapped (year in review) slides sit on decorative gradients in both themes:
         --wrapped-scrim           the dark layer between gradient and text
         --on-wrapped              the text colour on it, >= 4.5:1 on every gradient stop */
    --bg: #161918;
    --bg2: #222624;
    --bg3: #1c211f;
    --border: #353c36;
    --border2: #454e46;
    --text: #eceee8;
    --text2: #a8b2aa;
    --text3: #9ba69e; /* >= 4.5:1 on --bg3, WCAG AA */
    --success: #00b894;
    --success-bg: rgba(0,184,148,0.12);
    --warning: #fdcb6e;
    --warning-bg: rgba(253,203,110,0.14);
    --danger: #eb7864;
    --danger-bg: rgba(234,112,91,0.12);
    --control-border: #77857c;
    --focus-ring: var(--text);
    --muted-text: var(--text2);
    --disabled-text: var(--text3);
    /* Quiet Focus product identity. Deliberately NOT derived from the user accent preset: the
       deep forest surface, the thin ring and the tab bar are the same on every install, while
       the accent stays the personal colour of charts, course tints and highlights. */
    --brand: #2d473a;
    --brand-hover: #355b45;
    --on-brand: #eef1e9;
    --on-brand-accent: #b6ceb8;
    --brand-card: #2d473a;
    --brand-text: #b6ceb8;
    --brand-soft: color-mix(in srgb, #b6ceb8 16%, transparent);
    --ring-track: #353c36;
    --ring-fill: #b6ceb8;
    /* Course tint per theme and contrast mode: the highest whole percent at which --text (every line on a
       tinted item is --text) stays >= 4.5:1 (7:1 under Increase Contrast) on every course colour and
       surface. --tint-muted is half of it, capped so the muted name (--muted-text = --text2) still passes
       on it. check-contrast.py computes both and fails when a value here is not it. */
    --tint-dark: 32%;
    --tint-muted-dark: 13%;
    --tint-light: 39%;
    --tint-muted-light: 5%;
    --tint-more-dark: 19%;
    --tint-muted-more-dark: 9%;
    --tint-more-light: 23%;
    --tint-muted-more-light: 11%;
    --tint: var(--tint-dark);
    --tint-muted: var(--tint-muted-dark);
    --tint-more: var(--tint-more-dark);
    --tint-muted-more: var(--tint-muted-more-dark);
    --course-stripe: 5px; /* the course-colour edge of a calendar session block */
    --wrapped-scrim: rgba(0,0,0,0.6);
    --on-wrapped: #ffffff;

    /* Accent: "coral" is the default preset. Every preset sets --accent, --on-accent and the
       dark/light pairs below once; the theme blocks pick the pair that applies. */
    --accent: #CC785C;
    --on-accent: #ffffff;
    --accent-fill: #A7624B;
    --accent2-d: #E8A87C;
    --accent2-l: #bf6a4d;
    --accent-text-d: #CC785C;
    --accent-text-l: #935642;
    --accent2: var(--accent2-d);
    --accent-text: var(--accent-text-d);
    --accent-tint-text: color-mix(in srgb, var(--accent-text) 50%, var(--text));

    --focus-r: #E17055;
    --focus-b: #74B9FF;
    --radius: 12px;
    /* Quiet Focus layout scale: cards are quieter with a larger radius, controls stay tight. */
    --radius-card: 20px;
    --radius-btn: 14px;
    --space-page: 20px;
    --sidebar-w: 200px;
    --transition: 0.2s ease;
    /* MainPage.xaml no longer reserves native safe-area insets (SafeAreaEdges="None") - the
       WebView now gets the full physical screen, same as an installed PWA in standalone mode.
       Every fixed-position element anchored to a physical edge needs to add these back itself. */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Light theme. Applies when the system is light and the user has not forced dark (no [data-theme]
   = "system"), and when the user forced light on the Setup page. The two blocks below must stay
   identical; tools/check-contrast.py fails if they drift apart. CSS light-dark() would make this
   a single block, but the native app supports iOS 15 and light-dark() needs Safari 17.5, so the
   media query and the attribute stay two selectors for the same declarations. */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        color-scheme: light;
        --bg: #f5f5f0;
        --bg2: #ffffff;
        --bg3: #ecede5;
        --border: #e3e7df;
        --border2: #d2d8cd;
        --text: #202c26;
        --text2: #5b665e;
        --text3: #626c65; /* >= 4.5:1 on --bg3, WCAG AA */
        --success: #006954;
        --success-bg: rgba(0,184,148,0.14);
        --warning: #75581f;
        --warning-bg: rgba(225,169,60,0.22);
        --danger: #a03d2c;
        --danger-bg: rgba(231,76,60,0.12);
        --control-border: #7a857c;
        --brand: #284536;
        --brand-hover: #355b45;
        --on-brand: #f2f4ee;
        --on-brand-accent: #cfe3cf;
        --brand-card: #284536;
        --brand-text: #34503f;
        --brand-soft: color-mix(in srgb, #284536 8%, transparent);
        --ring-track: #e3e7df;
        --ring-fill: #284536;
        --accent2: var(--accent2-l);
        --accent-text: var(--accent-text-l);
        --tint: var(--tint-light);
        --tint-muted: var(--tint-muted-light);
        --tint-more: var(--tint-more-light);
        --tint-muted-more: var(--tint-muted-more-light);
    }
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f5f5f0;
    --bg2: #ffffff;
    --bg3: #ecede5;
    --border: #e3e7df;
    --border2: #d2d8cd;
    --text: #202c26;
    --text2: #5b665e;
    --text3: #626c65; /* >= 4.5:1 on --bg3, WCAG AA */
    --success: #006954;
    --success-bg: rgba(0,184,148,0.14);
    --warning: #75581f;
    --warning-bg: rgba(225,169,60,0.22);
    --danger: #a03d2c;
    --danger-bg: rgba(231,76,60,0.12);
    --control-border: #7a857c;
    --brand: #284536;
    --brand-hover: #355b45;
    --on-brand: #f2f4ee;
    --on-brand-accent: #cfe3cf;
    --brand-card: #284536;
    --brand-text: #34503f;
    --brand-soft: color-mix(in srgb, #284536 8%, transparent);
    --ring-track: #e3e7df;
    --ring-fill: #284536;
    --accent2: var(--accent2-l);
    --accent-text: var(--accent-text-l);
    --tint: var(--tint-light);
    --tint-muted: var(--tint-muted-light);
    --tint-more: var(--tint-more-light);
    --tint-muted-more: var(--tint-muted-more-light);
}

/* Manual dark override: the values are the :root defaults, only the colour-scheme hint differs
   (form controls and scrollbars follow it even when the system is light). */
:root[data-theme="dark"] { color-scheme: dark; }

/* Curated accent colors (Setup page, separate from the dark/light theme above) - pure
   CSS custom-property overrides; every derivation of --accent (color-mix(...) etc. in the
   feature CSS files) picks up a new value automatically without further changes.
   "coral" is the original default tone from the :root block and therefore needs no own
   [data-accent]. --accent stays theme-invariant (and so do --accent-fill, the darker shade used
   for solid fills with text on them, and --on-accent, the white text on it); --accent2 (hover/secondary tone) and --accent-text (the accent as text) come as a
   dark and a light value and the theme blocks above pick one. Applied via wwwroot/js/accent.js
   (AppStateService). --accent-fill is the preset hue darkened just enough for white text (4.5:1). */
:root[data-accent="blue"] { --accent: #4C86E0; --on-accent: #ffffff; --accent-fill: #4275C3; --accent2-d: #92B5EC; --accent2-l: #2261C3; --accent-text-d: #568ce1; --accent-text-l: #3B67AC; }
:root[data-accent="green"] { --accent: #3C8F40; --on-accent: #ffffff; --accent-fill: #37843B; --accent2-d: #60BC65; --accent2-l: #275D29; --accent-text-d: #539c56; --accent-text-l: #317534; }
:root[data-accent="purple"] { --accent: #7B5EEA; --on-accent: #ffffff; --accent-fill: #7A5DE8; --accent2-d: #B6A6F3; --accent2-l: #471FE2; --accent-text-d: #927bee; --accent-text-l: #6B52CC; }
:root[data-accent="red"] { --accent: #E5484D; --on-accent: #ffffff; --accent-fill: #D04246; --accent2-d: #EF8F92; --accent2-l: #C91D22; --accent-text-d: #e85f63; --accent-text-l: #B73A3E; }
:root[data-accent="teal"] { --accent: #178783; --on-accent: #ffffff; --accent-fill: #16827E; --accent2-d: #23CDC7; --accent2-l: #0D4A48; --accent-text-d: #3c9a97; --accent-text-l: #14736F; }
:root[data-accent="amber"] { --accent: #A66E10; --on-accent: #ffffff; --accent-fill: #9F6A0F; --accent2-d: #E99E1E; --accent2-l: #65430A; --accent-text-d: #b48434; --accent-text-l: #8B5C0D; }

/* Increase Contrast (iOS/macOS accessibility setting, also Windows contrast preferences exposed
   as prefers-contrast): text steps collapse to the primary colour, borders and the control
   outline get much stronger, and the accent as text becomes plain text. One theme-independent
   block: every value is derived from the tokens of the active theme. ":root:root" has the same
   specificity as the theme blocks above and comes later, so it wins over them. */
@media (prefers-contrast: more) {
    :root:root {
        --text2: var(--text);
        --text3: var(--text);
        --accent-text: var(--text);
        --accent-tint-text: var(--text);
        --tint: var(--tint-more);
        --tint-muted: var(--tint-muted-more);
        --border: color-mix(in srgb, var(--text) 45%, transparent);
        --border2: color-mix(in srgb, var(--text) 65%, transparent);
        --control-border: var(--text);
    }
}

/* Forced colours (Windows High Contrast): the user's palette replaces ours, so the tokens map to
   system colours and the places that signalled state by a background fill get a visible border. */
@media (forced-colors: active) {
    :root:root {
        --accent-text: LinkText;
        --accent-tint-text: LinkText;
        --control-border: ButtonText;
        --focus-ring: Highlight;
        --disabled-text: GrayText;
    }
    .btn-primary, .btn-focus, .fab-main, .lang-option.active { border: 1px solid ButtonText; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { opacity: 0.8; }
/* Links inside running text are underlined: colour alone must not be the only cue that something
   is a link (WCAG 1.4.1; accent against body text is only 2.6:1 on the dark theme). Button-styled
   anchors and navigation keep their own look. */
:where(p, li, label, .ss-desc, .public-legal) a:not([class*="btn"]):not(.nav-item) { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }

/* App.razor's <FocusOnNavigate Selector="h1" /> programmatically focuses each page's <h1>
   after every navigation (screen-reader-only accessibility feature: announces where the user
   landed) - Blazor sets tabindex="-1" on it to make that possible, which is also how the
   browser's default focus outline ends up wrapping the full-width heading (e.g. the Dashboard
   greeting) until the user taps/clicks something else. Real interactive elements (buttons,
   links, inputs) never carry tabindex="-1", so this leaves their own focus rings untouched. */
[tabindex="-1"]:focus { outline: none; }

/* Standard Blazor error banner (index.html) - hidden by default, the framework's own JS sets
   display:block on an actual unhandled exception. Without this rule the div renders inline
   (browser default display:block for a <div>) below the viewport, invisible in normal use
   (body/html clip via overflow:hidden above) but exposed once something removes that clipping
   - e.g. the print stylesheet below, which showed "An unhandled error has occurred" on every
   printed page even without a real error. */
#blazor-error-ui {
    background: lightyellow;
    color: #3b3a39;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    padding-bottom: calc(0.7rem + var(--safe-bottom));
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    /* A <button> now (keyboard reachable); keep it looking like the plain glyph it was. */
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
}

/* Boot screen (index.html, shown until Blazor renders the first page). Fixed colours on
   purpose: the theme variables are only applied by the app once it runs. Kept here instead of
   style attributes in index.html so the static shell carries no inline styles (CSP). */
.boot-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'DM Sans', sans-serif;
    background: #161918;
    color: #eceee8;
}
.boot-screen-inner { text-align: center; }
.boot-screen-mark { font-size: 2rem; margin-bottom: 1rem; color: #b6ceb8; }
.boot-screen-text { font-size: 0.875rem; color: #9ba69e; letter-spacing: 0.05em; }

/* === App Shell === */
.app-shell {
    display: flex;
    /* 100vh in mobile Safari means the viewport height with the toolbar collapsed (its
       tallest possible state), not what's actually visible right now - the fixed bottom
       navbar (tracks the real visual viewport) and this vh-based layout disagreed about
       where "the bottom" is, which looked like the navbar covering part of the page.
       100dvh tracks the real, current viewport and overrides the line above wherever
       supported; browsers without dvh support just keep the 100vh fallback. */
    height: 100vh;
    height: 100dvh;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    padding-top: calc(1.5rem + var(--safe-top));
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.25rem;
    margin-bottom: 2rem;
}

.brand-icon {
    font-size: 1.3rem;
    color: var(--accent-text);
}

.brand-name {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    padding: 0 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    color: var(--text2);
    font-size: 0.875rem;
    font-weight: 400;
    transition: var(--transition);
    position: relative;
    text-decoration: none;
}

.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--text); }
.nav-icon { font-size: 1rem; opacity: 0.7; }
.nav-badge { margin-left: auto; color: var(--danger); font-size: 0.5rem; }

/* Offline-sync badge (MainLayout): visible as long as writes from an offline
   phase are still waiting to be replayed. Fixed instead of in the nav so it stays
   visible on both desktop (sidebar) and mobile (bottom bar). */
.pending-sync-chip {
    position: fixed; top: calc(10px + var(--safe-top)); right: 12px; z-index: 900;
    display: flex; align-items: center; gap: 4px;
    background: var(--danger-bg); color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    border-radius: 999px; padding: 2px 10px; font-size: 0.75rem;
}
.psc-icon { font-size: 0.85rem; }

/* "New version available" toast (MainLayout): above the bottom bar, below modals (z-index) */
.update-toast {
    position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); z-index: 950;
    display: flex; align-items: center; gap: 10px;
    background: var(--bg2); color: var(--text);
    border: 1px solid var(--border2); border-radius: 12px;
    padding: 10px 14px; font-size: 0.85rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.update-toast .btn-primary { padding: 4px 12px; font-size: 0.8rem; }
.ut-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 0.9rem; }
.ut-spinner {
    width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%;
    border: 2px solid var(--border2); border-top-color: var(--danger);
    animation: ut-spin 0.8s linear infinite;
}
@keyframes ut-spin { to { transform: rotate(360deg); } }

/* "Timer running on another device" hint on the Focus page (user-scoped, purely informational) */
.focus-remote-banner {
    align-self: center; margin: 0 auto 4px;
    background: var(--bg3); color: var(--text3);
    border: 1px solid var(--border2);
    border-radius: 999px; padding: 4px 14px; font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

/* Movement-break nudge reuses .focus-remote-banner but needs room for longer text + a dismiss
   action, so it switches to a flexible pill shape when a dismiss button is present. */
.focus-remote-banner:has(.focus-nudge-dismiss) {
    display: flex; align-items: center; gap: 10px;
    border-radius: 14px; max-width: 440px; text-align: left;
}
.focus-nudge-dismiss {
    background: none; border: none; color: inherit; text-decoration: underline;
    cursor: pointer; font-size: 0.75rem; flex-shrink: 0; padding: 0; white-space: nowrap;
}

.sidebar-foot {
    padding: 1rem 1.25rem 0;
    border-top: 1px solid var(--border);
}

.time-display {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--text);
    letter-spacing: 0.02em;
}

.date-display {
    font-size: 0.75rem;
    color: var(--text3);
    margin-top: 2px;
}

.lang-flag { font-size: 1.15rem; line-height: 1; }

/* Speed dial: combined floating action button at the bottom right for search + language switcher
   (replaces the previous dedicated sidebar search entry and the top-right fixed
   language switcher). Higher than the sidebar (z-index 100) and the lang-popup backdrop.
   Its geometry lives in variables because .main-content reserves room for it (see there):
   page content must never end up underneath the button. */
:root {
    --fab-size: 52px;
    --fab-inset: 1.25rem;
    /* Width of the strip along the right edge the button occupies, plus a small gap. */
    --fab-lane: calc(var(--fab-size) + var(--fab-inset) + 0.5rem);
    /* Phones: room at the end of a scroll area, so its last content scrolls above the button. */
    --fab-clearance: calc(var(--fab-size) + 1.5rem);
}
.fab-dial { position: fixed; right: var(--fab-inset); bottom: var(--fab-inset); z-index: 110; display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; }
.fab-main {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background: var(--accent-fill);
    color: var(--on-accent);
    font-size: 1.3rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
}
.fab-main:hover { filter: brightness(1.1); }
.fab-main.open { background: var(--bg3); color: var(--text); }

.fab-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 0.6rem; }
.fab-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: var(--transition);
}
.fab-action:hover { border-color: var(--border2); background: var(--bg3); }

/* Combined selector instead of just .fab-lang-popup: .lang-popup (position:absolute) is
   defined further down in this file and, at equal specificity (both simple
   class selectors), could win depending on cascade order and reset the static override
   back to absolute - then the popup slides down out of the viewport relative to the
   fixed-positioned .fab-dial (bug: popup opened invisibly underneath the
   mobile bottom navbar). The combined class has higher specificity and is guaranteed to win. */
.lang-popup.fab-lang-popup { position: static; width: 260px; margin-bottom: 0; }

.lang-popup-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
}

.lang-popup {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 21;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    padding: 0.4rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.15rem;
    max-height: 320px;
    overflow-y: auto;
    width: 260px;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--text2);
    text-align: left;
    transition: var(--transition);
    min-width: 0;
}
.lang-option:hover { background: var(--bg3); color: var(--text); }
.lang-option.active { background: var(--accent-fill); color: var(--on-accent); }
.lang-option .lang-flag { font-size: 1rem; }
.lang-option .lang-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* === Global search overlay (Ctrl+K, GlobalSearch.razor) === */
/* A ModalDialog (shared.css, dialog.sl-modal) whose panel is .modal.gs-box: the palette sits
   towards the top instead of the centre and keeps its own, wider and flatter look. ".modal.gs-box"
   outranks the generic .modal rules, which shared.css loads after this file. */
dialog.sl-modal:has(> .gs-box) { margin-top: 12vh; }

.modal.gs-box {
    width: 560px;
    max-width: calc(100vw - 2rem);
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.gs-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
}
.gs-input::placeholder { color: var(--text3); }

/* Own font-size below 16px triggers iOS Safari/WKWebView's auto-zoom-on-focus, see the
   .input/.select rule in shared.css for the full explanation. */
@media (max-width: 768px) {
    .gs-input { font-size: 16px; }
}

.gs-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.4rem;
}

.gs-group-header {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text3);
    padding: 0.5rem 0.6rem 0.25rem;
}

.gs-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    color: var(--text2);
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
    transition: var(--transition);
}
.gs-row:hover,
.gs-row.highlighted { background: var(--bg3); color: var(--text); }
.gs-row-icon { font-size: 0.95rem; opacity: 0.75; flex-shrink: 0; }
.gs-row-title { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-row-detail {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45%;
    flex-shrink: 0;
}

.gs-empty {
    padding: 0.9rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text3);
    text-align: center;
}

@media (max-width: 768px) {
    dialog.sl-modal:has(> .gs-box) { margin-top: 8vh; }
    .modal.gs-box { max-width: calc(100vw - 1.5rem); }
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    /* overflow-y alone makes overflow-x compute to auto as well, so any child wider than the
       viewport turned the whole page horizontally pannable - visible only in WKWebView (iOS
       app), which sizes <select>s to their longest option and lets the user drag the page
       sideways where Chrome merely clips (2026-09, planner course select / note course select
       with a long course name). Pages that scroll horizontally on purpose (calendar grid) do
       so inside their own container, never through this one. */
    overflow-x: hidden;
    overscroll-behavior-x: none;
    /* Keyboard focus that scrolls into view must not land under the floating action button at the
       bottom (WCAG 2.4.11); the right-hand lane is already covered by the padding above. */
    scroll-padding-block: 1rem calc(var(--fab-clearance) + 0.5rem);
    /* Keep the floating action button's lane free: every page already pads its content 2rem
       from the right edge, this adds the rest of --fab-lane, so no card, legend value or chart
       label ever sits underneath the button (iPad store screenshots showed the dashboard
       donut's percentages covered). Phones get bottom clearance instead, see responsive.css. */
    padding-right: max(0px, calc(var(--fab-lane) - 2rem));
}

/* Calendar page: cap the entire shell at 100vh, no page scroll */
.app-shell.page-calendar {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
.app-shell.page-calendar .main-content {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* The calendar grid runs to the right edge (no page padding of its own there), so it
       reserves the full lane. */
    padding-right: var(--fab-lane);
}

