/*
 * VECT LMS: design tokens and components for the design prototype.
 *
 * Design language: warm editorial minimalism with a deep mineral-green accent.
 *   - Warm paper, never pure white or black; one green for actions and active states.
 *   - Serif headings (Newsreader 400/500), a modern sans for the interface
 *     (Plus Jakarta Sans), a mono for data (JetBrains Mono). All three have Vietnamese.
 *   - Flat: no shadows. Depth comes from 1px hairlines and small changes of tone.
 *   - 6px corners on controls, 8px on panels, 12px on cards; calm 150ms transitions.
 * Light and dark: follows the system, or the sun/moon switch (data-theme on <html>,
 * saved as localStorage["vect-theme"], applied before paint by theme-init.js).
 * Colours are "R G B" triplets so Tailwind can add opacity: rgb(var(--x) / .5).
 */
:root {
  color-scheme: light;
  /* Paper and ink */
  --bg: 250 249 245;            /* #FAF9F5 page */
  --surface: 240 239 234;       /* #F0EFEA sidebar, cards, fields, table headers */
  --elevated: 230 229 223;      /* #E6E5DF hover surface */
  --inset: 250 249 245;         /* #FAF9F5 a panel or field inside a card */
  --fg: 20 20 19;               /* #141413 text */
  --fg-2: 90 92 87;             /* #5A5C57 secondary text (5.9:1 on cards) */
  --fg-3: 135 137 131;          /* #878983 placeholders and faint marks only */
  --line: 227 226 220;          /* #E3E2DC hairlines */
  --line-strong: 212 211 204;   /* #D4D3CC secondary buttons, fields */
  /* Green */
  --accent: 46 90 68;           /* #2E5A44 primary buttons, active, links */
  --accent-hover: 35 71 53;     /* #234735 */
  --on-accent: 250 249 245;     /* #FAF9F5 on the green: 7.5:1 */
  --accent-soft: 230 239 234;   /* #E6EFEA badges, active items, row hover */
  --accent-soft-fg: 35 71 53;   /* #234735 green text: 9.0:1 on cards */
  --accent-soft-line: 200 221 209; /* #C8DDD1 */
  /* Warning and danger, low saturation */
  --warning: 184 115 51;        /* #B87333 */
  --warning-soft: 242 233 222;  /* #F2E9DE */
  --warning-fg: 138 85 35;      /* #8A5523 */
  --warning-line: 227 202 177;  /* #E3CAB1 */
  --danger: 184 62 44;          /* #B83E2C */
  --danger-fg: 184 62 44;       /* danger as text: 5.3:1 on the page */
  --on-danger: 250 249 245;
  --danger-soft: 243 230 225;   /* #F3E6E1 */
  --danger-soft-fg: 154 51 36;  /* #9A3324 */
  --danger-line: 230 193 185;   /* #E6C1B9 */
  /* Roles of the tones */
  --field: var(--surface);
  --table-head: var(--surface);
  --table-body: var(--bg);
  --scrim: 20 20 19;
  --toast-bg: 20 20 19;
  --toast-fg: 250 249 245;
  --toast-icon: 123 179 150;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235A5C57' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

  /* Type */
  --font-serif: "Newsreader", "Source Serif 4", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* Shape and motion */
  --r-control: 6px;
  --r-panel: 8px;
  --r-card: 12px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 150ms;

  /* Layout: a plain top bar (no floating gap) and a full-height sidebar */
  --navbar-top: 0px;
  --navbar-height: 3.75rem;
  --navbar-bottom: var(--navbar-height);
  --below-navbar: calc(var(--navbar-height) + 1.5rem);
}

