/* ==========================================================================
   Schoolmang PWA — shared design system
   Mobile first. No framework dependency. Works offline (precached).
   ========================================================================== */

:root {
    --brand: #231bd5;
    --brand-strong: #1a14a8;
    --brand-soft: #eceafe;
    --bg: #f5f6fb;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --text: #15162a;
    --muted: #5c6076;
    --line: #e2e4ef;
    --ok: #0f7b4f;
    --ok-soft: #e4f6ec;
    --warn: #9a5b00;
    --warn-soft: #fdf1dc;
    --danger: #b42318;
    --danger-soft: #fdeceb;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(20, 22, 42, .06), 0 8px 24px -18px rgba(20, 22, 42, .35);
    --bar-h: 60px;
    --tab-h: 64px;
    --maxw: 980px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html[data-pwa-app="parents"] { --brand: #0f766e; --brand-strong: #0b5a54; --brand-soft: #e2f3f1; }
html[data-pwa-app="students"] { --brand: #b45309; --brand-strong: #8a3f07; --brand-soft: #fbeedd; }
html[data-pwa-app="exams"] { --brand: #7c2d12; --brand-strong: #5f2210; --brand-soft: #fbe9e2; }

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

/* The `hidden` attribute must win over component display rules (e.g. .btn). */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

img, svg { max-width: 100%; }

a { color: var(--brand-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand); }

h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }

:focus-visible {
    outline: 3px solid #111;
    outline-offset: 2px;
    border-radius: 6px;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: .6rem 1rem;
    background: #111;
    color: #fff;
    border-radius: 8px;
    transition: top .15s ease;
}
.skip-link:focus { top: 12px; color: #fff; }

/* ---------------------------------------------------------------- app bar */
.app-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--brand);
    color: #fff;
    padding-top: env(safe-area-inset-top);
    box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}
.app-bar__inner {
    max-width: var(--maxw);
    margin: 0 auto;
    min-height: var(--bar-h);
    padding: .5rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    justify-content: space-between;
}
.app-bar__brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #fff;
    text-decoration: none;
    min-width: 0;
    flex: 1 1 auto;
}
.app-bar__mark {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .28);
}
.app-bar__titles { display: flex; flex-direction: column; min-width: 0; }
.app-bar__name {
    font-weight: 650;
    font-size: .98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-bar__school {
    font-size: .74rem;
    opacity: .85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46vw;
}
.app-bar__actions { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.app-bar__sub {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 1rem .55rem;
    font-size: .78rem;
    opacity: .85;
}

/* --------------------------------------------------------------- buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 44px;
    padding: .55rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--brand-strong); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn--sm { min-height: 36px; padding: .35rem .8rem; font-size: .82rem; }
.btn--ghost {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .34);
    color: #fff;
}
.btn--ghost:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.btn--outline {
    background: transparent;
    color: var(--brand-strong);
    border-color: var(--line);
}
.btn--outline:hover { background: var(--brand-soft); color: var(--brand-strong); }
.btn--danger { background: var(--danger); }
.btn--danger:hover { background: #8f1c13; }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
}

/* ------------------------------------------------------------------ main */
.pwa-main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 1rem 1rem calc(var(--tab-h) + 1.6rem + env(safe-area-inset-bottom));
}
.pwa-body--bare .pwa-main { padding-bottom: calc(1.6rem + env(safe-area-inset-bottom)); }

.page-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .muted { font-size: .85rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}

/* ----------------------------------------------------------------- cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .9rem 1rem .2rem;
}
.card__head h2 { margin: 0; font-size: 1rem; }
.card__body { padding: 0 1rem 1rem; }

.section-title {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    margin: 1.4rem 0 .5rem;
}

/* ----------------------------------------------------------------- stats */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    margin-bottom: 1rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .85rem .9rem;
    box-shadow: var(--shadow);
}
.stat__label { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat__value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; margin-top: .2rem; }
.stat__hint { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.stat--brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.stat--brand .stat__label, .stat--brand .stat__hint { color: rgba(255, 255, 255, .82); }

/* ----------------------------------------------------------------- lists */
.list { list-style: none; margin: 0; padding: 0; }
.list__item {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
    color: inherit;
    min-height: 56px;
}
.list__item:last-child { border-bottom: 0; }
a.list__item:hover { background: var(--surface-2); }
.list__main { min-width: 0; flex: 1 1 auto; }
/* Title and meta are stacked inside .list__main, never side by side. */
.list__main .list__title,
.list__main .list__meta { display: block; }
.list__title { font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.list__meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.list__aside { flex: 0 0 auto; text-align: right; font-size: .8rem; color: var(--muted); }

.avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 700;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ----------------------------------------------------------------- pills */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .55rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--line);
    white-space: nowrap;
}
.pill--ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill--brand { background: var(--brand-soft); color: var(--brand-strong); border-color: transparent; }

