/* =============================================================
   components.css — the shared component set
   Loaded on every page, immediately after theme.css.

   This file is §3 (icons), §4 (state vocabulary) and §6 (components) of
   `design/design_v2/handoff/01-design-system.md`. The build order puts these
   before any page work for a reason: "a slightly worse component used
   everywhere beats a perfect one used once" (principle 4). A page stylesheet
   should be able to assume all of this exists and add only what is genuinely
   peculiar to that screen.

   Nothing here names a colour. Every value resolves through a token in
   theme.css, so the two themes swap with one `data-theme` attribute.
   ============================================================= */

/* =============================================================
   §3 — Icons
   -------------------------------------------------------------
   One family, drawn in icons.js. The only rules the stylesheet owns are how
   an icon sits next to text: it inherits the colour of whatever it is inside
   (that is the entire point of `currentColor`) and it never pushes a line
   taller than the text beside it.
   ============================================================= */
.icon {
    display: inline-block;
    vertical-align: -0.14em;
    flex-shrink: 0;
    /* The stroke must not thin out when a container scales the icon. */
    vector-effect: non-scaling-stroke;
}

/* Render sizes the design fixes: 12px in table cells, 13px in buttons (the
   default in icons.js), 17px in the rail. */
td .icon, th .icon { width: 12px; height: 12px; }

/* =============================================================
   §4 — State vocabulary
   ============================================================= */

/* The badge: glyph then label, in a 1px border of its own darkened tone. */
.state-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    white-space: nowrap;
    color: var(--fg-dim);
}
.state-badge .icon { width: 12px; height: 12px; }

.state-not_started { color: var(--fg-dim);  border-color: var(--line-strong); }
.state-started     { color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.state-awaiting    { color: var(--pending); border-color: color-mix(in srgb, var(--pending) 45%, var(--line)); }
.state-partial     { color: var(--warn);    border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.state-solved      { color: var(--pass);    border-color: color-mix(in srgb, var(--pass) 45%, var(--line)); }

/* The two flags. Not states — icons that can accompany any state. */
.flag-is_closed       { color: var(--fg-dim); }
.flag-unread_comments { color: var(--accent); }

/* Banner: a 2px left border in the tone, a tinted ground, an icon, one
   sentence. Hidden by default and occupying no space when empty — an error
   slot that reserves a gap is a permanent hole in the layout. */
.banner {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-left: 2px solid var(--line-strong);
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
    background: var(--panel-2);
    color: var(--fg-2);
    font-size: 13px;
    line-height: 1.5;
}
.banner .icon { margin-top: 1px; }
.banner-fail { border-left-color: var(--fail);   background: var(--fail-soft);   color: var(--fail-ink); }
.banner-pass { border-left-color: var(--pass);   background: var(--pass-soft);   color: var(--pass-ink); }
.banner-info { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.banner-warn { border-left-color: var(--warn);   background: var(--warn-soft);   color: var(--warn-ink); }

/* Inline status: a dot while pending, an icon + text once it resolves.
   Never a spinner — an indeterminate spinner says "something is happening"
   and nothing else, which is the least useful thing it could say. */
.inline-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--fg-dim);
}
.inline-status.is-pending::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--fg-dim);
    flex-shrink: 0;
}
.inline-status.is-ok   { color: var(--pass); }
.inline-status.is-fail { color: var(--fail); }
.inline-status.is-warn { color: var(--warn); }

/* =============================================================
   §6 — Buttons
   -------------------------------------------------------------
   36px tall; 30px inside a table row, where a full-height control would push
   the row past the scan-friendly 13px of vertical padding; 44px only for the
   editor's Run band.
   ============================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    /* A link dressed as a button is a button: never underlined. */
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--transition), background var(--transition),
                border-color var(--transition);
}

.btn-primary {
    background: var(--fg);
    color: var(--bg);
    font-weight: 700;
    border-color: var(--fg);
}
.btn-primary:hover { background: var(--fg-2); border-color: var(--fg-2); }

.btn-secondary {
    background: var(--panel-2);
    color: var(--fg);
    border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--row-hover); }

.btn-quiet {
    background: transparent;
    color: var(--fg-2);
    border-color: var(--line);
}
.btn-quiet:hover { color: var(--fg); border-color: var(--line-strong); }

.btn-destructive {
    background: transparent;
    color: var(--fail);
    border-color: var(--line);
}
.btn-destructive:hover { border-color: var(--fail); }

/* Disabled says "not now" by going quiet, never by changing shape or ground —
   a button that also moves reads as a different button. */
.btn:disabled,
.btn[disabled],
.btn.is-disabled {
    color: var(--fg-mute);
    border-color: var(--line);
    cursor: not-allowed;
}
.btn-primary:disabled { background: var(--panel-2); }