/* Dark: warm obsidian and a softer sage. Written twice: the system setting, and the switch. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: 19 20 19;               /* #131413 */
  --surface: 27 28 27;          /* #1B1C1B */
  --elevated: 36 38 36;         /* #242624 */
  --inset: 36 38 36;
  --fg: 250 249 245;            /* #FAF9F5 */
  --fg-2: 156 158 152;          /* #9C9E98 */
  --fg-3: 118 120 115;          /* #767873 */
  --line: 43 45 43;             /* #2B2D2B */
  --line-strong: 58 61 58;      /* #3A3D3A */
  --accent: 82 140 110;         /* #528C6E */
  --accent-hover: 99 158 127;   /* #639E7F */
  --on-accent: 250 249 245;
  --accent-soft: 29 43 36;      /* #1D2B24 */
  --accent-soft-fg: 123 179 150; /* #7BB396 */
  --accent-soft-line: 44 66 55; /* #2C4237 */
  --warning-soft: 42 33 24;     /* #2A2118 */
  --warning-fg: 217 154 94;     /* #D99A5E */
  --warning-line: 69 49 29;     /* #45311D */
  --danger-fg: 224 128 110;     /* #E0806E */
  --danger-soft: 42 26 23;      /* #2A1A17 */
  --danger-soft-fg: 224 128 110;
  --danger-line: 69 33 27;      /* #45211B */
  --field: var(--elevated);
  --table-head: var(--elevated);
  --table-body: var(--surface);
  --scrim: 8 9 8;
  --toast-bg: 250 249 245;
  --toast-fg: 20 20 19;
  --toast-icon: 46 90 68;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239C9E98' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: 19 20 19;
    --surface: 27 28 27;
    --elevated: 36 38 36;
    --inset: 36 38 36;
    --fg: 250 249 245;
    --fg-2: 156 158 152;
    --fg-3: 118 120 115;
    --line: 43 45 43;
    --line-strong: 58 61 58;
    --accent: 82 140 110;
    --accent-hover: 99 158 127;
    --on-accent: 250 249 245;
    --accent-soft: 29 43 36;
    --accent-soft-fg: 123 179 150;
    --accent-soft-line: 44 66 55;
    --warning-soft: 42 33 24;
    --warning-fg: 217 154 94;
    --warning-line: 69 49 29;
    --danger-fg: 224 128 110;
    --danger-soft: 42 26 23;
    --danger-soft-fg: 224 128 110;
    --danger-line: 69 33 27;
    --field: var(--elevated);
    --table-head: var(--elevated);
    --table-body: var(--surface);
      --scrim: 8 9 8;
    --toast-bg: 250 249 245;
    --toast-fg: 20 20 19;
    --toast-icon: 46 90 68;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239C9E98' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: rgb(var(--line-strong)) transparent; }
body {
  margin: 0;
  background: rgb(var(--bg));
  color: rgb(var(--fg));
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
/* Headings are serif, never bold. (body + element beats Tailwind's preflight reset; utilities still win.) */
body :is(h1, h2, h3) { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; text-wrap: balance; }
body h1 { font-weight: 400; }
.font-display { letter-spacing: -0.02em; line-height: 1.2; }
::selection { background: rgb(var(--accent-soft)); color: rgb(var(--fg)); }
:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }
a.underline, .kit-link { color: rgb(var(--accent-soft-fg)); text-decoration-color: rgb(var(--accent-soft-line)); text-underline-offset: 3px; }
a.underline:hover, .kit-link:hover { text-decoration-color: currentColor; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Every interactive surface fades its colours the same way: quick, calm, no bounce, no scale. */
.kit-btn, .kit-pill, .kit-tab, .kit-field, .nav-item, .tabbar a, .tabbar button, .seg-status button, .lang-toggle button, a.kit-card, button.kit-card, .kit-table tbody td {
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), outline-color var(--dur) var(--ease);
}

