/* Hallmark · route: custom (tuned) · scope: restyle of an existing app
 * vibe: "ceria, kampus, putih hangat, jelas" · paper: oklch(97.5% 0.010 78) · accent: oklch(76% 0.150 78)
 * display: Bricolage Grotesque · body: Geist · axes: light / geometric-sans / chromatic-amber
 * structure: UNCHANGED (7 views, tab nav, routes preserved) · studied: no
 * contrast: 16/16 WCAG pass — verified by siswaspec-deploy/palette_check.py
 */

:root {
    /* ---- paper: warm white, tinted toward the amber anchor (never #fff) ---- */
    --paper: oklch(97.5% 0.010 78);
    --paper-2: oklch(95.5% 0.014 78);
    --paper-3: oklch(92.5% 0.016 78);
    --card: oklch(99.5% 0.005 78);

    /* ---- rules: hairlines only, no shadow language ---- */
    --rule: oklch(89% 0.014 78);
    --rule-2: oklch(93% 0.012 78);
    --rule-strong: oklch(84% 0.016 78);
    /* Edges of inputs and chips: WCAG 1.4.11 asks 3:1 against paper and card
       (--rule-strong is 1.5:1). Hairline rules and dividers keep --rule. */
    --control-border: oklch(62% 0.016 78);

    /* ---- ink ---- */
    --ink: oklch(24.5% 0.020 68);      /* 15.13:1 on paper */
    --ink-2: oklch(43% 0.018 70);      /*  7.56:1 */
    --muted: oklch(52% 0.016 72);      /*  5.13:1 */

    /* ---- accent: marigold. Fill only; ink sits on top at 7.44:1. ---- */
    --accent: oklch(76% 0.150 78);
    --accent-hover: oklch(72% 0.155 78);
    --accent-active: oklch(68% 0.155 78);
    --accent-deep: oklch(52% 0.130 52); /* borders + accent-coloured text, 5.38:1 */
    --accent-wash: oklch(96% 0.040 78); /* the one tinted band */
    --focus: oklch(56% 0.170 250);      /* cool ring, deliberately fights the amber */
    --focus-ring: oklch(56% 0.170 250 / 0.16);

    /* Text that sits ON a marigold fill. Its own token, NOT --ink: marigold
       stays a light fill in both themes, so this must stay dark in both. If it
       aliased --ink it would flip to near-white in dark mode and put light text
       on a light fill. This is the one token that does not invert. */
    --on-accent: oklch(24.5% 0.020 68);

    /* ---- semantic ---- */
    --success: oklch(50% 0.110 155);
    --warning: oklch(52% 0.130 62);
    --danger: oklch(53% 0.150 25);

    /* ---- elevation + overlay. Tokenised because a black-alpha shadow is
       invisible on a dark surface and a dark scrim over dark content does not
       separate the modal from the page. ---- */
    --scrim: oklch(24.5% 0.020 68 / 0.42);
    --shadow-bar: 0 -2px 12px oklch(24.5% 0.020 68 / 0.07);
    --shadow-card: 0 6px 16px oklch(24.5% 0.020 68 / 0.08);
    --bg-subtle: oklch(24.5% 0.020 68 / 0.04);

    /* Leaflet tiles are raster images from OSM and cannot be recoloured by CSS
       variables. 0 in light mode; the dark theme filters them instead. */
    --tile-filter: none;

    /* ---- medals: text tones, not fill tones ---- */
    --gold: oklch(54% 0.130 78);
    --silver: oklch(52% 0.016 78);
    --bronze: oklch(51% 0.090 45);

    /* ---- type ---- */
    --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
    --font-body: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;

    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1.0625rem;
    --text-lg: 1.3125rem;
    --text-xl: 1.625rem;
    --text-2xl: 2rem;
    --text-display: clamp(1.875rem, 3.5vw + 0.5rem, 2.625rem);

    /* ---- space: 4pt scale ---- */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;

    --radius: 6px;
    --radius-sm: 3px;   /* defined so Tailwind's own --radius-sm/md can't change these (ADR 0004) */
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-pill: 999px;

    --dur-fast: 0.12s;
    --dur-mid: 0.18s;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

    /* ---- legacy aliases. app.js L295 injects var(--gold) and
       var(--text-secondary) inline, so these two must stay resolvable.
       The rest are kept so a missed reference degrades to the right tone
       instead of to black. ---- */
    --bg-primary: var(--paper);
    --bg-secondary: var(--paper-2);
    --bg-card: var(--card);
    --glass-bg: var(--card);
    --glass-border: var(--rule);
    --border: var(--rule);
    --border-strong: var(--rule-strong);
    --text-primary: var(--ink);
    --text-secondary: var(--ink-2);
    --text-muted: var(--muted);
    --accent-cyan: var(--success);
    --accent-violet: var(--success);
    --accent-gradient: var(--accent);
    --shadow-glow: none;
    --shadow-sm: none;

    /* Tells the UA to draw form controls, scrollbars and the caret in the
       matching scheme. Without it, a dark page keeps white scrollbars. */
    color-scheme: light;
}

/* ---------- Dark theme ----------
 *
 * Overrides the token layer ONLY. Every rule below :root already consumes
 * var(--token), so nothing else in this file needs a dark variant — that is
 * the whole reason the palette was tokenised.
 *
 * Single selector, no `@media (prefers-color-scheme: dark)` duplicate: theme.js
 * is a synchronous <head> script that resolves the system preference and writes
 * data-theme before first paint, so the attribute is always present. A media
 * block would be a second copy of these values to keep in sync for no reason.
 * No-JS visitors get the light theme, which is the site's designed default and
 * fully usable.
 *
 * Hue stays 78 (the amber anchor) so dark mode reads as the same brand at
 * night, not a different product. Surfaces are warm near-black, never #000:
 * pure black against warm text produces a harsh edge and halation.
 */
:root[data-theme="dark"] {
    color-scheme: dark;

    /* ---- surfaces: warm near-black, lifting as they come forward ---- */
    --paper: oklch(20.5% 0.010 78);
    --paper-2: oklch(24.5% 0.012 78);
    --paper-3: oklch(29% 0.014 78);
    --card: oklch(23.5% 0.011 78);

    /* ---- rules: lighter than the surface they divide, the inverse of light
           mode. Kept low-chroma so they read as structure, not as colour. ---- */
    --rule: oklch(35% 0.012 78);
    --rule-2: oklch(30% 0.010 78);
    --rule-strong: oklch(45% 0.014 78);
    --control-border: var(--rule-strong); /* dark mode keeps its borders */

    /* ---- ink: warm off-white, never pure white ---- */
    --ink: oklch(95% 0.008 78);
    --ink-2: oklch(80% 0.012 78);
    --muted: oklch(68% 0.012 78);

    /* ---- accent: the marigold FILL is unchanged. It carries the brand and
           reads well on dark, and --on-accent stays dark so the label on top
           still passes. What must change is accent-coloured TEXT: --accent-deep
           was darkened for a white page and would sink into a dark one. ---- */
    --accent-deep: oklch(80% 0.120 76);
    --accent-wash: oklch(28% 0.028 78);
    --focus: oklch(72% 0.150 250);
    --focus-ring: oklch(72% 0.150 250 / 0.26);

    /* ---- semantic: lightened for text use on a dark surface ---- */
    --success: oklch(74% 0.130 155);
    --warning: oklch(80% 0.130 70);
    --danger: oklch(70% 0.150 25);

    /* ---- medals ---- */
    --gold: oklch(80% 0.120 78);
    --silver: oklch(74% 0.012 78);
    --bronze: oklch(72% 0.080 45);

    /* ---- elevation: a black-alpha shadow is invisible on a dark surface, so
           depth comes from a black scrim that still darkens, plus the lighter
           --card doing the actual lifting. The scrim is deepened because the
           content behind it is already dark. ---- */
    --scrim: oklch(12% 0.010 78 / 0.66);
    --shadow-bar: 0 -2px 12px oklch(0% 0 0 / 0.40);
    --shadow-card: 0 6px 16px oklch(0% 0 0 / 0.45);
    --bg-subtle: oklch(100% 0 0 / 0.05);

    /* ---- OSM raster tiles cannot be recoloured by tokens. Invert + rotate
           hue back so roads stay dark-on-light-relative and labels stay
           legible, then dim so the map does not glare against the page. ---- */
    --tile-filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.92) saturate(0.85);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    /* clip not hidden: hidden on the root creates a scroll container and
       breaks position:sticky on .navbar and .qa-form-panel. */
    overflow-x: clip;
}

body {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: oldstyle-nums;
}

h1,
h2,
h3,
h4,
h5 {
    font-family: var(--font-display);
    font-style: normal; /* italic display heads are the reliable AI tell */
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.15;
    /* long Malay compounds ("Rekomendasi") must break rather than overflow */
    overflow-wrap: anywhere;
    text-wrap: balance; /* no one-word last lines */
    min-width: 0;
}

h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
h4 { font-size: var(--text-base); font-weight: 600; }
h5 { font-size: var(--text-sm); font-weight: 600; }

/* Each tab's title is its page h1 (one per view, so screen-reader users can
   jump to it), but it keeps the section-heading size it had as an h2. Only the
   Dashboard hero uses the display size. */
h1.view-title { font-size: var(--text-lg); }
#leaderboard-page-title { margin-bottom: var(--space-md); }

p { color: var(--ink-2); }

a { color: inherit; text-decoration: none; }

small { color: var(--muted); font-size: var(--text-sm); }

strong { font-weight: 600; }

/* One visible focus ring for the whole app, never animated, never removed. */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius);
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.full-width { grid-column: 1 / -1; }
.mt-3 { margin-top: var(--space-sm); }
.mt-4 { margin-top: var(--space-md); }
.mb-3 { margin-bottom: var(--space-sm); }

/* ---------- Navbar ---------- */

.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}

.nav-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    height: 58px;
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.logo {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    letter-spacing: -0.03em;
    flex-shrink: 0;
}

/* The wordmark carries the single accent moment in the chrome. */
.logo span { color: var(--accent-deep); font-weight: 600; }

.nav-tabs {
    display: flex;
    gap: var(--space-2xs);
    flex-wrap: wrap;
}

.nav-tab {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-2xs) var(--space-sm);
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--ink-2);
    border-radius: var(--radius-pill);
    /* nav labels must never wrap to two lines */
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
}

.nav-tab:hover { color: var(--ink); background: var(--paper-2); }

.nav-tab.active {
    color: var(--ink);
    background: var(--accent-wash);
    font-weight: 600;
}

/* Komuniti menu */
.nav-group { position: relative; }
.nav-group-toggle { display: inline-flex; align-items: center; gap: 0.25rem; }
.nav-caret { transition: transform var(--dur-fast) var(--ease-out); }
.nav-group.open .nav-caret { transform: rotate(180deg); }
.nav-group:has(.nav-group-menu .nav-tab.active) .nav-group-toggle {
    color: var(--ink);
    background: var(--accent-wash);
    font-weight: 600;
}
.nav-group-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 0;
    z-index: 120;
    min-width: 11rem;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.375rem;
    background: var(--card);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.nav-group.open .nav-group-menu { display: flex; }
.nav-group-menu .nav-tab { text-align: left; border-radius: var(--radius); }

/* margin-left:auto moved to .theme-toggle, which is now the first item after
   the tab strip. Two elements both claiming auto margin would split the free
   space between them and drift the pair apart. */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: var(--text-md);
    cursor: pointer;
    color: var(--ink);
}

/* Theme toggle. 40px box: the audit found the nav tabs at 25-33px, under the
   44px comfort target, so a control added now starts at a real touch size
   rather than inheriting that problem.

   The resting state carries a real border and fill. The first version used
   `border: 1px solid transparent` with the frame appearing only on :hover,
   which meant the control read as a stray ☾ character sitting in whitespace
   until you happened to mouse over it -- and on touch, where there is no
   hover, it never looked like a button at all. A control the visitor cannot
   identify as a control is not discoverable, however correct its ARIA is.

   margin-left is a fixed gap, not `auto`. Auto pushed it hard against the
   right margin ~280px from the last tab, so it floated alone instead of
   reading as part of the nav chrome. */
.theme-toggle {
    margin-left: var(--space-lg);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* A ghost icon button: 44px touch target, no resting fill or ring. The old
       40px button with a 2px --ink-2 ring was the heaviest object in the
       header and competed with the logo. A lone icon button doesn't need a
       drawn boundary (WCAG 1.4.11 asks for the glyph to contrast, and full
       --ink does); the hover and focus states show its extent. */
    width: 44px;
    height: 44px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-pill);
    font-size: var(--text-lg);
    line-height: 1;
    /* Full ink, not --ink-2: on a single symbol --ink-2 reads as disabled. */
    color: var(--ink);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}

.theme-toggle:hover {
    background: var(--accent-wash);
    color: var(--accent-deep);
}

.theme-toggle:active {
    background: var(--paper-3);
}

/* Line icons (moon / sun, swapped by app.js) in a fixed box, so the button
   never shifts between the two. */
.theme-toggle-icon {
    display: inline-flex;
    width: 1.25rem;
    height: 1.25rem;
}
.theme-toggle-icon svg,
.menu-toggle svg { display: block; width: 1.25rem; height: 1.25rem; }

/* ---------- Layout ---------- */

.main-content {
    max-width: 1080px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg) var(--space-2xl);
}

.view-section { animation: fade var(--dur-mid) var(--ease-out); }

@keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.section-title {
    margin: var(--space-xl) 0 var(--space-md);
    font-size: var(--text-md);
    font-weight: 700;
}