/* Rows are denser than the page they sit in. */
.btn-row { height: 30px; padding: 0 10px; font-size: 13px; }

/* Icon-only button. 28×28 with the icon centred; its accessible name comes
   from `aria-label`, which every call site sets. */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    color: var(--fg-dim);
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}
.btn-icon:hover { color: var(--fg); border-color: var(--line); }
.btn-icon.is-destructive:hover { color: var(--fail); border-color: var(--fail); }
.btn-icon:disabled { color: var(--fg-mute); cursor: not-allowed; }

/* Delete: a small trash can with its word (owner, 2026-10-01) — not a bare cross,
   which reads as "close this". Quiet until hovered, then the destructive
   colour: it deletes for good. */
.btn-delete {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 8px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    color: var(--fg-dim);
    font-family: var(--font-sans);
    font-size: 12.5px;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.btn-delete:hover { color: var(--fail); border-color: var(--fail); background: var(--fail-soft); }
.btn-delete:focus-visible { outline: 1px solid var(--fail); outline-offset: 1px; }

/* =============================================================
   §6 — Fields
   ============================================================= */
.field { display: flex; flex-direction: column; gap: 5px; }

.field-label,
.field label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--fg-2);
}

.field-hint {
    font-size: 12px;
    line-height: 1.45;
    color: var(--fg-dim);
}
/* A dialog field's live check (dialog.js `check`): a mismatch, a strength. */
.field-live { margin: 0; font-size: 12px; line-height: 1.45; color: var(--fg-dim); }
.field-live[hidden] { display: none; }
.field-live.is-ok { color: var(--pass-ink); }
.field-live.is-warn { color: var(--warn-ink); }
.field-live.is-fail { color: var(--fail-ink); }
/* A strength meter (owner, 2026-11-07): "Strength", a grey bar that fills
   red, then yellow, then green, and the word. */
.field-live.has-meter { display: flex; align-items: center; gap: 8px; color: var(--fg-dim); }
.field-meter {
    flex: 0 0 96px;
    height: 5px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
}
.field-meter-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--fg-dim);
    transition: width 160ms ease, background-color 160ms ease;
}
.field-live.has-meter.is-fail .field-meter-fill { background: var(--fail); }
.field-live.has-meter.is-warn .field-meter-fill { background: var(--warn); }
.field-live.has-meter.is-ok .field-meter-fill { background: var(--pass); }
.field-live.has-meter.is-fail .field-meter-text { color: var(--fail-ink); }
.field-live.has-meter.is-warn .field-meter-text { color: var(--warn-ink); }
.field-live.has-meter.is-ok .field-meter-text { color: var(--pass-ink); }
@media (prefers-reduced-motion: reduce) {
    .field-meter-fill { transition: none; }
}

.field-input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="search"],
.field input[type="datetime-local"],
.field select,
.field textarea {
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    background-color: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    color: var(--fg);
    font-size: 13.5px;
    font-family: var(--font-sans);
}
/* A select keeps the chevron the base rule paints (§6): `background` as a
   shorthand would wipe it, so the colour is set on its own, and the right
   padding leaves the glyph room. */
.field select { padding-right: 26px; }

/* Machine values render mono; typed prose renders sans (design §6). */
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="datetime-local"] { font-family: var(--font-mono); }

/* A dropdown is drawn by us, not by the operating system (owner,
   2026-09-21). The native control brings its own chrome — a raised bezel on
   macOS, a different metric on every platform — which sat wrong beside the
   flat inputs, cards and banners everywhere else. `appearance: none` takes
   that away; the chevron comes back as a background image (a neutral grey
   that reads on both themes, since a background image cannot inherit
   `currentColor`), and the extra right padding keeps a long option from
   running underneath it. */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238b93a1' stroke-width='1.3' stroke-linecap='square'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 9px 6px;
    padding-right: 26px;
    cursor: pointer;
}
select::-ms-expand { display: none; }

/* The list the dropdown opens (select-menu.js). A `<select>`'s own list is
   drawn by the operating system and no CSS reaches it, so the product draws
   its own: the same flat panel, border and accent as every other surface. It
   lives in <body> and is positioned in script, because a panel with
   `overflow: hidden` would otherwise clip it. */
.select-menu {
    position: fixed;
    z-index: 1200;
    max-height: 17rem;
    overflow-y: auto;
    padding: 4px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    box-shadow: 0 10px 24px rgb(0 0 0 / 35%);
}
.select-menu-option {
    padding: 6px 10px;
    border-radius: var(--radius-control);
    color: var(--fg-2);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.35;
    white-space: nowrap;
    cursor: pointer;
}
.select-menu-option.is-active { background: var(--panel-2); color: var(--fg); }
.select-menu-option[aria-selected="true"] { color: var(--accent); }
.select-menu-option.is-disabled { color: var(--fg-mute); cursor: not-allowed; }

