/*
 * Kulliyati -- the application stylesheet: layer order, fonts, tokens, base,
 * layout and utilities. The components layer is static/css/components.css.
 *
 * Layers, lowest to highest priority: reset, tokens, base, layout, components,
 * utilities. Colours exist only as tokens ("Indigo", docs/design/visual-design.md,
 * listed in docs/design-tokens.json); every other layer refers to var(--attend-*).
 * tests/test_css_rules.py enforces: no hex/rgb/hsl colours outside the tokens
 * layer, no gradients, blur, backdrop-filter, filter or light-dark(), and shadows
 * only as the light theme's elevation tokens (none in the dark themes).
 *
 * Theme: <html data-theme="light|dark|system">, rendered by the server from the
 * user's profile (or the attend_theme cookie when signed out). "system", the
 * default when nobody has chosen (owner, 2026-11-11), follows
 * prefers-color-scheme with a media query, so there is no flash on load.
 */

@layer reset, tokens, base, layout, components, utilities;

/* Pages cross-fade (design review 2026-11-09, AD6): a same-origin navigation
   is a view transition; the shell's bars carry their own names (shell.css), so
   only the content changes. Browsers without it simply load the page. */
@view-transition {
  navigation: auto;
}

/* Figtree, the one Latin face: body, UI, headings and the wordmark (owner,
   2026-11-25: one face, not a separate display face; docs/design/visual-design.md
   §1). Self-hosted (@fontsource-variable 5.3.0, SIL OFL 1.1; scripts/vendor_fetch.py). */

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url("../vendor/fontsource-variable-figtree/5.3.0/figtree-latin-wght-normal.202cfb54d4e6.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: "Figtree";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url("../vendor/fontsource-variable-figtree/5.3.0/figtree-latin-ext-wght-normal.eca8d8b337ff.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;
}

/* Rubik (OFL), the Arabic face (owner, 2026-11-09; package approved 2026-11-10):
   its Arabic subset only, so Figtree keeps drawing the Latin letters and the
   digits. Used by the :lang(ar) stacks below; preloaded on Arabic pages only
   (templates/base.html). docs/dev/i18n.md, "Arabic type". */
@font-face {
  font-family: "Rubik";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url("../vendor/fontsource-variable-rubik/5.3.0/rubik-arabic-wght-normal.d2ec73878cf6.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC,
    U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EEFF;
}

/* ------------------------------------------------------------------ reset */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Our own pressed states replace the browser's grey tap box (design
       review AD3). */
    -webkit-tap-highlight-color: transparent;
  }

  body,
  h1,
  h2,
  h3,
  h4,
  p,
  figure,
  blockquote,
  dl,
  dd,
  ul,
  ol {
    margin: 0;
  }

  ul[role="list"],
  ol[role="list"] {
    list-style: none;
    padding: 0;
  }

  img,
  svg,
  video,
  canvas {
    display: block;
    max-width: 100%;
  }

  input,
  button,
  textarea,
  select {
    font: inherit;
    color: inherit;
  }

  button {
    cursor: pointer;
  }

  fieldset {
    margin: 0;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  legend {
    padding: 0;
  }

  table {
    border-collapse: collapse;
  }

  [hidden] {
    display: none !important;
  }

  /* A theme switch (static/js/theme.js) changes every colour in the same frame:
     no field or button fades on its own while the rest snaps. */
  :root[data-theme-switching] *,
  :root[data-theme-switching] *::before,
  :root[data-theme-switching] *::after {
    transition: none !important;
  }

  /* In the reset layer, !important outranks every later layer. Less motion
     is not none (§12): dialogs, sheets, the drawer and their backdrop fade in
     150ms instead of moving, and pages cross-fade in 150ms. */
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }

    dialog,
    dialog::backdrop {
      transition-property: opacity, overlay, display !important;
      transition-duration: var(--motion-fade) !important;
    }

    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
      animation-duration: var(--motion-fade) !important;
    }
  }
}