/* Shared surface. Flat: one hairline, no blur, no glow, no shadow. */
.glass-panel {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

/* ---------- Hero (docs/specs/hero-redesign.md) ---------- */

/* One short Headline, one big Ask box, three Example chips; decorative
   Floaters around them (the hero-floaters island) on a still, soft gradient.
   Utama is the hero only (2026-12-05), so before a question it fills the
   screen under the header (and above the bottom bar on phones). */
.hero {
    --hero-glow-1: oklch(76% 0.150 78 / 0.16);
    --hero-glow-2: oklch(52% 0.130 52 / 0.10);
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    --hero-above: calc(59px + var(--space-xl)); /* header + the page's top padding */
    min-height: max(26rem, calc(100svh - var(--hero-above) - var(--space-lg)));
    padding: var(--space-xl) var(--space-md);
    border: 1px solid var(--rule-2);
    border-radius: calc(var(--radius-lg) * 2);
    /* The Headline, the Answer and the Ask box column are separate rows (the
       Answer comes before the Ask box in reading order); keep them together. */
    align-content: center;
    background:
        radial-gradient(60% 70% at 12% 0%, var(--hero-glow-1), transparent 70%),
        radial-gradient(55% 65% at 92% 100%, var(--hero-glow-2), transparent 70%),
        linear-gradient(180deg, var(--card), var(--paper));
    overflow: hidden;
}
:root[data-theme="dark"] .hero {
    --hero-glow-1: oklch(76% 0.150 78 / 0.12);
    --hero-glow-2: oklch(60% 0.120 52 / 0.12);
}

.hero-copy {
    position: relative;
    z-index: 1;
    width: min(40rem, 58%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.hero-headline {
    position: relative;
    z-index: 1;
    width: min(40rem, 58%);
    text-align: center;
    max-width: none;
    margin-bottom: var(--space-lg);
    font-size: clamp(2rem, 1.1rem + 2.6vw, 3.5rem);
    line-height: 1.08;
    letter-spacing: -0.02em;
    text-wrap: balance;
}
.hero-accent { color: var(--accent-deep); white-space: nowrap; }
:root[data-theme="dark"] .hero-accent { color: var(--accent); }

.hero-ask {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: var(--space-2xs);
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    background: var(--card);
    border: 1px solid var(--control-border);
    border-radius: 28px;
    box-shadow: 0 10px 30px oklch(24.5% 0.020 68 / 0.10);
    transition: border-color var(--dur-fast) var(--ease-out);
    text-align: left;
}
/* The box, not the textarea, carries hover and focus: the same ring the
   site's other inputs use, drawn once around the whole control. */
.hero-ask:hover { border-color: var(--muted); }
/* The box's ring only while the cursor is in the text area: keyboard focus
   on "Tanya" shows the button's own ring alone (Hallmark audit 2026-12-05). */
.hero-ask:has(#hero-input:focus) { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }

/* Id + element, to outrank the global textarea rules (border, background,
   focus ring, 96px minimum) that would draw a second box inside. hero.js
   grows the height to 3 lines. */
#hero-input,
#hero-input:hover,
#hero-input:focus {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: auto;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    outline: none;
    resize: none;
    overflow-y: hidden;
    padding: 0.625rem 0;
    font: inherit;
    font-size: 1.125rem;
    line-height: 1.5;
    color: var(--ink);
}
#hero-input::placeholder { color: var(--muted); }
/* Changing hint (hero.js, spec "Changing hint"): while .is-rolling, the
   hint is drawn by .hero-hint-roll over the empty box, at the placeholder's
   exact spot, and the real placeholder is made transparent. It hides as soon
   as there is text. Taps go through to the textarea. */
.hero-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.hero-hint-roll {
    display: none;
    position: absolute;
    inset: 0.625rem 0 auto 0;
    height: 1.6875rem; /* one line: 1.125rem x 1.5 */
    overflow: hidden;
    pointer-events: none;
    font-size: 1.125rem;
    line-height: 1.5;
    color: var(--muted);
}
.hero-ask.is-rolling .hero-hint-roll { display: block; }
.hero-ask.is-rolling #hero-input::placeholder { color: transparent; }
#hero-input:not(:placeholder-shown) + .hero-hint-roll { visibility: hidden; }
.hero-hint { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-hint.is-in { animation: hero-hint-in 300ms var(--ease-out) both; }
.hero-hint.is-out { position: absolute; inset: 0; animation: hero-hint-out 300ms var(--ease-out) both; }
@keyframes hero-hint-in { from { transform: translateY(60%); opacity: 0; } }
@keyframes hero-hint-out { to { transform: translateY(-80%); opacity: 0; } }
/* Id-scoped so the general .btn-primary rules further down (6px radius,
   13px label, 44px) don't win (Hallmark audit 2026-12-05): a pill nests in
   the pill box; as tall as one line of the text area (its line plus its
   padding), so it sits centred; a 14px label at every width. */
#hero-ask .hero-ask-send {
    flex-shrink: 0;
    min-height: max(44px, calc(1.125rem * 1.5 + 1.25rem));
    padding-inline: 1.25rem;
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
}
/* Empty "Tanya": the box border and a line under it say what to write. */
.hero-ask.is-empty { border-color: var(--accent-deep); }
.hero-ask-hint { margin-top: var(--space-2xs); font-size: var(--text-sm); color: var(--accent-deep); }
.hero-ask-hint[hidden] { display: none; }

.hero-chips {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: var(--space-xs);
    max-width: 100%;
    margin-top: var(--space-md);
}
.hero-chip {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 36px;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-pill);
    background: var(--card);
    color: var(--ink-2);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
}
.hero-chip:hover { border-color: var(--accent-deep); color: var(--ink); background: var(--accent-wash); }

/* Review invite (docs/specs/hero-redesign.md): a small pill above the
   Headline asking Seniors for a Review. Full Hero only. */
.hero-invite {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 36px;
    padding: 0.375rem 0.875rem;
    margin-bottom: var(--space-md);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-pill);
    background: var(--card);
    color: var(--ink-2);
    font-size: var(--text-sm);
    white-space: nowrap;
    text-decoration: none;
    transition: border-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out),
                opacity 200ms var(--ease-out);
}
.hero-invite:hover { border-color: var(--accent-deep); color: var(--ink); background: var(--accent-wash); }
.hero-invite-arrow { width: 1em; height: 1em; flex-shrink: 0; color: var(--accent-deep); }
:root[data-theme="dark"] .hero-invite-arrow { color: var(--accent); }
.hero-invite[hidden] { display: none; }

/* Review strip (review-strip.js; docs/specs/hero-redesign.md): short Review
   cards under the chips, moving slowly. The track holds the cards twice, so
   sliding it by half its width loops without a jump. Each card carries its
   own right margin (not a flex gap) so the two halves are exactly equal. */
.review-strip {
    position: relative;
    z-index: 1;
    width: min(40rem, 58%);
    margin-top: var(--space-lg);
}
.review-strip[hidden] { display: none; }
/* With the strip the full Hero has one more row: tighter gaps so it still
   fits a 1280x720 laptop screen without scrolling. */
.hero.has-strip .hero-headline { margin-bottom: var(--space-md); }
.hero.has-strip .review-strip { margin-top: var(--space-md); }
@media (min-width: 900px) {
    .hero.has-strip { padding-block: var(--space-lg); }
}
.review-strip-viewport {
    overflow: hidden;
    padding-block: 2px; /* room for the focus ring */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 2.5rem, #000 calc(100% - 2.5rem), transparent);
}
.review-strip-track {
    display: flex;
    width: max-content;
    animation: review-strip-loop 40s linear infinite;
}
@keyframes review-strip-loop { to { transform: translateX(-50%); } }
.review-strip-viewport:hover .review-strip-track,
.review-strip-track:focus-within,
.review-strip.is-paused .review-strip-track,
.review-strip.is-away .review-strip-track { animation-play-state: paused; }
.review-strip.is-still .review-strip-track { animation: none; }
.review-strip.is-still .review-strip-viewport {
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-mask-image: none;
    mask-image: none;
}
@media (prefers-reduced-motion: reduce) {
    .review-strip-track { animation: none; }
}
.review-card {
    flex: none;
    width: 18rem;
    margin: 0 var(--space-sm) 0 0;
    padding: 0.625rem var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    text-align: left;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-lg);
    background: var(--card);
    color: var(--ink-2);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.review-card:hover { border-color: var(--accent-deep); background: var(--accent-wash); }
