/* IEEE Invoices — one stylesheet, organised in cascade layers (later layers win):
     reset → tokens → base → layout → components → pages → utilities
   Colour: two hues taken from the IEEE Tunisia Section logo, plus neutrals. Blue is for actions, links, the
   current step and "fine"; red is only for what a person must look at (wrong, missing, to review, errors).
   Tokens resolve for light and dark with light-dark(); change colours in `tokens` only.
   Type: Public Sans, six sizes, weights 400 / 600 / 700. Space: 4 px steps on an 8 px rhythm.
   The CSP forbids inline styles: every visual state is a class, a data-* attribute or a native state (:open,
   :popover-open, :disabled, :has()). Targets current evergreen browsers; newer features (anchor positioning,
   view transitions) only add polish and degrade to a working page. */

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

/* Public Sans (variable, 100–900; SIL OFL 1.1, see /static/fonts/OFL.txt), self-hosted: no third-party requests. */
@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/public-sans-latin.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  src: url("/static/fonts/public-sans-latin-ext.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  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;
}

/* Typed custom property: animatable (spinner angle). */
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

/* Same-origin page navigations cross-fade instead of flashing (cross-document view transitions). */
@view-transition { navigation: auto; }

/* ───────────────────────────────── reset ───────────────────────────────── */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, svg, picture { display: block; max-inline-size: 100%; }
  input, button, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
  button { cursor: pointer; }
  ol[class], ul[class] { list-style: none; padding: 0; }
  table { border-collapse: collapse; }
  [hidden] { display: none !important; }
}