/* ---------- surfaces ---------- */
.kit-border { border: 1px solid rgb(var(--line)); }
/* Card: a step of tone from the page, a hairline, 12px corners. */
.kit-card { border: 1px solid rgb(var(--line)); border-radius: var(--r-card); background: rgb(var(--surface)); color: rgb(var(--fg)); }
/* A panel inside a card: one step lighter. */
.kit-card-flat { border: 1px solid rgb(var(--line)); border-radius: var(--r-panel); background: rgb(var(--inset)); }
/* What floats over the page (the attendance bar, menus): a card with a stronger line. */
.kit-surface { border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-card); background: rgb(var(--surface)); }
a.kit-card:hover, button.kit-card:hover { background: rgb(var(--elevated)); }
.kit-card .kit-field { --field: var(--inset); }

/* A card's header: its serif title over a hairline. */
.kit-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid rgb(var(--line)); }
.kit-card-head h2, .kit-card-head h3 { margin: 0; font-family: var(--font-serif); font-size: 1.1875rem; font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }

/* ---------- text ---------- */
.kit-label { font-family: var(--font-sans); font-size: .8125rem; font-weight: 500; letter-spacing: .01em; }
.kit-caption { font-family: var(--font-sans); font-size: .8125rem; font-weight: 400; line-height: 1.45; }
/* Numbers that line up. Small ones (tables, counts, times) are set in the mono as data;
   big serif figures (.font-display) keep the serif. */
.tabular { font-variant-numeric: tabular-nums; }
.tabular:not(.font-display) { font-family: var(--font-mono); letter-spacing: -0.02em; }
.font-mono { letter-spacing: -0.01em; }

/* ---------- fields ---------- */
.kit-field {
  width: 100%; border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-control); background: rgb(var(--field));
  padding: .55rem .8rem; font: inherit; font-size: .9375rem; color: inherit;
}
.kit-field::placeholder { color: rgb(var(--fg-3)); }
.kit-field:hover { border-color: rgb(var(--fg-3)); }
.kit-field:focus { outline: 2px solid rgb(var(--accent) / .35); outline-offset: 1px; border-color: rgb(var(--accent)); }
select.kit-field { appearance: none; padding-right: 2.2rem; background-image: var(--chevron); background-repeat: no-repeat; background-position: right .7rem center; }

/* ---------- buttons ---------- */
/* Primary: the green, light text, 6px corners, medium weight. */
.kit-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; height: 2.5rem; padding: 0 1.125rem;
  border: 1px solid transparent; border-radius: var(--r-control);
  background: rgb(var(--accent)); color: rgb(var(--on-accent)); font-family: var(--font-sans); font-size: .875rem; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.kit-btn:hover { background: rgb(var(--accent-hover)); }
.kit-btn:focus-visible { outline: 2px solid rgb(var(--accent)); outline-offset: 2px; }
/* Secondary: paper (or clear, in dark) with a hairline; hover darkens one step. */
.kit-btn--outline { background: rgb(var(--bg)); border-color: rgb(var(--line-strong)); color: rgb(var(--fg)); }
:root[data-theme="dark"] .kit-btn--outline { background: transparent; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kit-btn--outline { background: transparent; } }
.kit-btn--outline:hover { background: rgb(var(--surface)); }
.kit-card .kit-btn--outline:hover, .kit-surface .kit-btn--outline:hover { background: rgb(var(--elevated)); }
/* The old "featured" and "success" variants are the primary green now. */
.kit-btn--featured, .kit-btn--success { background: rgb(var(--accent)); color: rgb(var(--on-accent)); }
.kit-btn--danger { background: rgb(var(--danger)); color: rgb(var(--on-danger)); }
.kit-btn--danger:hover { background: rgb(var(--danger) / .9); }
.kit-btn--ghost { background: transparent; border-color: transparent; color: rgb(var(--fg-2)); }
.kit-btn--ghost:hover { background: rgb(var(--surface)); color: rgb(var(--fg)); }
.kit-btn--sm { height: 2.125rem; padding: 0 .875rem; font-size: .8125rem; }
.kit-btn--lg { height: 2.75rem; padding: 0 1.5rem; font-size: .9375rem; }
.kit-btn--icon { width: 2.5rem; padding: 0; }
.kit-btn[disabled] { border-color: transparent; background: rgb(var(--elevated)); color: rgb(var(--fg-3)); cursor: not-allowed; }

