/* Learnium portal: components.css (design system v2, docs/plans/PORTAL_REDESIGN_PROPOSAL.md Parts 3.3 to 3.5).
   CSS only: the markup and JS that use these classes arrive in phase R2. Tokens only (tokens.css), radius 0,
   both themes through the tokens, and prefers-reduced-motion respected (the three durations become 0 there,
   plus the explicit overrides at the end of this file). Load order: style.css, tokens.css, components.css, portal.css.
   Classes that the public style.css also defines (.btn, .card, .field, .avatar) are scoped to .portal-body. */

/* page-level knobs that a page or the JS may override on any ancestor: sticky offset of table headers, stagger index of .en blocks */
:root { --table-sticky-top: 0px; --i: 0; }

/* ============ Icons (sprite: assets/icons.svg, <svg class="i"><use href="assets/icons.svg#i-name"/></svg>) ============ */
svg.i, .i {
  width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle;
  stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter;
}
svg.i-20, .i-20, .portal-body .btn svg.i-20 { width: 20px; height: 20px; }
.portal-body .btn svg.i { width: 16px; height: 16px; fill: none; }

/* ============ Glass: floating chrome only (header, bottom bars, palette, side-panel header, toasts) ============
   An approximation of Apple's Liquid Glass for the web; Apple documents it for its platforms only.
   Never on content cards, tables, forms or the exam question area: glass under text costs readability. */
.glass, .toast, .cmd-palette, .side-panel-hd {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass, .toast, .cmd-palette, .side-panel-hd { background: var(--surface); }
}
@media (prefers-reduced-transparency: reduce) {
  .glass, .toast, .cmd-palette, .side-panel-hd {
    background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
}

/* ============ Buttons: .btn-primary / .btn-secondary (.btn-outline) / .btn-ghost / .btn-danger; .btn-sm 32, default 36, .btn-lg 44 ============ */
.portal-body .btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 16px; border-radius: 0; border: 1px solid transparent;
  font: 500 14px/1 var(--font-body); letter-spacing: 0; text-transform: none; white-space: nowrap; text-decoration: none;
  cursor: pointer; background: var(--surface); color: var(--fg);
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast);
}
.portal-body .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.portal-body .btn:active:not(:disabled):not([aria-disabled="true"]) { transform: translateY(1px); }
.portal-body .btn:disabled, .portal-body .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.portal-body .btn-sm, .portal-body .btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.portal-body .btn-lg { min-height: 44px; padding: 0 24px; }

.portal-body .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.portal-body .btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

/* .btn-outline is the older name of the secondary button and stays as an alias until R2 renames the markup */
.portal-body .btn-secondary, .portal-body .btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--fg); }
.portal-body .btn-secondary:hover:not(:disabled), .portal-body .btn-outline:hover:not(:disabled) { background: var(--surface-2); border-color: var(--fg-subtle); color: var(--fg); }

.portal-body .btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.portal-body .btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; color: var(--fg); }

.portal-body .btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.portal-body .btn-danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); color: var(--on-danger); }

/* loading: the label hides and the double square steps through four positions (600 ms per cycle) */
.portal-body .btn.is-loading { color: transparent; pointer-events: none; --spin: var(--fg); }
.portal-body .btn-primary.is-loading { --spin: var(--accent-fg); }
.portal-body .btn-danger.is-loading { --spin: var(--on-danger); }
.portal-body .btn.is-loading > * { visibility: hidden; }
.portal-body .btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; box-sizing: border-box;
  border: 1.5px solid var(--spin); background: linear-gradient(var(--spin), var(--spin)) 0 0 / 6px 6px no-repeat;
  animation: lc-step 600ms steps(1, end) infinite;
}
@keyframes lc-step {
  0% { background-position: 0 0; } 25% { background-position: 100% 0; }
  50% { background-position: 100% 100%; } 75% { background-position: 0 100%; }
}