/* ───────────────────────────────── tokens ───────────────────────────────── */
@layer tokens {
  :root {
    color-scheme: light dark;
    interpolate-size: allow-keywords;  /* lets <details> animate to height: auto */

    /* brand: IEEE blue #00629B, as in the logo */
    --brand:        light-dark(#00629b, #6cb2e6);
    --brand-strong: light-dark(#004c78, #9bcbf0);
    --brand-soft:   light-dark(#e8f1f8, #1b3346);
    --on-brand:     light-dark(#ffffff, #0e1a24);

    /* alert: the logo's Tunisia red #C8102E. --alert is the text-strength shade (≥ 4.5:1 on --alert-soft and
       on surfaces), --alert-fill the solid shade for marks and rings. */
    --alert:      light-dark(#a50d26, #ff8a9b);
    --alert-fill: light-dark(#c8102e, #e0485e);
    --alert-soft: light-dark(#fcebee, #3a1b22);

    /* neutrals (slightly cool) */
    --bg:          light-dark(#f5f7f9, #11151b);
    --surface:     light-dark(#ffffff, #171c24);
    --surface-2:   light-dark(#eef1f4, #202733);
    --line:        light-dark(#dce1e7, #2c3542);
    --line-strong: light-dark(#b9c1cb, #45505f);
    --text:        light-dark(#16202b, #e8ecf0);
    --text-2:      light-dark(#3d4a57, #c3cbd4);
    --muted:       light-dark(#56616d, #9aa5b1);
    --focus: var(--brand);

    /* type: Public Sans; fixed small sizes, fluid headings */
    --font-sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    --text-xs: .8125rem;                                 /* 13 */
    --text-sm: .875rem;                                  /* 14 */
    --text-md: 1rem;                                     /* 16 */
    --text-lg: 1.125rem;                                 /* 18 */
    --text-xl: clamp(1.375rem, 1.2rem + .6vw, 1.625rem); /* 22 → 26 */
    --text-2xl: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem); /* 28 → 36 */

    /* space (4 px steps) */
    --s-1: .25rem; --s-2: .5rem; --s-3: .75rem; --s-4: 1rem; --s-5: 1.25rem; --s-6: 1.5rem; --s-8: 2rem;
    --s-10: 2.5rem; --s-12: 3rem; --s-16: 4rem;
    --gutter: clamp(1rem, .5rem + 2.5vw, 2rem);

    /* shape and depth: flat surfaces with hairlines; shadow only for floating layers */
    --radius-sm: 8px; --radius: 10px; --radius-lg: 14px; --radius-full: 999px;
    --shadow-color: light-dark(215 25% 20%, 220 40% 2%);
    --shadow-1: 0 1px 2px hsl(var(--shadow-color) / .05);
    --shadow-3: 0 2px 4px hsl(var(--shadow-color) / .08), 0 12px 32px -6px hsl(var(--shadow-color) / .22);

    /* motion */
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --ease-in-out: cubic-bezier(.65, 0, .35, 1);
    --dur-1: 120ms; --dur-2: 200ms; --dur-3: 320ms;

    --control-h: 2.75rem;  /* 44 px touch target */
    --content-max: 70rem;  /* 1120 px */
  }
}

/* ───────────────────────────────── base ───────────────────────────────── */
@layer base {
  body {
    min-block-size: 100dvh; display: flex; flex-direction: column;
    font-family: var(--font-sans); font-size: var(--text-md); line-height: 1.5;
    font-optical-sizing: auto; font-synthesis: none; -webkit-font-smoothing: antialiased;
    color: var(--text); background: var(--bg);
  }
  h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; font-weight: 700; text-wrap: balance; }
  p, li { text-wrap: pretty; }
  b, strong { font-weight: 600; }
  a { color: var(--brand); text-underline-offset: .18em; text-decoration-thickness: from-font; }
  a:hover { color: var(--brand-strong); }
  :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
  ::selection { background: color-mix(in srgb, var(--brand) 22%, transparent); }
  .icon { inline-size: 1.15em; block-size: 1.15em; flex: none; }
}

/* ───────────────────────────────── layout ───────────────────────────────── */
@layer layout {
  .skip-link {
    position: fixed; inset-inline-start: var(--s-4); inset-block-start: var(--s-3); z-index: 100;
    padding: var(--s-2) var(--s-4); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--brand); box-shadow: var(--shadow-3); font-weight: 600;
    translate: 0 -200%; transition: translate var(--dur-2) var(--ease-out);
    &:focus-visible { translate: 0; }
  }

  /* header: logo + product name on the start side, language and account on the end side */
  .site-header {
    position: sticky; inset-block-start: 0; z-index: 20;
    background: var(--surface); border-block-end: 1px solid var(--line);
    view-transition-name: site-header;
  }
  .site-header-inner {
    display: flex; align-items: center; gap: var(--s-3) var(--s-4);
    max-inline-size: var(--content-max); margin-inline: auto; min-block-size: 4rem;
    padding: var(--s-2) var(--gutter);
    padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
  }

  main {
    flex: 1; inline-size: 100%; max-inline-size: var(--content-max); margin-inline: auto;
    padding: var(--s-8) var(--gutter) var(--s-16);
    container: page / inline-size;
    &:focus { outline: none; }
  }

  /* footer: the full lockup (with "Technical Activities Committee") where it is large enough to read */
  .site-footer { background: var(--surface); border-block-start: 1px solid var(--line); }
  .site-footer-inner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4) var(--s-12);
    max-inline-size: var(--content-max); margin-inline: auto; padding: var(--s-6) var(--gutter) var(--s-8);
  }
  .footer-logo img { block-size: 3.5rem; inline-size: auto; }
  .site-footer-text {
    display: grid; gap: var(--s-1); max-inline-size: 60ch; color: var(--muted); font-size: var(--text-sm);
    & p:first-child { display: flex; gap: var(--s-2); align-items: flex-start; }
    & .icon { margin-block-start: .2em; }
  }

  /* sign-in: intro + form side by side when there is room */
  .split {
    display: grid; gap: var(--s-10); align-items: center;
    @container page (inline-size >= 52rem) {
      grid-template-columns: minmax(0, 1.15fr) minmax(22rem, .85fr); gap: var(--s-16); padding-block: var(--s-8);
    }
  }

  /* upload: main card + recent checks aside */
  .workspace {
    display: grid; gap: var(--s-6); max-inline-size: 44rem;
    &.has-aside {
      @container page (inline-size >= 60rem) {
        max-inline-size: none; grid-template-columns: minmax(0, 1fr) minmax(18rem, 21rem); align-items: start;
        gap: var(--s-8);
      }
    }
  }
}

/* ───────────────────────────────── components ───────────────────────────────── */
@layer components {
  /* brand: compact IEEE Tunisia Section logo | product name */
  .brand {
    display: flex; align-items: center; gap: var(--s-4); min-inline-size: 0;
    color: var(--text); text-decoration: none;
    &:hover { color: var(--text); }
  }
  .brand-logo img { block-size: 2rem; inline-size: auto; }
  .brand-name {
    padding-inline-start: var(--s-4); border-inline-start: 1px solid var(--line);
    font-size: 1.0625rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.75rem; white-space: nowrap;
  }

  /* language switcher: a two-item segmented control */
  .lang-switch {
    display: inline-flex; gap: 2px; padding: 3px; margin-inline-start: auto;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    & a {
      display: inline-grid; place-items: center; min-inline-size: 2.5rem; block-size: 2.25rem;
      border-radius: 7px; font-size: var(--text-xs); font-weight: 700; letter-spacing: .04em;
      color: var(--muted); text-decoration: none; transition: background-color var(--dur-1), color var(--dur-1);
      &:hover { color: var(--brand); background: var(--surface-2); }
      &[aria-current] { color: var(--brand); background: var(--brand-soft); }
    }
  }

  /* account menu: a native popover, anchored to its button */
  .account-trigger {
    anchor-name: --account;
    display: flex; align-items: center; gap: var(--s-2); max-inline-size: 18rem; min-block-size: var(--control-h);
    padding: var(--s-1) var(--s-3) var(--s-1) var(--s-1);
    border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--surface);
    color: var(--text-2); font-size: var(--text-sm);
    transition: border-color var(--dur-1);
    &:hover { border-color: var(--line-strong); }
    & .icon-chevron { inline-size: 1rem; color: var(--muted); transition: rotate var(--dur-2) var(--ease-out); }
    &:has(+ :popover-open) .icon-chevron { rotate: 180deg; }
  }
  .avatar {
    display: grid; place-items: center; inline-size: 2rem; block-size: 2rem; border-radius: 50%; flex: none;
    background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: var(--text-sm);
  }
  .account-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .account-menu {
    position-anchor: --account;
    position-area: block-end span-inline-start;
    position-try-fallbacks: flip-inline;
    inset: auto; margin: var(--s-2) 0 0;
    inline-size: max-content; min-inline-size: 15rem; max-inline-size: min(22rem, calc(100vw - 2rem));
    padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-3);
    opacity: 0; translate: 0 -6px;
    transition: opacity var(--dur-2) var(--ease-out), translate var(--dur-2) var(--ease-out),
      display var(--dur-2) allow-discrete, overlay var(--dur-2) allow-discrete;
    &:popover-open { opacity: 1; translate: 0; @starting-style { opacity: 0; translate: 0 -6px; } }
  }
  .account-menu-label { color: var(--muted); font-size: var(--text-xs); }
  .account-menu-email { font-weight: 600; overflow-wrap: anywhere; margin-block-end: var(--s-3); }

  /* phones: logo only (the product name is in the page title), avatar-only account button, and the language
     switcher reduced to the one language you can switch to */
  @media (width < 40rem) {
    .site-header-inner { min-block-size: 3.5rem; gap: var(--s-2); }
    .brand-logo img { block-size: 1.625rem; }
    .brand-name { display: none; }
    .lang-switch { border-color: transparent; padding: 0;
      & a[aria-current] { display: none; }
      & a { min-inline-size: var(--control-h); block-size: var(--control-h); color: var(--brand); } }
    .account-trigger { padding: var(--s-1); & .icon-chevron, & .account-email { display: none; } }
    .footer-logo img { block-size: 3rem; }
  }

  /* steps indicator (sign-in → upload → result) */
  .steps-nav { margin-block-end: var(--s-8); view-transition-name: steps; }
  .steps { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
    font-size: var(--text-sm); color: var(--muted); }
  .step {
    display: flex; align-items: center; gap: var(--s-2);
    & + .step::before {
      content: ""; inline-size: clamp(1rem, 4vw, 2rem); block-size: 2px; border-radius: 2px;
      background: var(--line); margin-inline-end: var(--s-1);
    }
    &.is-done + .step::before { background: var(--brand); }
  }
  .step-num {
    display: grid; place-items: center; inline-size: 1.5rem; block-size: 1.5rem; border-radius: 50%;
    border: 2px solid var(--line-strong); font-size: var(--text-xs); font-weight: 700;
    font-variant-numeric: tabular-nums;
    & .icon { inline-size: .8rem; block-size: .8rem; stroke-width: 3.5; }
  }
  .step.is-current { color: var(--text); font-weight: 600;
    & .step-num { border-color: var(--brand); background: var(--brand); color: var(--on-brand); } }
  .step.is-done .step-num { border-color: transparent; background: var(--brand-soft); color: var(--brand); }
  @container page (inline-size < 34rem) {
    .step:not(.is-current) .step-label { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
      clip-path: inset(50%); white-space: nowrap; }  /* phones: numbers only, except the current step */
  }

  /* cards */
  .card {
    position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: clamp(var(--s-5), 5cqi, var(--s-8)); box-shadow: var(--shadow-1);
    container: card / inline-size;
    animation: rise var(--dur-3) var(--ease-out) both;
  }
  .card-form { max-inline-size: 28rem; inline-size: 100%; margin-inline: auto; }
  .card-center { max-inline-size: 36rem; margin-inline: auto; text-align: center;
    & .actions { justify-content: center; } & .field, & form { text-align: start; } }
  .card-aside { padding: var(--s-6); animation-delay: 60ms; }
  .card-title { font-size: var(--text-xl); margin-block-end: var(--s-2); }
  .card-lead { color: var(--text-2); margin-block-end: var(--s-6); }
  .card-footer-links {
    display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s-2) var(--s-6);
    margin-block-start: var(--s-6); padding-block-start: var(--s-4); border-block-start: 1px solid var(--line);
    & form { display: contents; }
  }
  @keyframes rise { from { opacity: 0; translate: 0 6px; } }

  .eyebrow { color: var(--brand); font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em;
    text-transform: uppercase; margin-block-end: var(--s-2); }
  .display { font-size: var(--text-2xl); letter-spacing: -.02em; margin-block-end: var(--s-4); max-inline-size: 18ch; }
  .lead { color: var(--text-2); font-size: var(--text-lg); line-height: 1.55; max-inline-size: 40ch; }
  .note, .hint { color: var(--muted); font-size: var(--text-sm); }
  .hint { margin-block-start: var(--s-1); }
  .email-text { font-weight: 600; overflow-wrap: anywhere; unicode-bidi: isolate; }
  .file-name {
    display: inline-flex; align-items: center; gap: var(--s-2); max-inline-size: 100%;
    color: var(--muted); font-size: var(--text-sm);
    & span { overflow-wrap: anywhere; text-wrap: balance; }  /* long names without spaces break evenly */
  }

  /* round state icon heading a card */
  .state-badge {
    display: inline-grid; place-items: center; inline-size: 3rem; block-size: 3rem; border-radius: 50%;
    margin-block-end: var(--s-4); flex: none;
    & .icon { inline-size: 1.5rem; block-size: 1.5rem; }
  }
  .state-bad { background: var(--alert-soft); color: var(--alert); }
  .state-info, .state-pending { background: var(--brand-soft); color: var(--brand); }

  /* forms */
  .form { display: grid; gap: var(--s-4); }
  .field { display: grid; gap: var(--s-2); }
  label { font-weight: 600; font-size: var(--text-sm); color: var(--text); }
  input:where([type=email], [type=text], :not([type])) {
    inline-size: 100%; min-block-size: var(--control-h); padding: var(--s-2) var(--s-3);
    border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
    transition: border-color var(--dur-1), box-shadow var(--dur-1);
    &::placeholder { color: var(--muted); opacity: .75; }
    &:hover { border-color: var(--muted); }
    &:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
    &:user-invalid { border-color: var(--alert-fill); box-shadow: 0 0 0 3px var(--alert-soft); }
  }
  input.otp {
    font-family: var(--font-mono); font-size: clamp(1.5rem, 1.2rem + 1.5vw, 1.875rem); font-weight: 600;
    letter-spacing: .5em; text-align: center; padding-inline-start: calc(var(--s-3) + .5em);
    min-block-size: 3.5rem; font-variant-numeric: tabular-nums; caret-color: var(--brand);
    &::placeholder { color: var(--line-strong); opacity: 1; }
  }

  /* buttons: one filled style (the page's main action), one outlined, one text link */
  .button {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    min-block-size: var(--control-h); padding: var(--s-2) var(--s-5);
    border: 1px solid transparent; border-radius: var(--radius); font-weight: 600; text-decoration: none;
    line-height: 1.2; text-align: center; -webkit-tap-highlight-color: transparent;
    transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1), translate var(--dur-1);
    &:active:not(:disabled) { translate: 0 1px; }
    &:disabled { cursor: not-allowed; opacity: .5; }
    &[aria-busy=true] { cursor: progress; opacity: .8; }
    & .icon-arrow-right { transition: translate var(--dur-2) var(--ease-out); }
    &:hover .icon-arrow-right { translate: 3px 0; }
  }
  .button-primary {
    color: var(--on-brand); background: var(--brand);
    &:hover:not(:disabled) { color: var(--on-brand); background: var(--brand-strong); }
  }
  .button-secondary {
    color: var(--text); background: var(--surface); border-color: var(--line-strong);
    &:hover { color: var(--brand); border-color: var(--brand); }
  }
  .button-block { inline-size: 100%; }
  .button-large { min-block-size: 3rem; }
  .button-small { min-block-size: 2.5rem; padding-inline: var(--s-3); font-size: var(--text-sm); }
  .button-link {
    display: inline-flex; align-items: center; gap: var(--s-2); min-block-size: var(--control-h);
    padding: 0 var(--s-1); border: 0; background: none; color: var(--brand); font-weight: 600;
    text-decoration: none;
    & span { text-decoration: underline; text-decoration-color: transparent; text-underline-offset: .2em;
      transition: text-decoration-color var(--dur-1); }
    &:hover span { text-decoration-color: currentColor; }
    &:disabled { color: var(--muted); cursor: default; & span { text-decoration: none; } }
  }
  .actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-block-start: var(--s-6);
    & .button { flex: 1 1 14rem; } }

  /* alerts: red for errors, blue for information */
  .alert {
    display: flex; align-items: flex-start; gap: var(--s-3); text-align: start;
    padding: var(--s-3) var(--s-4); margin-block-end: var(--s-5); border-radius: var(--radius);
    font-size: var(--text-sm);
    & .icon { margin-block-start: .1em; }
    animation: rise var(--dur-2) var(--ease-out);
  }
  .alert-error { color: var(--alert); background: var(--alert-soft); }
  .alert-info { color: var(--brand-strong); background: var(--brand-soft); }

  /* status chips: fine = grey with a blue tick; wrong or missing = red tint; to review = red outline */
  .chip {
    display: inline-flex; align-items: center; gap: .35em; padding: .25rem .625rem; border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 600; white-space: nowrap; line-height: 1.4;
    color: var(--text); background: var(--surface-2);
    & .icon { inline-size: 1em; block-size: 1em; stroke-width: 3; }
  }
  .chip-ok .icon { color: var(--brand); }
  .chip-bad { color: var(--alert); background: var(--alert-soft); }
  .chip-review { color: var(--alert); background: transparent; box-shadow: inset 0 0 0 1.5px var(--alert-fill); }
  .chip-pending { color: var(--brand-strong); background: var(--brand-soft);
    &::before { content: ""; inline-size: .45rem; block-size: .45rem; border-radius: 50%; background: currentColor;
      animation: pulse 1.4s var(--ease-in-out) infinite; } }
  @keyframes pulse { 50% { opacity: .3; scale: .7; } }

  /* disclosure (<details>) with an animated open/close */
  .disclosure {
    margin-block-start: var(--s-6); border-block-start: 1px solid var(--line); padding-block-start: var(--s-3);
    & summary {
      display: flex; align-items: center; gap: var(--s-2); min-block-size: var(--control-h); cursor: pointer;
      font-weight: 600; color: var(--text-2); list-style: none; border-radius: var(--radius-sm);
      &::-webkit-details-marker { display: none; }
      &:hover { color: var(--brand); }
      & .icon-chevron { margin-inline-start: auto; transition: rotate var(--dur-2) var(--ease-out); }
    }
    &[open] summary .icon-chevron { rotate: 180deg; }
    &::details-content {
      block-size: 0; overflow: clip;
      transition: block-size var(--dur-3) var(--ease-out), content-visibility var(--dur-3) allow-discrete;
    }
    &[open]::details-content { block-size: auto; }
  }
  .checklist {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: var(--s-2) var(--s-6);
    padding-block: var(--s-2) var(--s-1); color: var(--text-2); font-size: var(--text-sm);
    & li { display: flex; gap: var(--s-2); align-items: baseline; }
    & li::before { content: ""; flex: none; inline-size: .375rem; block-size: .375rem; border-radius: 50%;
      background: var(--brand); translate: 0 -.15em; }
  }
}

/* ───────────────────────────────── pages ───────────────────────────────── */
@layer pages {
  /* sign-in: how it works */
  .intro { max-inline-size: 36rem; }
  .how {
    display: grid; gap: var(--s-5); margin-block-start: var(--s-8);
    & li { display: grid; grid-template-columns: auto 1fr; column-gap: var(--s-4); color: var(--muted);
      font-size: var(--text-sm); }
    & b { color: var(--text); font-size: var(--text-md); }
    & span:last-child { grid-column: 2; }
  }
  .how-num {
    grid-row: span 2; display: grid; place-items: center; inline-size: 2rem; block-size: 2rem; border-radius: 50%;
    background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
  }

  /* upload: drop zone, selected file, progress */
  .upload { display: grid; gap: var(--s-4); }
  .drop {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--s-2); min-block-size: clamp(11rem, 26vh, 15rem); padding: var(--s-6);
    border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); text-align: center;
    background: var(--surface); color: var(--muted); font-weight: 400; cursor: pointer;
    transition: border-color var(--dur-2), background-color var(--dur-2);
    &:hover, &.is-over { border-color: var(--brand); background-color: var(--brand-soft); }
    &.is-over { border-style: solid; & .drop-icon { translate: 0 -4px; } }
    &:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
  }
  .drop-icon { inline-size: 2.5rem; block-size: 2.5rem; color: var(--brand); margin-block-end: var(--s-1);
    transition: translate var(--dur-2) var(--ease-out); }
  .drop-title { color: var(--brand); font-weight: 600; font-size: var(--text-lg); }
  .drop-hint { font-size: var(--text-sm); }
  @media (hover: none) { .drop-hint-drag { display: none; } }  /* touch devices cannot drag files in */

  /* With scripting, the native input covers the whole drop zone (click or drop anywhere) and the form's
     data-state (empty | ready | uploading | checking) decides what shows. */
  @media (scripting: enabled) {
    .drop input[type=file] { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; opacity: 0;
      cursor: pointer; }
    .upload:is([data-state=ready], [data-state=uploading], [data-state=checking]) .drop { display: none; }
    .upload[data-state=empty] #upload-submit { display: none; }
  }

  .file-card {
    display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4);
    border: 1px solid var(--line); border-radius: var(--radius);
    animation: rise var(--dur-2) var(--ease-out);
  }
  .file-card-icon {
    flex: none; display: grid; place-items: center; inline-size: 2.75rem; block-size: 3.25rem;
    border-radius: 6px; background: var(--brand-soft); color: var(--brand);
    font-size: var(--text-xs); font-weight: 700; letter-spacing: .04em;
  }
  .file-card-text { display: grid; min-inline-size: 0; flex: 1; }
  .file-card-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .file-card-meta { color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }

  .upload-progress { display: grid; gap: var(--s-2); }
  .upload-progress-row { display: flex; justify-content: space-between; gap: var(--s-4); font-size: var(--text-sm);
    color: var(--text-2); }
  .upload-pct { font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; }
  progress {
    appearance: none; inline-size: 100%; block-size: .375rem; border: 0; border-radius: var(--radius-full);
    overflow: hidden; background: var(--surface-2); color: var(--brand);
    &::-webkit-progress-bar { background: var(--surface-2); }
    &::-webkit-progress-value { background: var(--brand); border-radius: var(--radius-full);
      transition: inline-size var(--dur-2) linear; }
    &::-moz-progress-bar { background: var(--brand); border-radius: var(--radius-full); }
  }
  /* server-side checks after the bytes are sent: no fake percentage, an indeterminate shimmer instead */
  .upload[data-state=checking] progress::-webkit-progress-value { animation: shimmer 1.2s linear infinite;
    background: linear-gradient(90deg, var(--brand) 30%, var(--brand-soft) 50%, var(--brand) 70%) 0 0 / 200% 100%; }
  .upload[data-state=checking] progress::-moz-progress-bar { animation: shimmer 1.2s linear infinite;
    background: linear-gradient(90deg, var(--brand) 30%, var(--brand-soft) 50%, var(--brand) 70%) 0 0 / 200% 100%; }
  @keyframes shimmer { to { background-position: -200% 0; } }

  /* recent checks */
  .aside-title { font-size: var(--text-md); font-weight: 600; margin-block-end: var(--s-2); }
  .aside-note { color: var(--muted); font-size: var(--text-xs); margin-block-start: var(--s-3); }
  .recent-list { display: grid; }
  .recent-list li + li { border-block-start: 1px solid var(--line); }
  .recent-item {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-3);
    padding: var(--s-3) 0; color: var(--text); text-decoration: none;
    &:hover { color: var(--text); & .recent-name { color: var(--brand); } }
  }
  .recent-text { display: grid; min-inline-size: 0; }
  .recent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600;
    font-size: var(--text-sm); transition: color var(--dur-1); }
  .recent-time { color: var(--muted); font-size: var(--text-xs); }
  @container card (inline-size < 16rem) {
    .recent-item { grid-template-columns: minmax(0, 1fr); & .chip { justify-self: start; } }
  }

  /* job progress */
  .job-spinner {
    /* conic ring whose angle is a typed @property, so it rotates smoothly */
    background: conic-gradient(from var(--spin), transparent 0 55%, var(--brand) 100%), var(--brand-soft);
    mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4px));
    animation: spin 1.1s linear infinite;
  }
  @keyframes spin { to { --spin: 360deg; } }
  .file-name + .queue { margin-block-start: var(--s-6); }
  .queue { display: inline-block; padding: var(--s-2) var(--s-4); border-radius: var(--radius-full);
    background: var(--brand-soft); color: var(--brand-strong); font-size: var(--text-sm);
    & b { font-variant-numeric: tabular-nums; } }
  .timeline { display: grid; margin: var(--s-6) auto; max-inline-size: 22rem; text-align: start; }
  .timeline-step {
    position: relative; display: flex; align-items: center; gap: var(--s-4); padding-block: var(--s-3);
    color: var(--muted); transition: color var(--dur-2);
    /* connector line between dots */
    &:not(:last-child)::after {
      content: ""; position: absolute; inset-inline-start: calc(.75rem - 1px); inset-block: calc(50% + .85rem) calc(-50% + .85rem);
      inline-size: 2px; background: var(--line); transition: background-color var(--dur-3);
    }
    &.is-done { color: var(--text-2); &::after { background: var(--brand); } }
    &.is-current { color: var(--text); font-weight: 600; }
  }
  .timeline-dot {
    position: relative; flex: none; display: grid; place-items: center; inline-size: 1.5rem; block-size: 1.5rem;
    border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface);
    transition: background-color var(--dur-2), border-color var(--dur-2);
    .is-done > & { border-color: var(--brand); background: var(--brand);
      &::after { content: ""; inline-size: .3rem; block-size: .6rem; border: solid var(--on-brand);
        border-width: 0 2px 2px 0; rotate: 45deg; translate: 0 -1px; animation: pop var(--dur-2) var(--ease-out); } }
    .is-current > & { border-color: var(--brand);
      &::after { content: ""; inline-size: .55rem; block-size: .55rem; border-radius: 50%; background: var(--brand);
        animation: pulse 1.4s var(--ease-in-out) infinite; } }
  }
  @keyframes pop { from { scale: 0; } }
  .elapsed { text-wrap: balance; display: inline-flex; align-items: center; gap: var(--s-2); color: var(--muted);
    font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
  .job .note { margin-block-start: var(--s-3); }

  /* result */
  .result { max-inline-size: 48rem; }
  .result-head { margin-block-end: var(--s-6); & .card-title { font-size: var(--text-2xl); } }
  .verdict {
    display: grid; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-radius: var(--radius);
    background: var(--surface-2); color: var(--text-2);
  }
  .tally { color: var(--text); font-variant-numeric: tabular-nums; }
  /* one segment per checked field, problems first: an at-a-glance picture of the summary table */
  .meter {
    display: flex; gap: 3px; block-size: .5rem;
    & li { flex: 1; border-radius: 2px; background: var(--brand); transform-origin: left;
      animation: grow var(--dur-3) var(--ease-out) both; }
    & li:nth-child(n+2) { animation-delay: 30ms; } & li:nth-child(n+4) { animation-delay: 60ms; }
    & li:nth-child(n+6) { animation-delay: 90ms; } & li:nth-child(n+8) { animation-delay: 120ms; }
    & .meter-bad { background: var(--alert-fill); }
    & .meter-review { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--alert-fill); }
  }
  @keyframes grow { from { scale: 0 1; } }
  .result .actions { margin-block: var(--s-6) var(--s-3); }
  .mail-state { display: flex; align-items: center; gap: var(--s-2); color: var(--muted); font-size: var(--text-sm);
    & b { overflow-wrap: anywhere; } }
  .result .alert { margin-block-end: 0; }

  .summary {
    inline-size: 100%; font-size: var(--text-sm); margin-block: var(--s-6) var(--s-5);
    & th, & td { padding: var(--s-3) 0; border-block-end: 1px solid var(--line); text-align: start; }
    & tbody th { font-weight: 400; color: var(--text); }
    & td { text-align: end; }
    & .summary-group-head th {
      padding-block: var(--s-5) var(--s-2); font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em;
      text-transform: uppercase; color: var(--muted); border-block-end-color: var(--line-strong);
    }
    & .summary-group:first-of-type .summary-group-head th { padding-block-start: 0; }
    & .summary-problems tr:not(.summary-group-head) th { font-weight: 600; }
  }
}