/* ---------- choices ---------- */
/* Filter pills: quiet until chosen; chosen is the soft green. */
.kit-pill {
  display: inline-flex; align-items: center; gap: .4rem; height: 2.125rem; border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-control);
  background: transparent; padding: 0 .8rem; font-family: var(--font-sans); font-size: .8125rem; font-weight: 500;
  color: rgb(var(--fg-2)); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.kit-pill:hover { background: rgb(var(--surface)); color: rgb(var(--fg)); }
.kit-card .kit-pill:hover { background: rgb(var(--elevated)); }
.kit-pill.is-on, .kit-pill[aria-pressed="true"], .kit-pill[aria-current="page"] { background: rgb(var(--accent-soft)); border-color: rgb(var(--accent-soft-line)); color: rgb(var(--accent-soft-fg)); }
.kit-pill .count { font-family: var(--font-mono); font-size: .75rem; font-weight: 500; opacity: .75; }

/* Tabs: a hairline track; the chosen tab is the soft green. Wraps on phones, never scrolls sideways. */
.kit-tabs { display: inline-flex; flex-wrap: wrap; gap: .25rem; max-width: 100%; border: 1px solid rgb(var(--line)); border-radius: var(--r-panel); background: rgb(var(--surface)); padding: .25rem; }
.kit-tab { border: 1px solid transparent; border-radius: var(--r-control); background: none; padding: .4rem .875rem; font-family: var(--font-sans); font-size: .875rem; font-weight: 500; color: rgb(var(--fg-2)); cursor: pointer; }
.kit-tab:hover { color: rgb(var(--fg)); background: rgb(var(--elevated)); }
.kit-tab[aria-selected="true"] { border-color: rgb(var(--accent-soft-line)); background: rgb(var(--accent-soft)); color: rgb(var(--accent-soft-fg)); }

/* Attendance: three choices in a hairline track. Chosen = the state's soft tone with its colour as the line. */
.seg-status { display: inline-flex; border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-panel); background: rgb(var(--inset)); padding: 3px; gap: 3px; }
.seg-status button { border: 1px solid transparent; border-radius: var(--r-control); background: none; padding: .3rem .8rem; font-family: var(--font-sans); font-size: .8125rem; font-weight: 500; cursor: pointer; color: rgb(var(--fg-2)); }
.seg-status button:hover { background: rgb(var(--elevated)); color: rgb(var(--fg)); }
.seg-status button[aria-pressed="true"][data-v="present"] { background: rgb(var(--accent-soft)); border-color: rgb(var(--accent)); color: rgb(var(--accent-soft-fg)); }
.seg-status button[aria-pressed="true"][data-v="late"] { background: rgb(var(--warning-soft)); border-color: rgb(var(--warning)); color: rgb(var(--warning-fg)); }
.seg-status button[aria-pressed="true"][data-v="absent"] { background: rgb(var(--danger-soft)); border-color: rgb(var(--danger)); color: rgb(var(--danger-soft-fg)); }
/* Phones: the switch sits under the name and fills the row, three equal touch targets. */
@media (max-width: 639px) { .seg-status--row { display: flex; } .seg-status--row button { flex: 1 1 0; padding-block: .5rem; } }

/* Language switch (assets/i18n.js). */
.lang-toggle { display: inline-flex; gap: 2px; border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-control); background: transparent; padding: 2px; }
.lang-toggle button { border: 0; border-radius: 4px; background: none; padding: .2rem .5rem; font-family: var(--font-mono); font-size: .6875rem; font-weight: 600; letter-spacing: .04em; color: rgb(var(--fg-2)); cursor: pointer; }
.lang-toggle button:hover { color: rgb(var(--fg)); background: rgb(var(--surface)); }
.lang-toggle button[aria-pressed="true"] { background: rgb(var(--accent-soft)); color: rgb(var(--accent-soft-fg)); }