.review-card p { margin: 0; }
.review-card-who { color: var(--text-secondary); font-size: 0.8125rem; }
.review-card-who .meta-row.is-one-line > .meta-part:nth-child(2) { flex: 0 1 auto; } /* a long university gives way */
.review-card-course { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-card-laptop { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-card-stars { font-size: var(--text-sm); line-height: 1; }
.review-card-text { line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.review-strip-pause {
    position: absolute;
    top: 50%;
    right: -2.75rem;
    translate: 0 -50%;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--control-border);
    border-radius: 50%;
    background: var(--card);
    color: var(--ink-2);
    cursor: pointer;
}
.review-strip-pause[hidden] { display: none; }
.review-strip-pause svg { width: 14px; height: 14px; }
.review-strip-pause .icon-play,
.review-strip-pause[aria-pressed="true"] .icon-pause { display: none; }
.review-strip-pause[aria-pressed="true"] .icon-play { display: block; }
.review-strip-pause:hover { border-color: var(--accent-deep); color: var(--ink); }

/* Advisor down: one big way forward instead of the Ask box. */
.hero-fallback-btn {
    min-height: 56px;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-pill);
    font-size: var(--text-lg);
}

/* ---- Floaters (the hero-floaters island; decorative, aria-hidden).
   Pictures: Microsoft Fluent Emoji 3D, MIT (assets/floaters/LICENSE.txt). ---- */
.hero-floaters { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.floaters { position: absolute; inset: 0; }
.floater {
    position: absolute;
    translate: -50% -50%;
    transition: transform 600ms cubic-bezier(0.55, 0, 0.8, 0.2), opacity 600ms ease-in;
    animation: floater-in 700ms var(--ease-out) backwards;
}
.floater-lean {
    transform: translate3d(calc(var(--px, 0) * var(--depth, 0) * 18px), calc(var(--py, 0) * var(--depth, 0) * 12px), 0);
    transition: transform 500ms var(--ease-out);
}
.floater-drift { animation: floater-drift var(--dur, 12s) ease-in-out var(--delay, 0s) infinite alternate; }
.floater-img {
    display: block;
    width: 100%;
    height: auto;
    -webkit-user-drag: none;
    user-select: none;
    filter: drop-shadow(0 10px 14px oklch(24.5% 0.020 68 / 0.14));
}
:root[data-theme="dark"] .floater-img { filter: drop-shadow(0 10px 16px oklch(0% 0 0 / 0.45)); }
.floaters[data-motion="still"] .floater,
.floaters[data-motion="still"] .floater-drift { animation: none; transition: none; }
@media (prefers-reduced-motion: reduce) {
    .floater, .floater-drift, .floater-lean { animation: none; transition: none; }
}
/* --drift scales the movement; phones move further so it shows on a small
   screen (the phone layout keeps room for it inside the border). */
@media (max-width: 899px) { .floaters { --drift: 1.4; } }
@keyframes floater-drift {
    0% { transform: translate(0, 0) rotate(-3deg); }
    50% { transform: translate(calc(6px * var(--drift, 1)), calc(-10px * var(--drift, 1))) rotate(2deg); }
    100% { transform: translate(calc(-5px * var(--drift, 1)), calc(5px * var(--drift, 1))) rotate(4deg); }
}
@keyframes floater-in { from { opacity: 0; scale: 0.8; } }

/* ---- Compact hero: after the first question everything stays in the same
   box (owner's "unified hero to chat" prototype, 2026-12-05). The box grows
   with the Answer: the page scrolls, nothing scrolls inside. The Headline
   stays for screen readers only. hero.js animates the switch.
   Answer screen (owner, 2026-12-05): the Ask box comes after the Answer, like
   an AI chat. It sticks to the bottom of the screen while the Answer runs
   past it, and rests at the box's end when the Answer is short. It clears
   the bottom bar (phones, --ask-clear) and the compare bar
   (--shortlist-live-h, measured by hero.js). overflow: clip, not hidden,
   rounds the strip's corners without making the box a scroll area, which
   would stop the sticking.
   ---- */
.hero.is-compact {
    --answer-col: 45rem; /* 720px */
    min-height: 0;
    display: flex;
    flex-direction: column;
    /* The full hero's place-items: center would also centre (and shrink)
       block children in browsers with block-layout alignment. */
    place-items: normal;
    padding: 0;
    overflow: clip;
}
/* No scroll anchoring on Utama while the Answer shows: the Answer is rebuilt
   as it streams, and the browser's anchoring then scrolled the page along
   with it (on CI, and here with a page ~40px taller than the window). Only
   the page itself (the scroller) turns it off; excluding the box did not.
   The page's scrolling here is advisor.scrollToQuestion's alone. */
html:has(#view-dashboard:not(.hidden) .hero.is-compact) { overflow-anchor: none; }
.hero.is-compact .hero-copy {
    position: sticky;
    bottom: calc(var(--ask-clear, 0px) + var(--shortlist-live-h, 0px));
    z-index: 2;
    width: 100%;
    align-items: stretch;
    /* The strip spans the box; the Ask box inside lines up with the Answer's
       centred column (--answer-col). */
    padding: var(--space-md) max(var(--space-lg), calc((100% - var(--answer-col)) / 2));
    background: var(--paper);
    border-top: 1px solid var(--rule);
}
.hero.is-compact .ai-answer {
    margin: 0;
    /* Centred column (owner, 2026-12-06): up to --answer-col wide, the spare
       room split evenly, like an AI chat. Narrower boxes keep the padding. */
    padding: var(--space-md) max(var(--space-lg), calc((100% - var(--answer-col)) / 2));
    border: 0;
    border-radius: 0;
    background: none;
}
.hero.is-compact .hero-headline {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.hero.is-compact .hero-floaters,
.hero.is-compact .hero-invite,
.hero.is-compact .review-strip,
.hero.is-compact .hero-chips { display: none; }
/* The full hero has no Answer under its chips, except to say the student is
   out of messages before asking (limited/capped). */
.hero:not(.is-compact) .ai-answer { order: 1; width: min(40rem, 100%); margin: var(--space-lg) 0 0; }
/* The switch (hero.js): the Headline, chips and Floaters fade out before the
   Ask box moves up, and fade back in after it moves down. The Answer waits
   for the new layout. is-moving clips the box while its height animates. */
.hero-headline, .hero-chips, .hero-floaters { transition: opacity 200ms var(--ease-out); }
.hero.is-leaving .hero-invite,
.hero.is-entering .hero-invite,
.hero.is-leaving .review-strip,
.hero.is-entering .review-strip { opacity: 0; }
.review-strip { transition: opacity 200ms var(--ease-out); }
.hero.is-leaving .hero-headline,
.hero.is-leaving .hero-chips,
.hero.is-leaving .hero-floaters,
.hero.is-entering .hero-headline,
.hero.is-entering .hero-chips,
.hero.is-entering .hero-floaters { opacity: 0; }
.hero.is-leaving .ai-answer { display: none; }
.hero.is-moving { overflow: hidden; }

/* Utama has nothing under the hero: no footer, a short bottom margin. */
body:has(#view-dashboard:not(.hidden)) .site-footer { display: none; }
body:has(#view-dashboard:not(.hidden)) .main-content { padding-bottom: var(--space-lg); }

/* Below desktop width the Floaters sit in a band above the Headline. */
@media (max-width: 899px) {
    /* The top padding clears the Floater band above the Headline (phone
       layout: centres 52 to 58px down, up to 40px tall, plus the drift; about
       84px). Content taller than the box sits right under it, so less let
       the Review invite slide under the band on a CI runner whose fonts ran
       taller (2026-12-06). */
    .hero { padding: 5.5rem var(--space-md) var(--space-lg); }
    .hero-copy, .hero-headline { width: min(40rem, 100%); }
    /* The strip takes the bottom Floater band's place (spec, Q16). */
    .review-strip { width: calc(100% + 2 * var(--space-md)); margin-inline: calc(-1 * var(--space-md)); }
    .hero.has-strip [data-band="bottom"] { display: none; }
    /* No room beside it: the button sits over the strip's faded right edge. */
    .review-strip-pause { right: var(--space-xs); }
}

/* Phones: the chips become one swipeable row; the row bleeds to the hero's
   edges (negative margin = its padding) so it reads as scrollable. The page
   itself never scrolls sideways. */
@media (max-width: 640px) {
    .review-strip { width: calc(100% + 2 * var(--space-sm)); margin-inline: calc(-1 * var(--space-sm)); margin-top: var(--space-md); }
    .review-card { width: 16rem; }
    .review-strip-pause { width: 44px; height: 44px; }
    .hero {
        --hero-above: calc(59px + var(--space-lg));
        min-height: max(24rem, calc(100svh - var(--hero-above) - var(--space-md) - var(--bottom-nav-h) - env(safe-area-inset-bottom, 0px)));
        padding: 5.5rem var(--space-sm) var(--space-md); /* the Floater band, see above */
        border-radius: var(--radius-lg);
    }
    body:has(#view-dashboard:not(.hidden)) .main-content { padding-bottom: var(--space-md); }
    .hero.is-compact { padding: 0; }
    .hero.is-compact .hero-copy { padding: var(--space-sm); }
    .hero.is-compact .ai-answer { padding: var(--space-sm); }
    .hero-headline { font-size: clamp(1.75rem, 1rem + 4vw, 2.25rem); margin-bottom: var(--space-md); }
    .hero-ask { padding-left: 1rem; border-radius: 24px; }
    #hero-input, #hero-input:hover, #hero-input:focus { font-size: 16px; }
    #hero-ask .hero-ask-send { min-height: max(44px, calc(16px * 1.5 + 1.25rem)); } /* one line of the 16px text area */
    .hero-hint-roll { font-size: 16px; height: 24px; } /* the box's phone size, one line */
    .hero-chips {
        justify-content: flex-start;
        overflow-x: auto;
        margin-inline: calc(-1 * var(--space-sm));
        padding: 0.125rem var(--space-sm);
        scrollbar-width: none;
        scroll-padding-inline: var(--space-sm);
        align-self: stretch;
        max-width: none;
    }
    .hero-chips::-webkit-scrollbar { display: none; }
    #hero-ask .hero-ask-send { padding-inline: var(--space-md); }
}

/* ---------- Buttons ---------- */

/* Short facts side by side (price, rating, sold; RAM, storage, chip),
   spaced apart instead of joined with " · " (Hallmark audit 2026-12-05).
   .is-one-line keeps them on one row; the later parts give way first. */
.meta-row { display: flex; flex-wrap: wrap; column-gap: var(--space-sm); row-gap: 0; }
.meta-row.is-one-line { flex-wrap: nowrap; overflow: hidden; }
.meta-row.is-one-line > .meta-part { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-row.is-one-line > .meta-part:nth-child(-n+2) { flex: none; }

/* 44px tall at every width, not just on phones (Hallmark audit 2026-12-05):
   touch laptops and tablets past 640px get the same target. */
.btn-primary,
.btn-secondary,
.btn-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary,
.btn-secondary {
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: var(--radius);
    padding: 0.5rem var(--space-md);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}

/* Marigold fill, ink label. 7.44:1 — the cheerful note that still reads. */
.btn-primary {
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid var(--accent);
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-primary:active { background: var(--accent-active); }

.btn-secondary {
    background: transparent;
    color: var(--ink-2);
    border: 1px solid var(--rule-strong);
    margin-left: var(--space-xs);
}

.btn-secondary:hover { color: var(--ink); border-color: var(--accent-deep); }

/* Disabled looks disabled (Hallmark audit 2026-12-05, gates 26b and 39a):
   dimmed, a not-allowed cursor and the native attribute; no hover, press or
   shimmer. */
.btn-primary:disabled,
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:disabled:hover,
.btn-primary:disabled:active { background: var(--accent); border-color: var(--accent); }
.btn-secondary:disabled:hover,
.btn-secondary:disabled:active { color: var(--ink-2); border-color: var(--rule-strong); }

.btn-submit { margin-top: var(--space-lg); width: 100%; margin-left: 0; }

/* Tertiary action: reads as a link but IS a button, because these trigger script
   rather than navigate. Underlined so it is not colour-only signalling. */
.btn-link {
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 400;
    background: none;
    border: none;
    padding: 0;
    color: var(--accent-deep);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.btn-link:hover { color: var(--ink); }

/* Empty states carry the way out, not just a description of the problem. */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-xl) var(--space-md);
    text-align: center;
    color: var(--ink-2);
}

.empty-state .btn-primary { margin-left: 0; }

/* ---------- Nav selection count ---------- */

/* aria-hidden on the span: the count reaches assistive tech through the tab's
   aria-label instead, so it is announced as part of one coherent name rather
   than as a stray number after it. */
.nav-count {
    display: inline-block;
    min-width: 1.25rem;
    margin-left: var(--space-2xs);
    padding: 0 0.3rem;
    border-radius: var(--radius-pill);
    background: var(--accent);
    /* on-accent, not ink: this is a marigold pill and the count sits on top of
       it. See the --on-accent note in :root. */
    color: var(--on-accent);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}

/* ---------- Sticky shortlist bar ---------- */

.shortlist-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--card);
    border-top: 1px solid var(--rule-strong);
    /* The only real shadow in the file: this element floats above content and
       needs to read as a layer, not as an inline band. */
    box-shadow: var(--shadow-bar);
}

.shortlist-bar-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
}

.shortlist-bar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
}

.shortlist-bar-actions .btn-secondary { margin-left: 0; }

/* The bar overlays the end of the page, so the last content would sit under it.
   Reserve room only while it is actually shown. */
body:has(.shortlist-bar:not(.hidden)) .main-content {
    padding-bottom: calc(var(--space-2xl) + 3.5rem);
}

@media (max-width: 560px) {
    .shortlist-bar {
        flex-direction: column;
        align-items: stretch;
        padding: var(--space-sm) var(--space-md);
    }
    .shortlist-bar-actions { justify-content: space-between; }
}

/* ---------- Stats ---------- */

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.stat-card {
    background: var(--card);
    padding: var(--space-md) var(--space-md) var(--space-md);
}

.stat-icon { color: var(--ink); opacity: 0.55; margin-bottom: var(--space-2xs); }
.stat-icon svg { display: block; width: 1.25rem; height: 1.25rem; }

.stat-value {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--muted);
    margin-top: 0.125rem;
}

/* There are three stats. auto-fit gave two columns on phones, leaving an empty
   grey cell under the third; one row of three fits at 320px and up. */
@media (max-width: 640px) {
    .stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stat-card { padding: var(--space-sm); }
    .stat-value { font-size: var(--text-lg); }
    .stat-label { font-size: var(--text-xs); }
}

/* ---------- Tips ---------- */

/* 6 tips. minmax(240px) auto-fits to 4 columns at 1080px, which leaves two
   orphans and a dead half-row. A 3-column cap gives two clean rows of three. */
.tips-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: var(--space-md);
}

@media (min-width: 721px) {
    .tips-container { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tip-card {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.tip-card h3 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--space-2xs);
    display: flex;
    align-items: flex-start;
}

/* Centred on the first line of the title. Baseline alignment let the icon
   poke above a wrapped title and make it taller than its neighbours, so the
   tip text under it no longer lined up. The margin (not gap) also works where
   phones make h3 inline. */
.tip-icon {
    flex: none;
    width: 1.1em;
    height: 1.1em;
    margin-top: calc((1lh - 1.1em) / 2);
    margin-right: var(--space-xs);
    color: var(--accent-deep);
}

.tip-card p { font-size: var(--text-sm); }

/* ---------- Filter bar ---------- */

/* 5 controls. At a 180px floor all five fit on one row at ~187px each, which
   clips the longest option ("Paling Membantu (Helpful)" needs ~198px). A 200px
   floor drops the row to 4 tracks of ~249px and wraps the fifth — nothing is
   truncated. Pre-existing clip, not introduced by the restyle. */
.filter-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    gap: var(--space-sm);
    align-items: center;
    margin-bottom: var(--space-lg);
}

/* A select is not a text input: it must show its selected option in full. */
.filter-bar select {
    text-overflow: ellipsis;
    padding-right: 1.75rem;
}

/* Semua / Shopee / Lazada on Teroka Model. Same look as the hero chips; the
   chosen shop is aria-pressed, shown as a filled chip. */
.shop-filter { display: flex; flex-wrap: wrap; gap: var(--space-xs, 0.375rem); }
.shop-filter[hidden] { display: none; }
.shop-chip {
    min-height: 36px;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
}
.shop-chip:hover { border-color: var(--accent-deep); color: var(--ink); background: var(--accent-wash); }
.shop-chip[aria-pressed="true"] { border-color: var(--accent-deep); background: var(--accent-wash); color: var(--ink); font-weight: 600; }
@media (max-width: 640px) {
    .shop-chip { min-height: 44px; flex: 1 1 0; }
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--control-border);
    border-radius: var(--radius);
    padding: 0.5rem 0.625rem;
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--ink);
    transition: border-color var(--dur-fast) var(--ease-out);
}

input:hover,
select:hover,
textarea:hover { border-color: var(--muted); }

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder,
textarea::placeholder { color: var(--muted); }

textarea { resize: vertical; min-height: 96px; line-height: 1.6; }

select { cursor: pointer; }

.budget-filter label {
    font-size: var(--text-sm);
    color: var(--ink-2);
    display: block;
    margin-bottom: var(--space-2xs);
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--rule-strong);
    border-radius: var(--radius-pill);
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 1px solid var(--accent-deep);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent);
    border: 1px solid var(--accent-deep);
    border-radius: 50%;
    cursor: pointer;
}

/* ---------- Laptop cards ---------- */

.explore-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
}

.laptop-card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    transition: border-color var(--dur-fast) var(--ease-out);
}

.laptop-card:hover { border-color: var(--accent-deep); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xs);
}

.brand-badge {
    font-size: var(--text-xs);
    color: var(--muted);
    font-weight: 600;
}

.card-price {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.laptop-model { font-size: var(--text-md); font-weight: 700; }

.specs-list { list-style: none; }

.specs-list li {
    font-size: var(--text-sm);
    color: var(--ink-2);
    padding: 0.1875rem 0;
}

.specs-list strong { color: var(--ink); font-weight: 600; }

.card-stars { font-size: var(--text-base); }

.card-review {
    font-size: var(--text-sm);
    color: var(--ink-2);
    padding-left: var(--space-sm);
    border-left: 2px solid var(--accent);
}

/* .badge is declared later at equal specificity and was silently winning, so
   the Trusted badge rendered muted grey instead of green. Pre-existing bug;
   the compound selector settles it without depending on source order. */
.badge.badge-trusted,
.badge-trusted {
    color: var(--success);
    border-color: var(--success);
    font-weight: 600;
}

/* Quick Match compatibility score. Flat chip, in flow, no absolute offset.
   Tiered: a weak match must not borrow the confident green of a strong one. */
.score-pill {
    align-self: flex-start;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--success);
    border: 1px solid var(--success);
    border-radius: var(--radius-pill);
    padding: 0.125rem var(--space-xs);
}

.score-pill.score-strong {
    color: var(--success);
    border-color: var(--success);
}

.score-pill.score-partial {
    color: var(--warning);
    border-color: var(--warning);
}

.score-pill.score-weak {
    color: var(--muted);
    border-color: var(--rule-strong);
}

.card-user {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--rule);
    margin-top: auto;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-wash);
    color: var(--accent-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 600;
    flex-shrink: 0;
}

.user-info .user-name {
    margin: 0;
    color: var(--ink);
    font-size: var(--text-sm);
    font-weight: 600;
    display: flex;
    gap: var(--space-2xs);
    flex-wrap: wrap;
    align-items: center;
}

.user-info p { font-size: var(--text-xs); color: var(--muted); }

.badge {
    font-size: var(--text-xs);
    padding: 0.0625rem 0.375rem;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-pill);
    color: var(--muted);
    white-space: nowrap;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--rule);
}