/* ----------------------------------------------------------------- tokens */
@layer tokens {
  /* Light: also the default before/without a data-theme attribute. */
  :root {
    color-scheme: light;
    /* Surfaces, borders and text */
    --attend-ground: #f2f4fd;
    --attend-signin-ground: #f2f4fd;
    --attend-surface: #ffffff;
    --attend-raised: #ffffff;
    --attend-border: #e1e4ed;
    --attend-card-edge: #e1e4ed;
    --attend-border-strong: #7a8196;
    --attend-field: #e0e4f3;
    --attend-field-raised: #e0e4f3;
    --attend-field-edge-hover: #c4c9d8;
    --attend-field-halo: #d5dbfa;
    --attend-signin-ring: #c9cef2;
    --attend-signin-card: #fbfbff;
    --attend-signin-card-edge: #e6e8f6;
    --attend-signin-field: #f1f3fc;
    --attend-signin-track: #eceefa;
    --attend-scrollbar: #868ca0;
    --attend-text-strong: #151b35;
    --attend-text: #343a52;
    --attend-text-muted: #5e6580;
    --attend-row-hover: #f6f7fb;
    --attend-row-selected: #eef1fd;
    --attend-table-head: #f4f5f9;
    /* Brand: primary button, active navigation, links, focus, progress */
    --attend-brand: #4a5bd0;
    --attend-brand-hover: #3c4cb8;
    --attend-on-brand: #ffffff;
    --attend-brand-tint: #e8ebfc;
    --attend-brand-text: #3445b4;
    --attend-link-hover: #3c4cb8;
    --attend-accent: #4a5bd0;
    --attend-progress-track: #e8ebfc;
    --attend-focus: #4a5bd0;
    --attend-hero: #eef1fd;
    --attend-hero-border: #dce2f8;
    --attend-hero-mint: #e3f4ec;
    --attend-code-dark: #000000;
    --attend-code-light: #ffffff;
    /* Status families: tint, text (also the icon), solid fill */
    --attend-positive-bg: #edf0fc;
    --attend-positive-text: #3b4aa8;
    --attend-positive-solid: #4a5bd0;
    --attend-warning-bg: #f4eff8;
    --attend-warning-text: #6a4a86;
    --attend-danger-bg: #f9eef1;
    --attend-danger-text: #983d55;
    --attend-danger-solid: #983d55;
    --attend-info-bg: #ebf1f8;
    --attend-info-text: #3e5f86;
    --attend-inactive-bg: #eff0f4;
    --attend-inactive-text: #575a6a;
    /* Sidebar: deep ink */
    --attend-sidebar: #1a1f31;
    --attend-sidebar-border: #1a1f31;
    --attend-sidebar-text: #d9dce4;
    --attend-sidebar-strong: #f4f5f8;
    --attend-sidebar-muted: #a0a6b4;
    --attend-sidebar-hover: #242a3f;
    --attend-sidebar-active: #2c3349;
    --attend-sidebar-accent: #afbaff;
    --attend-sidebar-on-accent: #1a1f31;
    --attend-sidebar-scrollbar: #3b4150;
    --attend-sidebar-found: #8fdcbc;
    --attend-sidebar-refused: #f0c674;
    /* Icons inside native controls (scripts/build_ui_icons.py) */
    --attend-icon-chevron: url("../img/ui/chevron-down-light.6768753a87d1.svg");
    --attend-icon-calendar: url("../img/ui/calendar-light.94ba3173c3bb.svg");
    --attend-icon-clock: url("../img/ui/clock-light.0348794b444b.svg");
    --attend-icon-clear: url("../img/ui/x-light.cfc68ad8dfbb.svg");
    --attend-icon-check: url("../img/ui/check-light.b298186ba4dc.svg");
    --attend-icon-dot: url("../img/ui/dot-light.55d95ce78c3a.svg");
    --attend-icon-row-chevron: url("../img/ui/chevron-right-light.d41fff67125b.svg");
    --attend-icon-lock: url("../img/ui/lock-light.e7a1695e97b3.svg");
    /* Elevation (light theme only) */
    --attend-shadow-card: 0 1px 2px rgba(21, 27, 53, 0.04), 0 4px 16px rgba(21, 27, 53, 0.05);
    --attend-shadow-raised: 0 12px 40px rgba(21, 27, 53, 0.14), 0 2px 6px rgba(21, 27, 53, 0.06);
    --attend-shadow-primary: 0 4px 12px -6px rgba(74, 91, 208, 0.35);
    --attend-shadow-bar: 0 -4px 20px rgba(21, 27, 53, 0.05);
    --attend-shadow-signin: 0 1px 2px rgba(21, 27, 53, 0.04), 0 24px 56px rgba(74, 91, 208, 0.12);
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    /* Surfaces, borders and text */
    --attend-ground: #0d1120;
    --attend-signin-ground: #0d1120;
    --attend-surface: #171d33;
    --attend-raised: #1f2640;
    --attend-border: #2a3352;
    --attend-card-edge: #20284a;
    --attend-border-strong: #7480a6;
    --attend-field: #28314f;
    --attend-field-raised: #2d3756;
    --attend-field-edge-hover: #3a4568;
    --attend-field-halo: #3a4494;
    --attend-signin-ring: #4047a4;
    --attend-signin-card: #171d33;
    --attend-signin-card-edge: #262d4a;
    --attend-signin-field: #28314f;
    --attend-signin-track: #1b2240;
    --attend-scrollbar: #7480a6;
    --attend-text-strong: #f5f6ff;
    --attend-text: #d6dbee;
    --attend-text-muted: #a2abc6;
    --attend-row-hover: #1c2340;
    --attend-row-selected: #212852;
    --attend-table-head: #1f2640;
    /* Brand: primary button, active navigation, links, focus, progress */
    --attend-brand: #5b63f0;
    --attend-brand-hover: #4f57e2;
    --attend-on-brand: #ffffff;
    --attend-brand-tint: #272f5c;
    --attend-brand-text: #b9c0ff;
    --attend-link-hover: #b9c0ff;
    --attend-accent: #5b63f0;
    --attend-progress-track: #1e2650;
    --attend-focus: #99a3ff;
    --attend-hero: #1e2650;
    --attend-hero-border: #333e7a;
    --attend-hero-mint: #183129;
    --attend-code-dark: #000000;
    --attend-code-light: #ffffff;
    /* Status families: tint, text (also the icon), solid fill */
    --attend-positive-bg: #232b5c;
    --attend-positive-text: #bcc4ff;
    --attend-positive-solid: #5b63f0;
    --attend-warning-bg: #2f2545;
    --attend-warning-text: #dcc3f2;
    --attend-danger-bg: #3a1d2b;
    --attend-danger-text: #f6aec0;
    --attend-danger-solid: #b4506a;
    --attend-info-bg: #1a2c45;
    --attend-info-text: #abcbee;
    --attend-inactive-bg: #252c42;
    --attend-inactive-text: #bcc2d6;
    /* Sidebar: a navy panel, one step above the page (owner, 2026-11-11) */
    --attend-sidebar: #171d33;
    --attend-sidebar-border: #2a3352;
    --attend-sidebar-text: #d9dce4;
    --attend-sidebar-strong: #f4f5f8;
    --attend-sidebar-muted: #a0a6b4;
    --attend-sidebar-hover: #1f2640;
    --attend-sidebar-active: #283056;
    --attend-sidebar-accent: #afbaff;
    --attend-sidebar-on-accent: #0d1120;
    --attend-sidebar-scrollbar: #2e3344;
    --attend-sidebar-found: #8fdcbc;
    --attend-sidebar-refused: #f0c674;
    /* Icons inside native controls (scripts/build_ui_icons.py) */
    --attend-icon-chevron: url("../img/ui/chevron-down-dark.c2c792ba4d66.svg");
    --attend-icon-calendar: url("../img/ui/calendar-dark.5137051af5fb.svg");
    --attend-icon-clock: url("../img/ui/clock-dark.ec386c78c32f.svg");
    --attend-icon-clear: url("../img/ui/x-dark.1cc682927246.svg");
    --attend-icon-check: url("../img/ui/check-dark.b298186ba4dc.svg");
    --attend-icon-dot: url("../img/ui/dot-dark.55d95ce78c3a.svg");
    --attend-icon-row-chevron: url("../img/ui/chevron-right-dark.820beee1dc49.svg");
    --attend-icon-lock: url("../img/ui/lock-dark.1a217ee96559.svg");
    /* Elevation (none in the dark themes) */
    --attend-shadow-card: none;
    --attend-shadow-raised: none;
    --attend-shadow-primary: none;
    --attend-shadow-bar: none;
    --attend-shadow-signin: none;
  }

  @media (prefers-color-scheme: dark) {
    :root[data-theme="system"] {
      color-scheme: dark;
      /* Surfaces, borders and text */
      --attend-ground: #0d1120;
      --attend-signin-ground: #0d1120;
      --attend-surface: #171d33;
      --attend-raised: #1f2640;
      --attend-border: #2a3352;
      --attend-card-edge: #20284a;
      --attend-border-strong: #7480a6;
      --attend-field: #28314f;
      --attend-field-raised: #2d3756;
      --attend-field-edge-hover: #3a4568;
      --attend-field-halo: #3a4494;
      --attend-signin-ring: #4047a4;
      --attend-signin-card: #171d33;
      --attend-signin-card-edge: #262d4a;
      --attend-signin-field: #28314f;
      --attend-signin-track: #1b2240;
      --attend-scrollbar: #7480a6;
      --attend-text-strong: #f5f6ff;
      --attend-text: #d6dbee;
      --attend-text-muted: #a2abc6;
      --attend-row-hover: #1c2340;
      --attend-row-selected: #212852;
      --attend-table-head: #1f2640;
      /* Brand: primary button, active navigation, links, focus, progress */
      --attend-brand: #5b63f0;
      --attend-brand-hover: #4f57e2;
      --attend-on-brand: #ffffff;
      --attend-brand-tint: #272f5c;
      --attend-brand-text: #b9c0ff;
      --attend-link-hover: #b9c0ff;
      --attend-accent: #5b63f0;
      --attend-progress-track: #1e2650;
      --attend-focus: #99a3ff;
      --attend-hero: #1e2650;
      --attend-hero-border: #333e7a;
      --attend-hero-mint: #183129;
      --attend-code-dark: #000000;
      --attend-code-light: #ffffff;
      /* Status families: tint, text (also the icon), solid fill */
      --attend-positive-bg: #232b5c;
      --attend-positive-text: #bcc4ff;
      --attend-positive-solid: #5b63f0;
      --attend-warning-bg: #2f2545;
      --attend-warning-text: #dcc3f2;
      --attend-danger-bg: #3a1d2b;
      --attend-danger-text: #f6aec0;
      --attend-danger-solid: #b4506a;
      --attend-info-bg: #1a2c45;
      --attend-info-text: #abcbee;
      --attend-inactive-bg: #252c42;
      --attend-inactive-text: #bcc2d6;
      /* Sidebar: a navy panel, one step above the page (owner, 2026-11-11) */
      --attend-sidebar: #171d33;
      --attend-sidebar-border: #2a3352;
      --attend-sidebar-text: #d9dce4;
      --attend-sidebar-strong: #f4f5f8;
      --attend-sidebar-muted: #a0a6b4;
      --attend-sidebar-hover: #1f2640;
      --attend-sidebar-active: #283056;
      --attend-sidebar-accent: #afbaff;
      --attend-sidebar-on-accent: #0d1120;
      --attend-sidebar-scrollbar: #2e3344;
      --attend-sidebar-found: #8fdcbc;
      --attend-sidebar-refused: #f0c674;
      /* Icons inside native controls (scripts/build_ui_icons.py) */
      --attend-icon-chevron: url("../img/ui/chevron-down-dark.c2c792ba4d66.svg");
      --attend-icon-calendar: url("../img/ui/calendar-dark.5137051af5fb.svg");
      --attend-icon-clock: url("../img/ui/clock-dark.ec386c78c32f.svg");
      --attend-icon-clear: url("../img/ui/x-dark.1cc682927246.svg");
      --attend-icon-check: url("../img/ui/check-dark.b298186ba4dc.svg");
      --attend-icon-dot: url("../img/ui/dot-dark.55d95ce78c3a.svg");
      --attend-icon-row-chevron: url("../img/ui/chevron-right-dark.820beee1dc49.svg");
      --attend-icon-lock: url("../img/ui/lock-dark.1a217ee96559.svg");
      /* Elevation (none in the dark themes) */
      --attend-shadow-card: none;
      --attend-shadow-raised: none;
      --attend-shadow-primary: none;
      --attend-shadow-bar: none;
      --attend-shadow-signin: none;
    }
  }

  :root {
    /* Earlier names the components still use (docs/design-tokens.json "alias"):
       each is one of the Indigo tokens above. Later redesign steps move the
       components onto the new names. */
    --attend-surface-subtle: var(--attend-ground);
    --attend-surface-hover: var(--attend-brand-tint);
    --attend-text-secondary: var(--attend-text-muted);
    --attend-edge: var(--attend-border);
    --attend-control-edge: var(--attend-border-strong);
    --attend-action: var(--attend-brand);
    --attend-action-text: var(--attend-on-brand);
    --attend-accent-line: var(--attend-focus);
    --attend-accent-soft: var(--attend-brand-tint);
    --attend-avatar-bg: var(--attend-ground);
    --attend-positive: var(--attend-positive-text);
    --attend-warning: var(--attend-warning-text);
    --attend-danger: var(--attend-danger-text);
    --attend-inactive: var(--attend-inactive-text);

    /* Projection is white/black in both themes (UI_UX §4 Projection). */
    --attend-projection-bg: #ffffff;
    --attend-projection-fg: #000000;

    --font-display: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    /* Arabic text inside a page of another language (a bilingual half, the
       language switch's العربية): Rubik, as on Arabic pages. */
    --font-arabic: "Rubik", "Figtree", system-ui, "Segoe UI", "Noto Sans Arabic", "Geeza Pro", Tahoma,
      sans-serif;

    /* Type scale (visual-design.md §3): phone values here, desktop from 768px. */
    --text-display: 34px;
    --leading-display: 38px;
    --weight-display: 800;
    --tracking-display: -0.025em;
    --text-h1: 26px;
    --leading-h1: 32px;
    --weight-h1: 750;
    --tracking-h1: -0.02em;
    --text-h2: 19px;
    --leading-h2: 26px;
    --weight-h2: 700;
    --tracking-h2: -0.01em;
    --text-body: 16px;
    --leading-body: 24px;
    --weight-body: 450;
    --tracking-body: 0;
    --text-small: 14px;
    --leading-small: 20px;
    --weight-small: 500;
    --tracking-small: 0;
    --text-label: 12px;
    --leading-label: 16px;
    --weight-label: 700;
    --tracking-label: 0;
    --text-button: 16px;
    --leading-button: 20px;
    --weight-button: 650;
    --tracking-button: 0;
    --text-num-xl: 64px;
    --leading-num-xl: 64px;
    --weight-num-xl: 800;
    --tracking-num-xl: -0.03em;
    --text-num-m: 20px;
    --leading-num-m: 24px;
    --weight-num-m: 700;
    --tracking-num-m: 0;
    --text-input-mobile: 16px;
    --text-meta: var(--text-label);
    --text-support: var(--text-small);
    --text-section: var(--text-h2);
    --text-course: var(--text-h1);
    --text-page: var(--text-h1);
    --weight-book: 450;
    --weight-medium: 500;
    --weight-semi: 550;
    --weight-bold: 600;
    --weight-strong: 650; /* names and course titles */

    /* Spacing: 4px base (visual-design.md §5) */
    --space-05: 2px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-14: 56px;
    --space-18: 72px;

    /* Radii (visual-design.md §4) */
    --r-check: 5px; /* checkboxes (design review 2026-11-09): 8px read as a radio */
    --r-xs: 8px;
    --r-sm: 12px;
    --r-md: 16px;
    --r-lg: 22px;
    --r-xl: 28px;
    --r-pill: 999px;
    --radius-control: var(--r-sm);
    --radius-panel: var(--r-md);
    --touch: 44px;

    /* Motion (design review 2026-11-09, owner): dialogs, phone sheets (rise
       slower than they leave), and the fade that replaces motion when the
       person asks for less (§12). */
    --motion-dialog: 200ms;
    --motion-sheet: 280ms;
    --motion-exit: 200ms;
    --motion-fade: 150ms;
    --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);

    --sidebar-w: 248px;
    --rail-w: 56px;
    --topbar-h: 56px;
    --bottom-nav-h: 64px;
    /* The C1a bar (Board, 2026-11-18): its circle rises this far above the pill;
       a bar fixed above the tab bar sits at --bottom-nav-room, clear of the
       circle and its 5px ring. */
    --bottom-nav-lift: 18px;
    --bottom-nav-room: calc(var(--bottom-nav-h) + var(--bottom-nav-lift) + var(--space-2) + max(var(--space-4), env(safe-area-inset-bottom)));
    --content-max: 1440px;
    --narrow-max: 720px;
    /* Running text stays readable while pages fill the width. */
    --measure: 72ch;
  }

  @media (min-width: 768px) {
    :root {
      --text-display: 40px;
      --leading-display: 44px;
      --text-h1: 28px;
      --leading-h1: 34px;
      --text-h2: 18px;
      --leading-h2: 24px;
      --text-body: 15px;
      --leading-body: 22px;
      --text-small: 13px;
      --leading-small: 18px;
      --text-label: 12px;
      --leading-label: 16px;
      --text-button: 15px;
      --leading-button: 20px;
      --text-num-xl: 72px;
      --leading-num-xl: 72px;
      --text-num-m: 20px;
      --leading-num-m: 24px;
    }
  }

  /* Arabic type (docs/dev/i18n.md, "Arabic type"; owner 2026-11-09: Rubik, OFL).
     Rubik is named first, but its files are not vendored yet: the font package
     is a new dependency waiting for the owner's yes. Until then Figtree draws
     the Latin letters and digits, and the phone's own Arabic font the Arabic. */
  :root:lang(ar) {
    --font-arabic-fallback: system-ui, "Segoe UI", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
    --font-display: "Rubik", "Figtree", var(--font-arabic-fallback);
    --font-body: "Rubik", "Figtree", var(--font-arabic-fallback);
    /* The letters join: no tracking. */
    --tracking-display: 0;
    --tracking-h1: 0;
    --tracking-h2: 0;
    --tracking-label: 0;
    --tracking-num-xl: 0;
    /* Taller lines for the dots and the descenders (about 1.75 for text). */
    --leading-display: 48px;
    --leading-h1: 40px;
    --leading-h2: 32px;
    --leading-body: 28px;
    --leading-small: 24px;
    --leading-label: 20px;
    --leading-button: 24px;
    /* Rubik reads heavy at small sizes: one step lighter there. */
    --weight-body: 400;
    --weight-small: 400;
    --weight-label: 600;
    --weight-button: 600;
  }

  @media (min-width: 768px) {
    :root:lang(ar) {
      --leading-display: 52px;
      --leading-h1: 42px;
      --leading-h2: 30px;
      --leading-body: 26px;
      --leading-small: 22px;
      --leading-label: 20px;
      --leading-button: 24px;
    }
  }
}