/* ============ Status chip: 22 px, 12 px / 500, icon slot, never colour alone (always text) ============ */
.status-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border: 1px solid transparent; border-radius: 0;
  font: 500 12px/1 var(--font-body); white-space: nowrap; background: var(--surface-2); color: var(--fg-muted);
}
.status-chip .i { width: 14px; height: 14px; }
.status-chip.tone-neutral { background: var(--surface-2); color: var(--fg-muted); border-color: var(--border); }
.status-chip.tone-accent  { background: var(--accent-soft); color: var(--accent-soft-text); }
.status-chip.tone-success { background: var(--success-soft); color: var(--success-text); }
.status-chip.tone-warning { background: var(--warning-soft); color: var(--warning-text); }
.status-chip.tone-danger  { background: var(--danger-soft); color: var(--danger-text); }
.status-chip.tone-info    { background: var(--info-soft); color: var(--info-text); }

/* ============ Card: surface + border, no shadow in dark (the dark shadow tokens are empty); header row ============ */
.portal-body .card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 0; padding: 24px; box-shadow: var(--shadow-sm);
  transform: none; transition: none;
}
.portal-body .card:hover { border-color: var(--border); transform: none; }
.card-hd { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.card-hd h2, .card-hd h3, .card-hd .card-title { font-family: var(--font-head); font-weight: 400; font-size: 16px; line-height: 24px; margin: 0; color: var(--fg); }
.card-hd .card-count { font-size: 12px; font-weight: 500; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.card-hd .card-action { margin-left: auto; }

/* ============ Table: 36 px rows, sticky header, hover, selected, skeleton rows ============ */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 18px; color: var(--fg); }
.table th {
  position: sticky; top: var(--table-sticky-top); z-index: 1; height: 36px; padding: 0 12px; text-align: left; white-space: nowrap;
  background: var(--surface); color: var(--fg-muted); border-bottom: 1px solid var(--border-strong);
  font: 500 12px/16px var(--font-body); letter-spacing: 0.06em; text-transform: uppercase;
}
.table td { height: 36px; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.is-selected td { background: var(--accent-soft); }
.table tbody tr.is-selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .skeleton-row td::after { content: ""; display: block; height: 12px; background: var(--surface-2); }
@media (pointer: coarse) { .table td, .table th { height: 44px; } }

/* ============ Field: label, 36 px input, hint, error ============ */
.portal-body .field label, .portal-body .field > .field-label {
  display: block; margin: 0 0 4px; font: 500 13px/18px var(--font-body); letter-spacing: 0; text-transform: none; color: var(--fg);
}
.portal-body .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), .portal-body .field select, .portal-body .field textarea {
  display: block; width: 100%; min-width: 0; height: 36px; padding: 0 12px; border-radius: 0;
  font: 400 14px/20px var(--font-body); color: var(--fg); background: var(--surface); border: 1px solid var(--border-strong);
  transition: border-color var(--dur-fast);
}
.portal-body .field textarea { height: auto; min-height: 84px; padding: 8px 12px; resize: vertical; }
.portal-body .field input:hover, .portal-body .field select:hover, .portal-body .field textarea:hover { border-color: var(--fg-subtle); }
.portal-body .field input:focus, .portal-body .field select:focus, .portal-body .field textarea:focus { background: var(--surface); border-color: var(--accent); }
.portal-body .field input:focus-visible, .portal-body .field select:focus-visible, .portal-body .field textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.portal-body .field input:disabled, .portal-body .field select:disabled, .portal-body .field textarea:disabled { background: var(--surface-2); color: var(--fg-muted); cursor: not-allowed; }
.portal-body .field input::placeholder, .portal-body .field textarea::placeholder { color: var(--fg-subtle); }
.field-hint { margin: 4px 0 0; font-size: 12px; line-height: 16px; color: var(--fg-muted); }
.field-hint.is-warn { color: var(--warning-text); font-weight: 600; }
.field-error { display: none; align-items: center; gap: 4px; margin: 4px 0 0; font-size: 12px; line-height: 16px; color: var(--danger-text); }
.portal-body .field.is-invalid .field-error { display: flex; }
.portal-body .field.is-invalid input, .portal-body .field.is-invalid select, .portal-body .field.is-invalid textarea { border-color: var(--danger); }
.portal-body .field.is-invalid > label { color: var(--danger-text); }

/* ============ Dialog (native <dialog>, class kept: portal.js creates .lc-dialog) ============ */
/* style.css resets every margin to 0, which would pin the dialog to the top-left corner: centre it ourselves. */
.lc-dialog {
  position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100% - 32px); overflow: auto;
  width: calc(100% - 32px); max-width: var(--dialog-w); padding: 24px; border-radius: 0;
  border: 1px solid var(--elev-border, var(--border)); background: var(--surface-raised); color: var(--fg); box-shadow: var(--shadow-lg);
}
.lc-dialog[open] { animation: lc-pop var(--dur) var(--ease-out); }
.lc-dialog::backdrop { background: var(--overlay); }
.lc-dialog h2 { font-family: var(--font-head); font-weight: 400; font-size: 20px; line-height: 26px; margin: 0 0 8px; color: var(--fg); }
.lc-dialog p { font-size: 14px; line-height: 20px; color: var(--fg-muted); margin: 0 0 16px; white-space: pre-line; }
.lc-dialog label { display: block; font-size: 13px; font-weight: 500; line-height: 18px; margin-bottom: 4px; color: var(--fg); }
.lc-dialog textarea, .lc-dialog input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 0; margin-bottom: 16px;
  background: var(--surface); color: var(--fg); font: 400 14px/20px var(--font-body);
}
.lc-dialog textarea { min-height: 84px; resize: vertical; }
.lc-dialog .field-error { color: var(--danger-text); margin: 4px 0 0; }   /* beats .lc-dialog p (muted, 16 px below) */
.lc-dialog textarea:focus, .lc-dialog input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--accent); }
.lc-dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.lc-dialog.danger .lc-confirm { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.lc-dialog.danger .lc-confirm:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
@keyframes lc-pop { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes lc-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============ Toast: bottom-left (staff), .is-center for students and phones; max 3 stacked; aria-live set by JS ============ */
.toast-stack { position: fixed; left: 16px; bottom: 16px; z-index: 9100; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast-stack.is-center { left: 50%; transform: translateX(-50%); }
@media (max-width: 760px) { .toast-stack { left: 50%; transform: translateX(-50%); bottom: calc(72px + env(safe-area-inset-bottom)); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 0;
  border: 1px solid var(--elev-border, var(--border)); border-left: 3px solid var(--info);
  color: var(--fg); font-size: 14px; line-height: 20px; animation: lc-rise var(--dur) var(--ease-out);
}
.toast.tone-success { border-left-color: var(--success); }
.toast.tone-danger  { border-left-color: var(--danger); }
.toast.tone-info    { border-left-color: var(--info); }
.toast .toast-action { margin-left: auto; flex: none; }

/* ============ Skeleton and empty state (usage for every page; both themes through tokens) ============
   SKELETON (loading placeholder, shown instead of content while data loads, not for errors):
     .skeleton                a surface-2 block with a 1.2 s shimmer (transform only); give it a size with a width/height utility or a wrapper
     .skeleton-line           one text line (12 px tall); .skeleton-line.is-short (60%) and .is-title (40%, 20 px tall) vary it
     .skeleton-block          a media/card block (96 px tall); .skeleton-circle for an avatar (40 px)
     .skeleton-stack          a column of lines with 8 px gaps: <div class="skeleton-stack"><span class="skeleton skeleton-line is-title"></span><span class="skeleton skeleton-line"></span><span class="skeleton skeleton-line is-short"></span></div>
     .table .skeleton-row     a table row of grey cells
     Add aria-busy="true" on the region being loaded. Under prefers-reduced-motion the shimmer is off and the block stays flat.
   EMPTY STATE (nothing here yet, or nothing matches; one title, one line, at most one action):
     <div class="empty-state">
       <svg class="i empty-icon" aria-hidden="true"><use href="assets/icons.svg#i-inbox"/></svg>   (optional icon slot; or <span class="glyph"></span> for the double-square)
       <h3 class="empty-title">Title</h3><p>One plain line.</p><a class="btn btn-primary">Action</a>
     </div>
     .empty-state.is-compact   tighter padding for use inside a card, a side panel or a table cell
     .empty-state.is-boxed     adds the dashed border so it reads as a drop area/placeholder on a plain page */
.skeleton { position: relative; display: block; min-height: 12px; overflow: hidden; background: var(--surface-2); border-radius: 0; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--fg) 7%, transparent), transparent);
  animation: lc-shimmer 1.2s ease-in-out infinite;
}
@keyframes lc-shimmer { to { transform: translateX(100%); } }
.skeleton-line { height: 12px; width: 100%; }
.skeleton-line.is-short { width: 60%; }
.skeleton-line.is-title { width: 40%; height: 20px; }
.skeleton-block { height: 96px; width: 100%; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 0; }
.skeleton-stack { display: grid; gap: 8px; }

/* ============ Empty state and the double-square glyph (outline + filled purple, also used by the loader and success) ============ */
.empty-state { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; color: var(--fg-muted); }
.empty-state h2, .empty-state h3, .empty-state .empty-title { font-family: var(--font-head); font-weight: 400; font-size: 20px; line-height: 26px; margin: 0; color: var(--fg); }
.empty-state p { margin: 0; max-width: 420px; font-size: 14px; line-height: 20px; }
.empty-state .btn { margin-top: 8px; }
.empty-state .empty-icon, .empty-state svg.i.empty-icon { width: 40px; height: 40px; margin-bottom: 8px; color: var(--accent); stroke-width: 1.25; }
.empty-state.is-compact { padding: 24px 16px; }
.empty-state.is-boxed { border: 1px dashed var(--border-strong); background: var(--surface); }
.glyph { position: relative; display: block; width: 48px; height: 48px; margin: 0 auto 8px; flex: none; }
.glyph::before { content: ""; position: absolute; left: 0; top: 0; width: 32px; height: 32px; box-sizing: border-box; border: 1.5px solid var(--fg-subtle); }
.glyph::after { content: ""; position: absolute; right: 0; bottom: 0; width: 24px; height: 24px; background: var(--accent); }

/* ============ Tabs: 40 px, 2 px accent underline (role="tablist", arrow keys and hash links come from JS) ============ */
.tabs { display: flex; gap: 0; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tabs [role="tab"], .tabs .tab {
  flex: none; height: 40px; padding: 0 16px; margin-bottom: -1px; background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  font: 500 14px/40px var(--font-body); color: var(--fg-muted); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.tabs [role="tab"]:hover, .tabs .tab:hover { color: var(--fg); }
.tabs [role="tab"][aria-selected="true"], .tabs .tab.is-active { color: var(--fg); border-bottom-color: var(--accent); }
.tabs [role="tab"]:focus-visible, .tabs .tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ============ kbd ============ */
kbd {
  display: inline-block; min-width: 20px; padding: 0 6px; text-align: center; border-radius: 0;
  font: 500 12px/18px var(--font-body); color: var(--fg-muted); background: var(--surface-2); border: 1px solid var(--border);
}

/* ============ Avatar: square initials on --accent-soft, 32 px (.avatar-sm 24) ============ */
.portal-body .avatar {
  display: inline-grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 0;
  background: var(--accent-soft); color: var(--accent-soft-text); font: 500 12px/1 var(--font-body); text-transform: uppercase; letter-spacing: 0;
}
.portal-body .avatar-sm { width: 24px; height: 24px; }

/* ============ Stat: label over a Questrial value; .stat-hero is the one 44 px number per page ============ */
.stat { display: grid; gap: 4px; min-width: 0; color: var(--fg); text-decoration: none; }
a.stat:hover .stat-value { color: var(--accent-text); }
.stat-label { font-size: 12px; line-height: 16px; color: var(--fg-muted); }
.stat-value { font-family: var(--font-head); font-weight: 400; font-size: 32px; line-height: 36px; font-variant-numeric: tabular-nums; color: var(--fg); overflow-wrap: anywhere; }
.stat-hero .stat-value { font-size: 44px; line-height: 48px; }
.stat-delta { font-size: 12px; line-height: 16px; color: var(--fg-muted); }

/* ============ Side panel: 440 px drawer from the right (full width below 768 px); header 52 px (glass) ============ */
.side-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 200; display: flex; flex-direction: column;
  width: min(var(--panel-w), 100vw); background: var(--surface-raised); color: var(--fg);
  border-left: 1px solid var(--elev-border, var(--border)); box-shadow: var(--shadow-lg);
  transform: translateX(16px); opacity: 0; visibility: hidden;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out), visibility 0s linear var(--dur);
}
.side-panel.is-open { transform: none; opacity: 1; visibility: visible; transition-delay: 0s; }
.side-panel[hidden] { display: none; }
.side-panel-hd { flex: none; display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.side-panel-hd h2, .side-panel-hd .side-panel-title { font-family: var(--font-head); font-weight: 400; font-size: 16px; line-height: 24px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-panel-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; }
@media (max-width: 767px) { .side-panel { width: 100vw; border-left: 0; } }   /* L2: a right-hand panel down to tablet width */

/* ============ Command palette: <dialog class="cmd-palette">, 600 px, rows 40 px ============ */
.cmd-palette {
  position: fixed; inset: 0; margin: 12vh auto auto; padding: 0; overflow: hidden; border-radius: 0;
  width: min(var(--palette-w), calc(100% - 32px)); max-height: 70vh; color: var(--fg);
  border: 1px solid var(--elev-border, var(--border-strong));
}
.cmd-palette[open] { display: flex; flex-direction: column; animation: lc-rise var(--dur) var(--ease-out); }
.cmd-palette::backdrop { background: var(--overlay); }
.cmd-input {
  flex: none; width: 100%; height: 52px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0;
  background: transparent; color: var(--fg); font: 400 16px/24px var(--font-body); outline: none;
}
.cmd-input::placeholder { color: var(--fg-subtle); }
.cmd-list { flex: 1; min-height: 0; overflow: auto; padding: 4px 0 8px; }
.cmd-group { padding: 12px 16px 4px; font: 500 12px/16px var(--font-body); letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); }
.cmd-row { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 16px; color: var(--fg); font-size: 14px; cursor: pointer; }
.cmd-row .i { color: var(--fg-muted); }
.cmd-row kbd { margin-left: auto; }
.cmd-row:hover, .cmd-row[aria-selected="true"] { background: var(--accent-soft); }

/* ============ Section rail (long pages): 200 px mini-map; built on IntersectionObserver by JS, which sets --rail-progress 0..1 ============ */
.rail-nav {
  --rail-progress: 0;
  position: sticky; top: calc(var(--header-h, 68px) + 24px); align-self: start; width: 200px; display: grid; gap: 4px;
  padding-left: 16px; border-left: 1px solid var(--border); font-size: 13px; line-height: 18px;
}
.rail-nav::before {
  content: ""; position: absolute; left: -1px; top: 0; bottom: 0; width: 2px; background: var(--accent);
  transform-origin: top; transform: scaleY(var(--rail-progress)); transition: transform var(--dur) var(--ease-out);
}
.rail-nav a { position: relative; display: block; padding: 4px 0; color: var(--fg-muted); text-decoration: none; transition: color var(--dur-fast); }
.rail-nav a:hover { color: var(--fg); }
.rail-nav a.is-read { color: var(--fg-subtle); }
.rail-nav a.is-current { color: var(--fg); font-weight: 600; }
.rail-nav a.is-current::before { content: ""; position: absolute; left: -17px; top: 4px; bottom: 4px; width: 2px; background: var(--accent); }
.rail-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 1100px) {
  .rail-nav {
    top: var(--header-h, 68px); z-index: 4; display: flex; gap: 16px; width: auto; height: 40px; align-items: center; overflow-x: auto;
    padding: 0 16px; border-left: 0; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  }
  .rail-nav::before { display: none; }
  .rail-nav a { flex: none; white-space: nowrap; }
  .rail-nav a.is-current::before { left: 0; right: 0; top: auto; bottom: -1px; width: auto; height: 2px; }
}