.btn-helpful {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    background: none;
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-pill);
    padding: 0.3125rem 0.625rem;
    font-family: inherit;
    font-size: var(--text-sm);
    color: var(--ink-2);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out);
}

.btn-helpful:hover { color: var(--ink); border-color: var(--accent-deep); }
.btn-icon { flex: none; width: 1em; height: 1em; }

.btn-helpful.voted {
    color: var(--success);
    border-color: var(--success);
    font-weight: 600;
}

.compare-check {
    font-size: var(--text-sm);
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    cursor: pointer;
    white-space: nowrap;
}

.compare-check input { cursor: pointer; accent-color: var(--accent-deep); }

/* ---------- Share form ---------- */

.share-container { max-width: 720px; margin: 0 auto; }

.share-container > p {
    font-size: var(--text-sm);
    margin-bottom: var(--space-lg);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-md);
}

.form-group { display: flex; flex-direction: column; }

.form-group label {
    font-size: var(--text-sm);
    color: var(--ink-2);
    margin-bottom: 0.3125rem;
}

.form-section-title {
    grid-column: 1 / -1;
    font-size: var(--text-xs);
    color: var(--accent-deep);
    font-weight: 700;
    padding-top: var(--space-md);
    border-top: 1px solid var(--rule);
    margin-top: var(--space-xs);
}

/* Negative margin pulls the row back into the form's rhythm: the buttons
   carry 44px tap targets, but the glyphs should still sit flush left and not
   look like they float in a tall empty band. */
.star-rating-input {
    display: flex;
    gap: 0;
    margin: -0.5rem -0.625rem;
}

/* Was a <span>: unfocusable, so the rating could not be set by keyboard.
   Now real buttons, which means stripping the UA chrome and restoring
   font-family (buttons do not inherit it). Padding — not width/height — gives
   the 44px touch target while the glyph keeps its 1.5rem size. */
.star {
    background: none;
    border: none;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.625rem;
    font-family: inherit;
    font-size: 1.5rem;
    color: var(--rule-strong);
    cursor: pointer;
    transition: color 0.1s var(--ease-out);
    line-height: 1;
}

.star:hover,
.star.active { color: var(--accent); }

/* ---------- Quick Match ---------- */

.wizard-container { max-width: 720px; margin: 0 auto; }

.wizard-steps {
    display: flex;
    gap: var(--space-md);
    margin: var(--space-md) 0 var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--rule);
    flex-wrap: wrap;
}

.step {
    font-size: var(--text-sm);
    color: var(--muted);
}

.step.active {
    color: var(--ink);
    font-weight: 600;
}

.qm-step h2 { margin-bottom: var(--space-md); font-size: var(--text-md); }

.qm-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-sm);
}

/* Now a real <button>, not a div. font-family/text-align were already
   overridden here, so the only additions needed are width (buttons size to
   their content, divs filled the grid cell) and a visible focus ring. */
.qm-card {
    display: block;
    width: 100%;
    background: var(--card);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    padding: var(--space-md);
    font-family: inherit;
    font-size: var(--text-sm);
    text-align: left;
    color: var(--ink);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
}

.qm-card:hover {
    border-color: var(--accent-deep);
    background: var(--accent-wash);
}

/* Step 1: the 8 categories as large tappable cards (UI/UX spec, Phase 3a).
   Two columns on phones, four on wide screens, every card the same height. */
.qm-cat-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.qm-cat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    min-height: 5rem;
}
.qm-cat-name { font-size: var(--text-base); font-weight: 600; line-height: 1.25; }
.qm-cat-hint { font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.35; }
@media (max-width: 900px) { .qm-cat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Where a Quick Match result comes from. */
.qm-source {
    margin: 0 0 0.5rem;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-secondary);
}
.qm-source-reviews::before { color: var(--success); }
.qm-source-specs::before { color: var(--accent-deep); }
.qm-spec-cards { grid-column: 1 / -1; max-width: 46rem; }

.qm-card:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.qm-budget-wrapper { padding: var(--space-lg) 0; }

.qm-budget-display {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: var(--space-md);
    font-variant-numeric: tabular-nums;
}

.qm-results h2 { margin-bottom: var(--space-sm); font-size: var(--text-md); }

/* align-items:start, because the score breakdown is collapsible. With the
   default stretch, opening one card's <details> stretches its whole grid row
   and the sibling card grows with it — measured 429px of card around 216px of
   content, leaving ~140px of blank space under the collapsed toggle that reads
   as failed-to-load. Scoped to Quick Match so the Teroka grid keeps its
   equal-height cards. */
.qm-results .explore-grid {
    margin-top: var(--space-md);
    align-items: start;
}

/* Budget note. Plain text row, hairline rule, no coloured banner. */
.qm-note {
    font-size: var(--text-sm);
    color: var(--ink-2);
    margin-bottom: var(--space-sm);
}

.qm-note:empty { display: none; }

/* Nothing in budget is a state worth reading, so it gets the one accent band
   rather than the muted treatment. */
.qm-note-empty {
    color: var(--ink);
    background: var(--accent-wash);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    padding: var(--space-sm);
    line-height: 1.55;
}

/* Data limits, stated in the smaller voice. Used in Quick Match step 3, the
   score legend, and the leaderboard note. */
.qm-caveat {
    font-size: var(--text-xs);
    color: var(--muted);
    line-height: 1.55;
    margin-top: var(--space-xs);
}

/* Score / ranking formula disclosure. */
.qm-formula {
    margin-top: var(--space-md);
    border-top: 1px solid var(--rule);
    padding-top: var(--space-sm);
    font-size: var(--text-sm);
}

.qm-formula > summary {
    cursor: pointer;
    color: var(--ink-2);
    font-weight: 600;
    font-size: var(--text-sm);
}

.qm-formula > summary:focus-visible,
.score-breakdown > summary:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius);
}

.qm-formula > div { margin-top: var(--space-sm); }

.qm-formula p { color: var(--ink-2); line-height: 1.6; }

.qm-formula p + p,
.qm-formula ul { margin-top: var(--space-xs); }

/* One continuous rule on the container, not one stub per item. Per-li borders
   plus a row gap render as a broken dashed line, which looks accidental. */
.qm-formula ul {
    list-style: none;
    display: grid;
    gap: 0.1875rem;
    padding-left: var(--space-sm);
    border-left: 1px solid var(--rule-strong);
}

.qm-formula li {
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

/* Per-card score working. */
.score-breakdown {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--rule);
    font-size: var(--text-xs);
}

.score-breakdown > summary {
    cursor: pointer;
    color: var(--ink-2);
    font-weight: 600;
}

.score-breakdown ul {
    list-style: none;
    display: grid;
    gap: 0.125rem;
    margin-top: var(--space-xs);
}

.score-breakdown li {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.score-breakdown .part-negative { color: var(--danger); }

/* Score pill is in normal flow, so no extra top padding is needed here. */

/* ---------- Compare ---------- */

.compare-container > p {
    font-size: var(--text-sm);
    margin-bottom: var(--space-md);
}

.compare-slots {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-sm);
}

.compare-slot {
    position: relative;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    font-size: var(--text-sm);
}

.compare-slot span { color: var(--ink-2); }

.btn-remove-compare {
    position: absolute;
    top: 0.375rem;
    right: var(--space-xs);
    background: none;
    border: none;
    color: var(--muted);
    font-size: var(--text-md);
    cursor: pointer;
    line-height: 1;
}

.btn-remove-compare:hover { color: var(--danger); }

.table-responsive { overflow-x: auto; }

.compare-table,
.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    /* Without a floor these 6 columns squeeze to ~92px at 320px and a name
       like "Universiti Teknikal Malaysia Melaka" stacks 4 lines deep. The
       .table-responsive parent is overflow-x:auto, so the correct answer is
       to let the table keep its natural width and scroll it. */
    min-width: 34rem;
}

/* Keep the university name on one line; it is the column that reads worst
   when wrapped, and horizontal scroll already handles the width. */
.ranking-table td .uni-link { white-space: nowrap; }

.compare-table th,
.compare-table td,
.ranking-table th,
.ranking-table td {
    padding: 0.625rem var(--space-sm);
    text-align: left;
    border-bottom: 1px solid var(--rule);
}

.compare-table th,
.ranking-table th {
    font-size: var(--text-xs);
    color: var(--muted);
    font-weight: 700;
    background: var(--paper-2);
}

.compare-table td { color: var(--ink-2); }
.compare-table td strong { color: var(--ink); font-weight: 600; }

/* ---------- Q&A ---------- */

.qa-container {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    gap: var(--space-lg);
    align-items: start;
}

.qa-form-panel { position: sticky; top: 78px; }

.qa-form-panel h1 { margin-bottom: var(--space-md); }

.qa-form-panel form { display: flex; flex-direction: column; gap: var(--space-sm); }

.qa-list { display: flex; flex-direction: column; gap: var(--space-md); }

.qa-item {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.qa-tag {
    font-size: var(--text-xs);
    color: var(--accent-deep);
    font-weight: 700;
}

.qa-title { margin: var(--space-2xs) 0 0.25rem; font-size: var(--text-md); }

.qa-meta { font-size: var(--text-xs); color: var(--muted); margin-bottom: var(--space-xs); }

.qa-item > p { font-size: var(--text-sm); }

.qa-answers {
    margin-top: var(--space-md);
    padding-top: 0.875rem;
    border-top: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.answer-item {
    background: var(--paper-2);
    border-radius: var(--radius);
    padding: 0.625rem var(--space-sm);
    font-size: var(--text-sm);
}

.answer-meta { font-size: var(--text-xs); color: var(--muted); }

/* Visually hidden but readable by screen readers. The answer inputs were
   placeholder-only, so the field name disappeared as soon as the user typed and
   assistive tech had nothing stable to announce. Labels now exist in the DOM
   without changing the compact single-row layout.
   Not display:none and not visibility:hidden — both remove the element from the
   accessibility tree, which would defeat the point. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.qa-empty { color: var(--ink-2); font-size: var(--text-sm); }

.qa-answer-count {
    font-size: var(--text-xs);
    color: var(--muted);
    font-weight: 600;
}

.answer-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    margin-top: var(--space-xs);
    flex-wrap: wrap;
}

/* Long answers collapse behind a summary so they cannot push the reply form
   off-screen. <details> carries the keyboard behaviour itself. */
.answer-collapse > summary {
    cursor: pointer;
    color: var(--ink);
}

.answer-collapse > summary:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--radius);
}

.answer-collapse[open] > summary {
    color: var(--muted);
    font-size: var(--text-xs);
    margin-bottom: var(--space-2xs);
}

.answer-full { color: var(--ink); }

/* --rule-strong measured 1.44:1 against the answer tint — under the 3:1 WCAG
   floor for a control's own boundary, so the pill read as decoration rather
   than something you can press. --muted is the lightest token that clears it. */
.answer-vote {
    font-size: var(--text-xs);
    font-family: inherit;
    color: var(--ink-2);
    background: transparent;
    border: 1px solid var(--muted);
    border-radius: var(--radius-pill);
    padding: 0.125rem var(--space-xs);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out);
}

.answer-vote:hover {
    border-color: var(--accent-deep);
    color: var(--accent-deep);
}

.answer-vote:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* Voted state. The button stays enabled because the vote is a toggle — a
   second press withdraws it, same as the submission votes. So no :disabled
   rule here and the cursor stays a pointer. */
.answer-vote.voted {
    color: var(--success);
    border-color: var(--success);
}

.answer-form {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    margin-top: var(--space-2xs);
}

.answer-form input { flex: 1; min-width: 120px; }

.answer-form .answer-name { flex: 0 1 150px; max-width: 150px; }

/* The answer body takes the remaining width. This class is also the JS hook the
   submit handler selects on, replacing a form.elements[1] index lookup that broke
   the moment a field was inserted above it. */
.answer-form .answer-body { flex: 1 1 200px; min-width: 0; }

.btn-answer { padding: 0.375rem var(--space-sm); font-size: var(--text-sm); margin-left: 0; }

/* ---------- Leaderboard ---------- */

.leaderboard-container { display: flex; flex-direction: column; gap: var(--space-lg); }

/* Equal-height columns so a name that wraps to two lines does not leave
   the row ragged. stretch + grid keeps all three tops and bottoms flush. */
.podium-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: var(--space-sm);
    padding: var(--space-lg) 0;
    max-width: 640px;
    margin: 0 auto;
}

.podium-bar {
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2xs);
    text-align: center;
}

/* DOM order is 1-2-3 (winner first for screen readers and the stacked phone
   layout); on wider screens show the classic 2-1-3. */
.podium-bar.silver { order: 1; }
.podium-bar.gold { order: 2; }
.podium-bar.bronze { order: 3; }

/* Score pinned to the bottom so all three line up even when one name wraps
   to three lines and another fits on one. */
.podium-score { margin-top: auto; }

/* Only the winner carries an accent; 2nd and 3rd stay neutral so they
   do not compete with it. */
.podium-bar.gold {
    border-color: var(--accent);
    background: var(--accent-wash);
}

.podium-bar.silver,
.podium-bar.bronze { border-color: var(--rule); }

/* The place number in a ring, tinted by place (was medal emoji). */
.trophy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 2px solid var(--rule-strong);
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--ink-2);
}
.podium-bar.gold .trophy { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.podium-bar.bronze .trophy { border-color: var(--accent-deep); color: var(--accent-deep); }

.podium-uni { font-size: var(--text-sm); font-weight: 600; }

.podium-score {
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.uni-link {
    cursor: pointer;
    border-bottom: 1px solid var(--rule-strong);
}

.uni-link:hover { border-bottom-color: var(--accent-deep); color: var(--accent-deep); }

.ranking-table-container h3 { margin-bottom: var(--space-md); font-size: var(--text-md); }

.leaderboard-insufficient {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.leaderboard-insufficient h3 { font-size: var(--text-md); }

.leaderboard-insufficient p { color: var(--muted); max-width: 46ch; }

.unranked-container h3 { font-size: var(--text-md); margin-bottom: var(--space-2xs); }

.unranked-intro { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-md); }

.unranked-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: var(--space-2xs) var(--space-lg);
}

.unranked-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    border-bottom: 1px solid var(--rule);
    font-size: var(--text-sm);
}