/* The date-and-time picker (date-picker.js; owner, 2026-10-24): the
   browser's has no OK, so the input keeps its typing and a calendar button
   opens this — days, the time, Clear, Cancel, OK. Positioned in page
   coordinates under its field. */
.date-field {
    display: flex;
    align-items: stretch;
    gap: 4px;
}
.date-field input { flex: 1; min-width: 0; }
.date-field-input { font-family: var(--font-mono); }
.date-field input::-webkit-calendar-picker-indicator { display: none; }
.date-field-btn {
    width: 36px;
    height: auto;
    border-color: var(--line);
    background: var(--panel-2);
}
.date-picker {
    position: absolute;
    z-index: 1200;
    width: 264px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    box-shadow: 0 10px 24px rgb(0 0 0 / 35%);
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--fg-2);
}
.date-picker-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.date-picker-month { color: var(--fg); font-weight: 600; }
.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.date-picker-weekday {
    padding: 4px 0;
    text-align: center;
    color: var(--fg-dim);
    font-size: 11px;
}
.date-picker-day {
    height: 30px;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    color: var(--fg-2);
    font-family: var(--font-mono);
    font-size: 12.5px;
    cursor: pointer;
}
.date-picker-day:hover:not(:disabled) { background: var(--row-hover); }
.date-picker-day.is-other-month { color: var(--fg-dim); }
.date-picker-day.is-today { border-color: var(--line-strong); }
.date-picker-day.is-selected { background: var(--accent); color: var(--on-accent); }
.date-picker-day:disabled { color: var(--fg-mute); cursor: not-allowed; }
.date-picker-time {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}
.date-picker-time[hidden] { display: none; }
.date-picker-time-label { margin-right: auto; color: var(--fg-dim); }
.date-picker-time input {
    width: 52px;
    min-height: 30px;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--panel-2);
    color: var(--fg);
    font-family: var(--font-mono);
    text-align: center;
}
.date-picker-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}
.date-picker-spacer { flex: 1; }

/* A control that is off is legible but plainly not in play. */
.field input:disabled,
.field select:disabled,
.field-input:disabled { opacity: 0.45; cursor: not-allowed; }

/* A field whose control sits on its label's line (owner, 2026-09-21): three
   one-choice settings stacked as two-line blocks read as six things; on one
   line each they read as three. The hint, when there is one, still takes the
   line below — it is a sentence, not a control. */
.field.is-inline {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-3);
}
/* One column for the labels, so the controls start at the same x down the
   whole block rather than stepping in and out with the length of the word. */
.field.is-inline > .field-label,
.field.is-inline > label { flex: 0 0 auto; min-width: 6.5rem; }
.field.is-inline > select,
.field.is-inline > input { flex: 1 1 55%; width: auto; min-width: 6rem; }
/* A number is as wide as its digits — the shared min-width above is meant
   for a select or a text field, and made "3" sit in a 6rem box. The right
   padding is for the spinner, which the browser paints INSIDE the field on
   hover and focus: without the room it sits on top of the digits (owner,
   2026-09-21). */
.field.is-inline > input[type="number"] {
    flex: 0 0 5rem;
    min-width: 0;
    padding-right: 1.5rem;
    text-align: left;
}
.field.is-inline > .field-hint,
.field.is-inline > .field-error { flex: 1 0 100%; }

.field-input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.field-input.is-invalid,
.field input.is-invalid,
.field.is-invalid input { border-color: var(--fail); }

.field-error { font-size: 12px; color: var(--fail); }

/* A password field carries its Show/Hide inside, on the right. It must not
   steal focus — the caret stays where the user left it.

   Two things are pinned here rather than inherited, because Show/Hide swaps
   the input's `type` and every type-keyed rule above therefore stops applying
   mid-interaction (owner, 2026-08-06: revealing the password made the whole
   auth card resize and everything above it shift down):
     * the face — mono is chosen because a password is a machine value, and it
       must not become sans just because the type is momentarily "text";
     * the height — a fixed 36px, not a `min-height`, so the field cannot
       breathe at all when its content metrics change. */
.password-field { position: relative; display: flex; align-items: center; }
.password-field input,
.field .password-field input {
    width: 100%;
    padding-right: 36px;
    height: 36px;
    font-family: var(--font-mono);
}
.password-toggle {
    position: absolute;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: none;
    border: none;
    border-radius: var(--radius-control);
    color: var(--fg-dim);
    padding: 0;
    cursor: pointer;
    transition: color var(--transition);
}
.password-toggle:hover { color: var(--fg); }
/* A secret as text, masked, the same eye beside it (helpers.secretValue). */
.secret-value { display: inline-flex; align-items: center; gap: 4px; }
.secret-value .password-toggle { position: static; width: 22px; height: 22px; }