/* ============ Progress rail: the 10-stage journey as square nodes on a line; the name shows under the current node only ============ */
.progress-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); list-style: none; margin: 0; padding: 0; }
.progress-rail > li { position: relative; display: grid; justify-items: center; align-content: start; gap: 8px; min-width: 0; }
.progress-rail > li::before { content: ""; position: absolute; top: 6px; left: -50%; right: 50%; height: 2px; background: var(--border-strong); }
.progress-rail > li:first-child::before { display: none; }
.progress-rail > li.is-done::before, .progress-rail > li.is-current::before { background: var(--accent); }
.progress-rail .node { position: relative; z-index: 1; width: 14px; height: 14px; box-sizing: border-box; border: 2px solid var(--border-strong); background: var(--surface); }
.progress-rail > li.is-done .node { background: var(--accent); border-color: var(--accent); }
.progress-rail > li.is-current .node { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.progress-rail .node-label { display: none; max-width: 100%; text-align: center; font-size: 12px; line-height: 16px; color: var(--fg); overflow-wrap: anywhere; }
.progress-rail > li.is-current .node-label { display: block; }

/* ============ Motion: page-enter and the hover-dim rule (3.5). Only transform and opacity animate. ============ */
.en { animation: lc-enter 320ms var(--ease-out) both; animation-delay: calc(var(--i) * 40ms); }
.en:nth-child(2) { animation-delay: 40ms; } .en:nth-child(3) { animation-delay: 80ms; } .en:nth-child(4) { animation-delay: 120ms; }
.en:nth-child(5) { animation-delay: 160ms; } .en:nth-child(n+6) { animation-delay: 200ms; }
@keyframes lc-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Hovering one of 3 to 9 peers dims the others (keyboard: :focus-within). Never on tables, buttons, forms, chips or fewer than 3 items. */
@media (hover: hover) {
  .dim-group > * { transition: opacity 150ms var(--ease-out); }
  .dim-group:hover > *:not(:hover) { opacity: 0.55; }
  .dim-group:focus-within > *:not(:focus-within) { opacity: 0.55; }
}

/* ============ Reduced motion: every duration is 0 through the tokens; the keyframed pieces switch off here ============ */
@media (prefers-reduced-motion: reduce) {
  .en, .lc-dialog[open], .cmd-palette[open], .toast { animation: none; }
  .skeleton::after { animation: none; display: none; }
  .portal-body .btn.is-loading::after { animation: none; }
  .portal-body .btn, .tabs [role="tab"], .tabs .tab, .rail-nav::before, .rail-nav a, .side-panel { transition: none; }
}

/* charts (ui-charts.js) */
.spark-mini { display: inline-block; vertical-align: middle; overflow: visible; }
.trend-chart { display: block; width: 100%; height: auto; overflow: visible; }
.trend-chart text { font-family: inherit; }
.chart-table { border-collapse: collapse; font-size: 13px; }
.chart-table caption { text-align: left; color: var(--fg-muted); padding-bottom: 6px; white-space: nowrap; }
.chart-table th, .chart-table td { text-align: left; padding: 4px 12px 4px 0; border-bottom: 1px solid var(--border); }
.chart-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.heat-cal { display: grid; grid-template-columns: repeat(13, 10px); grid-template-rows: repeat(7, 10px); grid-auto-flow: column; gap: 2px; width: max-content; }
.heat-cal .cell { width: 10px; height: 10px; background: var(--surface-2); }
.heat-cal .cell.l1 { background: var(--m2); }
.heat-cal .cell.l2 { background: var(--m3); }
.heat-cal .cell.l3 { background: var(--m4); }
.heat-cal .cell.l4 { background: var(--m5); }
.heat-cal .cell.future { visibility: hidden; }
.heat-cal .cell.today { outline: 1.5px solid var(--fg); outline-offset: 1px; }
.heat-cal .cell:hover { outline: 1.5px solid var(--fg-muted); outline-offset: 1px; }

.mg { display: grid; gap: 4px; }
.mg .r { display: grid; grid-template-columns: 200px 1fr 56px; gap: 12px; align-items: center; font-size: 13px; }
.mg .r .t { color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mg .r .n { color: var(--fg-subtle); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.mg .cells { display: flex; flex-wrap: wrap; gap: 4px; }
.mg .sq { width: 18px; height: 18px; padding: 0; margin: 0; display: block; box-sizing: border-box; border: 1.5px solid var(--border-strong); border-radius: 0; background: transparent; cursor: pointer; }
.mg .sq.l1 { background: var(--m1); border-color: transparent; }
.mg .sq.l2 { background: var(--m2); border-color: transparent; }
.mg .sq.l3 { background: var(--m3); border-color: transparent; }
.mg .sq.l4 { background: var(--m4); border-color: transparent; }
.mg .sq.l5 { background: var(--m5); border-color: transparent; }
.mg .sq.low { background: var(--surface-2); border-color: var(--border-strong); }
.mg .sq:hover { outline: 2px solid var(--fg-muted); outline-offset: 1px; }
.mg .sq:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
@media (max-width: 640px) { .mg .r { grid-template-columns: 110px 1fr 48px; } }

.bars { display: grid; gap: 10px; }
.bars .b { display: grid; grid-template-columns: 150px 1fr 90px; gap: 12px; align-items: center; font-size: 13px; }
.bars .b .l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .b .tr { height: 14px; background: var(--surface-2); position: relative; }
.bars .b .tr i { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.bars .b .v { color: var(--fg-muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .bars .b { grid-template-columns: 110px 1fr 70px; } }

.stack-bar { display: flex; gap: 2px; height: 14px; }
.stack-bar .seg { flex-basis: 0; min-width: 2px; }
.stack-bar .seg.rest { background: var(--surface-2); }
.stack-bar .c1, .stack-legend .c1 { background: var(--chart-1); }
.stack-bar .c2, .stack-legend .c2 { background: var(--chart-2); }
.stack-bar .c3, .stack-legend .c3 { background: var(--chart-3); }
.stack-bar .c4, .stack-legend .c4 { background: var(--chart-4); }
.stack-bar .c5, .stack-legend .c5 { background: var(--chart-5); }
.stack-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--fg-muted); }
.stack-legend li { display: flex; align-items: center; gap: 6px; }
.stack-legend .sw { width: 10px; height: 10px; display: inline-block; flex: none; }

/* ============ Touch and phone: every button, select and text field is at least 44 px tall (a mouse keeps 32 to 36) ============ */
@media (pointer: coarse), (max-width: 760px) {
  .portal-body .btn, .portal-body .btn-sm, .portal-body .btn-small { min-height: 44px; }
  .portal-body .field select, .portal-body .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]) { height: 44px; }
}


/* ============ Get started page (get-started.html): progress rail, step cards, Do and Don't pairs, Stuck block ============ */
.gs, .gs .portal-page-head { max-width: 860px; }
.gs-rail { list-style: none; margin: 0 0 24px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.gs-rail li { position: relative; }
.gs-rail li:not(:last-child)::after { content: ""; position: absolute; left: calc(50% + 18px); right: calc(-50% + 18px); top: 15px; height: 2px; background: var(--border-strong); }
.gs-rail a { display: grid; justify-items: center; gap: 6px; padding: 4px; color: var(--fg-muted); font-size: 12px; line-height: 16px; text-align: center; text-decoration: none; }
.gs-rail a:hover { color: var(--fg); }
.gs-rail a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gs-dot { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--border-strong); color: var(--fg); font-size: 14px; font-weight: 700; position: relative; z-index: 1; }
.gs-rail a:hover .gs-dot { border-color: var(--accent); color: var(--accent-text); }
.gs-step { margin-bottom: 16px; scroll-margin-top: 72px; }
.gs-step h2 { font-size: 20px; line-height: 28px; margin: 0 0 8px; }
.gs-step > p { margin: 0 0 12px; color: var(--fg-muted); }
.gs-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px 32px; }
.gs-do, .gs-dont { min-width: 0; }
.gs-h3 { display: flex; align-items: center; gap: 6px; font-size: 16px; margin: 4px 0; padding-bottom: 4px; border-bottom: 2px solid; }
.gs-h3.good { border-color: var(--success); color: var(--success-text); }
.gs-h3.bad { border-color: var(--danger); color: var(--danger-text); }
.gs .guide-list li { color: var(--fg-muted); }
.gs .guide-list li::before { background: var(--accent); }
.gs .guide-list strong, .gs .guide-list em { color: var(--fg); }
.gs-dont .guide-list li::before { background: var(--danger); }
.gs-more { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.gs-more summary { cursor: pointer; font-size: 14px; color: var(--accent-text); padding: 4px 0; }
.gs-more summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.gs-stuck { border: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.gs-stuck .guide-cta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.gs-stuck .guide-cta .btn { max-width: 100%; white-space: normal; text-align: center; }
@media (max-width: 700px) {
  .gs-cols { grid-template-columns: minmax(0, 1fr); }
  .gs-rail a { font-size: 11px; }
  .gs-rail-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .gs-stuck { padding: 32px 16px; }
}

/* L3: the brand name and the last nav tab are never cut off on a phone or at 1024 px (override of shell.css sizes) */
@media (max-width: 480px) {
  .shell-top.shell-top { gap: 6px; }
  .shell-top .shell-brand { gap: 8px; }
  .shell-top .shell-brand .shell-brand-name { font-size: 14px; }
  .shell-top .shell-actions { gap: 0; }
  .shell-top .shell-actions .shell-iconbtn { width: 30px; }
}
@media (min-width: 768px) and (max-width: 1180px) {
  .shell-top .shell-link { padding: 0 9px; gap: 6px; }
  .shell-top .shell-nav { flex: 1 1 auto; }
  .shell-top .shell-search { width: 40px; padding: 0; justify-content: center; }
  .shell-top .shell-search span, .shell-top .shell-search kbd { display: none; }
}

/* 056: parts of the portal that open once the agreement is signed and the first payment is confirmed. They are shown
   greyed out so the student sees they exist; nothing inside them is clickable. */
.lc-locked, .portal-panel.lc-locked, .fam-card.lc-locked { opacity: 0.62; background: var(--surface-2); border-style: dashed; cursor: not-allowed; user-select: none; }
.lc-locked a, .lc-locked button { pointer-events: none; }
.lc-locked h2, .lc-locked h3 { display: flex; align-items: center; gap: 8px; }
.lc-locked .i-lock { width: 16px; height: 16px; flex: none; color: var(--fg-muted); }
.lc-locked .lock-line { color: var(--fg-muted); font-size: 14px; margin-top: 6px; }
a.lc-locked.shell-link, a.lc-locked.shell-tab { pointer-events: auto; cursor: not-allowed; border-style: none; background: none; }
a.lc-locked.shell-link:hover { color: var(--fg-muted); }
.lock-status { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--surface); padding: 16px 20px; margin: 0 0 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.lock-status .lock-status-text { flex: 1; min-width: 240px; display: grid; gap: 6px; }
.lock-status h2 { font-size: 18px; }
.lock-status ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 15px; }
.lock-status li { display: flex; align-items: center; gap: 8px; }
.lock-status li .lock-mark { width: 16px; height: 16px; border: 2px solid var(--border-strong); flex: none; }
.lock-status li.is-yes .lock-mark { background: var(--success); border-color: var(--success); }
.lock-status .btn { flex: none; }
.lock-staff { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 14px; color: var(--fg-muted); }
.lock-staff.lock-state-on { color: var(--fg); }
.fam-card.lock-status { border-left: 4px solid var(--accent); }
.doc-stats > .lock-status { grid-column: 1 / -1; }