.unranked-list .uni-link { min-width: 0; }

.unranked-count {
    font-size: var(--text-xs);
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ranking-table td { color: var(--ink-2); }
.ranking-table td strong { color: var(--ink); font-weight: 600; }

/* ---------- Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    z-index: 100;
}

.modal-content {
    position: relative;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h2 { margin-bottom: var(--space-md); padding-right: var(--space-xl); }

.modal-body h3 { font-size: var(--text-sm); color: var(--ink-2); font-weight: 600; }

.modal-sub-list {
    margin-top: var(--space-sm);
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.modal-sub-item {
    background: var(--paper-2);
    border-radius: var(--radius);
    padding: 0.625rem var(--space-sm);
    font-size: var(--text-sm);
}

/* Was a <span>: unfocusable and invisible to screen readers. Now a real
   button, so it needs the UA styles stripped and font-family restored
   (buttons do not inherit it), plus a 44px tap target. */
.close-modal {
    position: absolute;
    top: var(--space-xs);
    right: var(--space-xs);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: var(--text-lg);
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
    border-radius: var(--radius);
    transition: color var(--dur-fast) var(--ease-out),
                background var(--dur-fast) var(--ease-out);
}

.close-modal:hover { color: var(--ink); background: var(--paper-2); }

/* ---------- Toast ---------- */

/* The toast is now ALWAYS in the DOM and always rendered, kept invisible with
   opacity instead of the old `hidden` class.

   Why: `.hidden` is `display:none`, which removes the node from the
   accessibility tree entirely. Text assigned to a display:none live region is
   usually never announced, so adding role="status" while keeping `hidden` would
   have looked like an a11y fix while changing nothing. Staying rendered is what
   makes the live region work.

   pointer-events:none is required as a consequence -- a permanently rendered
   fixed element at the bottom centre would otherwise swallow clicks on whatever
   sits beneath it. */
.toast {
    position: fixed;
    bottom: var(--space-lg);
    left: 50%;
    transform: translateX(-50%) translateY(0.5rem);
    background: var(--ink);
    color: var(--paper);
    padding: 0.625rem var(--space-md);
    border-radius: var(--radius);
    font-size: var(--text-sm);
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-mid) var(--ease-out),
                transform var(--dur-mid) var(--ease-out);
    z-index: 200;
}

/* The toast no longer carries .hidden, so the old `display: block !important`
   override is gone with it -- .show now only needs to reveal what is already
   rendered. */
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .qa-container { grid-template-columns: minmax(0, 1fr); }
    .qa-form-panel { position: static; }
}

@media (max-width: 720px) {
    .nav-container { gap: var(--space-md); }
    .menu-toggle { display: block; }

    /* .theme-toggle dropped `margin-left: auto` so it would sit beside the tab
       strip instead of floating at the far right. Nothing else claimed auto
       after that, so on mobile -- where .nav-tabs is absolutely positioned and
       out of flow -- the wordmark, toggle and hamburger all bunched at the
       left. The auto margin has to live on whichever control is last in the
       flow, and at this width that is .theme-toggle, with the hamburger
       immediately after it. */
    .theme-toggle { margin-left: auto; }

    .nav-tabs {
        display: none;
        position: absolute;
        top: 58px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--paper);
        border-bottom: 1px solid var(--rule);
        padding: var(--space-xs);
        gap: 0.125rem;
    }

    .nav-tabs.show { display: flex; }

    .nav-tab { text-align: left; padding: var(--space-xs) var(--space-sm); }

    /* In the phone menu the Komuniti pages are listed inline under a plain
       label (the menu's own aria-label, drawn by ::before); a menu inside a
       menu would be one tap too many, so the toggle is not shown here. */
    .nav-group-toggle { display: none; }
    .nav-group-menu::before {
        content: "Komuniti";
        padding: var(--space-xs) var(--space-sm) 0;
        color: var(--muted);
        font-size: var(--text-xs);
        font-weight: 600;
    }
    .nav-group-menu {
        display: flex;
        position: static;
        min-width: 0;
        padding: 0;
        background: none;
        border: 0;
        box-shadow: none;
    }

    .main-content { padding: var(--space-lg) var(--space-md) var(--space-2xl); }

    .glass-panel { padding: var(--space-md); }

    /* podium-section is a grid now, so stack via columns not flex-direction. */
    .podium-section { grid-template-columns: minmax(0, 1fr); }
    .podium-bar.silver, .podium-bar.gold, .podium-bar.bronze { order: 0; }


    .btn-secondary { margin-left: 0; margin-top: var(--space-xs); }
}

@media (max-width: 400px) {
    .filter-bar,
    .form-grid,
    .qm-cards { grid-template-columns: minmax(0, 1fr); }
    /* Eight categories in one column is a long scroll; two fit a phone. */
    .qm-cards.qm-cat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .qm-cat-card { padding: 0.75rem; min-height: 4.5rem; }

    .card-header { flex-wrap: wrap; }
}

/* ---------- Teroka sub-panes: kedai + model ---------- */

/* Sub-tabs sit inside Teroka. Flat and hairline to match the rest of the
   palette: no pills, no shadows, no gradient. */
.subtab-strip {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-md);
    overflow-x: auto;
}

.subtab {
    appearance: none;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: var(--text-sm);
    font-weight: 400;
    padding: 0.5rem var(--space-md);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out);
}

.subtab:hover { color: var(--text-primary); }

.subtab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-deep);
}

/* Visible focus ring: these are the newest interactive controls on the page and
   a keyboard user must be able to see where they are. */
.subtab:focus-visible,
.shop-card:focus-visible {
    outline: 2px solid var(--accent-deep);
    outline-offset: -2px;
}

/* Map beside list on desktop, stacked on mobile (see the 860px block below). */
.shops-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: var(--space-md);
    align-items: start;
}

#shop-map {
    height: 460px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper-2);
    /* Leaflet gives its panes and controls z-index 400-1000. Without a
       stacking context of its own the map drew over the sticky header
       (z-index 50) and the phone bottom bar (150) when scrolled under them.
       Checked by tests/browser/bottom-nav.cjs. */
    isolation: isolate;
}

/* OSM tiles are raster PNGs from a third party, so no token can recolour them.
   The filter is applied to the tile layer only -- NOT to .leaflet-container --
   because inverting the container would also invert the markers, the popups and
   the attribution, turning the marker pins into their colour opposites. In
   light mode --tile-filter is `none`, so this rule costs nothing there. */
.leaflet-tile-pane {
    filter: var(--tile-filter);
}

/* Leaflet's own chrome is hardcoded light in 13 places in vendor/leaflet.css
   (#fff backgrounds, #333 text). Those are NOT reachable by the token layer, so
   in dark mode the attribution pill and the zoom buttons stayed bright white --
   the brightest thing on the page, reading as a bug rather than a control.
   
   Overridden here rather than edited in vendor/leaflet.css: that file is
   vendored verbatim so it can be replaced on a Leaflet upgrade, and edits to it
   would be silently lost. Scoped to [data-theme="dark"] so light mode keeps
   Leaflet's stock appearance exactly.
   
   Deliberately NOT done with a filter on .leaflet-container: that would invert
   the marker pins too. The tile pane above is the only thing filtered. */
:root[data-theme="dark"] .leaflet-container .leaflet-control-attribution {
    background: oklch(20.5% 0.010 78 / 0.82);
    color: var(--ink-2);
}

:root[data-theme="dark"] .leaflet-control-attribution a {
    color: var(--accent-deep);
}

/* Zoom buttons. Probed as rgb(255,255,255) with black glyphs before this. */
:root[data-theme="dark"] .leaflet-bar a,
:root[data-theme="dark"] .leaflet-bar a:hover {
    background-color: var(--card);
    color: var(--ink);
    border-bottom-color: var(--rule);
}

:root[data-theme="dark"] .leaflet-bar a:hover {
    background-color: var(--paper-3);
}

:root[data-theme="dark"] .leaflet-bar {
    border-color: var(--rule);
}

/* Popups: the shop name/address bubble. bindPopup is used for all 84 markers,
   so this is a real surface, not defensive styling. */
:root[data-theme="dark"] .leaflet-popup-content-wrapper,
:root[data-theme="dark"] .leaflet-popup-tip {
    background: var(--card);
    color: var(--ink);
}

:root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button {
    color: var(--muted);
}

:root[data-theme="dark"] .leaflet-container a.leaflet-popup-close-button:hover {
    color: var(--ink);
}

.shop-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 460px;
    overflow-y: auto;
    /* The list holds 60 cards in a 460px box, so it always overflows. Without a
       visible track the partial card at the bottom edge reads as a layout bug
       rather than "there is more below". Hairline, monochrome, no glow. */
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    padding-right: 4px;
}

/* Map above list on narrow screens. The map gets shorter so it does not eat
   the whole screen and hide the list that follows it. This block must come
   after the rules above: in the 860px block near the top of the file it lost
   to them on source order, and phones showed map and list side by side.
   Checked by tests/browser/bottom-nav.cjs. */
@media (max-width: 860px) {
    .shops-layout { grid-template-columns: minmax(0, 1fr); }
    #shop-map { height: 300px; }
    .shop-list { max-height: none; }
}

.shop-list::-webkit-scrollbar { width: 8px; }
.shop-list::-webkit-scrollbar-track { background: transparent; }
.shop-list::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-sm, 3px);
}

/* Each shop is a real <button>, so it is tabbable and Enter-activatable for
   free. Styled to read as a card rather than a form control. */
.shop-card {
    appearance: none;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.625rem var(--space-sm);
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out);
}

.shop-card:hover { border-color: var(--border-strong); }

.shop-name {
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.shop-meta { font-size: var(--text-sm); color: var(--text-muted); }
.shop-extra { font-size: var(--text-xs); color: var(--text-secondary); }

.model-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.model-card h2 { font-size: var(--text-base); margin: 0; }
.model-price { font-weight: 600; color: var(--text-primary); margin: 0; }
.model-spec { font-size: var(--text-sm); color: var(--text-muted); margin: 0; }
.model-meta { font-size: var(--text-sm); color: var(--text-secondary); margin: 0; }
.model-shop {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin: 0;
    /* Shop names run long and must not push the card wider than its column. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The whole card is the affiliate link, so it needs to read as one target:
   inherit type colour rather than link blue, and keep the CTA as the only
   coloured affordance. */
.model-card-link {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.model-card-link:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

/* Keyboard focus: the site's ring and the accent border, with no lift or
   shadow and no transition, so the ring appears at once (a fade-in loses a
   keyboard user's place; Hallmark audit 2026-12-05). */
.model-card-link:focus-visible {
    border-color: var(--accent);
    outline: 2px solid var(--focus); /* the site's ring: 3:1 or better, light and dark */
    outline-offset: 2px;
    transition: none;
}

/* Fixed aspect box so 300 mixed-size listing photos do not make the grid
   ragged, and so the reserved space stops layout shifting as they load. */
.model-thumb {
    aspect-ratio: 1 / 1;
    border-radius: calc(var(--radius) - 2px);
    overflow: hidden;
    background: var(--bg-subtle);
}

.model-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* The photo, name and price: one shop link for the mouse (the named link is
   "Lihat di …" below). Fills the card so the buttons line up at the bottom. */
.model-card-main {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1 1 auto;
    color: inherit;
    text-decoration: none;
}
/* WhatsApp share spec: "Lihat di …" full width, then WhatsApp and Bandingkan
   side by side. Sits at the bottom of the card regardless of how many lines
   the title took, so a row of cards has its buttons aligned. */
.model-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs);
    margin-top: auto;
    padding-top: 0.375rem;
}
.model-actions > * {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-width: 0;
    white-space: nowrap;
    text-decoration: none;
    margin: 0; /* .btn-secondary's left margin would push the row off the photo's edge */
}
.model-cta { grid-column: 1 / -1; text-align: center; }
.model-cta .cta-icon { display: none; }
.cta-icon { flex: none; width: 1em; height: 1em; }
.model-compare[aria-pressed="true"] { border-color: var(--accent-deep); background: var(--accent-wash); color: var(--ink); }
.ai-card-whatsapp { display: inline-flex; align-items: center; gap: 0.375rem; text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
    .model-card-link { transition: none; }
    .model-card-link:hover,
    .model-card-link:focus-visible { transform: none; }
}

.muted-note { color: var(--text-muted); font-size: var(--text-sm); }

/* ---------- Model grid paging ---------- */

/* Sits directly under the grid: the count and the way past the cap read as one
   unit rather than as a stray note floating near the attribution line. */
.model-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    margin-top: var(--space-lg);
}

.model-more:empty { margin-top: 0; }

.model-more .btn-secondary { margin-left: 0; }

/* ---------- Q&A actions and deep-link focus ---------- */

.qa-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.qa-actions .btn-secondary { margin-left: 0; }

.qa-date { color: var(--muted); font-size: var(--text-xs); margin-left: var(--space-xs); }

/* Marks the question a shared link pointed at. A left rule plus a tinted band,
   not colour alone, so the target is identifiable without colour vision. */
.qa-item.qa-focused {
    border-left: 3px solid var(--accent-deep);
    background: var(--accent-wash);
}

/* ---------- Footer ---------- */

.site-footer {
    border-top: 1px solid var(--rule-strong);
    background: var(--paper-2);
    padding: var(--space-xl) var(--space-lg);
}

.footer-grid {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
}

.footer-col h2 {
    font-family: var(--font-display);
    font-size: var(--text-base);
    margin-bottom: var(--space-xs);
    color: var(--ink);
}

.footer-col p,
.footer-col li {
    font-size: var(--text-sm);
    /* --ink-2 at 7.56:1, not --muted: this is the text that has to be readable
       for the disclosure and methodology to count as disclosed. */
    color: var(--ink-2);
    line-height: 1.55;
}

.footer-col p + p { margin-top: var(--space-xs); }