/* Checkbox — every one in the product, drawn by us like the dropdown
   (owner, 2026-10-15: "checkboxes in general should be styled similarly to
   all the rest of the page"). The native box is the operating system's —
   white, rounded, glossy on macOS — and sat wrong beside the flat inputs
   around it. `appearance: none` takes it away; what is left is an input's
   own surface and border, filled with the accent and a check when on. The
   check is a mask, so it takes `--on-accent` in both themes. */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    display: inline-grid;
    place-content: center;
    width: 15px;
    height: 15px;
    min-height: 0;
    margin: 0;
    padding: 0;
    vertical-align: -0.2em;
    background-color: var(--panel-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition);
}
input[type="checkbox"]::before {
    content: '';
    width: 9px;
    height: 9px;
    background-color: var(--on-accent);
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><path d='M1.5 5.2l2.3 2.3 4.7-5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='square'/></svg>") center / contain no-repeat;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><path d='M1.5 5.2l2.3 2.3 4.7-5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='square'/></svg>") center / contain no-repeat;
    transform: scale(0);
    transition: transform var(--transition);
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--accent); }
input[type="checkbox"]:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate {
    background-color: var(--accent);
    border-color: var(--accent);
}
input[type="checkbox"]:indeterminate::before {
    transform: scale(1);
    height: 2px;
    -webkit-mask: none;
    mask: none;
}
input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
input[type="checkbox"]:disabled { opacity: 0.45; cursor: not-allowed; }

/* =============================================================
   §6 — Table
   ============================================================= */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table thead th {
    padding: 8px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 500;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--fg-dim);
    text-align: left;
    white-space: nowrap;
}
.data-table tbody td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--panel-2);
    color: var(--fg-2);
    font-size: 13px;
    vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--row-hover); }

/* Numbers and dates are read by comparison, so they are right-aligned, mono
   and fixed width. Exactly one column — the title — is elastic. */
.data-table .col-score,
.data-table .col-attempts,
.data-table .col-due,
.data-table .col-start,
.data-table .col-activity {
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: right;
    white-space: nowrap;
}

/* A wide table scrolls inside its own card rather than squashing its columns:
   a table nobody can read is worse than one they have to push sideways. */
.table-scroll { overflow-x: auto; }

/* Sortable headers are buttons so they are reachable by keyboard, and they
   say which way they sort through `aria-sort`, not only through the chevron. */
.sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: pointer;
}
.sort-btn:hover { color: var(--fg-2); }
th[aria-sort="ascending"] .sort-btn,
th[aria-sort="descending"] .sort-btn { color: var(--fg); }
.sort-btn .icon { opacity: 0; transition: opacity var(--transition); }
th[aria-sort="ascending"] .sort-btn .icon,
th[aria-sort="descending"] .sort-btn .icon,
.sort-btn:hover .icon { opacity: 1; }

/* =============================================================
   §6 — Card header and empty state
   ============================================================= */
.card-header {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}
/* The hairline eats the slack between the label and the one right-hand fact. */
.card-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
    order: 1;
}
.card-header > :first-child { order: 0; }
.card-header > :last-child:not(:first-child) { order: 2; }
.card-header-fact {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-5);
    padding: var(--sp-9) var(--sp-6);
    /* Sans, not serif: v2 §2 rules out "every empty state" by name. An empty
       state is the application explaining itself, not an exercise. */
    font-family: var(--font-sans);
    font-size: 14.5px;
    color: var(--fg-2);
    text-align: center;
}

/* =============================================================
   §6 — Dialog
   -------------------------------------------------------------
   The replacement for every native confirm/alert/prompt. Native dialogs
   cannot be themed, cannot carry a subtitle naming *which* student a
   destructive action is about, and on some platforms are suppressed
   altogether — which turns "are you sure?" into "done".
   ============================================================= */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6);
    background: rgba(6, 8, 11, 0.72);
    animation: dialog-overlay-in 190ms ease-out;
}

.dialog {
    width: 100%;
    max-width: 460px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-overlay);
    display: flex;
    flex-direction: column;
    animation: dialog-panel-in 190ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* Quick enough not to be a wait, moved enough to be an *arrival*: the panel
   rises and settles.

   The first attempt (140ms, 6px, 0.985) was reported as "either too fast or
   not working" — and it was neither: it ran correctly and was simply below
   the threshold where the eye registers motion at all. An animation nobody
   can see is the same as no animation, but with the cost. 14px and 4% over
   190ms is the smallest version that reads as one movement; it is still
   under a fifth of a second, so a second open never feels like a wait. */