/* ---------- small facts ---------- */
/* Chip: a small fact (level, size, room, time); figures line up. Codes add .font-mono. */
.kit-chip {
  display: inline-flex; align-items: center; gap: .3rem; border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-control);
  background: transparent; padding: .05rem .45rem; font-family: var(--font-sans); font-size: .75rem; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.5; white-space: nowrap; color: rgb(var(--fg));
}
/* Tag: a state. Default = good (soft green); then quiet, warning, danger, neutral, attention. */
.kit-tag {
  display: inline-flex; align-items: center; gap: .25rem; border: 1px solid rgb(var(--accent-soft-line)); border-radius: var(--r-control);
  padding: .05rem .45rem; font-family: var(--font-sans); font-size: .75rem; font-weight: 500; line-height: 1.5; white-space: nowrap;
  background: rgb(var(--accent-soft)); color: rgb(var(--accent-soft-fg));
}
.kit-tag--soft { background: transparent; }
.kit-tag--yellow, .kit-tag--coral { background: rgb(var(--warning-soft)); border-color: rgb(var(--warning-line)); color: rgb(var(--warning-fg)); }
.kit-tag--red { background: rgb(var(--danger-soft)); border-color: rgb(var(--danger-line)); color: rgb(var(--danger-soft-fg)); }
.kit-tag--blue { background: rgb(var(--elevated)); border-color: rgb(var(--line-strong)); color: rgb(var(--fg)); }
.kit-tag--muted { background: transparent; border-color: rgb(var(--line-strong)); color: rgb(var(--fg-2)); }