.footer-col ul { padding-left: 1.1rem; margin-bottom: var(--space-xs); }

/* Underlined, not colour alone: against the footer's body text the link
   colour is only 1.0-1.4:1, so the underline is what marks it as a link. */
.footer-col a { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }

.footer-note {
    max-width: 1080px;
    margin: var(--space-lg) auto 0;
    padding-top: var(--space-md);
    border-top: 1px solid var(--rule);
    font-size: var(--text-xs);
    color: var(--muted);
}

/* Attribution is a licence obligation for OSM data, not decoration. */
.attrib-note {
    color: var(--text-muted);
    font-size: var(--text-xs);
    margin-top: var(--space-sm);
}

/* Affiliate disclosure sits above the listings and must be readable, not a
   greyed-out footnote: it is the one line that tells the reader money is
   involved before they act on a recommendation. Full body contrast, a left rule
   to separate it from the filter bar, no colour-only signalling. */
.affiliate-disclosure {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: 1.5;
    margin: 0 0 var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid var(--accent-deep);
    background: var(--paper-2);
    border-radius: var(--radius);
}

.affiliate-disclosure strong { color: var(--text-primary); }

/* Leaflet ships its own popup styling; align it with the flat palette so the
   map does not look bolted on. */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: none;
    border: 1px solid var(--border-strong);
}

.leaflet-container { font: inherit; }

/* Honeypot field.
   Bait for bots that fill every input they find. Real visitors never see it and
   never tab into it, so a non-empty value means the submission was automated.

   Deliberately NOT display:none or visibility:hidden -- some bots skip those on
   purpose. This keeps the field technically rendered but pushed off-canvas, and
   aria-hidden + tabindex="-1" in the markup keep it away from screen readers and
   keyboard users. Accessibility is not traded for spam defence here. */
.hp-field {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Spatial motion collapses to an opacity crossfade; nothing else moves. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.15s !important;
        scroll-behavior: auto !important;
    }

    .view-section { animation: none; }
    .toast { transition: opacity 0.15s linear !important; }
}

/* ---------------------------------------------------------------------------
   Tanya SiswaSpecs (advisor.js): laptop cards, follow-ups and status, shown
   in the Dashboard answer area under the hero box.
   --------------------------------------------------------------------------- */
.ai-cards { display: flex; flex-direction: column; gap: 0.625rem; }
.ai-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    background: var(--bg-primary);
}
.ai-card-head { display: flex; gap: 0.75rem; color: inherit; text-decoration: none; }
.ai-card-head img, .ai-card-ph { flex: none; width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); }
.ai-card-ph {
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    box-sizing: border-box;
    color: var(--text-muted);
}
a.ai-card-head:hover h3 { text-decoration: underline; }
.ai-card-title h3 {
    margin: 0 0 0.25rem;
    font-size: var(--text-base);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* "Lihat di Shopee" + a line icon: the whole header is the link; this line
   looks like one. */
.ai-card-shop { margin: 0; font-size: var(--text-sm); color: var(--ink-2); }
.ai-card-shop-icon { width: 0.875em; height: 0.875em; margin-left: 0.25em; vertical-align: -0.0625em; }
a.ai-card-head .ai-card-shop { color: var(--accent-deep); text-decoration: underline; text-underline-offset: 2px; }
.ai-card-price { margin: 0; font-weight: 600; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.ai-badge-over {
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--accent-deep);
    color: var(--accent-deep);
}
.ai-card-specs, .ai-card-hint, .ai-card-reason, .ai-card-review, .ai-cards-note, .ai-why p, .ai-why li {
    font-size: var(--text-sm);
}
.ai-card-specs { margin: 0.5rem 0 0; color: var(--text-secondary); }
.ai-card-hint, .ai-cards-note { margin: 0.25rem 0 0; color: var(--text-muted); }
.ai-card-reason { margin: 0.5rem 0 0; }
.ai-score { margin-top: 0.625rem; }
.ai-score-row { display: flex; align-items: center; gap: 0.5rem; font-size: var(--text-xs); }
.ai-score-label { color: var(--text-secondary); white-space: nowrap; }
.ai-score-bar {
    flex: 1; min-width: 3rem; height: 6px;
    border-radius: var(--radius-pill);
    background: var(--bg-secondary);
    box-shadow: inset 0 0 0 1px var(--border);
    overflow: hidden;
}
.ai-score-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.ai-score-num { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.ai-checks { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem; }
.ai-check {
    font-size: var(--text-xs);
    line-height: 1.4;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.ai-check.is-ok span[aria-hidden] { color: var(--success, var(--text-primary)); font-weight: 700; }
.ai-check.is-miss { border-style: dashed; color: var(--text-muted); }
.ai-check.is-miss span[aria-hidden] { color: var(--accent-deep); font-weight: 700; }
.ai-card-review {
    margin: 0.5rem 0 0;
    padding-left: 0.625rem;
    border-left: 2px solid var(--border-strong);
    color: var(--text-secondary);
}
/* Kenapa ini?, Bandingkan and WhatsApp: equal outlined buttons in one row
   (Chat thread spec, "Answer card"). Quick Match's card has two. */
.ai-card-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.ai-card-actions > .btn-secondary {
    margin: 0;
    min-width: 0;
    min-height: 40px;
    padding: 0 0.375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    white-space: nowrap;
    text-decoration: none;
}
.ai-card-actions svg { flex: none; width: 16px; height: 16px; }
.ai-why-chevron { transition: transform var(--motion-fast, 150ms) var(--ease-out, ease-out); }
.ai-why-btn.is-open { border-color: var(--accent-deep); background: var(--accent-wash); }
.ai-why-btn.is-open .ai-why-chevron { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .ai-why-chevron { transition: none; } }
/* The labels follow the card's own width, not the screen's: a narrow card
   (phones, and two per row on a tablet) reads "Kenapa?" with tighter
   spacing. */
.ai-card { container-type: inline-size; }
@container (max-width: 309.98px) {
    .ai-card-actions { gap: 0.25rem; }
    .ai-card-actions > .btn-secondary { padding: 0 0.25rem; gap: 0.25rem; font-size: 13px; } /* the site's smallest text */
    .ai-card-actions svg { width: 14px; height: 14px; }
    .ai-card-actions .cta-long { display: none; }
    /* "Bandingkan" is the longest word: no room for its icon here. */
    .ai-compare-btn svg { display: none; }
}
.ai-why { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.ai-why p { margin: 0 0 0.25rem; }
.ai-why ul { margin: 0 0 0.25rem; padding-left: 1.125rem; }

.empty-cat p { margin: 0 0 0.75rem; }
.empty-cat-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.75rem; }
/* Two outlined buttons side by side ("Tanya AI tentang laptop..." was a text
   link; owner, 2026-12-06): the gap spaces them, not .btn-secondary's margin. */
.empty-cat-actions .btn-secondary { margin: 0; min-height: 44px; }

.ai-status { padding: 0.5rem var(--space-md); border-top: 1px solid var(--border); font-size: var(--text-sm); }
.ai-status p { margin: 0; }
.ai-status-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.ai-typing { color: var(--text-muted); }

.ai-disclaimer { margin: 0; padding: 0.375rem var(--space-md) 0.625rem; font-size: var(--text-xs); color: var(--text-muted); }
.qm-ai-link { margin-top: var(--space-md); text-align: center; }

/* ---- Kongsi in steps (Phase 3d) ---- */
.share-step { border: 0; margin: 0; padding: 0; min-width: 0; }
.share-step-title { margin: 0 0 var(--space-md); font-size: var(--text-lg, 1.125rem); }
.share-step-title:focus { outline: none; }
.share-step-title:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 4px; }

.share-progress { margin: var(--space-md) 0 var(--space-lg); }
.share-progress-steps {
    list-style: none; margin: 0 0 0.5rem; padding: 0;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
    font-size: var(--text-sm); color: var(--text-muted);
}
.share-progress-steps li { display: flex; align-items: center; gap: 0.5rem; }
.share-progress-steps span {
    flex: none; display: inline-flex; align-items: center; justify-content: center;
    width: 1.5rem; height: 1.5rem; border-radius: 50%;
    border: 1px solid var(--rule-strong); font-size: var(--text-xs); font-weight: 600;
}
.share-progress-steps li.is-current { color: var(--ink); font-weight: 600; }
.share-progress-steps li.is-current span { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #1a1408); }
.share-progress-steps li.is-done span { border-color: var(--accent-deep); color: var(--accent-deep); }
.share-progress-track { height: 4px; border-radius: 2px; background: var(--rule); overflow: hidden; }
/* Grows by transform (scaleX, set by app.js), not width: no layout work per frame. */
.share-progress-fill { display: block; height: 100%; width: 100%; transform: scaleX(0.3333); transform-origin: left center; background: var(--accent); transition: transform var(--dur-fast, 160ms) var(--ease-out, ease-out); }

.field-error { margin: 0.375rem 0 0; font-size: var(--text-sm); color: var(--danger); font-weight: 600; }
.field-error::before { content: '! '; font-weight: 700; }
#share-form [aria-invalid="true"] { border-color: var(--danger); }
#share-form .star-rating-input[aria-invalid="true"] { outline: 1px solid var(--danger); outline-offset: 4px; border-radius: var(--radius); }
.share-error-summary {
    margin: 0 0 var(--space-md); padding: 0.625rem 0.75rem;
    border: 1px solid var(--danger); border-radius: var(--radius);
    color: var(--danger); font-size: var(--text-sm); font-weight: 600;
}

.share-nav { display: flex; gap: var(--space-sm); justify-content: flex-end; margin-top: var(--space-lg); }
.share-nav .btn-primary, .share-nav .btn-secondary { margin: 0; min-width: 8rem; }
.share-nav .btn-submit { width: auto; margin: 0; }
.share-nav #share-back { margin-right: auto; }

@media (max-width: 640px) {
    .share-progress-steps { font-size: var(--text-xs); }
    .share-progress-steps li { flex-direction: column; gap: 0.25rem; text-align: center; }
    .share-nav { flex-direction: column-reverse; }
    .share-nav .btn-primary, .share-nav .btn-secondary, .share-nav .btn-submit { width: 100%; }
    /* Keep the step buttons clear of the round chat button (story 48). */
    #view-share .share-container { padding-bottom: 6rem; }
}

/* ---- Teroka filters: inline on desktop, bottom sheet on phones (Phase 3c) ---- */
.filter-sheet, .filter-sheet-body { display: contents; }
.filter-sheet-head, .filter-sheet-foot, .filter-open, .filter-chips, .filter-backdrop { display: none; }

@media (max-width: 640px) {
    /* Search and "Tapis" share one row; laptops start right below. */
    #pane-reviews .filter-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        margin-bottom: var(--space-sm);
    }
    .filter-open { display: inline-flex; align-items: center; margin: 0; white-space: nowrap; }
    .filter-open.has-active { border-color: var(--accent-deep); color: var(--accent-deep); }

    .filter-chips:not(:empty) {
        display: flex;
        flex-wrap: wrap;
        gap: 0.375rem;
        margin: 0 0 var(--space-sm);
    }
    .filter-chip {
        font: inherit;
        font-size: var(--text-xs);
        min-height: 32px;
        padding: 0.25rem 0.75rem;
        border-radius: var(--radius-pill);
        border: 1px solid var(--accent-deep);
        background: var(--accent-wash);
        color: var(--ink);
        cursor: pointer;
    }

    .filter-sheet { display: none; }
    .filter-sheet.is-open {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 170;
        max-height: 85vh;
        background: var(--card);
        border-top: 1px solid var(--rule-strong);
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.25);
        padding-bottom: env(safe-area-inset-bottom, 0);
        animation: sheet-up 220ms var(--ease-out);
        transition: transform 180ms var(--ease-out);
    }
    .filter-sheet.is-dragging { transition: none; }
    .filter-sheet.is-open .filter-sheet-head {
        display: grid;
        grid-template-columns: 2.75rem 1fr 2.75rem;
        align-items: center;
        padding: 0.75rem var(--space-md) 0.25rem;
        position: relative;
        touch-action: none;
    }
    .filter-sheet-handle {
        position: absolute; top: 0.4rem; left: 50%;
        width: 2.5rem; height: 4px; margin-left: -1.25rem;
        border-radius: 2px; background: var(--rule-strong);
    }
    .filter-sheet-head h2 { grid-column: 2; margin: 0; text-align: center; font-size: var(--text-base); }
    .filter-sheet-close {
        grid-column: 3; justify-self: end;
        width: 2.75rem; height: 2.75rem;
        border: 0; background: none; color: var(--ink);
        font-size: 1.5rem; line-height: 1; cursor: pointer;
    }
    .filter-sheet.is-open .filter-sheet-body {
        display: flex;
        flex-direction: column;
        gap: var(--space-md);
        padding: var(--space-sm) var(--space-md) var(--space-md);
        overflow-y: auto;
    }
    .filter-sheet.is-open .filter-sheet-foot {
        display: grid;
        grid-template-columns: 1fr 1.4fr;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md) var(--space-md);
        border-top: 1px solid var(--rule);
    }
    .filter-sheet-foot .btn-secondary, .filter-sheet-foot .btn-primary { margin: 0; width: 100%; }

    .filter-backdrop:not(.hidden) {
        display: block;
        position: fixed; inset: 0;
        z-index: 165;
        background: rgba(0, 0, 0, 0.45);
    }
    body.sheet-open { overflow: hidden; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
    .filter-sheet.is-open { animation: none; transition: none; }
}

/* Very narrow phones: long category names like "Kemanusiaan" need the full width. */
@media (max-width: 359px) {
    .qm-cards.qm-cat-cards { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Mobile round: touch and text sizes (spec: docs/specs/mobile-round.md, "Sizes") ----
   On phones every control is at least 44px tall (icon-only ones also 44px
   wide), labels are at least 13px and body copy at least 14px. Checked by
   tests/browser/sizes.cjs. Desktop is unchanged. */
@media (max-width: 640px) {
    /* Type tokens up one step: 12px labels become 13px, 13px copy becomes 14px. */
    :root {
        --text-xs: 0.8125rem;
        --text-sm: 0.875rem;
    }

    input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
    select,
    .btn-primary,
    .btn-secondary,
    .subtab,
    .hero-chip,
    .hero-invite,
    .btn-helpful,
    .answer-vote,
    #btn-locate {
        min-height: 44px;
    }
    /* Text inputs keep 16px so iOS doesn't zoom in when one is focused. */
    input:not([type=checkbox]):not([type=radio]):not([type=range]),
    select,
    textarea {
        font-size: max(16px, 1em);
    }
    .btn-primary,
    .btn-secondary,
    .subtab,
    .hero-chip,
    .btn-helpful,
    .answer-vote,
    .btn-link,
    #btn-locate {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .btn-link { min-height: 44px; padding-block: 0; }
    .answer-vote { padding-inline: var(--space-sm); }
    /* Flex drops the space between "Helpful" and its count; put it back. */
    .btn-helpful, .answer-vote { gap: 0.3em; }

    /* The whole "Bandingkan" label is the target, not just the 13px box. */
    .compare-check { min-height: 44px; padding-inline: var(--space-2xs); margin-inline: calc(-1 * var(--space-2xs)); }

    .menu-toggle {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    /* Stays display: list-item so the ▸ marker shows; padding makes the height. */
    summary { min-height: 44px; padding-block: 0.6rem; box-sizing: border-box; }
    .uni-link { display: inline-flex; align-items: center; min-height: 44px; }

    /* Leaflet's map zoom buttons (30px by default). */
    .leaflet-touch .leaflet-bar a {
        width: 44px;
        height: 44px;
        line-height: 44px;
    }
}

/* ---- Mobile round: bottom bar and "Lagi" sheet (spec: "Bottom bar", "Lagi sheet") ----
   Phone only. The bar replaces the menu, the theme button and the round chat
   button; the header keeps only the logo. The bar stays put on scroll and
   hides while a sheet or the chat is open. Checked by tests/browser/bottom-nav.cjs. */
.bottom-nav, .more-sheet { display: none; }

@media (max-width: 640px) {
    :root { --bottom-nav-h: 3.5rem; }

    .navbar .menu-toggle,
    .navbar .theme-toggle,
    .navbar .nav-tabs { display: none !important; }

    body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }

    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 150;
        height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: var(--card);
        border-top: 1px solid var(--rule-strong);
    }
    body.sheet-open .bottom-nav { display: none; }
    /* Typing in the Ask box (Answer screen): the bar steps aside for the
       keyboard, and the Ask box and compare bar drop to the edge. hero.js
       sets is-typing, and clears it a moment after the box loses focus so a
       tap that moved focus lands before the layout shifts back. */
    :root { --ask-clear: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px)); }
    body.is-typing { --ask-clear: 0px; }
    body.is-typing .bottom-nav { display: none; }
    /* Toasts sit above the bar instead of behind it. */
    .toast { bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + var(--space-sm)); }

    .bottom-nav-item {
        flex: 1 1 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 0.25rem 0.125rem;
        border: 0;
        background: none;
        color: var(--ink-2);
        font: inherit;
        font-size: var(--text-xs);
        line-height: 1.15;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-item.hidden { display: none; }
    /* "Quick Match" and "Leaderboard" are the longest labels: a bigger share
       keeps them whole at 360px. */
    .bottom-nav-item[data-arg="quickmatch"],
    .bottom-nav-item[data-arg="leaderboard"] { flex-grow: 1.4; }
    .bottom-nav-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .bottom-nav-item[aria-current="page"],
    .bottom-nav-item.active { color: var(--accent-deep); font-weight: 600; }
    .bottom-nav-item[aria-current="page"] svg,
    .bottom-nav-item.active svg { stroke-width: 2.4; }
    .bottom-nav-item:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: -4px; border-radius: var(--radius-md, 8px); }

    .more-sheet-body { gap: 0 !important; padding-top: 0 !important; }
    .more-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-sm);
        min-height: 52px;
        padding: 0 var(--space-2xs);
        border: 0;
        border-bottom: 1px solid var(--rule);
        background: none;
        color: var(--ink);
        font: inherit;
        font-size: var(--text-base);
        text-align: left;
        cursor: pointer;
    }
    .more-item:last-child { border-bottom: 0; }
    .more-count {
        min-width: 1.5rem;
        padding: 0 0.4rem;
        border-radius: var(--radius-pill);
        background: var(--accent);
        color: var(--on-accent);
        font-size: var(--text-xs);
        font-weight: 600;
        text-align: center;
    }
    .more-count.hidden { display: none; }
    /* A switch drawing; the state itself is aria-pressed on the button. */
    .more-switch {
        position: relative;
        flex: none;
        width: 2.5rem; height: 1.5rem;
        border-radius: var(--radius-pill);
        background: var(--rule-strong);
        transition: background var(--dur-fast) var(--ease-out);
    }
    .more-switch::after {
        content: "";
        position: absolute; top: 3px; left: 3px;
        width: calc(1.5rem - 6px); height: calc(1.5rem - 6px);
        border-radius: 50%;
        background: var(--card);
        transition: transform var(--dur-fast) var(--ease-out);
    }
    .more-theme[aria-pressed="true"] .more-switch { background: var(--accent-deep); }
    .more-theme[aria-pressed="true"] .more-switch::after { transform: translateX(1rem); }
}