/* A modal to read in (dialog.js openModal): the page behind is blurred a
   little and dimmed less, so it is still there but out of the way. */
.dialog-overlay.is-blurred {
    background: rgba(6, 8, 11, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

@keyframes dialog-overlay-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes dialog-panel-in {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .dialog-overlay, .dialog { animation: none; }
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-4);
    padding: var(--sp-6) var(--sp-7) var(--sp-4);
}
.dialog-heading { flex: 1; min-width: 0; }
/* Sans: a dialog title is the application asking a question ("Delete class?"),
   which v2 §2 rules out of serif along with every dialog body. Where a dialog
   is titled with a task, the caller puts the task in the subtitle slot. */
.dialog-title {
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 700;
    color: var(--fg);
    margin: 0;
}
.dialog-subtitle {
    display: block;
    margin-top: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--fg-dim);
}

.dialog-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
    padding: 0 var(--sp-7) var(--sp-7);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--fg-2);
}
.dialog-body p { margin: 0; }
.dialog-note { font-size: 12.5px; color: var(--fg-dim); }

/* Two buttons, separated by a rule, primary on the right and wider: the
   action the dialog exists to offer should be the one the eye ends on. */
.dialog-footer {
    display: flex;
    border-top: 1px solid var(--line);
}
.dialog-footer .btn {
    flex: 1;
    height: 44px;
    border-radius: 0;
    border: none;
}
.dialog-footer .btn + .btn {
    flex: 1.4;
    border-left: 1px solid var(--line);
}
.dialog-footer .btn-primary.is-destructive {
    background: var(--fail);
    color: var(--bg);
}

/* =============================================================
   Utility
   ============================================================= */

/* Present for screen readers, absent to the eye. Used for the labels that a
   sighted user reads from the layout and a screen-reader user cannot. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* =============================================================
   The create button on a list screen
   -------------------------------------------------------------
   "+ New task" on Tasks and "Create new assignment" on Assignments are the
   same act on two screens, so they are one rule rather than two that drift
   (owner, 2026-08-12). Outlined in accent rather than filled: it is the
   primary action *of the list*, but the list itself is what the teacher came
   to read, so it announces itself without shouting over the rows.
   ============================================================= */
.btn-create {
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--accent);
    /* The control radius every other button has; 8px made "Create new …"
       the one pill on a square-cornered site (owner, 2026-09-14). */
    border-radius: var(--radius-control);
    background: var(--accent-soft);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
}
.btn-create:hover { background: var(--accent); color: var(--bg); }

/* =============================================================
   Touch (M6 responsive, 2026-09-15)
   -------------------------------------------------------------
   The design's 26-28px icon buttons are right for a mouse and too small for a
   finger (the guidance is ~44px). They grow on a COARSE pointer only — a
   tablet or a phone — so the dense desktop stays dense for the people using
   a mouse, which is who principle 10's teacher tables are drawn for. The
   visible glyph does not grow; the hit box does. The topbar's own controls
   grow in shell.css, which alone shapes the bar.
   ============================================================= */
@media (pointer: coarse) {
    .btn-icon,
    .todo-delete,
    .dialog-close {
        min-width: 40px;
        min-height: 40px;
    }
    .btn,
    .btn-row {
        min-height: 40px;
    }
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }
}

/* ── Tag chips ─────────────────────────────────────────────────────────
   One pill for a tag wherever a tag can be clicked: the Task Library and
   Tasks filters, and the authoring picker. A toggle carries `aria-pressed`
   where it is one. On a SELECTED chip the click removes, so its hover says
   remove (owner, 2026-09-12) — --fail as a tint, because taking a tag off is
   not a mistake. */