.net-pill {
    font-size: .7rem;
    font-weight: 700;
    padding: .2rem .5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .3);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.net-pill[data-state="offline"] { background: #ffd9d6; color: #7a1d14; border-color: transparent; }

/* ---------------------------------------------------------------- alerts */
.alert {
    border-radius: var(--radius-sm);
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    font-size: .9rem;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text);
}
.alert--ok { background: var(--ok-soft); border-color: #bfe6cf; color: #0b5539; }
.alert--warn { background: var(--warn-soft); border-color: #f0d9ae; color: #6d4000; }
.alert--danger { background: var(--danger-soft); border-color: #f4c7c3; color: #7a1d14; }
.alert strong { font-weight: 700; }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}
table.data th, table.data td {
    text-align: left;
    padding: .6rem .75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
table.data th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); }
table.data tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------- forms */
.field { margin-bottom: .85rem; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.input, .select, .textarea {
    width: 100%;
    min-height: 46px;
    padding: .6rem .8rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 1rem;
}
.textarea { min-height: 96px; resize: vertical; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.searchbar .input { flex: 1 1 auto; }
.searchbar .btn { flex: 0 0 auto; }

/* ------------------------------------------------------------- chooser */
.hero {
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-strong) 100%);
    color: #fff;
    border-radius: 20px;
    padding: 1.4rem 1.2rem;
    margin-bottom: 1.2rem;
}
.hero h1 { font-size: 1.55rem; margin-bottom: .4rem; }
.hero p { color: rgba(255, 255, 255, .88); margin-bottom: 0; font-size: .95rem; }
.hero__eyebrow {
    display: inline-block;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .28);
    padding: .2rem .6rem;
    border-radius: 999px;
    margin-bottom: .7rem;
}

.app-grid { display: grid; grid-template-columns: 1fr; gap: .9rem; }
.app-card {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    border-top: 4px solid var(--app-color, var(--brand));
}
.app-card__top { display: flex; align-items: center; gap: .7rem; }
.app-card__icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--app-soft, var(--brand-soft));
    color: var(--app-color, var(--brand));
}
.app-card h2 { margin: 0; font-size: 1.05rem; }
.app-card p { margin: 0; font-size: .88rem; color: var(--muted); }
.app-card__actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .2rem; }

/* -------------------------------------------------------------- tabbar */
.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: rgba(255, 255, 255, .97);
    backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