/* ---- Mobile round: compact compare bar (spec: "Compare bar") ----
   Desktop shows words; phones get one row above the bottom bar:
   "2 dipilih · [Bandingkan] [share] [✕]". Checked by
   tests/browser/shortlist-phone.cjs. */
.sb-icon { display: none; }

@media (max-width: 640px) {
    :root { --shortlist-h: 3.75rem; }
    .shortlist-bar {
        bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: var(--space-xs);
        min-height: var(--shortlist-h);
        padding: var(--space-xs) var(--space-md);
        box-shadow: none;
    }
    body.is-typing .shortlist-bar { bottom: 0; }
    body.sheet-open .shortlist-bar,
    .shortlist-bar-label { white-space: nowrap; }
    .sb-word { display: none; }
    .shortlist-bar-actions { flex-wrap: nowrap; justify-content: flex-end; gap: var(--space-2xs); margin-left: auto; }
    .shortlist-bar-actions > button { margin: 0; }
    .sb-compare { gap: 0.3em; }
    .sb-icon { display: block; }
    .sb-text { display: none; }
    .sb-share, .sb-clear {
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        justify-content: center;
    }
    .sb-clear { color: var(--ink-2); text-decoration: none; }
    /* The page and the toast clear both bars while the compare bar is up. */
    body:has(.shortlist-bar:not(.hidden)) { padding-bottom: calc(var(--bottom-nav-h) + var(--shortlist-h) + env(safe-area-inset-bottom, 0px)); }
    body:has(.shortlist-bar:not(.hidden)) .main-content { padding-bottom: var(--space-2xl); }
    body:has(.shortlist-bar:not(.hidden)):not(.sheet-open) .toast { bottom: calc(var(--bottom-nav-h) + var(--shortlist-h) + env(safe-area-inset-bottom, 0px) + var(--space-sm)); }
}
/* Narrowest phones: the count alone ("2"); the word stays for screen readers. */
@media (max-width: 340px) {
    .sb-tail {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
    }
}

/* ---- Mobile round: Dashboard (spec: "Dashboard") ----
   Phones: the example chips snap and fade at the edge they continue past. Checked by tests/browser/dash-hero.cjs. */
@media (max-width: 640px) {
    .hero-chips {
        scroll-snap-type: x mandatory;
        -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
        mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
    }
    .hero-chips.at-end { -webkit-mask-image: none; mask-image: none; }
    .hero-chip { scroll-snap-align: start; }
}

/* Tips are <details>: open and marker-less on desktop, so they look as before. */
@media (min-width: 641px) {
    .tip-card summary { list-style: none; cursor: default; }
    .tip-card summary::-webkit-details-marker { display: none; }
}
/* Three across: every title takes two lines' height, so the text under a
   one-line title starts level with the text under a two-line one. */
@media (min-width: 721px) {
    .tip-card h3 { min-height: 2.6em; min-height: 2lh; }
}
/* Phones: the native marker hangs outside the title, so a wrapped title's
   second line sits under its first, not under the marker. */
@media (max-width: 640px) {
    .tips-container { gap: var(--space-xs); }
    .tip-card { padding: 0 var(--space-md); }
    .tip-card summary { cursor: pointer; list-style-position: outside; margin-left: 1.1em; }
    .tip-card summary h3 { display: inline; margin: 0; }
    /* Inline title: nudge the icon down to sit on the text, as before. */
    .tip-card summary .tip-icon { margin-top: 0; position: relative; top: 0.15em; }
    .tip-card p { padding-bottom: var(--space-md); }
}

/* ---- Mobile round: Teroka (spec: "Teroka tabs", "Review cards") ----
   Phones: short equal-width tab labels, specs on one line, quotes clamped to
   2 lines with "Baca lagi". Checked by tests/browser/teroka-cards.cjs. */
.subtab-short, .specs-line, .read-more, .uni-short { display: none; }
/* Wider than a phone the title row stacks exactly like the old separate rows. */
.card-title-row { display: flex; flex-direction: column; gap: 0.625rem; }
@media (max-width: 640px) {
    .subtab-strip { display: flex; }
    .subtab-strip .subtab { flex: 1 1 0; min-width: 0; padding-inline: var(--space-2xs); }
    .subtab-full { display: none; }
    .subtab-short { display: inline; }

    .laptop-card .specs-list { display: none; }

    /* Model name left, stars right, one row; the name wraps, stars never do. */
    .card-title-row { flex-direction: row; align-items: baseline; justify-content: space-between; gap: var(--space-xs); }
    .card-title-row .card-stars { flex-shrink: 0; white-space: nowrap; font-size: var(--text-sm); }

    /* Reviewer on one line: name, badge · UiTM • course (the course ellipsizes).
       The initial avatar only repeated the name's first letter. */
    .card-user .avatar { display: none; }
    .card-user .user-info { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; flex: 1; }
    .card-user .user-name { flex-wrap: nowrap; white-space: nowrap; flex-shrink: 0; max-width: 65%; overflow: hidden; }
    .card-user .user-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
    .uni-full { display: none; }
    .uni-short { display: inline; }
    .specs-line {
        display: flex;
        margin: var(--space-2xs) 0 var(--space-xs);
        font-size: var(--text-sm);
        color: var(--ink-2);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .card-review:not(.is-expanded) {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
    }
    /* A 44px tap target that takes one text line of space: the extra height
       overlaps the gaps above and below instead of adding a row. */
    .read-more:not(.hidden) {
        display: inline-flex;
        align-self: flex-start;
        position: relative;
        margin-block: -0.75rem -0.5rem;
    }
}

/* ---- Mobile round: Teroka Model rows (spec: "Model rows") ----
   Every card keeps its photo slot; a missing photo shows a laptop outline.
   Phones: one compact row per listing, about 4 per screen:
     [photo] clean name (2 lines)
             RM 1,299   ★ 4.7   72 terjual
             shop name
     [ Shopee ↗ ][ WhatsApp ][ Bandingkan ]
   The photo and name stay the shop link; the buttons (WhatsApp share spec,
   2026-12-06) replaced the small "Shopee ↗" cue. Checked by
   tests/browser/teroka-models.cjs and whatsapp-share.cjs. */
.model-thumb.is-placeholder {
    background: var(--bg-subtle) center / 45% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='5' width='16' height='11' rx='1.5'/%3E%3Cpath d='M2 19h20'/%3E%3C/svg%3E");
}

@media (max-width: 640px) {
    #model-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-xs); }
    .model-card { padding: var(--space-xs); }
    .model-card-link:hover, .model-card-link:focus-visible { transform: none; }
    .model-thumb { grid-column: 1; grid-row: 1 / span 4; align-self: start; width: 72px; margin-right: calc(var(--space-sm) - 0.3em); }
    .model-card h2 {
        grid-column: 2 / -1; grid-row: 1;
        font-size: var(--text-sm);
        line-height: 1.3;
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
        overflow: hidden;
    }
    .model-price { grid-column: 2; grid-row: 2; font-size: var(--text-sm); white-space: nowrap; }
    .model-meta { grid-column: 3 / -1; grid-row: 2; margin-left: var(--space-xs); }
    .model-spec { grid-column: 2 / -1; grid-row: 3; font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .model-shop { grid-column: 2 / 4; grid-row: 4; }
    /* The photo, name and price keep the compact row; the three buttons sit in
       one row under it (WhatsApp share spec), each 44px tall. */
    .model-card { display: flex; flex-direction: column; gap: var(--space-xs); }
    .model-card-main {
        display: grid;
        grid-template-columns: 72px auto minmax(0, 1fr) auto;
        column-gap: 0.3em;
        row-gap: 2px;
        align-items: baseline;
    }
    /* The shop button takes what "Shopee ↗" needs; the other two share the rest. */
    .model-actions { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); padding-top: 0; }
    .model-actions > * { min-height: 44px; padding-inline: 0.25rem; font-size: var(--text-sm); }
    .model-cta { grid-column: auto; }
    .model-cta .cta-long { display: none; }
    .model-cta .cta-icon { display: inline; }
    .model-actions > .model-cta { padding-inline: 0.625rem; }
    .model-compare .cta-long { display: none; }
}

/* ===================================================================   Motion round (docs/specs/motion-round.md): "calm with life".
   Only transform and opacity animate (plus the --beam-angle custom property).
   Every animated element carries .motion-anim; reduced motion stops them all.
   ========================================================================== */
:root {
    --motion-fast: 150ms;
    --motion-base: 300ms;
    --motion-slow: 600ms;
    /* --ease-out already exists above (the site's easing); reused here. */
    --beam-loop: 6s;
}

@media (prefers-reduced-motion: reduce) {
    .motion-anim, .motion-anim::before, .motion-anim::after {
        animation: none !important;
        transition: none !important;
    }
}

/* Follow-up chips under the latest chat reply (A1) */
.ai-followups {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin: 0.25rem 0 0.5rem;
}
.ai-chip {
    font: inherit;
    font-size: var(--text-sm);
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    min-height: 36px;
    cursor: pointer;
    animation: chip-in var(--motion-base) var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 60ms);
    transition: border-color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out);
}
.ai-chip:hover { border-color: var(--accent-deep); background: var(--accent-wash); }
.ai-chip:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@keyframes chip-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
    .ai-chip { min-height: 44px; font-size: 0.875rem; }
}