.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: transparent;
    color: var(--fg-dim);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.4;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition),
                background var(--transition);
}
.tag-chip:hover { color: var(--fg); border-color: var(--line-strong); }
.tag-chip.is-selected {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.tag-chip.is-selected:hover {
    background: var(--fail-soft);
    color: var(--fail);
    border-color: color-mix(in srgb, var(--fail) 50%, var(--line));
}
.tag-chip:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* ── Tag picker (authoring and its wizard) ─────────────────────────────
   One field (owner, 2026-10-15): the chosen tags are pills inside it and the
   filter input follows the last one, so the caret stands right of the pills.
   The vocabulary below is the library's chips, grouped by category and
   narrowed by what is typed. */
.tag-picker {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}
.tag-picker-row { display: flex; align-items: flex-start; gap: var(--sp-2); }
.tag-picker-field {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    min-height: 34px;
    padding: 4px 8px 4px 28px;
    position: relative;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    cursor: text;
}
.tag-picker-field:focus-within { border-color: var(--accent); }
.tag-picker-pills { display: contents; }
.tag-picker-search-icon {
    position: absolute;
    left: 9px;
    top: 10px;
    display: inline-flex;
    color: var(--fg-dim);
    pointer-events: none;
}
/* Borderless inside the field: the field is the box. Outranks
   `.field input[type="search"]` by specificity, not by load order — the
   picker lives inside a .field. */
.tag-picker .tag-picker-field input.tag-picker-search {
    flex: 1 1 8rem;
    min-width: 8rem;
    min-height: 24px;
    padding: 0 2px;
    background: transparent;
    border: none;
    color: var(--fg);
    font-family: var(--font-sans);
    font-size: 13px;
}
.tag-picker .tag-picker-field input.tag-picker-search:focus { outline: none; }
/* Opens the vocabulary; quiet, because picking tags is not the main job on
   this screen. `.is-open` when the chips are showing — including while the
   search has text, which opens them without latching the button. */
.tag-picker-toggle {
    flex: none;
    min-height: 34px;
    padding: 5px 10px;
    background: transparent;
    color: var(--fg-dim);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    font-family: var(--font-mono);
    font-size: 11px;
    cursor: pointer;
}
.tag-picker-toggle:hover { color: var(--fg); border-color: var(--line-strong); }
.tag-picker-toggle.is-open { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tag-picker-toggle:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
/* Categories side by side, not stacked (owner, 2026-09-21): typing removes
   whole groups, and with one column per group the rows below stayed put while
   a stack made everything under the picker jump with every keystroke. The
   height is fixed rather than capped for the same reason — the box does not
   grow or shrink as the matches change. */
.tag-picker-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    align-content: start;
    gap: var(--sp-3);
    height: 190px;
    overflow-y: auto;
    padding-right: 4px;
}
.tag-picker-category {
    display: block;
    margin-bottom: 4px;
    color: var(--fg-dim);
    font-size: 11px;
}
.tag-picker-chips { display: flex; flex-wrap: wrap; gap: 4px; }
/* Smaller here than in the Library (owner, 2026-09-21): there they are the
   content, here they are a list to pick from and ~90 of them have to fit. */
.tag-picker .tag-chip { gap: 4px; padding: 2px 7px; font-size: 10.5px; }
.tag-picker-empty { margin: 0; color: var(--fg-dim); font-size: 12px; }
/* The keyboard's place among the offered tags (arrows in the search field). */
.tag-picker-option.is-active { outline: 1px solid var(--accent); outline-offset: 1px; }
/* At the six-tag ceiling the rest stay visible but cannot be picked; the
   status line above the search says why. */
.tag-picker-option:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Page transitions (owner, 2026-08-12 "eye candy") ──────────────────
   Not decoration — this is what a slow connection looks like.

   The owner tests on a throttled 3G profile, and what a page used to do
   there was: white screen, then bare boxes with no animation at all (the
   entrance had long since played to an empty page), then the topbar and
   rail popping in, then text appearing inside the boxes. Four visible
   steps, in the wrong order.

   So nothing arrives before it is worth looking at, and each piece
   animates at the moment it becomes real:

     1. **The background is instant** — every page carries the two theme
        colours in an inline <style> in its own <head>, so it paints with
        the HTML itself, before theme.css has been fetched.
     2. **The chrome slides in when it is built.** `shell.js` adds
        `body.chrome-in` the moment the topbar and rail exist.
     3. **The blocks rise when their data is in.** `page-transitions.js`
        waits for the page's API calls to go quiet, then adds
        `body.page-in`.

   On a fast connection all three happen within a few hundred ms and it
   reads as one assembly. On a slow one it reads as "it was always there,
   the lag made it late" — which is the whole point.

   Everything moves on ONE axis and LINEARLY: in from below the screen,
   out downwards, no easing curve (owner, 2026-09-21 — a curve is bytes on
   the wire and arithmetic per frame, for a difference nobody asked for).
   Every knob lives in theme.css.

   The starting position is applied only under `html.js`, which the same
   inline script sets: a page whose JavaScript never runs must not be left
   holding its content one screen below the fold for ever.

   Motion is opt-out globally: theme.css collapses every animation under
   `prefers-reduced-motion: reduce`, and the script then navigates without
   waiting. */

/* Absent, until told otherwise.

   Two different arrivals on purpose (owner, 2026-09-22):

     * a page's **blocks** simply **dim up and down**. They were flown in,
       then risen from below the screen, then blurred — and plain opacity
       is what the owner kept. Nothing moves and nothing defocuses; the
       page brightens into place.
     * the **IDE workspace** keeps the **flight**, rising from below the
       screen as one piece. It is a single slab of four panels rather than
       a column of blocks, and that reads better arriving bodily than
       fading up.

   Both start at opacity 0 rather than merely dim, because the premise has
   not changed: nothing may be visible before it holds its data, or the
   page is back to showing empty boxes that fill in afterwards. */
html.js main.page > * {
    opacity: 0;
}
html.js .ide-workspace {
    opacity: 0;
    transform: translateY(var(--motion-rise));
}

/* Their own arrival, staggered so the page assembles rather than snapping.
   Capped at six: beyond that the wait is longer than the animation. */
html.js body.page-in main.page > * {
    opacity: 1;
    transition: opacity var(--motion-in) linear;
}
html.js body.page-in .ide-workspace {
    opacity: 1;
    transform: none;
    transition: opacity var(--motion-in) linear, transform var(--motion-in) linear;
}
body.page-in main.page > *:nth-child(2) { transition-delay: calc(var(--motion-stagger) * 1); }
body.page-in main.page > *:nth-child(3) { transition-delay: calc(var(--motion-stagger) * 2); }
body.page-in main.page > *:nth-child(4) { transition-delay: calc(var(--motion-stagger) * 3); }
body.page-in main.page > *:nth-child(5) { transition-delay: calc(var(--motion-stagger) * 4); }
body.page-in main.page > *:nth-child(n+6) { transition-delay: calc(var(--motion-stagger) * 5); }

/* On the way out everything goes together — no stagger, or the page looks
   like it is falling apart rather than stepping aside. The delays above
   have to be cancelled, or the last block would wait its turn to leave. */
body.is-leaving main.page > * {
    opacity: 0 !important;
    transition: opacity var(--motion-out) linear !important;
    transition-delay: 0ms !important;
}
body.is-leaving .ide-workspace {
    opacity: 0 !important;
    transform: translateY(var(--motion-rise)) !important;
    transition: opacity var(--motion-out) linear, transform var(--motion-out) linear !important;
    transition-delay: 0ms !important;
}

/* The workspace travels a screen's height, so on the IDE pages it can push
   the document taller while it does. Scoped to the pages that actually
   move something: a page whose blocks only fade needs no guard, and login
   and register — a `main.auth-container`, never given `page-in` at all —
   would sit at `overflow: hidden` for good if this were unscoped. */
html.js body:has(.ide-workspace):not(.page-in),
html.js body.is-leaving:has(.ide-workspace) { overflow: hidden; }


/* ── A detail panel that slides out of its list ───────────────────────────
   Tasks, Task Library, Arena and Inbox (detail-slide.js). Not there
   until a row is selected (owner, 2026-10-01): no empty card saying "select
   something". Selecting slides it out from under the list — the list sits
   above it — and switching folds it back in first (`DETAIL_FOLD_MS` is the
   fold below). Short and decelerating, so it reads as a response rather than
   a show. Stacked on a narrow screen it drops down out of the list instead;
   each screen says so at its own breakpoint (library.css, inbox.css). */
.slide-master { position: relative; z-index: 2; }
.slide-detail {
    z-index: 1;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-28%);
    /* The fold: quick, accelerating into the list. */
    transition:
        transform 120ms cubic-bezier(0.5, 0, 0.75, 0),
        opacity 100ms ease-in 20ms,
        visibility 0s linear 120ms;
}
.slide-detail.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    /* The unfold: a touch longer, decelerating out of the list. */
    transition:
        transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
        opacity 140ms ease-out,
        visibility 0s;
}
@media (prefers-reduced-motion: reduce) {
    .slide-detail, .slide-detail.is-open { transition: none; }
}