/* A few words of a title on the soft green, once per page. */
.kit-highlight { border-radius: 4px; background: rgb(var(--accent-soft)); padding: 0 .2em; color: rgb(var(--accent-soft-fg)); -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* Avatars: initials on the soft green. */
.kit-avatar { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; flex: 0 0 auto; border: 1px solid rgb(var(--accent-soft-line)); border-radius: 9999px; background: rgb(var(--accent-soft)); font-family: var(--font-sans); font-weight: 600; font-size: .75rem; letter-spacing: .02em; color: rgb(var(--accent-soft-fg)); }
.kit-avatar--sm { width: 1.75rem; height: 1.75rem; font-size: .625rem; }
.kit-avatar--lg { width: 4rem; height: 4rem; font-size: 1.125rem; }

/* Notes: opaque, a hairline in the note's tone. */
.kit-note { border: 1px solid rgb(var(--accent-soft-line)); border-radius: var(--r-panel); background: rgb(var(--accent-soft)); padding: .8rem 1rem; font-size: .9375rem; color: rgb(var(--fg)); }
.kit-note--warn { background: rgb(var(--warning-soft)); border-color: rgb(var(--warning-line)); }
.kit-note--error { background: rgb(var(--danger-soft)); border-color: rgb(var(--danger-line)); color: rgb(var(--danger-soft-fg)); }
.kit-note--info { background: rgb(var(--elevated)); border-color: rgb(var(--line-strong)); }

/* Progress: a quiet track, a green fill; amber when nearly out, brick when full. */
.kit-progress { height: .5rem; border-radius: 9999px; background: rgb(var(--elevated)); overflow: hidden; }
.kit-card .kit-progress { background: rgb(var(--line-strong) / .7); }
.kit-progress > span { display: block; height: 100%; border-radius: 9999px; background: rgb(var(--accent)); }
.kit-progress.is-warn > span { background: rgb(var(--warning)); }
.kit-progress.is-full > span { background: rgb(var(--danger)); }

/* ---------- tables ---------- */
/* Header on the stone tone in small capitals; rows on paper; hover is the faintest green. */
.kit-table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.kit-table thead th { text-align: left; background: rgb(var(--table-head)); font-family: var(--font-sans); font-size: .75rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; line-height: 1.4; color: rgb(var(--fg-2)); padding: .75rem 1rem; border-bottom: 1px solid rgb(var(--line)); white-space: nowrap; }
.kit-table tbody td { background: rgb(var(--table-body)); padding: .875rem 1rem; border-bottom: 1px solid rgb(var(--line)); vertical-align: middle; }
.kit-table tbody tr:last-child td { border-bottom: 0; }
.kit-table tbody tr:hover td { background: rgb(var(--accent-soft)); }

/* ---------- journey (student profile): steps joined by a hairline ---------- */
.node-flow { --node-line: 1px; --node-gap: 2.5rem; --node-rise: 1rem; --node-spine-x: 1.25rem; display: flex; flex-direction: column; gap: var(--node-rise); }
.node-flow-step { position: relative; }
.node-flow-step + .node-flow-step::before { content: ""; position: absolute; left: calc(var(--node-spine-x) - var(--node-line) / 2); top: calc(-1 * var(--node-rise)); height: var(--node-rise); border-left: var(--node-line) solid rgb(var(--line-strong)); }
.node-port { position: absolute; z-index: 1; width: .5rem; height: .5rem; border: 1px solid rgb(var(--accent)); border-radius: 9999px; background: rgb(var(--bg)); transform: translate(-50%, -50%); pointer-events: none; }
.node-flow-step > .node-port-in { left: var(--node-spine-x); top: 0; }
.node-flow-step > .node-port-out { left: var(--node-spine-x); top: 100%; }
.node-flow-step:first-child > .node-port-in, .node-flow-step:last-child > .node-port-out { display: none; }
@media (min-width: 768px) {
  .node-flow-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); column-gap: var(--node-gap); align-items: stretch; }
  .node-flow-row > .node-flow-step > :first-child { height: 100%; }
  .node-flow-row > .node-flow-step + .node-flow-step::before { left: calc(-1 * var(--node-gap)); top: calc(50% - var(--node-line) / 2); width: var(--node-gap); height: 0; border-left: 0; border-top: var(--node-line) solid rgb(var(--line-strong)); }
  .node-flow-row > .node-flow-step > .node-port-in { left: 0; top: 50%; }
  .node-flow-row > .node-flow-step > .node-port-out { left: 100%; top: 50%; }
}

/* ---------- shell: top bar, sidebar, phone tab bar, sheet, toast ---------- */
.app-header { position: sticky; top: 0; z-index: 40; height: var(--navbar-height); border-bottom: 1px solid rgb(var(--line)); background: rgb(var(--bg)); }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 16rem; border-right: 1px solid rgb(var(--line)); background: rgb(var(--surface)); }
@media (min-width: 768px) { .app-header--with-side { margin-left: 16rem; } }

.nav-item { position: relative; margin: 1px 0; display: flex; align-items: center; gap: .75rem; border-radius: var(--r-control); padding: .5rem .75rem; font-size: .875rem; font-weight: 500; color: rgb(var(--fg-2)); text-decoration: none; }
.nav-item:hover { background: rgb(var(--elevated)); color: rgb(var(--fg)); }
.nav-item[aria-current="page"] { background: rgb(var(--accent-soft)); color: rgb(var(--accent-soft-fg)); }
.nav-item svg { width: 1rem; height: 1rem; flex: 0 0 auto; }
.nav-count { margin-left: auto; min-width: 1.375rem; height: 1.25rem; display: inline-grid; place-items: center; padding: 0 .35rem; border-radius: var(--r-control); background: rgb(var(--elevated)); font-family: var(--font-mono); font-size: .6875rem; font-weight: 500; color: rgb(var(--fg-2)); }
.nav-item[aria-current="page"] .nav-count { background: rgb(var(--bg) / .7); color: rgb(var(--accent-soft-fg)); }
/* The unread count on the bell: the one solid green mark in the bar. */
.dot-count { position: absolute; top: .3rem; right: .25rem; min-width: 1rem; height: 1rem; display: inline-grid; place-items: center; padding: 0 .25rem; border-radius: 9999px; background: rgb(var(--accent)); font-family: var(--font-mono); font-size: .625rem; font-weight: 600; line-height: 1; color: rgb(var(--on-accent)); }