.tabbar ul {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0;
    list-style: none;
    display: flex;
    align-items: stretch;
}
.tabbar li { flex: 1 1 0; min-width: 0; }
.tabbar__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .15rem;
    min-height: var(--tab-h);
    padding: .35rem .2rem;
    text-decoration: none;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 600;
}
.tabbar__link.is-current { color: var(--brand-strong); }
.tabbar__link.is-current .tabbar__icon { background: var(--brand-soft); }
.tabbar__icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 28px;
    border-radius: 8px;
}
.tabbar__label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------- toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tab-h) + 1rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 60;
    max-width: min(92vw, 460px);
    background: #15162a;
    color: #fff;
    padding: .7rem 1rem;
    border-radius: 12px;
    font-size: .88rem;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
}
.toast[data-tone="error"] { background: #8f1c13; }
.toast[data-tone="ok"] { background: #0b5539; }

/* ------------------------------------------------------------ utilities */
.stack > * + * { margin-top: .6rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.divider { height: 1px; background: var(--line); margin: .9rem 0; border: 0; }
.empty {
    text-align: center;
    padding: 1.6rem 1rem;
    color: var(--muted);
    font-size: .9rem;
}
.metric-row { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.metric-row:last-child { border-bottom: 0; }
.metric-row__label { color: var(--muted); font-size: .88rem; }
.metric-row__value { font-weight: 700; }

.progress {
    height: 8px;
    border-radius: 999px;
    background: var(--line);
    overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }

.day-block + .day-block { margin-top: 1rem; }
.day-block h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

.pagination { display: flex; gap: .5rem; align-items: center; justify-content: space-between; margin-top: 1rem; }

/* --------------------------------------------------------------- tablets */
@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pwa-main { padding: 1.4rem 1.25rem calc(var(--tab-h) + 1.8rem + env(safe-area-inset-bottom)); }
}

@media (min-width: 900px) {
    h1 { font-size: 1.75rem; }
    .app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tabbar { position: sticky; bottom: 0; }
    .pwa-main { padding-bottom: 2rem; }
    .toast { bottom: 1.5rem; }
}

/* --------------------------------------------------------------- reduced */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    .app-bar, .tabbar, .toast, .btn { display: none !important; }
    .pwa-main { padding: 0; }
    .card { box-shadow: none; border-color: #ccc; }
}

/* ==========================================================================
   Exam runner
   ========================================================================== */
.exam-shell { display: grid; gap: .9rem; }
.exam-top {
    position: sticky;
    top: calc(var(--bar-h) + env(safe-area-inset-top));
    z-index: 30;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .7rem .9rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: .8rem;
    justify-content: space-between;
    flex-wrap: wrap;
}
.timer {
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: .02em;
}
.timer[data-state="warning"] { color: var(--warn); }
.timer[data-state="critical"] { color: var(--danger); }
.sync-state { font-size: .78rem; font-weight: 700; display: inline-flex; align-items: center; gap: .35rem; }
.sync-state::before {
    content: "";
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--muted);
}
.sync-state[data-state="saved"]::before { background: var(--ok); }
.sync-state[data-state="pending"]::before { background: var(--warn); }
.sync-state[data-state="offline"]::before { background: var(--danger); }
.sync-state[data-state="conflict"]::before { background: var(--danger); }

.question-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.question-card__meta { display: flex; justify-content: space-between; gap: .5rem; font-size: .78rem; color: var(--muted); margin-bottom: .5rem; }
.question-card__text { font-size: 1.02rem; font-weight: 600; margin-bottom: .9rem; overflow-wrap: anywhere; }
.options { display: grid; gap: .55rem; margin: 0; padding: 0; border: 0; }
.option {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .75rem .8rem;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-height: 48px;
    background: #fff;
}
.option:hover { border-color: #c9cce0; }
.option input { margin-top: .22rem; flex: 0 0 auto; width: 18px; height: 18px; accent-color: var(--brand); }
.option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.option__label { flex: 1 1 auto; overflow-wrap: anywhere; }
.option__key {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: .72rem; font-weight: 700;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.question-nav { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.qbtn {
    width: 40px; height: 40px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    font: inherit;
    font-weight: 700;
    font-size: .82rem;
    cursor: pointer;
    display: grid;
    place-items: center;
}
.qbtn[data-answered="1"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.qbtn[data-current="1"] { outline: 3px solid #111; outline-offset: 1px; }
.qbtn[data-flagged="1"] { box-shadow: inset 0 -4px 0 var(--warn); }

.exam-footer { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: space-between; margin-top: 1rem; }
.exam-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.disclosure { font-size: .85rem; color: var(--muted); }
.disclosure summary { cursor: pointer; font-weight: 700; color: var(--text); min-height: 44px; display: flex; align-items: center; }

.exam-result__score { font-size: 2.6rem; font-weight: 800; line-height: 1; }

/* ==========================================================================
   First-run onboarding
   ========================================================================== */
.onboard {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(15, 16, 32, .55);
}
.onboard[hidden] { display: none; }
.onboard__panel {
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px -12px rgba(0, 0, 0, .5);
}
.onboard__dots { list-style: none; display: flex; gap: .35rem; margin: 0 0 .9rem; padding: 0; }
.onboard__dots li { width: 26px; height: 5px; border-radius: 999px; background: var(--line); }
.onboard__dots li.is-current { background: var(--brand); }
.onboard__title { font-size: 1.15rem; margin-bottom: .4rem; }
.onboard__title:focus { outline: none; }
.onboard__body { color: var(--muted); font-size: .95rem; margin: 0; }
.onboard__actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-top: 1rem; }
.onboard__nav { display: flex; gap: .5rem; }
.onboard__hint { color: var(--muted); font-size: .78rem; margin: .7rem 0 0; }
body.pwa-onboarding-open { overflow: hidden; }

@media (min-width: 640px) {
    .onboard { align-items: center; padding: 1.25rem; }
    .onboard__panel { border-radius: 20px; padding: 1.5rem; }
}

/* ==========================================================================
   App identity: launch splash and logo
   ========================================================================== */

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-bar__logo {
    width: 34px; height: 34px;
    border-radius: 10px;
    flex: 0 0 auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .22);
}

/* In-app launch screen. It is removed by pwa-core.js after the first paint,
   and it also covers the gap while an installed app cold-starts. */
.app-splash {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    background: linear-gradient(165deg, var(--brand) 0%, var(--brand-strong) 100%);
    color: #fff;
    transition: opacity .28s ease, visibility .28s ease;
}
.app-splash.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.app-splash__logo img {
    width: 92px; height: 92px;
    border-radius: 24px;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .6);
    animation: splash-pop .5s cubic-bezier(.2, .9, .3, 1.3) both;
}
.app-splash__name { margin: .7rem 0 0; font-size: 1.1rem; font-weight: 700; letter-spacing: .01em; }
.app-splash__school { margin: 0; font-size: .8rem; color: rgba(255, 255, 255, .78); text-align: center; padding: 0 1.4rem; }
.app-splash__spinner {
    margin-top: 1.1rem;
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, .32);
    border-top-color: #fff;
    animation: splash-spin .9s linear infinite;
}
@keyframes splash-spin { to { transform: rotate(360deg); } }
@keyframes splash-pop { from { transform: scale(.82); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Launched from the home screen: no browser chrome, so respect the notch. */
html.is-standalone .app-bar { padding-top: env(safe-area-inset-top); }
html.is-standalone .tabbar { padding-bottom: env(safe-area-inset-bottom); }

/* ==========================================================================
   Student persona: mascot greeting, level bar, learning hub
   ========================================================================== */

.hero {
    position: relative;
    overflow: hidden;
    padding: 1.15rem 1.1rem 1rem;
    border-radius: 24px;
    background: linear-gradient(150deg, #c2410c 0%, #f59e0b 62%, #fbbf24 100%);
    box-shadow: 0 18px 34px -22px rgba(180, 83, 9, .85);
}
html[data-pwa-app="parents"] .hero { background: linear-gradient(150deg, #0f766e 0%, #14b8a6 65%, #5eead4 100%); box-shadow: 0 18px 34px -22px rgba(15, 118, 110, .85); }
html[data-pwa-app="admin"] .hero { background: linear-gradient(150deg, #312e81 0%, #4f46e5 65%, #818cf8 100%); box-shadow: 0 18px 34px -22px rgba(49, 46, 129, .85); }
html[data-pwa-app="exams"] .hero { background: linear-gradient(150deg, #7c2d12 0%, #ea580c 65%, #fb923c 100%); box-shadow: 0 18px 34px -22px rgba(124, 45, 18, .85); }

.hero__glow {
    position: absolute;
    width: 220px; height: 220px;
    right: -70px; top: -90px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .28);
    filter: blur(6px);
    pointer-events: none;
}
.hero__top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.hero__id { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.hero__photo {
    width: 58px; height: 58px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, .75);
    background: rgba(255, 255, 255, .3);
    flex: 0 0 auto;
}
.hero .hero__hi {
    margin: 0 0 .1rem;
    font-size: 1.32rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.02em;
    line-height: 1.15;
}
.hero .hero__school { margin: 0; font-size: .78rem; color: rgba(255, 255, 255, .86); }
.wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.6s ease-in-out infinite; }
/* The animal that greets the student. One emoji per student, chosen from the
   mascot list, with a slow hop so it feels alive without distracting. */
.hero__animal {
    display: inline-block;
    margin-left: .25rem;
    font-size: 1.35em;
    line-height: 1;
    vertical-align: -.12em;
    transform-origin: 50% 90%;
    animation: animal-hop 3.4s ease-in-out infinite;
}
@keyframes animal-hop {
    0%, 62%, 100% { transform: translateY(0) rotate(0deg); }
    70% { transform: translateY(-.22em) rotate(-6deg); }
    78% { transform: translateY(0) rotate(5deg); }
    86% { transform: translateY(-.1em) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) {
    .hero__animal { animation: none; }
}
@keyframes wave {
    0%, 60%, 100% { transform: rotate(0deg); }
    68% { transform: rotate(16deg); }
    76% { transform: rotate(-8deg); }
    84% { transform: rotate(14deg); }
    92% { transform: rotate(-4deg); }
}

.hero__mascot { flex: 0 0 auto; margin-top: -.2rem; }
.mascot__bubble {
    display: grid;
    place-items: center;
    width: 74px; height: 74px;
    border-radius: 50%;
    font-size: 2.45rem;
    line-height: 1;
    background: radial-gradient(circle at 32% 26%, #fff 0%, #fff8e7 62%, #ffe7b8 100%);
    box-shadow: 0 12px 22px -12px rgba(69, 26, 3, .55), inset 0 -3px 0 rgba(180, 83, 9, .12);
    animation: mascot-bob 3.4s ease-in-out infinite;
}
@keyframes mascot-bob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-7px) rotate(2deg); }
}
.hero .hero__tag {
    position: relative;
    margin: .65rem 0 0;
    font-size: .8rem;
    color: rgba(255, 255, 255, .9);
    background: rgba(0, 0, 0, .14);
    border-radius: 999px;
    padding: .4rem .75rem;
    display: inline-block;
}

.levelbar {
    position: relative;
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-top: .95rem;
    padding: .7rem .75rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, .22);
    border: 1px solid rgba(255, 255, 255, .32);
    backdrop-filter: blur(6px);
}
.levelbar__star { font-size: 1.35rem; line-height: 1; flex: 0 0 auto; }
.levelbar__main { flex: 1 1 auto; min-width: 0; }
.levelbar__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .4rem;
    color: #fff;
    font-size: .78rem;
    margin-bottom: .3rem;
}
.levelbar__row strong { font-size: .8rem; font-weight: 700; }
.levelbar__row .small { color: rgba(255, 255, 255, .82); white-space: nowrap; }
.pill--streak {
    flex: 0 0 auto;
    background: rgba(255, 255, 255, .95);
    color: #7c2d12;
    border-color: transparent;
    font-weight: 700;
    font-size: .7rem;
    white-space: nowrap;
}

.bar {
    height: 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .34);
    overflow: hidden;
}
.bar > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: #fff;
    transition: width .5s ease;
}
.bar--xp { background: rgba(255, 255, 255, .34); }
.card .bar, .wallet .bar { background: var(--line); }
.card .bar > span, .wallet .bar > span { background: linear-gradient(90deg, var(--brand), #f59e0b); }
.bar--wallet > span { background: linear-gradient(90deg, #0f766e, #34d399); }

.section-title {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin: 1.35rem 0 .7rem;
    font-size: 1.02rem;
    font-weight: 700;
}
.section-title span { font-size: 1.05rem; }

.hub { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.hub-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .85rem .8rem .8rem;
    border-radius: 20px;
    color: #fff;
    text-decoration: none;
    overflow: hidden;
    min-height: 118px;
    box-shadow: 0 14px 26px -20px rgba(15, 23, 42, .8);
    transition: transform .18s ease, box-shadow .18s ease;
}
.hub-card:active { transform: scale(.985); }
.hub-card:hover { color: #fff; box-shadow: 0 18px 30px -18px rgba(15, 23, 42, .75); }
.hub-card--blue { background: linear-gradient(150deg, #1d4ed8, #38bdf8); }
.hub-card--pink { background: linear-gradient(150deg, #be185d, #fb7185); }
.hub-card--green { background: linear-gradient(150deg, #047857, #34d399); }
.hub-card--purple { background: linear-gradient(150deg, #6d28d9, #c084fc); }
.hub-card__icon { font-size: 1.55rem; line-height: 1; margin-bottom: .15rem; }
.hub-card__title { font-weight: 800; font-size: .95rem; letter-spacing: -.01em; }
.hub-card__meta { font-size: .72rem; color: rgba(255, 255, 255, .9); }
.hub-card__badge {
    position: absolute;
    top: .6rem; right: .6rem;
    font-size: .62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    background: rgba(255, 255, 255, .24);
    border: 1px solid rgba(255, 255, 255, .34);
    padding: .18rem .45rem;
    border-radius: 999px;
}

.quick-list { display: grid; gap: .55rem; }
.quick {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .8rem;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    color: var(--text);
    text-decoration: none;
    transition: transform .16s ease, border-color .16s ease;
}
.quick:hover { color: var(--text); border-color: #c9cce0; transform: translateY(-1px); }
.quick__icon {
    width: 44px; height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    font-size: 1.25rem;
    flex: 0 0 auto;
}
.quick--yellow .quick__icon { background: #fef3c7; }
.quick--sky .quick__icon { background: #e0f2fe; }
.quick--mint .quick__icon { background: #d1fae5; }
.quick--violet .quick__icon { background: #ede9fe; }
.quick__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.quick__title { font-weight: 700; font-size: .92rem; }
.quick__meta { font-size: .76rem; color: var(--muted); }
.quick__go { font-size: 1.3rem; color: var(--muted); flex: 0 0 auto; }

.badge-row { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
.badge-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .38rem .62rem .38rem .45rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--badge, #f59e0b) 34%, #fff);
    background: color-mix(in srgb, var(--badge, #f59e0b) 12%, #fff);
    font-size: .78rem;
    font-weight: 650;
    color: #1f2937;
    text-decoration: none;
}
.badge-chip__icon { font-size: .95rem; line-height: 1; }
.badge-chip--more { border-style: dashed; background: var(--surface); color: var(--muted); }

.badge-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.badge-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .18rem;
    padding: .75rem .7rem;
    border-radius: 16px;
    border: 1px dashed var(--line);
    background: var(--surface-2);
    opacity: .62;
}
.badge-tile.is-earned {
    opacity: 1;
    border-style: solid;
    border-color: color-mix(in srgb, var(--badge, #f59e0b) 45%, #fff);
    background: linear-gradient(165deg, color-mix(in srgb, var(--badge, #f59e0b) 16%, #fff), #fff 70%);
}
.badge-tile__icon { font-size: 1.4rem; line-height: 1.1; }
.badge-tile__name { font-weight: 750; font-size: .86rem; }
.badge-tile__desc { font-size: .72rem; color: var(--muted); }
.badge-tile__state {
    margin-top: .2rem;
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}
.badge-tile.is-earned .badge-tile__state { color: var(--ok); }

.alert--info { background: #eef2ff; border-color: #dbe3ff; color: #26306b; }
.alert--error { background: var(--danger-soft); border-color: #f4c7c3; color: #7a1d14; }
.alert--link { display: flex; flex-direction: column; gap: .1rem; text-decoration: none; color: inherit; }
.alert--link strong { color: inherit; }

/* ==========================================================================
   Sign in inside the app
   ========================================================================== */

.auth { max-width: 430px; margin: .6rem auto 1.5rem; }
.auth__card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 1.5rem 1.15rem 1.2rem;
    box-shadow: var(--shadow);
    text-align: center;
}
.auth__logo img { border-radius: 22px; box-shadow: 0 14px 26px -18px rgba(15, 23, 42, .8); }
.auth__title { margin: .9rem 0 .15rem; font-size: 1.22rem; }
.auth__sub { margin: 0 0 1rem; color: var(--muted); font-size: .86rem; }
.auth__form { text-align: left; }
.auth__hint { margin: 1rem 0 0; font-size: .76rem; color: var(--muted); }
.auth__foot { display: flex; justify-content: center; gap: .5rem; margin-top: .8rem; font-size: .8rem; }
.auth__install {
    margin-top: .9rem;
    padding: .8rem .9rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px dashed var(--line);
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
}
.auth__install p { margin: 0; }

.field__label { display: block; font-weight: 650; font-size: .82rem; margin-bottom: .3rem; }
.field__wrap { position: relative; display: block; }
.field__wrap .input { padding-right: 4.2rem; }
.field__reveal {
    position: absolute;
    right: .35rem;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: var(--brand-strong);
    font-size: .78rem;
    font-weight: 700;
    padding: .45rem .5rem;
    min-height: 36px;
    cursor: pointer;
}

/* ==========================================================================
   Report card viewer
   ========================================================================== */

.page-head--tight { margin-bottom: .6rem; }
.report-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
}
.report-toolbar__actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.report-toolbar .is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.report-stage {
    background: #dfe3ee;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: .5rem;
    max-height: 76vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}
.report-paper {
    background: #fff;
    width: fit-content;
    min-width: 100%;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
}
.report-stage.is-actual .report-paper { width: max-content; }

.report-status {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .5rem;
    padding: 1.4rem .8rem;
    color: var(--muted);
    font-size: .86rem;
    text-align: center;
}
.report-status[hidden] { display: none; }
.report-status--error { color: #b42318; }
.report-status__spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--brand);
    animation: report-spin .8s linear infinite;
}
.report-status--error .report-status__spinner { display: none; }
@keyframes report-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .report-status__spinner { animation-duration: 2.4s; }
}

/* The school template is a fixed A4 sheet; do not let the app CSS reflow it. */
.report-paper .mark-container { background: #fff; }
.report-paper table { border-collapse: collapse; }

@media print {
    .app-bar, .tabbar, .report-toolbar, .report-hint, .report-status, .toast, .app-splash, .skip-link { display: none !important; }
    .pwa-main { padding: 0 !important; }
    .report-stage { border: 0; padding: 0; max-height: none; overflow: visible; background: #fff; }
    .report-paper { width: auto; box-shadow: none; }
    body { background: #fff; }
}

/* ==========================================================================
   Fees wallet and profile
   ========================================================================== */

.wallet {
    background: linear-gradient(160deg, #065f46, #10b981);
    color: #fff;
    border-radius: 22px;
    padding: 1.15rem 1.05rem;
    margin-bottom: 1rem;
    box-shadow: 0 18px 34px -24px rgba(6, 95, 70, .9);
}
.wallet__row { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; margin-bottom: .6rem; }
.wallet__label { font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: rgba(255, 255, 255, .82); }
.wallet__value { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.wallet .bar { background: rgba(255, 255, 255, .3); }
.wallet__split { display: flex; justify-content: space-between; gap: .5rem; margin-top: .55rem; font-size: .78rem; color: rgba(255, 255, 255, .92); }

.profile-card {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: 1.05rem;
    border-radius: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    margin-bottom: .8rem;
}
.profile-card__photo { position: relative; flex: 0 0 auto; }
.profile-card__photo img {
    width: 92px; height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--brand-soft);
    background: var(--surface-2);
}
.profile-card__photo.is-busy img { opacity: .55; }
.profile-card__camera {
    position: absolute;
    right: -2px; bottom: -2px;
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    border: 3px solid var(--surface);
    cursor: pointer;
}
.profile-card__camera svg { width: 17px; height: 17px; }
.profile-card__main { min-width: 0; }
.profile-card__main h2 { margin: 0 0 .2rem; font-size: 1.12rem; overflow-wrap: anywhere; }
.profile-card__mascot { margin: .3rem 0 0; font-size: .78rem; color: var(--muted); }

.facts { margin: 0; }
.facts__row {
    display: flex;
    justify-content: space-between;
    gap: .6rem;
    padding: .45rem 0;
    border-bottom: 1px dashed var(--line);
    font-size: .88rem;
}
.facts__row:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 650; text-align: right; overflow-wrap: anywhere; }

/* ==========================================================================
   ICG AI
   ========================================================================== */

.ai { display: flex; flex-direction: column; gap: .8rem; }
.ai__head { display: flex; align-items: center; gap: .7rem; }
.ai__orb {
    width: 52px; height: 52px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(150deg, #4338ca, #06b6d4);
    color: #fff;
    box-shadow: 0 12px 24px -14px rgba(67, 56, 202, .9);
    flex: 0 0 auto;
}
.ai__spark { font-size: 1.4rem; animation: ai-pulse 2.8s ease-in-out infinite; }
@keyframes ai-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.16); opacity: .82; } }
.ai__title { margin: 0; font-size: 1.25rem; letter-spacing: -.01em; }
.ai__sub { margin: 0; font-size: .78rem; color: var(--muted); }

.ai__log {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    padding: .9rem .7rem;
    border-radius: 22px;
    background: linear-gradient(180deg, #f8fafc, #eef2ff);
    border: 1px solid var(--line);
    min-height: 260px;
    max-height: 54vh;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.ai-msg { display: flex; gap: .5rem; align-items: flex-end; max-width: 100%; }
.ai-msg--user { flex-direction: row-reverse; }
.ai-msg__avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .9rem;
    background: #fff;
    border: 1px solid var(--line);
    flex: 0 0 auto;
}
.ai-msg--user .ai-msg__avatar { background: var(--brand-soft); border-color: transparent; }
.ai-msg--error .ai-msg__avatar { background: var(--danger-soft); color: var(--danger); border-color: transparent; font-weight: 800; }
.ai-msg__bubble {
    padding: .6rem .8rem;
    border-radius: 16px 16px 16px 5px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: .9rem;
    line-height: 1.45;
    max-width: 82%;
    overflow-wrap: anywhere;
    box-shadow: 0 6px 14px -12px rgba(15, 23, 42, .5);
    white-space: pre-wrap;
}
.ai-msg--user .ai-msg__bubble {
    background: var(--brand);
    color: #fff;
    border-color: transparent;
    border-radius: 16px 16px 5px 16px;
}
.ai-msg--error .ai-msg__bubble { background: var(--danger-soft); border-color: #f4c7c3; color: #7a1d14; }
.ai-msg__bubble.is-typing { display: inline-flex; gap: 4px; align-items: center; }
.ai-msg__bubble.is-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: ai-typing 1.1s infinite ease-in-out;
}
.ai-msg__bubble.is-typing span:nth-child(2) { animation-delay: .15s; }
.ai-msg__bubble.is-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-typing { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }

.ai__suggestions { display: flex; gap: .4rem; flex-wrap: wrap; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    padding: .42rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    min-height: 36px;
}
.chip:hover { border-color: var(--brand); color: var(--brand-strong); }
.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.ai__form { display: flex; gap: .5rem; align-items: stretch; }
.ai__form .input { flex: 1 1 auto; min-width: 0; }
.ai__send {
    flex: 0 0 auto;
    width: 48px;
    min-height: 48px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 14px;
}
.ai__note { margin: 0; }

/* ==========================================================================
   Admin: quotas, filters, login card batches
   ========================================================================== */

.card--accent { border-color: #dbe3ff; }
.quota { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.quota__main { flex: 1 1 220px; }
.quota__main strong { display: block; font-size: .9rem; }
.quota__count { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }

.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .8rem; }
.filters .field { margin-bottom: 0; flex: 1 1 150px; }
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    flex-wrap: wrap;
    margin-top: .4rem;
}
.card__body--flush { padding: 0; }

.callout {
    display: block;
    padding: .8rem .9rem;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    font-size: .85rem;
    margin: .3rem 0 .8rem;
}
.callout--ok { background: var(--ok-soft); border-color: #bfe6cf; color: #0b5539; }
.callout--warn { background: var(--warn-soft); border-color: #f0d9ae; color: #6d4000; }
.callout__actions { margin-top: .6rem; }

.person { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.person--lg { gap: .75rem; }
.person__photo {
    width: 38px; height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
    flex: 0 0 auto;
}
.person--lg .person__photo { width: 56px; height: 56px; }
.person__name { display: flex; flex-direction: column; min-width: 0; font-weight: 650; font-size: .9rem; }
.person__meta { font-weight: 400; font-size: .74rem; color: var(--muted); }
.person--lg h1 { font-size: 1.3rem; margin: 0; }

.code {
    font-family: "Consolas", "SF Mono", "Courier New", monospace;
    font-size: .8rem;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: .12rem .35rem;
    overflow-wrap: anywhere;
}

.avatar--soft { background: var(--brand-soft); color: var(--brand-strong); }

/* ==========================================================================
   Exam result celebration
   ========================================================================== */

.result-hero {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem;
    border-radius: 22px;
    margin-bottom: 1rem;
    color: #fff;
}
.result-hero--pass { background: linear-gradient(150deg, #047857, #34d399); box-shadow: 0 18px 34px -24px rgba(4, 120, 87, .9); }
.result-hero--effort { background: linear-gradient(150deg, #b45309, #f59e0b); box-shadow: 0 18px 34px -24px rgba(180, 83, 9, .9); }
.result-hero__ring { position: relative; width: 104px; height: 104px; flex: 0 0 auto; }
.result-hero__ring svg { width: 104px; height: 104px; }
.result-hero__score {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.24rem;
    font-weight: 800;
    letter-spacing: -.02em;
}
.result-hero__text h2 { margin: 0 0 .25rem; font-size: 1.1rem; }
.result-hero__text p { margin: 0; font-size: .82rem; color: rgba(255, 255, 255, .92); }
.card--celebrate { border-color: #fde68a; background: linear-gradient(165deg, #fffbeb, #fff); }
.badge-chip__text { display: flex; flex-direction: column; line-height: 1.2; }
.badge-chip__text .small { font-weight: 400; color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .7rem; }

/* ==========================================================================
   Responsive tables
   ========================================================================== */

.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table caption { text-align: left; }
.table th, .table td { padding: .55rem .45rem; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.table .num { text-align: right; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }

.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data th, .data td { padding: .5rem .4rem; border-bottom: 1px solid var(--line); text-align: left; }
.data th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

@media (max-width: 520px) {
    .table--cards thead { display: none; }
    .table--cards tr { display: block; padding: .55rem 0; border-bottom: 1px solid var(--line); }
    .table--cards td { display: flex; justify-content: space-between; gap: .6rem; border: 0; padding: .18rem 0; }
    .table--cards td::before {
        content: attr(data-label);
        font-size: .72rem;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--muted);
        font-weight: 700;
        flex: 0 0 auto;
    }
    .table--cards td[data-label="Student"]::before { content: none; }
    .table--cards td[data-label="Student"] { padding-bottom: .35rem; }
}

/* ==========================================================================
   Small screens and motion preferences
   ========================================================================== */

@media (max-width: 560px) {
    .app-bar__inner { padding: .45rem .65rem; gap: .4rem; }
    .app-bar__brand { gap: .45rem; }
    .app-bar__logo { width: 30px; height: 30px; }
    .app-bar__name { font-size: .9rem; }
    .app-bar__school { display: none; }
    .app-bar__actions { gap: .25rem; }
    .app-bar__actions .btn { padding: .32rem .5rem; font-size: .76rem; }
    /* Keep the connection state as a dot so Online + the title never collide. */
    #pwa-net {
        width: 10px;
        height: 10px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        font-size: 0;
        color: transparent;
        overflow: hidden;
    }
}

@media (max-width: 380px) {
    .hero .hero__hi { font-size: 1.08rem; }
    .hero__photo { width: 50px; height: 50px; }
    .mascot__bubble { width: 52px; height: 52px; font-size: 1.7rem; }
    .app-bar__name { max-width: 88px; }
    .hub-card { min-height: 108px; padding: .75rem .7rem; }
    .hub-card__title { font-size: .88rem; }
    .badge-grid { grid-template-columns: 1fr; }
    .stat-grid--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .app-bar__school { display: none; }
    .profile-card__photo img { width: 76px; height: 76px; }
    .result-hero { gap: .7rem; padding: .9rem; }
    .result-hero__ring, .result-hero__ring svg { width: 86px; height: 86px; }
    .result-hero__score { font-size: 1.05rem; }
}

@media (min-width: 720px) {
    .hub { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .badge-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ai__log { min-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