/* ── Toast: an action's outcome, as a card over the page (toast.js) ────────
   Slides in at the top right, below the topbar, and out again after its time
   bar has run down. It lies on top of the page and moves nothing in it. The
   tones are the banner's; the ground is solid (the panel with the tone mixed
   in), because a translucent tint over a table is unreadable. */
.toast-host {
    position: fixed;
    top: calc(46px + var(--sp-4));
    right: var(--sp-5);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--sp-3);
    width: min(380px, calc(100vw - 2 * var(--sp-5)));
    pointer-events: none;
}
.toast {
    --toast-tone: var(--line-strong);
    /* toast.js sets it per card from TOAST_MS; this is the same default. */
    --toast-ms: 5000ms;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    width: 100%;
    box-sizing: border-box;
    padding: var(--sp-4) var(--sp-5) calc(var(--sp-4) + 3px);
    border: 1px solid color-mix(in srgb, var(--toast-tone) 40%, var(--line));
    border-left: 3px solid var(--toast-tone);
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--toast-tone) 12%, var(--panel));
    color: var(--fg);
    box-shadow: var(--shadow-overlay);
    font-size: 13px;
    line-height: 1.5;
    overflow: hidden;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(calc(100% + var(--sp-5)));
    transition: transform 200ms cubic-bezier(0.5, 0, 0.75, 0), opacity 200ms ease-in;
}
.toast.is-in {
    opacity: 1;
    transform: none;
    transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 160ms ease-out;
}
.toast .icon { flex: none; margin-top: 2px; color: var(--toast-tone); }
.toast-pass { --toast-tone: var(--pass); }
.toast-fail { --toast-tone: var(--fail); }
.toast-warn { --toast-tone: var(--warn); }
.toast-info { --toast-tone: var(--accent); }
/* A delete is not a success: it is final once the card runs out (owner,
   2026-10-01). The destructive red, filled more strongly than a failure's
   tint so the two read apart at a glance — a failure is "nothing happened",
   this is "it is going". Closing stays green: it can be undone any time. */