/* ------------------------------------------------------------------- base */
@layer base {
  html {
    background: var(--attend-ground);
  }

  /* Scrollbars (owner, 2026-11-01): thin, a token thumb on a clear track.
     scrollbar-color inherits; the ink sidebar sets its own (shell.css). */
  :root {
    scrollbar-color: var(--attend-scrollbar) transparent;
  }

  * {
    scrollbar-width: thin;
  }

  /* The same for browsers without scrollbar-color (Safari). Chromium and
     Firefox use the two properties above and ignore these. */
  ::-webkit-scrollbar {
    inline-size: 8px;
    block-size: 8px;
  }

  ::-webkit-scrollbar-track {
    background-color: transparent;
  }

  ::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: var(--r-pill);
    background-clip: padding-box;
    background-color: var(--attend-scrollbar);
  }

  ::selection {
    background-color: var(--attend-brand-tint);
    color: var(--attend-text-strong);
  }

  body {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--attend-ground);
    color: var(--attend-text);
    font-family: var(--font-body);
    font-size: var(--text-body);
    font-weight: var(--weight-body);
    line-height: var(--leading-body);
    /* Light text on the dark surfaces reads as designed on a Mac (design
       review AD24); no effect on Windows or Android. */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  h1,
  h2,
  h3,
  h4 {
    color: var(--attend-text-strong);
    line-height: 1.25;
    text-wrap: balance;
  }

  /* Arabic letters join, so no tracking anywhere: important in this early
     layer, it outranks every later layer's letter-spacing. Arabic type has no
     italic either (a slanted Arabic is the browser's fake). */
  :lang(ar) {
    letter-spacing: 0 !important;
  }

  :lang(ar) :is(em, i, cite, .na) {
    font-style: normal !important;
  }

  /* Arabic inside an English page takes the Arabic face; an Arabic page has it already. */
  :root:not(:lang(ar)) [lang="ar"] {
    font-family: var(--font-arabic);
  }

  /* Display text: the wordmark, titles and big counters (§1). */
  h1,
  h2,
  .brand__mark,
  .course-card__title,
  .round-panel__count,
  .presenter__code {
    font-family: var(--font-display);
    font-optical-sizing: auto;
  }

  h1 {
    font-size: var(--text-h1);
    font-weight: var(--weight-h1);
    letter-spacing: var(--tracking-h1);
    line-height: var(--leading-h1);
  }

  h2 {
    font-size: var(--text-h2);
    font-weight: var(--weight-h2);
    letter-spacing: var(--tracking-h2);
    line-height: var(--leading-h2);
  }

  h3 {
    font-size: var(--text-body);
    font-weight: var(--weight-strong);
  }

  p {
    text-wrap: pretty;
  }

  /* No one-word last lines in table cells and row meta ("Demo Group / B";
     design review AD22). */
  td,
  .row__meta {
    text-wrap: pretty;
  }

  /* Times, countdowns, counts and IDs keep their width (§1). */
  time,
  output,
  .tabular,
  .num,
  .count-badge,
  .round-panel__count,
  .round-card__tally,
  .presenter__countdown,
  .presenter__code,
  .day-row__time,
  .activation-code {
    font-variant-numeric: tabular-nums;
  }

  /* --brand-text in both themes: --brand is too dim as text on dark (3.56:1). */
  a {
    color: var(--attend-brand-text);
    text-underline-offset: 2px;
  }

  /* Hover only with a mouse: on a touch screen it would stick after a tap
     (design review AD3). */
  @media (hover: hover) and (pointer: fine) {
    a:hover {
      color: var(--attend-link-hover);
    }
  }

  code,
  kbd {
    font-family: var(--font-mono);
    font-size: 0.92em;
  }

  /* The design's ring (3px gap, 2px ring) as an outline: also in forced colours. */
  :focus-visible {
    outline: 2px solid var(--attend-focus);
    outline-offset: 3px;
  }

  ::placeholder {
    color: var(--attend-text-muted);
    opacity: 1;
  }

  /* Inputs (visual-design.md §7): 48px on phones, 40px from 768px. Soft
     filled (owner, 2026-11-01; "Dark & Soft Fill" 2026-11-11): the fill
     marks an editable field, with no edge at rest in either theme (the edge
     stays transparent, so forced colours still draw it); an edge shows
     under a mouse. The label and the fill identify the field. */
  input:not([type="checkbox"], [type="radio"]),
  select,
  textarea {
    width: 100%;
    min-height: 48px;
    padding: var(--space-2) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background-color: var(--attend-field);
    color: var(--attend-text-strong);
    caret-color: var(--attend-focus);
    transition:
      border-color 120ms ease,
      background-color 120ms ease;
  }

  @media (hover: hover) and (pointer: fine) {
    input:not([type="checkbox"], [type="radio"]):hover,
    select:hover,
    textarea:hover {
      border-color: var(--attend-field-edge-hover);
    }
  }

  /* Inside a raised surface (dialogs, their phone sheets, menus) a field
     takes the lighter field-raised fill, so it never sinks into it. */
  :where(.dialog, .tools-more__panel) :is(input:not([type="checkbox"], [type="radio"]), select, textarea) {
    background-color: var(--attend-field-raised);
  }

  /* Focus: the fill stays, the edge turns to the focus colour and a soft
     halo sits outside it. The halo is an outline at the edge (not a
     shadow), so it shows in the dark themes and in forced colours too. */
  input:not([type="checkbox"], [type="radio"]):focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    border-color: var(--attend-focus);
    outline: 3px solid var(--attend-field-halo);
    outline-offset: 0;
  }

  /* Chromium's date and time fields have one more Tab stop, their picker
     button, inside the field: the field is still the focused element but
     matches neither :focus nor :focus-visible there, so they keep the same
     ring on :focus-within (they are always typed into). */
  input:is([type="date"], [type="time"], [type="datetime-local"]):focus-within {
    border-color: var(--attend-focus);
    outline: 3px solid var(--attend-field-halo);
    outline-offset: 0;
  }

  input[type="search"] {
    border-radius: var(--r-pill);
  }

  /* Compact for a mouse only; a touched tablet keeps 48px fields. */
  @media (min-width: 768px) and (pointer: fine) {
    input:not([type="checkbox"], [type="radio"]),
    select {
      min-height: 40px;
    }
  }

  /* Native parts drawn in the Indigo look (owner, 2026-11-01). The pop-up
     calendar, a select's open list and the date format stay the browser's;
     color-scheme gives them the theme. Icons: --attend-icon-* tokens. */
  select {
    appearance: none;
    padding-inline-end: var(--space-8);
    background-image: var(--attend-icon-chevron);
    background-repeat: no-repeat;
    background-position: right var(--space-3) center; /* physical: mirrored below */
    background-size: 16px;
  }

  /* No logical background-position yet: the chevron moves to the left in Arabic. */
  :root[dir="rtl"] select {
    background-position: left var(--space-3) center; /* physical: the rtl mirror */
  }

  select[multiple],
  select[size]:not([size="1"]) {
    padding-inline-end: var(--space-4);
    background-image: none;
  }

  ::-webkit-calendar-picker-indicator {
    inline-size: 18px;
    block-size: 18px;
    padding: 0;
    color: transparent;
    background-image: var(--attend-icon-calendar);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px;
    opacity: 1;
    cursor: pointer;
  }

  input[type="time"]::-webkit-calendar-picker-indicator {
    background-image: var(--attend-icon-clock);
  }

  ::-webkit-search-cancel-button {
    appearance: none;
    inline-size: 16px;
    block-size: 16px;
    background-image: var(--attend-icon-clear);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px;
    cursor: pointer;
  }

  /* No spinners: the value is typed (arrow keys still step it). */
  input[type="number"] {
    appearance: textfield;
  }

  ::-webkit-inner-spin-button,
  ::-webkit-outer-spin-button {
    appearance: none;
    margin: 0;
  }

  textarea {
    resize: vertical;
  }

  /* Chrome paints its autofill colour with !important; holding that
     transition keeps the field's own fill, and the text keeps its colour. */
  input:autofill {
    -webkit-text-fill-color: var(--attend-text-strong);
    transition: background-color 600000s 0s, color 600000s 0s;
  }

  input[type="checkbox"],
  input[type="radio"] {
    flex: none;
    inline-size: 18px;
    block-size: 18px;
    margin: 0;
    appearance: none;
    border: 1.5px solid var(--attend-border-strong);
    background-color: var(--attend-surface);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px;
    vertical-align: middle;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease;
  }

  input[type="checkbox"] {
    border-radius: var(--r-check);
  }

  input[type="radio"] {
    border-radius: 50%;
  }

  @media (hover: hover) and (pointer: fine) {
    input[type="checkbox"]:hover,
    input[type="radio"]:hover {
      border-color: var(--attend-accent);
    }
  }

  /* --accent: indigo in both themes, the dark one the dark brand (owner,
     2026-11-11; it was lavender): 3:1 on every surface, the mark white. */
  input[type="checkbox"]:checked,
  input[type="radio"]:checked {
    border-color: var(--attend-accent);
    background-color: var(--attend-accent);
  }

  input[type="checkbox"]:checked {
    background-image: var(--attend-icon-check);
  }

  input[type="radio"]:checked {
    background-image: var(--attend-icon-dot);
  }

  input[type="checkbox"]:disabled,
  input[type="radio"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  input[aria-invalid="true"],
  select[aria-invalid="true"],
  textarea[aria-invalid="true"] {
    border-color: var(--attend-danger-text);
    outline: 3px solid var(--attend-danger-bg);
    outline-offset: 0;
  }

  /* The fill marks an editable field: disabled fades to half, read-only
     drops the fill and keeps a hairline (2026-11-11). */
  input:not([type="checkbox"], [type="radio"]):disabled,
  select:disabled,
  textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  /* Read-only also shows a small muted lock at the inline end (owner,
     2026-11-11): a background image, since an input has no ::after; it is
     decorative, the field keeps its name and readonly semantics. A select
     has no readonly, so it is aria-readonly there, and the lock replaces
     its chevron. The end padding keeps the text clear of the lock. */
  input:not([type="checkbox"], [type="radio"])[readonly],
  textarea[readonly],
  select[aria-readonly="true"] {
    padding-inline-end: var(--space-8);
    border-color: var(--attend-border);
    background-color: transparent;
    background-image: var(--attend-icon-lock);
    background-repeat: no-repeat;
    background-position: right var(--space-3) center; /* physical: mirrored below */
    background-size: 16px;
  }

  /* The field's own direction, so an ID typed left to right in Arabic
     keeps the lock on the side its end padding is on. */
  input:not([type="checkbox"], [type="radio"])[readonly]:dir(rtl),
  select[aria-readonly="true"]:dir(rtl) {
    background-position: left var(--space-3) center; /* physical: the rtl mirror */
  }

  /* A text area's lock sits beside its first line. */
  textarea[readonly] {
    background-position: right var(--space-3) top var(--space-3); /* physical: mirrored below */
  }

  textarea[readonly]:dir(rtl) {
    background-position: left var(--space-3) top var(--space-3); /* physical: the rtl mirror */
  }

  /* iOS zooms into inputs smaller than 16px. */
  @media (max-width: 767px) {
    input,
    select,
    textarea {
      font-size: var(--text-input-mobile);
    }
  }

  /* Disclosure headings are touch targets too (44px, UI_UX §2). A simple
     chevron replaces the browser's triangle: it points down when closed and
     up when open. */
  summary {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch);
    min-inline-size: var(--touch);
    padding-block: var(--space-3);
    list-style: none;
    cursor: pointer;
  }

  summary::-webkit-details-marker {
    display: none;
  }

  summary::after {
    content: "";
    flex: none;
    inline-size: 8px;
    block-size: 8px;
    border-inline-end: 2px solid currentColor;
    border-block-end: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 150ms ease-out;
  }

  /* The chevron turns over instead of jumping (design review AD21). */
  details[open] > summary::after {
    transform: translateY(2px) rotate(-135deg);
  }

  /* Disclosures open and close smoothly where the browser can size to auto
     (design review AD21); elsewhere they snap as before. A details used as a
     menu (data-menu) is left alone: clipping would hide its popup. */
  @media (prefers-reduced-motion: no-preference) {
    :root {
      interpolate-size: allow-keywords;
    }

    details:not([data-menu])::details-content {
      block-size: 0;
      overflow-y: clip;
      transition:
        block-size var(--motion-dialog) cubic-bezier(0.22, 1, 0.36, 1),
        content-visibility var(--motion-dialog) allow-discrete;
    }

    /* Open, it stops clipping once it has grown, so a focus ring or a
       field's halo at its edge shows whole (batch 1 review); closing clips
       again at once. Opening shows the content at once (no content-visibility
       transition here), so Tab right after Enter reaches its fields (design
       integration 2026-11-10); closing keeps it visible until it has shrunk. */
    details:not([data-menu])[open]::details-content {
      block-size: auto;
      overflow-y: visible;
      transition:
        block-size var(--motion-dialog) cubic-bezier(0.22, 1, 0.36, 1),
        overflow-y 0s linear var(--motion-dialog) allow-discrete;
    }
  }

  /* Right to left the corner is drawn on the other side: turned the other way,
     the chevron still points down (open: up). */
  :root[dir="rtl"] summary::after {
    transform: rotate(-45deg);
  }

  :root[dir="rtl"] details[open] > summary::after {
    transform: rotate(135deg);
  }

  hr {
    border: 0;
    border-top: 1px solid var(--attend-edge);
    margin: var(--space-6) 0;
  }
}