/* A button inside the toast (Batal) */
.toast-action {
    font: inherit;
    font-weight: 600;
    color: inherit;
    background: none;
    border: 0;
    border-bottom: 1px solid currentColor;
    padding: 0 0.125rem;
    margin-left: 0.5rem;
    cursor: pointer;
}
.toast-action:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* The toast itself stays click-through (it must never block what's beneath
   it); only its button takes clicks, and only while the toast is showing. */
.toast.show .toast-action { pointer-events: auto; }

/* Travelling glow on an input's border (A3): a conic-gradient ring masked to
   the border. Off until a trigger applies: the chat input while the AI works
   here, and the idle hero box (see below). Reduced motion: a static ring. */
@property --beam-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}
.beam { position: relative; }
.beam::after {
    content: '';
    position: absolute;
    inset: -1px;
    padding: 1px;
    border-radius: inherit;
    background: conic-gradient(from var(--beam-angle),
        transparent 0deg 250deg,
        var(--accent) 300deg,
        var(--accent-deep) 330deg,
        transparent 360deg);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-base) var(--ease-out);
}
/* The hero box glows slowly while it waits for a question (empty, unfocused,
   on screen). hero.js toggles is-idle and is-paused. */
.beam.is-idle::after {
    opacity: 0.55;
    animation: beam-spin var(--beam-loop) linear infinite;
}
.beam.is-idle.is-paused::after { animation-play-state: paused; }
/* Busy: the hero box glows faster while an answer is on its way
   (advisor.setStatus toggles is-working). After is-idle so it wins. */
.beam.is-working::after {
    opacity: 0.55;
    animation: beam-spin 2.4s linear infinite;
}
:root[data-theme="dark"] .beam.is-working::after,
:root[data-theme="dark"] .beam.is-idle::after { opacity: 0.9; padding: 1.5px; inset: -1.5px; }
@keyframes beam-spin { to { --beam-angle: 360deg; } }
@media (prefers-reduced-motion: reduce) {
    .beam.is-working::after,
    .beam.is-idle::after { background: var(--accent-deep); opacity: 1; animation: none; }
}

/* Rotating example text over an empty input (A4). Visual only (aria-hidden);
   the input keeps its own label. */
.ph-rotator {
    position: absolute;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--muted);
    pointer-events: none;
    transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}
.ph-rotator.is-swapping { opacity: 0; transform: translateY(-4px); }

/* Thinking orb (A2): marigold dots on a disc, slowly turning, label beside. */
.ai-thinking {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--muted);
    font-size: var(--text-sm);
}
.ai-orb {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, transparent 0 30%, var(--card) 85%),
        radial-gradient(circle, var(--accent-deep) 0 1.1px, transparent 1.5px) 0 0 / 4px 4px;
    -webkit-mask: radial-gradient(circle, #000 62%, transparent 70%);
    mask: radial-gradient(circle, #000 62%, transparent 70%);
    animation: orb-turn 3.2s linear infinite;
}
@keyframes orb-turn {
    0%   { transform: rotate(0deg) scale(1); }
    50%  { transform: rotate(180deg) scale(0.92); }
    100% { transform: rotate(360deg) scale(1); }
}

/* ---- Site-wide motion (C) ---- */

/* C1. Primary buttons: a light sweep on hover/focus (desktop), once when
   first seen (phones), and every button presses down slightly. */
.btn-primary { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 30%, oklch(100% 0 0 / 0.42) 50%, transparent 70%);
    transform: translateX(-110%);
    pointer-events: none;
    z-index: -1;
}
@media (hover: hover) {
    .btn-primary:hover::after,
    .btn-primary:focus-visible::after { animation: shimmer var(--motion-slow) var(--ease-out); }
}
.btn-primary.shimmer-once::after { animation: shimmer var(--motion-slow) var(--ease-out) 200ms; }
@keyframes shimmer {
    from { transform: translateX(-110%); }
    to { transform: translateX(110%); }
}
.btn-primary, .btn-secondary, .hero-chip, .ai-chip {
    transition-property: background, border-color, color, transform;
    transition-duration: var(--dur-fast);
    transition-timing-function: var(--ease-out);
}
.btn-primary:active, .btn-secondary:active, .hero-chip:active, .ai-chip:active { transform: scale(0.97); }
.btn-primary:disabled:active, .btn-secondary:disabled:active { transform: none; }
.btn-primary:disabled::after { animation: none !important; }

/* C3/C6. Rise-in (scroll) and stagger-in (Quick Match). The animation only
   fills backwards, so once it ends a card's own hover transform works. */
.reveal:not(.is-revealed) { opacity: 0; }
.reveal.is-revealed,
.stagger-in {
    animation: rise-in var(--motion-base) var(--ease-out) backwards;
    animation-delay: calc(var(--i, 0) * 60ms);
}
.stagger-in { animation-delay: calc(var(--i, 0) * 100ms); }
@keyframes rise-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* C4. Cards lift on hover (desktop) and press on tap (phones). Model cards
   already lift (.model-card-link). */
.laptop-card, .tip-card, .ai-card {
    transition: border-color var(--dur-fast) var(--ease-out),
                transform var(--motion-fast) var(--ease-out),
                box-shadow var(--motion-fast) var(--ease-out);
}
@media (hover: hover) {
    .laptop-card:hover, .tip-card:hover, .ai-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-card);
    }
}
@media (hover: none) {
    .laptop-card:active, .tip-card:active, .ai-card:active, .model-card-link:active { transform: scale(0.98); }
}

@media (prefers-reduced-motion: reduce) {
    .btn-primary::after, .reveal, .stagger-in { animation: none !important; }
    .reveal:not(.is-revealed) { opacity: 1; }
    .btn-primary:active, .btn-secondary:active, .hero-chip:active, .ai-chip:active,
    .laptop-card:hover, .tip-card:hover, .ai-card:hover { transform: none; }
}

/* Tab cross-fade (motion round): opacity only, 200ms. app.applyRoute skips
   the transition under reduced motion; this is the second line of defence. */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 200ms;
    animation-timing-function: var(--ease-out);
}
@media (prefers-reduced-motion: reduce) {
    ::view-transition-old(root),
    ::view-transition-new(root) { animation: none; }
}

/* Leaderboard on the Dashboard (Dashboard AI spec, PR A). */
.dash-leaderboard { margin-top: var(--space-xl); scroll-margin-top: 5rem; }
.dash-leaderboard > h2 { margin-bottom: var(--space-2xs); }
.dash-leaderboard > p { color: var(--ink-2); margin-bottom: var(--space-sm); }
/* The podium sits in a flex column with auto margins, which shrink-wraps it; keep its 640px track. */
.dash-leaderboard .podium-section { width: 100%; }
.leaderboard-more > .glass-panel { margin-top: var(--space-sm); }
.leaderboard-more > summary {
    /* list-item keeps the disclosure triangle; padding gives the 44px target. */
    cursor: pointer;
    display: list-item;
    min-height: 44px;
    padding: 0.625rem 0;
    line-height: 1.5;
    font-weight: 600;
    color: var(--accent-deep);
}
.leaderboard-more[open] > summary { margin-bottom: var(--space-md); }
.leaderboard-more > summary:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
.leaderboard-more > .glass-panel + .glass-panel { margin-top: var(--space-lg); }
@media (max-width: 640px) {
    /* Phones: the podium is three one-line rows, and the table keeps rank,
       university and score so it fits without scrolling sideways (the other
       columns feed the score, explained in "Bagaimana skor ini dikira"). */
    .dash-leaderboard .podium-section { gap: var(--space-2xs); padding: var(--space-sm) 0; max-width: none; width: 100%; justify-items: stretch; }
    .dash-leaderboard .podium-bar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        text-align: left;
        padding: var(--space-2xs) var(--space-sm);
        min-height: 44px;
    }
    .dash-leaderboard .trophy { font-size: var(--text-md); }
    .dash-leaderboard .podium-uni { flex: 1 1 auto; min-width: 0; }
    .dash-leaderboard .podium-score { margin-top: 0; font-size: var(--text-base); }
    .dash-leaderboard .ranking-table { min-width: 0; }
    .dash-leaderboard .ranking-table th:nth-child(3), .dash-leaderboard .ranking-table td:nth-child(3),
    .dash-leaderboard .ranking-table th:nth-child(4), .dash-leaderboard .ranking-table td:nth-child(4),
    .dash-leaderboard .ranking-table th:nth-child(5), .dash-leaderboard .ranking-table td:nth-child(5) { display: none; }
    .dash-leaderboard .ranking-table td .uni-link { white-space: normal; }
    .dash-leaderboard .ranking-table th { padding: 0.5rem var(--space-xs); }
    /* The 44px university link is the tap target; cell padding would only add height. */
    .dash-leaderboard .ranking-table td { padding: 0 var(--space-xs); }
    .dash-leaderboard .leaderboard-container { gap: var(--space-sm); }
    .dash-leaderboard { margin-top: var(--space-lg); }
    .dash-leaderboard > p { font-size: var(--text-sm); }
    .dash-leaderboard .leaderboard-insufficient { padding: var(--space-sm) var(--space-md); text-align: left; align-items: flex-start; gap: var(--space-2xs); }
    .dash-leaderboard .leaderboard-insufficient p { max-width: none; }
    .dash-leaderboard .leaderboard-insufficient h3 { font-size: var(--text-base); margin-bottom: var(--space-2xs); }
    .dash-leaderboard .leaderboard-insufficient p { font-size: var(--text-sm); margin-bottom: var(--space-sm); }
}

/* ---------------------------------------------------------------------------
   Dashboard answer area (Dashboard AI spec, PR B): the latest turn under the
   hero box, as page text rather than chat bubbles.
   --------------------------------------------------------------------------- */
.ai-answer {
    margin: var(--space-lg) 0 var(--space-xl);
    padding: var(--space-lg);
    background: var(--card);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
}
/* "Mula semula", once, at the top right of the thread (phones too). */
.ai-answer-head { display: flex; justify-content: flex-end; margin: 0 0 var(--space-sm); }
#ai-answer .ai-new { flex: none; display: inline-flex; align-items: center; gap: 0.375rem; min-height: 44px; margin: 0; padding: 0 var(--space-md); }
#ai-answer .ai-new svg { flex: none; }
/* The Chat thread: every turn, oldest first. The student's question is a
   bubble on the right in its own shade, no label (screen readers hear
   "Anda:" from a hidden span). */
.ai-log { display: flex; flex-direction: column; gap: var(--space-xl); }
.ai-turn { display: flex; flex-direction: column; gap: var(--space-md); }
.ai-question {
    align-self: flex-end;
    max-width: min(80%, 32rem);
    margin: 0;
    padding: 0.5rem 0.875rem;
    border-radius: 18px 18px 4px 18px;
    background: color-mix(in srgb, var(--ink) 9%, var(--card));
    color: var(--ink);
    line-height: 1.5;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.ai-log > .ai-followups { margin-top: calc(-1 * var(--space-md)); }
.ai-reply { margin: 0; max-width: 65ch; white-space: pre-line; line-height: 1.6; }
/* Every card is over the budget: said once, above them (advisor.overBudgetNote). */
.ai-over-note { margin: 0; font-size: var(--text-sm); font-weight: 600; color: var(--ink); }
.ai-status { padding: var(--space-xs) 0; font-size: var(--text-sm); }
.ai-status p { margin: 0; }
.ai-status-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.ai-disclaimer { margin: var(--space-md) 0 0; padding: 0; font-size: var(--text-xs); color: var(--text-muted); }
/* Wide: the laptops two per row; phones keep them stacked. */
@media (min-width: 641px) {
    /* Two per row (owner, 2026-12-06): one card is half the column, on the
       left; a third wraps below. (auto-fit squeezed one card to a third,
       because the full-width notes kept the empty tracks open.) */
    .ai-answer .ai-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
    .ai-answer .ai-cards-note, .ai-answer .ai-over-note { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .ai-answer { padding: var(--space-md); margin: var(--space-md) 0 var(--space-lg); }
    /* One row of three 44px buttons (the card is narrow: "Kenapa?"). */
    .ai-card-actions > .btn-secondary { min-height: 44px; }
}

/* Skip link (design critique): off-screen until focused, then the first thing
   on the page. */
.skip-link {
    position: absolute;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    left: var(--space-sm);
    top: -100px;
    z-index: 1000;
    padding: var(--space-xs) var(--space-sm);
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--radius);
    font-weight: 600;
    text-decoration: none;
}
.skip-link:focus { top: var(--space-sm); outline: 2px solid var(--focus); outline-offset: 2px; }
#main-content:focus { outline: none; }

/* Desktop and touch laptops (design critique): nav tabs are 40px targets.
   Phones keep their own sizes (bottom bar, sheet). */
@media (min-width: 721px) {
    .nav-tab { min-height: 40px; display: inline-flex; align-items: center; }
}

/* Desktop: the theme toggle sits at the right edge of the header instead of
   floating after the last tab (design critique). */
@media (min-width: 721px) {
    .theme-toggle { margin-left: auto; }
}

/* Under the stat cards: the review count and a way to add to it. */
.stats-note { margin: var(--space-xs) 0 0; font-size: var(--text-sm); color: var(--muted); }
@media (max-width: 640px) {
    .stats-note .btn-link { min-height: 44px; display: inline-flex; align-items: center; }
    /* One line at 360px: "15 ulasan graduan · Kongsi ulasan anda". */
    .stats-note-long { display: none; }
    .stats-note { margin-top: 0; }
}