.toast-delete {
    --toast-tone: var(--fail);
    background: color-mix(in srgb, var(--fail) 24%, var(--panel));
}

/* Undo: the one button a card can carry, at its right edge. */
.toast-action {
    flex: none;
    margin: -3px 0 -3px auto;
    padding: 3px 10px;
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--toast-tone) 60%, var(--line));
    border-radius: var(--radius-control);
    color: var(--fg);
    font: 600 12.5px var(--font-sans);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}
.toast-action:hover { background: color-mix(in srgb, var(--toast-tone) 22%, transparent); border-color: var(--toast-tone); }
.toast-action:focus-visible { outline: 1px solid var(--toast-tone); outline-offset: 2px; }

/* A card that stays until it is answered (an ask to continue): its buttons
   sit in a row under the sentence, and there is no time bar to run down. */
.toast.is-sticky { flex-wrap: wrap; padding-bottom: var(--sp-4); }
.toast.is-sticky .toast-text { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.toast.is-sticky .toast-text a { color: inherit; }
.toast-actions {
    flex: 1 0 100%;
    display: flex;
    gap: var(--sp-3);
    /* Under the sentence, not under the icon. */
    padding-left: calc(16px + var(--sp-3));
}
.toast-actions .toast-action { margin: 0; }
.toast-action.is-primary { background: var(--toast-tone); border-color: var(--toast-tone); color: var(--on-accent); }
.toast-action.is-primary:hover { background: color-mix(in srgb, var(--toast-tone) 85%, var(--fg)); }

/* The five seconds, running down along the bottom edge. */
.toast-timebar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--toast-tone);
    transform-origin: left center;
    animation: toast-timebar var(--toast-ms) linear forwards;
}
/* Pointer on the card, or focus in it: the countdown halts (toast.js stops
   its timer at the same moment), and resumes with what was left. */
.toast.is-paused .toast-timebar { animation-play-state: paused; }
@keyframes toast-timebar {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* A phone has no top right to speak of: the card comes down from the top,
   across the width, like the system's own notifications (the shell's phone
   breakpoint, shell.css). */
@media (max-width: 599px) {
    .toast-host {
        top: var(--sp-3);
        right: var(--sp-3);
        left: var(--sp-3);
        width: auto;
        align-items: stretch;
    }
    .toast { transform: translateY(calc(-100% - var(--sp-5))); }
}
@media (prefers-reduced-motion: reduce) {
    .toast, .toast.is-in { transition: opacity 120ms linear; transform: none; }
}



/* =============================================================
   Modules (owner, 2026-10-06) — shared by the catalogue lists and the
   student's My Work: a task's number in its module, and REQUIRED.
   ============================================================= */
.module-task-position {
    display: inline-block;
    min-width: 1.6em;
    margin-right: var(--sp-2);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--fg-mute);
}
/* REQUIRED and OPTIONAL — every task in a module wears one, both grey
   (owner, 2026-10-08): the word says which, the tooltip what it means. */
.module-required-badge,
.module-optional-badge {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--fg-dim);
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 2px 6px;
    cursor: help;
}
/* In an assignment of several items (owner, 2026-10-16), the module a task
   is in — on My Work, the student page and the overview grid. */
.assignment-module-chip {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--fg-mute);
    white-space: nowrap;
    margin-left: var(--sp-2);
}
.assignment-module-chip::before { content: '\25B8\00a0'; color: var(--line-strong); }
/* PASSED / NOT PASSED — a module with required tasks, on My Work and
   the overview grid alike. */
.module-passed {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.1em;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 1px 5px;
}
.module-passed.is-passed { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 45%, var(--line)); }
.module-passed.is-not-passed { color: var(--fg-dim); }

/* A link in a dialog's sentence (exam-awareness.js). */
.dialog-message a { color: var(--accent-ink); }