/* ----------------------------------------------------------------- layout */
@layer layout {
  .skip-link {
    position: absolute;
    inset-inline-start: var(--space-3);
    top: var(--space-3);
    z-index: 100;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-control);
    background: var(--attend-action);
    color: var(--attend-action-text);
    font-weight: var(--weight-medium);
    transform: translateY(-200%);
  }

  .skip-link:focus {
    transform: none;
  }

  /* App shell: sidebar >=1024px, 56px rail 768-1023px, top bar + bottom nav <768px. */
  .shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: var(--topbar-h);
    padding-block: var(--space-1);
    padding-inline: var(--space-4) var(--space-2);
    padding-top: max(var(--space-1), env(safe-area-inset-top));
    border-bottom: 1px solid var(--attend-edge);
    background: var(--attend-surface);
  }

  /* A column the content fills, so the footer sits at the bottom of a short
     page (design review AL19); .content__body grows, the page flows in it. */
  .main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: var(--space-6) var(--space-4);
    padding-left: max(var(--space-4), env(safe-area-inset-left)); /* physical: the screen's own sides */
    padding-right: max(var(--space-4), env(safe-area-inset-right)); /* physical: the screen's own sides */
  }

  .shell--bottom-nav .main {
    padding-bottom: calc(
      var(--bottom-nav-h) + var(--bottom-nav-lift) + var(--space-6) +
        max(var(--space-4), env(safe-area-inset-bottom))
    );
  }

  .main:focus {
    outline: none;
  }

  /* Pages use the width of wide screens, centered (owner, 2026-11-02, after
     the Rad360 reference); running text keeps --measure, forms --narrow-max. */
  .content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
  }

  .content__body {
    flex: 1 0 auto;
  }

  .content__body > p {
    max-width: var(--measure);
  }

  /* Flow: blocks in the content column and in a plain section are spaced, so
     a paragraph never sits on the next form, table or heading. Zero
     specificity in this layer: a component's own margin wins, and sibling
     margins collapse, so a larger gap is never added to. Sections that are
     flex or grid containers space their children with gap instead. */
  :where(.content__body, section.section:not(.stack, .form, .roster-card)) > :where(* + *) {
    margin-block-start: var(--space-4);
  }

  .content--narrow {
    max-width: var(--narrow-max);
    margin-inline: auto;
  }

  .main-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
    margin-top: var(--space-8);
    padding-top: var(--space-4);
    border-top: 1px solid var(--attend-edge);
    font-size: var(--text-meta);
    color: var(--attend-text-secondary);
  }

  /* One line: a long university name ends in an ellipsis (the full name is
     its title) instead of wrapping the footer. */
  .main-foot__org {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  @media (min-width: 768px) {
    .shell {
      grid-template-columns: var(--rail-w) minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr);
    }

    .topbar,
    .bottom-nav {
      display: none;
    }

    .shell--bottom-nav .main {
      padding-bottom: var(--space-8);
    }

    .sidebar {
      position: sticky;
      top: 0;
      height: 100vh;
      height: 100dvh;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: var(--space-4);
      padding: var(--space-6) var(--space-1) var(--space-4);
      border-inline-end: 1px solid var(--attend-edge);
      /* A card-white column on the ground until the ink sidebar lands. */
      background: var(--attend-surface);
    }

    .main {
      padding: var(--space-8) var(--space-8) var(--space-6);
    }
  }

  @media (min-width: 1024px) {
    .shell {
      grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    }

    .shell[data-nav="collapsed"] {
      grid-template-columns: var(--rail-w) minmax(0, 1fr);
    }

    .shell:not([data-nav="collapsed"]) .sidebar {
      padding-inline: var(--space-3);
    }

    .main {
      padding: 28px var(--space-8) var(--space-6);
    }
  }

  /* Bare pages: sign-in, verification, errors. */
  .bare {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: var(--space-8) var(--space-4) var(--space-6);
  }

  .bare__inner {
    width: 100%;
    max-width: 400px;
    margin: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
  }

  .bare__foot {
    margin-top: var(--space-8);
    text-align: center;
  }

  /* The privacy policy (templates/ui/privacy.html; its reading measure is in
     shell.css): the language switch at the inline end above the text. */
  .policy__lang {
    display: flex;
    justify-content: flex-end;
  }

  .policy h2 {
    font-size: var(--text-h2);
  }

  .policy__list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-inline-start: var(--space-5);
  }

  /* "Privacy policy" under the credit (sign-in), on Account and the Android page. */
  .policy-link {
    color: var(--attend-text-muted);
    font-size: var(--text-label);
  }

  .signin__foot .policy-link {
    display: block;
    margin-block-start: var(--space-1);
  }
}

/* -------------------------------------------------------------- utilities */
@layer utilities {
  .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .muted {
    color: var(--attend-text-secondary);
  }

  .small {
    font-size: var(--text-small);
  }

  .stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }

  .stack--tight {
    gap: var(--space-2);
  }

  .mt-0 {
    margin-top: 0;
  }

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

  /* A piece that wraps as one word: a room code's hyphenated token (|code), a
     time range, "Section A" (apps/core/line_breaks.py). */
  .nowrap {
    white-space: nowrap;
  }

  /* A piece that moves to the next line as one: a lecturer's name, a hall (the
     week pages; owner, 2026-11-13: a name never breaks across lines). Only a
     piece longer than the whole line wraps inside itself, so nothing is cut.
     A dot that belongs to the piece goes inside it: a browser breaks the line
     between a no-break space and an inline block (tests/e2e/test_real_week.py). */
  .whole {
    display: inline-block;
    max-inline-size: 100%;
  }

  .only-mobile {
    display: none;
  }

  @media (max-width: 767px) {
    .only-mobile {
      display: revert;
    }

    .hide-mobile {
      display: none;
    }
  }
}