/* ───────────────────────────────── utilities ───────────────────────────────── */
@layer utilities {
  .visually-hidden { position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; }

  /* cross-document view transitions: a short cross-fade; header and steps stay put */
  ::view-transition-old(root) { animation: var(--dur-2) var(--ease-out) both vt-out; }
  ::view-transition-new(root) { animation: var(--dur-3) var(--ease-out) both vt-in; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; translate: 0 6px; } }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
      animation-duration: 1ms !important; animation-iteration-count: 1 !important;
      transition-duration: 1ms !important; scroll-behavior: auto !important;
    }
    /* keep a static cue for "in progress" where motion was the cue */
    .job-spinner { background: conic-gradient(var(--brand) 0 25%, var(--brand-soft) 0); }
  }

  @media (forced-colors: active) {
    .chip, .alert, .verdict, .button, .card, .file-card, .lang-switch a[aria-current] { border: 1px solid CanvasText; }
    .meter li { background: CanvasText !important; }
    .step.is-current .step-num, .timeline-step.is-current .timeline-dot { border-color: Highlight; }
  }

  @media print {
    .site-header, .steps-nav, .site-footer, .actions, .disclosure, .recent { display: none !important; }
    body { background: none; }
    .card { box-shadow: none; border: 0; padding: 0; }
  }
}