/* Phone tab bar: attached to the bottom edge, a hairline on top. */
.tabbar { border-top: 1px solid rgb(var(--line)); background: rgb(var(--bg)); padding: .375rem .5rem calc(.375rem + env(safe-area-inset-bottom)); }
.tabbar a, .tabbar button { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .4rem .1rem; border: 0; border-radius: var(--r-panel); background: none; font-family: var(--font-sans); font-size: .6875rem; font-weight: 500; color: rgb(var(--fg-2)); text-decoration: none; cursor: pointer; min-width: auto; }
/* Equal tabs, but no tab shrinks below its own label (e.g. "Attendance"); very narrow phones fall back to ellipsis. */
@media (max-width: 359px) { .tabbar a, .tabbar button { min-width: 0; } }
.tabbar a span, .tabbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar a:hover, .tabbar button:hover { color: rgb(var(--fg)); }
.tabbar a[aria-current="page"] { background: rgb(var(--accent-soft)); color: rgb(var(--accent-soft-fg)); }
.tabbar svg { width: 1.25rem; height: 1.25rem; }

/* The menu sheet: a bottom sheet on phones, a panel under the account button from md up. */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgb(var(--scrim) / .4); animation: fade-in var(--dur) var(--ease); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 80vh; overflow: auto; border: 1px solid rgb(var(--line)); border-bottom: 0; border-radius: var(--r-card) var(--r-card) 0 0; background: rgb(var(--bg)); padding-bottom: env(safe-area-inset-bottom); animation: sheet-in calc(var(--dur) * 1.5) var(--ease); }
@media (min-width: 768px) { .sheet { left: auto; right: 1rem; top: calc(var(--navbar-height) + .5rem); bottom: auto; width: 21rem; border-bottom: 1px solid rgb(var(--line)); border-radius: var(--r-card); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Toast: inverted (ink on paper becomes paper on ink), so it reads over anything without a shadow. */
.toast { position: fixed; z-index: 70; right: 1.5rem; bottom: 1.5rem; max-width: min(26rem, calc(100vw - 2rem)); padding: .875rem 1rem; display: flex; gap: .65rem; align-items: flex-start; border-radius: var(--r-panel); background: rgb(var(--toast-bg)); color: rgb(var(--toast-fg)); animation: sheet-in calc(var(--dur) * 1.5) var(--ease); }
.toast svg { color: rgb(var(--toast-icon)); }
@media (max-width: 767px) { .toast { left: 1rem; right: 1rem; bottom: 5.5rem; } }

/* A phone mock (reports: what the parent sees). */
.phone-frame { border: 1px solid rgb(var(--line-strong)); border-radius: 1.5rem; background: rgb(var(--bg)); overflow: hidden; }
/* The VietQR code stays dark-on-paper in both themes, so it can be scanned. */
.qr-paper { background: #FAF9F5; color: #141413; }

.scrollbar-none { scrollbar-width: none; }
.scrollbar-none::-webkit-scrollbar { display: none; }

/* ---------- student practice (practice.html and the players) ---------- */
/* A card that works as a choice (skill tiles): chosen = the soft green. */
.kit-card[aria-pressed="true"] { border-color: rgb(var(--accent-soft-line)); background: rgb(var(--accent-soft)); }
.kit-card[aria-pressed="true"] .tile-icon { background: rgb(var(--accent)); border-color: transparent; color: rgb(var(--on-accent)); }
/* A filter row: a checkbox, its label, and a count; values with nothing are greyed out. */
.kit-check { display: flex; align-items: center; gap: .6rem; border-radius: var(--r-control); padding: .3rem .4rem; font-size: .875rem; cursor: pointer; }
.kit-check:hover { background: rgb(var(--surface)); }
.kit-check input { width: 1rem; height: 1rem; accent-color: rgb(var(--accent)); }
.kit-check .count { margin-left: auto; font-family: var(--font-mono); font-size: .75rem; color: rgb(var(--fg-2)); }
.kit-check.is-empty { color: rgb(var(--fg-3)); cursor: default; }
.kit-check.is-empty:hover { background: none; }
/* Transcript words you can tap to look up. */
.word { border-radius: 3px; cursor: pointer; transition: background-color var(--dur) var(--ease); }
.word:hover, .word.is-on { background: rgb(var(--accent-soft)); color: rgb(var(--accent-soft-fg)); }
/* Marking: dictation differences and shadowing scores. */
.mark-ok { color: rgb(var(--accent-soft-fg)); }
.mark-mid { background: rgb(var(--warning-soft)); color: rgb(var(--warning-fg)); border-radius: 3px; padding: 0 .1em; }
.mark-bad { background: rgb(var(--danger-soft)); color: rgb(var(--danger-soft-fg)); border-radius: 3px; padding: 0 .1em; text-decoration: line-through; text-decoration-thickness: 1px; }
.mark-miss { background: rgb(var(--warning-soft)); color: rgb(var(--warning-fg)); border-radius: 3px; padding: 0 .15em; }
.mark-fix { color: rgb(var(--accent-soft-fg)); font-weight: 600; }
/* The record button: one round green control; while recording it turns brick and breathes slowly. */
.rec-btn { display: inline-grid; place-items: center; width: 4.5rem; height: 4.5rem; border-radius: 9999px; border: 0; background: rgb(var(--accent)); color: rgb(var(--on-accent)); cursor: pointer; transition: background-color var(--dur) var(--ease); }
.rec-btn:hover { background: rgb(var(--accent-hover)); }
.rec-btn[aria-pressed="true"] { background: rgb(var(--danger)); animation: rec-breathe 1.8s var(--ease) infinite; }
@keyframes rec-breathe { 50% { opacity: .7; } }
/* A reading passage: the serif, a comfortable measure. */
.reading { font-family: var(--font-serif); font-size: 1.0625rem; line-height: 1.8; max-width: 68ch; }
.reading p + p { margin-top: .9em; }
/* Mock test: the question palette. */
.q-cell { display: inline-grid; place-items: center; width: 2.125rem; height: 2.125rem; border: 1px solid rgb(var(--line-strong)); border-radius: var(--r-control); background: rgb(var(--bg)); font-family: var(--font-mono); font-size: .75rem; font-weight: 500; color: rgb(var(--fg-2)); cursor: pointer; position: relative; transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.q-cell:hover { border-color: rgb(var(--fg-3)); }
.q-cell.is-answered { background: rgb(var(--accent-soft)); border-color: rgb(var(--accent-soft-line)); color: rgb(var(--accent-soft-fg)); }
.q-cell[aria-current="true"] { outline: 2px solid rgb(var(--accent)); outline-offset: 1px; }
.q-cell.is-flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 9999px; background: rgb(var(--warning)); }
.q-cell.is-right { background: rgb(var(--accent-soft)); border-color: rgb(var(--accent)); color: rgb(var(--accent-soft-fg)); }
.q-cell.is-wrong { background: rgb(var(--danger-soft)); border-color: rgb(var(--danger)); color: rgb(var(--danger-soft-fg)); }

/* The hidden attribute must win over display utilities (.grid, .flex, .block) on filtered rows and tab panels. */
[hidden] { display: none !important; }
@media print { .app-header, .app-sidebar, .tabbar { display: none !important; } body { background: #FAF9F5; color: #141413; } }
