/* ATLAS PSU - ui2-polish.css
   UI2 layer 3 of 3. Owner: Arthur (lane H, branch ui2/arthur).
   Loads last, after ui2-foundation.css and ui2-pages.css.
   Rule: every selector starts with html.ui2 (dark: html.ui2[data-theme="dark"]).
   Colors come from tokens, font sizes in rem. No gradient, no shadow, no side-accent border.
   Guarded by tests/test_ui2_layers.py. */

/* S1 dark (A-05): night pass. Tokens only. Legacy dark hacks in main-style.css are neutralized here, never edited. */

/* Charts: status marks and series use the teal chart palette from main-style.css (--chart-ok, --chart-warn, --chart-bad,
   --chart-s1 to s10), light and night. Charts re-read --chart-* on theme change. Capacity bars keep the --cap-* tokens. */

/* Legacy phone hero card (main-style.css 4008 and 4110): the night primary-600 is a light orange, so white text
   on it fell to 2.5 to 1. Night uses the brand fill with the on-accent text (5.1 to 1). */
@media (max-width: 767px) {
  html.ui2[data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) { background: var(--brand); border-color: var(--brand); }
  html.ui2[data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-label,
  html.ui2[data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-sub,
  html.ui2[data-theme="dark"] .stats-row:not(.fs-stats) .stat-card:nth-child(3) .stat-value { color: var(--on-accent); }
}

/* Active labels and links use --brand-text at night (D-9), not the legacy primary-600. */
html.ui2[data-theme="dark"] .side-nav .nav-item.active,
html.ui2[data-theme="dark"] .side-nav .side-sub-item.active,
html.ui2[data-theme="dark"] .bn-item.active,
html.ui2[data-theme="dark"] .bottom-nav .bn-item.bn-timetable.is-current { color: var(--brand-text); }
html.ui2[data-theme="dark"] .bn-item.active::before { background: var(--brand-text); }
html.ui2[data-theme="dark"] .auth-forgot { color: var(--brand-text); }

/* Legacy hard-coded night colors for delete and the status chip: take the status tokens so the Figma look wins. */
html.ui2[data-theme="dark"] .btn-delete,
html.ui2[data-theme="dark"] .btn-delete:hover { color: var(--ui-danger-fg); }
html.ui2[data-theme="dark"] .status-chip { color: var(--ui-success-fg); }

/* Night surfaces for the new components: borders keep 3:1, selected rows and disclosures stay on the night ramp. */
html.ui2[data-theme="dark"] .info-tip-pop,
html.ui2[data-theme="dark"] .menu-list { background: var(--bg-surface-2); border-color: var(--border-input); color: var(--text-primary); }
html.ui2[data-theme="dark"] .row-selected { background: var(--bg-surface-3); }
html.ui2[data-theme="dark"] .step-strip > li[aria-current="step"] { border-color: var(--brand-text); }
html.ui2[data-theme="dark"] .disclosure,
html.ui2[data-theme="dark"] .btn-tertiary { color: var(--brand-text); }

/* S5 app pages (A-01): Account, Help, About inside the sidebar shell. Scoped to body.has-shell so the pages
   that still use the old app layout (application settings, notifications, appearance) are not touched. */
html.ui2 body.page-app.has-shell .app-nav { display: none; }
@media (min-width: 901px) {
  html.ui2 body.page-app.has-shell .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: start;
    gap: 0;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  html.ui2 body.page-app.has-shell .app-main { min-height: 100vh; min-height: 100dvh; }
  html.ui2 body.page-app.has-shell .app-back { margin-right: var(--space-2); }
  html.ui2 body.page-app.has-shell .app-top { padding-left: var(--space-6); }
  html.ui2 body.page-app.has-shell .app-title {
    position: static;
    left: auto;
    transform: none;
    max-width: none;
    text-align: left;
    font-size: var(--text-xl);
    line-height: var(--lh-tight);
    letter-spacing: -0.015em;
  }
  html.ui2 body.page-app.has-shell .app-content {
    width: 100%;
    max-width: var(--page-max);   /* U6-02: was 76rem, left aligned */
    margin-inline: auto;
    padding: var(--space-6) var(--page-pad);
  }
  /* U6-02: chairperson and faculty scroll inside .panel, so the scrollbar must stay at the window edge. The column is
     centered with symmetric padding: the box between the paddings is --page-max minus both --page-pad, centered. */
  html.ui2 .panels-container > .panel {
    padding-inline: max(var(--page-pad), calc((100% - var(--page-max)) / 2 + var(--page-pad)));
  }
  html.ui2 body.page-app.has-shell .acct-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
  }
  html.ui2 body.page-app.has-shell .app-content-help {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    align-items: start;
  }
  html.ui2 body.page-app.has-shell .app-content-help .help-lead,
  html.ui2 body.page-app.has-shell .app-content-help .help-terms { grid-column: 1 / -1; }
  html.ui2 body.page-app.has-shell .app-content-about { max-width: 52rem; margin-inline: auto; }
}
@media (max-width: 900px) {
  html.ui2 body.page-app.has-shell .app-content { padding: var(--space-4); }
  html.ui2 body.page-app.has-shell .acct-grid { display: flex; flex-direction: column; gap: var(--space-4); }
}
html.ui2 body.page-app.has-shell .acct-main,
html.ui2 body.page-app.has-shell .acct-side { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
html.ui2 body.page-app.has-shell .app-card { border-radius: var(--radius-lg); }
html.ui2 body.page-app.has-shell .app-card h2 { color: var(--text-primary); font-weight: var(--fw-semibold); }
html.ui2 body.page-app.has-shell .app-row .app-value { overflow-wrap: anywhere; }
html.ui2 body.page-app.has-shell .app-row-text span { color: var(--text-secondary); }
html.ui2 body.page-app.has-shell .app-note { color: var(--text-secondary); }
html.ui2 body.page-app.has-shell .about-facts .app-actions { margin-top: var(--space-3); }

/* Help: numbered steps with a small badge, terms list */
html.ui2 body.page-app.has-shell .help-steps { list-style: none; padding: 0; margin: 0; counter-reset: helpstep; }
html.ui2 body.page-app.has-shell .help-steps li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
  counter-increment: helpstep;
  color: var(--text-primary);
}
html.ui2 body.page-app.has-shell .help-steps li::before {
  content: counter(helpstep);
  display: inline-flex;
  flex: 0 0 1.5rem;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.1rem;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  background: var(--bg-surface-3);
  border: 1px solid var(--border-default);
  border-radius: 50%;
}
html.ui2 body.page-app.has-shell .help-lead { color: var(--text-secondary); }
html.ui2 body.page-app.has-shell .help-defs { display: grid; gap: var(--space-3); margin: 0; }
html.ui2 body.page-app.has-shell .help-defs dt { font-weight: var(--fw-semibold); color: var(--text-primary); }
html.ui2 body.page-app.has-shell .help-defs dd { margin: 0; color: var(--text-secondary); }
@media (min-width: 901px) {
  html.ui2 body.page-app.has-shell .help-defs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* S5 appearance (A-03): app/appearance.html. Same shell and body.set-page rules as the two settings pages.
   The theme previews depict fixed themes, so their colors are fixed values and do not follow the active theme. */
html.ui2 body.set-page #scheduleCard[hidden] { display: block; }
html.ui2 body.set-page .app-time-row { flex-wrap: wrap; }
html.ui2 body.set-page .app-time-row .app-field { flex: 1 1 8rem; min-width: 0; }
html.ui2 body.set-page .app-time-row .app-input { width: 100%; min-width: 0; }
html.ui2 body.set-page .theme-grid { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--space-3); }
html.ui2 body.set-page .theme-card {
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg-surface);
  border: 2px solid var(--border-input);
  box-shadow:none;
  min-height: 44px;
}
html.ui2 body.set-page .theme-card:hover { background: var(--bg-surface-3); }
html.ui2 body.set-page .theme-card[aria-checked="true"] { border-color: var(--clr-primary-500); box-shadow:none; background: var(--bg-surface-3); }
html.ui2 body.set-page .theme-card:focus-visible,
html.ui2 body.set-page .opt-cards button:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }
html.ui2 body.set-page .theme-card small { color: var(--text-secondary); font-size: var(--text-sm); }
html.ui2 body.set-page .theme-line { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); width: 100%; }
html.ui2 body.set-page .theme-line strong { font-weight: var(--fw-semibold); font-size: var(--text-base); }
html.ui2 body.set-page .theme-state { display: none; align-items: center; gap: 0.25rem; font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-primary); }
html.ui2 body.set-page .theme-card[aria-checked="true"] .theme-state { display: inline-flex; }
html.ui2 body.set-page .theme-state::before {
  content: "";
  width: 0.75rem; height: 0.75rem; background: currentColor;
  -webkit-mask: var(--ic-check) center / contain no-repeat; mask: var(--ic-check) center / contain no-repeat;
}

/* Tiny page previews, CSS only */
html.ui2 body.set-page .theme-swatch {
  --pv-l-bg: #fffefb; --pv-l-ln: #564c43; --pv-l-ac: #c0440a;
  --pv-d-bg: #17120f; --pv-d-ln: #a99d90; --pv-d-ac: #e8763f;
  display: flex; height: 3.5rem; margin-bottom: 0; border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden;
}
html.ui2 body.set-page .theme-swatch i { flex: none; display: block; border-radius: 2px; }
html.ui2 body.set-page .pv-light { --pv-bg: var(--pv-l-bg); --pv-ln: var(--pv-l-ln); --pv-ac: var(--pv-l-ac); }
html.ui2 body.set-page .pv-dark { --pv-bg: var(--pv-d-bg); --pv-ln: var(--pv-d-ln); --pv-ac: var(--pv-d-ac); }
html.ui2 body.set-page .theme-swatch.pv-light,
html.ui2 body.set-page .theme-swatch.pv-dark,
html.ui2 body.set-page .pv-half { background: var(--pv-bg); }
html.ui2 body.set-page .theme-swatch.pv-light,
html.ui2 body.set-page .theme-swatch.pv-dark,
html.ui2 body.set-page .pv-half { flex-direction: column; gap: 0.25rem; padding: 0.5rem; }
html.ui2 body.set-page .pv-half { display: flex; flex: 1; min-width: 0; }
html.ui2 body.set-page .pv-bar { width: 60%; height: 0.3rem; background: var(--pv-ln); }
html.ui2 body.set-page .pv-line { width: 40%; height: 0.25rem; background: var(--pv-ln); }
html.ui2 body.set-page .pv-btn { width: 2.25rem; height: 0.875rem; margin-top: auto; background: var(--pv-ac); }
html.ui2 body.set-page .theme-split .pv-line { display: none; }

/* Text size and Density: the existing data-seg buttons drawn as option cards. The button text stays the plain label;
   the sample, size and description are decoration drawn by CSS. */
html.ui2 body.set-page .opt-cards { display: grid; gap: var(--space-3); padding: 0; background: none; border-radius: 0; margin-top: var(--space-3); }
html.ui2 body.set-page .opt-text { grid-template-columns: repeat(4, minmax(0, 1fr)); }
html.ui2 body.set-page .opt-density { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) {
  html.ui2 body.set-page .opt-text { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html.ui2 body.set-page .opt-density { grid-template-columns: minmax(0, 1fr); }
}
html.ui2 body.set-page .opt-cards button {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 0.25rem;
  min-width: 0; min-height: max(4.5rem, 44px); padding: var(--space-3); white-space: normal; overflow-wrap: anywhere;
  text-align: left; font-size: var(--text-base); font-weight: 400; line-height: 1.3;
  color: var(--text-primary); background: var(--bg-surface);
  border: 2px solid var(--border-input); border-radius: var(--radius-lg); box-shadow:none;
}
html.ui2 body.set-page .opt-cards button:hover { background: var(--bg-surface-3); }
html.ui2 body.set-page .opt-cards button[aria-pressed="true"] {
  color: var(--text-primary); background: var(--bg-surface-3); border-color: var(--clr-primary-500); box-shadow:none; font-weight: var(--fw-semibold);
}
html.ui2 body.set-page .opt-text button::before { content: "Aa" / ""; order: -1; font-size: 1rem; font-weight: var(--fw-semibold); line-height: 1.1; }
html.ui2 body.set-page .opt-text button[data-value="small"]::before { font-size: 0.9rem; }
html.ui2 body.set-page .opt-text button[data-value="large"]::before { font-size: 1.15rem; }
html.ui2 body.set-page .opt-text button[data-value="xlarge"]::before { font-size: 1.35rem; }
html.ui2 body.set-page .opt-text button::after { order: 1; font-size: var(--text-sm); font-weight: 400; color: var(--text-secondary); }
html.ui2 body.set-page .opt-text button[data-value="small"]::after { content: "13 px" / ""; }
html.ui2 body.set-page .opt-text button[data-value="medium"]::after { content: "14 px" / ""; }
html.ui2 body.set-page .opt-text button[data-value="large"]::after { content: "16 px" / ""; }
html.ui2 body.set-page .opt-text button[data-value="xlarge"]::after { content: "19 px" / ""; }

html.ui2 body.set-page .opt-density button { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--space-3); row-gap: 0.125rem; align-items: start; }
html.ui2 body.set-page .opt-density button::before {
  content: ""; grid-column: 1; grid-row: 1 / span 2; box-sizing: border-box;
  width: 1.125rem; height: 1.125rem; margin-top: 0.0625rem; border: 2px solid var(--border-input); border-radius: 50%; background: var(--bg-surface);
}
html.ui2 body.set-page .opt-density button[aria-pressed="true"]::before { border: 0.3125rem solid var(--clr-primary-500); }
html.ui2 body.set-page .opt-density button::after { grid-column: 2; grid-row: 2; font-size: var(--text-sm); font-weight: 400; color: var(--text-secondary); }
html.ui2 body.set-page .opt-density button[data-value="comfortable"]::after { content: "Default spacing and control height" / ""; }
html.ui2 body.set-page .opt-density button[data-value="compact"]::after { content: "Reduced row height and spacing" / ""; }

/* Department accent: the swatch takes the department palette from the data-dept tokens in main-style.css */
html.ui2 body.set-page .dept-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
html.ui2 body.set-page .dept-chip {
  display: inline-flex; align-items: center; gap: var(--space-2); min-height: 2.25rem; padding: 0 var(--space-3);
  background: var(--bg-surface); border: 1px solid var(--border-input); border-radius: var(--radius-md); font-size: var(--text-sm);
}
html.ui2 body.set-page .dept-chip strong { font-weight: var(--fw-semibold); }
html.ui2 body.set-page .dept-chip span { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
html.ui2 body.set-page .dept-dot { display: block; width: 0.875rem; height: 0.875rem; border-radius: 3px; background: var(--clr-primary-600); }

/* S5 settings (A-02): Application settings and Notifications. body.set-page is on both pages; the shell, the
   acct-grid columns and the card look come from the has-shell rules above. */
html.ui2 body.set-page .set-lead { margin: 0; color: var(--text-secondary); }
html.ui2 body.set-page .set-note { margin-top: 0; }
html.ui2 body.set-page .set-tabs { margin: 0; }
@media (min-width: 901px) {
  html.ui2 body.set-page .set-narrow { max-width: 48rem; }
  html.ui2 body.set-page .m-period-change { display: none; }
}

/* Switch: the state is a word (On or Off) beside the control, never colour alone. The word is decoration for the
   eye only (empty alt text), the checkbox itself already tells assistive technology its state. */
html.ui2 body.set-page label.app-row:has(> input.app-switch) { min-height: max(3.5rem, var(--ctl-min)); }
html.ui2 body.set-page label.app-row > input.app-switch { order: 2; }
html.ui2 body.set-page label.app-row:has(> input.app-switch)::after {
  content: "Off";
  content: "Off" / "";
  order: 1;
  flex: 0 0 auto;
  min-width: 1.75rem;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}
html.ui2 body.set-page label.app-row:has(> input.app-switch:checked)::after {
  content: "On";
  content: "On" / "";
  color: var(--text-primary);
}
html.ui2 body.set-page input[type="checkbox"].app-switch { background-color: var(--border-input); }
html.ui2 body.set-page input[type="checkbox"].app-switch:checked { background-color: var(--clr-primary-500); }
html.ui2 body.set-page input[type="checkbox"].app-switch:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }

/* One filled button on the page: Save period. The other save and apply buttons are outlined. */
html.ui2 body.set-page .app-btn:not(.app-btn-primary):not(.app-btn-danger) { border-color: var(--border-input); }
html.ui2 body.set-page .app-btn-primary:not(#periodSave) {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-input);
}
html.ui2 body.set-page .app-btn-primary:not(#periodSave):hover { background: var(--bg-surface-3); }
html.ui2 body.set-page a.app-btn { text-decoration: none; }

/* Solver: the Advanced disclosure is a native details element (closed by default, Enter or Space opens it) */
html.ui2 body.set-page .set-advanced { margin-top: var(--space-4); border-top: 1px solid var(--border-default); }
html.ui2 body.set-page .set-advanced > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--ctl-min);
  cursor: pointer;
  list-style: none;
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
}
html.ui2 body.set-page .set-advanced > summary::-webkit-details-marker { display: none; }
html.ui2 body.set-page .set-advanced > summary::after {
  content: "Show";
  content: "Show" / "";
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}
html.ui2 body.set-page .set-advanced[open] > summary::after { content: "Hide"; content: "Hide" / ""; }
html.ui2 body.set-page .set-advanced:not([open]):has(.app-error:not([hidden])) > summary::after {
  content: "Check the values";
  content: "Check the values" / "";
  color: var(--bad);
}
html.ui2 body.set-page .set-advanced > summary:focus-visible { outline: var(--focus-outline); outline-offset: 2px; }
html.ui2 body.set-page .set-advanced-body { margin-top: var(--space-2); }

/* Audit log: the latest 5 rows show first, the View all switch shows the rest of the page */
html.ui2 body.set-page .audit-table { width: 100%; border-collapse: collapse; font-size: var(--fs-body); }
/* U5-11: one data table look for app and admin pages: same padding, text size, header and row line as html.ui2 body.admin-page main table */
html.ui2 body.set-page .audit-table th { color: var(--text-primary); font-weight: var(--fw-semibold); font-size: var(--text-xs); padding: var(--sp-2); background: var(--bg-surface-2); border-bottom: 1px solid var(--border-subtle); }
html.ui2 body.set-page .audit-table td { padding: var(--sp-3) var(--sp-2); font-size: var(--text-xs); border-top: 0; border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); }
html.ui2 body.set-page #auditTable tbody tr:nth-child(n+6) { display: none; }
html.ui2 body.set-page #auditCard:has(#auditViewAll:checked) #auditTable tbody tr:nth-child(n+6) { display: table-row; }

/* A-04 sweep 1: long sidebar sub-item labels (Room Capacity Analytics) wrap instead of being clipped by the sidebar edge */
/* U6-01: reversed. Every sidebar label is ONE row (nowrap, ellipsis, title tooltip); the nested rows give back padding and icon gap first. */
html.ui2 .side-nav .side-sub-item { white-space: nowrap; flex-wrap: nowrap; padding-top: var(--sp-1); padding-bottom: var(--sp-1); padding-left: 0.875rem; padding-right: 0.25rem; gap: 0.375rem; overflow: hidden; min-width: 0; }
html.ui2 .side-nav .nav-item,
html.ui2 .side-nav .nav-item > span:not(.nav-ic),
html.ui2 .side-nav .side-sub-item > span:not(.nav-ic),
html.ui2 .side-nav .side-section-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* U6-01 item 9: the Inputs and Reports row icon and chevron never disappear. Not reproduced in the sandbox; the one real
   cause found is the U5-02 flex-wrap on these rows, which let the chevron drop to a second line and be clipped. The rows
   are nowrap now, and the icon and chevron are pinned visible here (the chevron only rotates; the rail hides it on purpose). */
html.ui2 #sideGroupInputs > .nav-item > .nav-ic,
html.ui2 #sideGroupReports > .nav-item > .nav-ic { display: block; opacity: 1; visibility: visible; flex: 0 0 20px; }
html.ui2 #sideGroupInputs > .nav-item::after,
html.ui2 #sideGroupReports > .nav-item::after { display: block; opacity: 1; visibility: visible; flex: 0 0 1rem; }
@media (min-width: 901px) {
  html.ui2[data-side="collapsed"] .side-nav:not(.is-peek) #sideGroupInputs > .nav-item::after,
  html.ui2[data-side="collapsed"] .side-nav:not(.is-peek) #sideGroupReports > .nav-item::after { display: none; }
}

/* A-04 sweep 1: one filled button per view. Subjects and Service requests share a view, so Add service request is the outlined one */
html.ui2 #addServiceRequest { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-input); }
html.ui2 #addServiceRequest:hover { background: var(--bg-surface-2); border-color: var(--text-secondary); color: var(--text-primary); }

/* S2 department (A-06, D-6): the brand stays rust for every department. Only when the Department accent switch is on
   does app-core.js set data-dept, and then the UI2 brand tokens take the department steps. Fills use the 500 step with
   --on-accent text, accent colored text uses the 600 step (dark: the light 600 tint) so it keeps 4.5 to 1 on both themes.
   Status colors, Lecture teal, Lab orange and the capacity tokens are not touched. */
html.ui2[data-dept] {
  --brand: var(--clr-primary-500);
  --brand-text: var(--clr-primary-600);
  --brand-hover: var(--clr-primary-700);
  --focus-ring-color: var(--clr-primary-500);
}
html.ui2[data-dept][data-theme="dark"] {
  --brand-text: var(--clr-primary-600);
  --brand-hover: var(--btn-hover);
  --focus-ring-color: var(--clr-primary-600);
}

/* S3 density and text size (A-07). Spacing already follows the compact scale (--sp-* aliases --space-*). Compact only
   shortens controls to the laptop floor of 40 px (the legacy compact value is 34 px); phones keep 44 px in both densities. */
@media (min-width: 901px) {
  html.ui2[data-density="compact"] { --ctl-h: 2.5rem; --ctl-min: max(2.5rem, 40px); }
}
@media (max-width: 900px) {
  html.ui2[data-density="compact"] { --ctl-min: max(2.75rem, 44px); }
}
html.ui2[data-density="compact"] .card { padding: var(--sp-4); }

/* Extra large text (root 19 or 20 px): long labels wrap or truncate instead of overflowing the viewport. */
html.ui2[data-text="xlarge"] .btn-hero,
html.ui2[data-text="large"] .btn-hero { max-width: 100%; height: auto; white-space: normal; overflow-wrap: anywhere; text-align: center; }
html.ui2[data-text="xlarge"] .disclosure,
html.ui2[data-text="xlarge"] .btn-tertiary { max-width: 100%; height: auto; white-space: normal; overflow-wrap: anywhere; text-align: left; }
html.ui2[data-text="xlarge"] .step-strip > li { min-width: 0; overflow-wrap: anywhere; }
html.ui2[data-text="xlarge"] .step-strip-name { font-size: var(--fs-small); }
@media (max-width: 480px) {
  html.ui2[data-text="xlarge"] .step-strip,
  html.ui2[data-text="large"] .step-strip { grid-template-columns: minmax(0, 1fr); }
  html.ui2[data-text="xlarge"] .bottom-nav .bn-item { min-width: 0; padding-left: 0; padding-right: 0; }
  html.ui2[data-text="xlarge"] .bottom-nav .bn-item .bn-label { font-size: 0.625rem; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; }
}
@media (min-width: 901px) {
  html.ui2[data-text="xlarge"] .side-nav .nav-item,
  html.ui2[data-text="xlarge"] .side-nav .side-sub-item { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
}

/* S4 motion */

/* S4 (A-08): motion. Interaction tier is always on and at most 300 ms. Showpiece tier needs html[data-motion="show"]
   and stops at 800 ms. Only transform and opacity animate. Nothing decorative. */
html.ui2 {
  --dur-fast: 120ms; --dur-base: 200ms; --dur-show: 600ms; --dur-show-long: 800ms;
  --ease-ui: cubic-bezier(0.4, 0, 0.2, 1); --ease-standard: cubic-bezier(0.4, 0, 0.2, 1); --ease-emphasized: cubic-bezier(0.3, 0, 0, 1);
}
@keyframes ui2-panel-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ui2-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes ui2-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ui2-pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes ui2-grow { from { transform: scaleX(0); } to { transform: none; } }

/* U4-01: section entrance inside a panel (desktop, class added by section-nav.js) and the panel fade used when view transitions are missing */
@keyframes ui4-sec-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes ui4-fade { from { opacity: 0; } to { opacity: 1; } }
html.ui2[data-motion="show"] .ui4-sec-in { animation: ui4-sec-in 200ms var(--ease-ui) both; }
html.ui2[data-motion="show"] .panel.ui4-fade-in { animation: ui4-fade 200ms var(--ease-ui) both; }
@media (prefers-reduced-motion: reduce) { html.ui2 .ui4-sec-in, html.ui2 .panel.ui4-fade-in { animation: none; } }

/* Interaction tier */
@media (min-width: 901px) { html.ui2 .panel.active { animation: ui2-panel-in var(--dur-base) var(--ease-ui); } }
html.ui2 .modal-overlay, html.ui2 .auth-modal { animation: ui2-fade-in var(--dur-base) var(--ease-standard); }
html.ui2 .btn:not(:disabled):not([aria-busy="true"]) { transition: transform var(--dur-fast) var(--ease-standard); }
html.ui2 .btn:not(:disabled):active { transform: scale(0.98); }

/* Showpiece tier */
html.ui2[data-motion="show"] .ui2-rise { animation: ui2-rise var(--dur-show) var(--ease-emphasized) both; animation-delay: var(--ui2-delay, 0ms); }
html.ui2[data-motion="show"] .ui2-slide { animation: ui2-rise var(--dur-show) var(--ease-emphasized) both; }
html.ui2[data-motion="show"] .ui2-pop { animation: ui2-fade-in 300ms var(--ease-standard) both; animation-delay: var(--ui2-delay, 0ms); }
html.ui2[data-motion="show"] .cap-stack-ok, html.ui2[data-motion="show"] .cap-stack-warn {
  transform-origin: left center; animation: ui2-grow var(--dur-show) var(--ease-standard) both;
}
html.ui2 .ui2-count-overlay { position: absolute; margin: 0; pointer-events: none; }
html.ui2 .ui2-counting { visibility: hidden; }

/* Off: the OS setting, the Reduce motion setting, and a click or key that finishes everything now */
@media (prefers-reduced-motion: reduce) {
  html.ui2 *, html.ui2 *::before, html.ui2 *::after { animation: none !important; transition: none !important; }
  html.ui2 .ui2-counting { visibility: visible; }
  html.ui2 .ui2-count-overlay { display: none; }
}
html.ui2[data-motion="reduce"] *, html.ui2[data-motion="reduce"] *::before, html.ui2[data-motion="reduce"] *::after,
html.ui2[data-motion="off"] *, html.ui2[data-motion="off"] *::before, html.ui2[data-motion="off"] *::after { animation: none !important; transition: none !important; }
/* A click or key finishes the showpiece animations now; it never touches the app's own transitions */
html.ui2.ui2-skip .ui2-rise, html.ui2.ui2-skip .ui2-slide, html.ui2.ui2-skip .ui2-pop, html.ui2.ui2-skip .cap-stack-ok, html.ui2.ui2-skip .cap-stack-warn,
html.ui2.ui2-skip #gaProgressBar::after { animation: none !important; }
html.ui2[data-motion="reduce"] .ui2-counting, html.ui2.ui2-skip .ui2-counting { visibility: visible; }
html.ui2[data-motion="reduce"] .ui2-count-overlay, html.ui2.ui2-skip .ui2-count-overlay { display: none; }
html.ui2 .stat-card { position: relative; }

/* S4 (A-08) additions: tab underline slide, indeterminate run bar, coverage figure */
html.ui2 .tab-strip > a, html.ui2 .tab-strip > button, html.ui2 .tab-strip > [role="tab"] { position: relative; }
html.ui2 .tab-strip > [aria-selected="true"], html.ui2 .tab-strip > [aria-current="page"], html.ui2 .tab-strip > .is-active { border-bottom-color: transparent; }
html.ui2 .tab-strip > a::after, html.ui2 .tab-strip > button::after, html.ui2 .tab-strip > [role="tab"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--brand);
  transform: scaleX(0); transform-origin: left center; transition: transform var(--dur-base) var(--ease-standard);
}
html.ui2 .tab-strip > [aria-selected="true"]::after, html.ui2 .tab-strip > [aria-current="page"]::after, html.ui2 .tab-strip > .is-active::after { transform: scaleX(1); }
@keyframes ui2-indet { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
html.ui2 #gaProgressBar { position: relative; }
html.ui2[data-motion="show"] #gaProgressBar.ui2-indet::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 30%; background: var(--clr-primary-500);
  border-radius: var(--radius-sm); animation: ui2-indet var(--dur-show-long) linear infinite;
}
html.ui2 #resultCoverage { position: relative; }

/* S6 accessibility (A-09): skip link and main target. The link is off screen until it takes focus. */
html.ui2 .skip-link { position: fixed; top: var(--space-2); left: var(--space-2); z-index: 20100; padding: var(--space-3) var(--space-4); min-height: 44px; display: inline-flex; align-items: center;
  background: var(--bg-surface); color: var(--text-link); border: 1px solid var(--text-link); border-radius: var(--radius-md); font-weight: 600; text-decoration: underline;
  transform: translateY(-300%); }
html.ui2 .skip-link:focus, html.ui2 .skip-link:focus-visible { transform: none; outline: 2px solid var(--brand); outline-offset: 2px; }
html.ui2 main[tabindex="-1"]:focus { outline: none; }
/* A-09: a closed dialog fades out and then leaves the tab order (it was only transparent, so Tab landed in it) */
html.ui2 .modal-overlay { transition: opacity 0.18s ease, visibility 0s linear 0.18s; }
html.ui2 .modal-overlay:not(.open) { visibility: hidden; }
html.ui2 .modal-overlay.open { visibility: visible; transition-delay: 0s; }

/* A-09 follow-up: the generating screen shows a small unlabelled bar set, not the labelled load chart (it scrolled with many professors) */
html.ui2 #gaLoading .mini-chart-wrapper { display: none; }
html.ui2 .ga-mini { display: flex; align-items: flex-end; gap: var(--space-1); width: 11rem; height: 6.5rem; padding: var(--space-2); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm); background: var(--bg-surface-2); overflow: hidden; }
html.ui2 .ga-mini-bar { flex: 1 1 0; min-width: 0; height: 0; background: var(--clr-primary-500); border-radius: var(--radius-sm) var(--radius-sm) 0 0; transition: height 0.4s var(--ease-standard); }

/* A-10 extra request: while a run is going the page shows only the loading card and Saved runs. The Prepare a run card
   and the Optimization Result area (result card and the approval note) are hidden only while #gaLoading is shown (its
   hidden class is toggled by initRunGA), so they return by themselves when the run ends, fails or is cancelled. No ids,
   classes or markup changed; things are hidden, never removed. The card has the same width and look as Prepare a run. */
html.ui2 .run-hero:has(#gaLoading:not(.hidden)) .workload-controls-card { display: none; }
html.ui2 .run-hero:has(#gaLoading:not(.hidden)) ~ .workload-grid { display: none; }
html.ui2 .run-hero:has(#gaLoading:not(.hidden)) {
  display: flex; align-items: center; justify-content: center;
  min-height: min(60dvh, 30rem); margin: var(--sp-5) 0 var(--sp-7);
}
html.ui2 .run-hero .ga-loading:not(.hidden) {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--sp-5);
  width: 100%; max-width: 40rem; margin: 0 auto; padding: var(--sp-6);
}
html.ui2 .run-hero .ga-loading .loader-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-4); }
html.ui2 .run-hero .ga-loading .loader-box { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); text-align: center; min-width: 0; }
html.ui2 .run-hero .ga-loading .loader-box .spinner { width: 3rem; height: 3rem; border-width: 0.25rem; }
html.ui2 .run-hero .ga-loading .loader-box p { margin: 0; color: var(--text-secondary); font-size: var(--fs-body); line-height: var(--lh-body); overflow-wrap: anywhere; }
html.ui2 .run-hero .ga-loading .loader-box p:first-of-type { color: var(--text-primary); font-size: var(--fs-section); font-weight: var(--fw-section); line-height: var(--lh-tight); }
html.ui2 .run-hero .ga-loading .ga-mini { width: min(100%, 11rem); height: 6.5rem; }
html.ui2 .run-hero .ga-loading #gaProgressContainer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--sp-3); width: 100%; max-width: none; }
html.ui2 .run-hero .ga-loading #gaProgressBar { flex: 1 1 10rem; min-width: 0; }
html.ui2 .run-hero .ga-loading #cancelRunBtn { flex: 0 0 auto; min-height: max(var(--ctl-min), 2.75rem, 44px); }
@media (max-width: 900px) {
  html.ui2 .run-hero .ga-loading #gaProgressContainer { flex-direction: column; align-items: stretch; }
  html.ui2 .run-hero .ga-loading #gaProgressBar { flex: 0 0 auto; }
  html.ui2 .run-hero .ga-loading #cancelRunBtn { width: 100%; }
}

/* A-10 extra request: flagship motion and loading everywhere. Interaction items are 300 ms or less and always on; the
   showpiece items need html[data-motion="show"]. Only transform and opacity animate. Everything is off under
   prefers-reduced-motion and the Reduce motion setting (the S4 rules above), and a click or key finishes it. */
@keyframes ui2-bar-run { from { transform: scaleX(0.04); } to { transform: scaleX(0.82); } }
@keyframes ui2-veil-out { from { opacity: 0.6; } to { opacity: 0; } }
@keyframes ui2-pulse { from { opacity: 0.45; } to { opacity: 1; } }
@keyframes ui2-toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Page loading bar: runs while a page loads, while a request is slower than 180 ms, and while leaving for another page */
html.ui2 .ui2-bar { position: fixed; top: 0; left: 0; right: 0; height: 0.25rem; z-index: 20020; background: var(--brand);
  transform: scaleX(0); transform-origin: left center; opacity: 0; pointer-events: none; }
html.ui2 .ui2-bar.is-on { opacity: 1; transform: scaleX(0.6); animation: ui2-bar-run var(--dur-show-long) var(--ease-standard) both; }
html.ui2 .ui2-bar.is-done { opacity: 0; transform: scaleX(1); transition: transform var(--dur-base) var(--ease-standard), opacity var(--dur-base) var(--ease-standard) 120ms; }

/* Page transition: the next page fades in, the current page dims while it is left */
html.ui2 body { animation: ui2-fade-in var(--dur-base) var(--ease-standard); }
html.ui2.ui2-leaving body { opacity: 0.55; transition: opacity var(--dur-base) var(--ease-standard); }

/* Showpiece: panels rise in child by child (JS reveal), so the whole panel does not also fade */
html.ui2[data-motion="show"] .panel.active { animation: none; }

/* Theme change veil (showpiece) */
html.ui2 .ui2-veil { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20015; background: var(--bg-canvas); opacity: 0;
  pointer-events: none; animation: ui2-veil-out 300ms var(--ease-standard) both; }

/* Loading placeholders pulse (opacity only) wherever a skeleton shows */
html.ui2 .ui-skeleton span, html.ui2 .ui-skeleton .ui-skel { animation: ui2-pulse 800ms ease-in-out infinite alternate; }
html.ui2 .ui-skeleton span:nth-child(2) { animation-delay: 120ms; }
html.ui2 .ui-skeleton span:nth-child(3) { animation-delay: 240ms; }
html.ui2 [aria-busy="true"] { cursor: progress; }
/* U5-07: admin buttons show the same busy spinner as the chair hero button (ui2-spin is defined in ui2-foundation.css) */
html.ui2 .admin-page .btn[aria-busy="true"]::before {
  content: ""; display: inline-block; flex-shrink: 0; width: 0.875rem; height: 0.875rem; box-sizing: border-box; margin-right: var(--sp-2);
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; vertical-align: -0.125em;
  animation: ui2-spin 0.8s linear infinite;
}
html.ui2[data-motion="reduce"] .admin-page .btn[aria-busy="true"]::before { animation: none; }
@media (prefers-reduced-motion: reduce) { html.ui2 .admin-page .btn[aria-busy="true"]::before { animation: none; } }

/* Toasts rise in; hero and cards respond to a pointer (interaction tier) */
/* The toast element always exists and is hidden by opacity until .show, so it is never animated with a fill mode. */
html.ui2 .toast-notif.show { animation: ui2-toast-in var(--dur-base) var(--ease-standard); }
@media (hover: hover) {
  html.ui2 .btn-hero:not(:disabled) { transition: transform var(--dur-base) var(--ease-standard); }
  html.ui2 .btn-hero:not(:disabled):hover { transform: translateY(-2px); }
  html.ui2 .btn-hero:not(:disabled):active { transform: scale(0.98); }
  html.ui2 .stat-card { transition: transform var(--dur-base) var(--ease-standard); }
  html.ui2 .stat-card:hover { transform: translateY(-2px); }
}

/* Hardening: the run screen swap also works without :has(), through the ui2-running class set by ui2-motion.js */
html.ui2.ui2-running .run-hero .workload-controls-card { display: none; }
html.ui2.ui2-running .run-hero ~ .workload-grid { display: none; }
/* Hardening: finishing early (click or key) never leaves a veil or a half dimmed page */
html.ui2.ui2-skip .ui2-veil { display: none; }

/* UI3 P-01: the period shows once on desktop, in the top bar chip (#navPeriod) */
@media (min-width: 901px) {
  html.ui2 #dashboardSemContext,
  html.ui2 #optimizationSemContext,
  html.ui2 #reportsSemContext,
  html.ui2 .result-period { display: none; }
}

/* UI3 P-03: the department shows once on desktop, in the top bar */
@media (min-width: 901px) {
  html.ui2 #deptBanner { display: none; }
  html.ui2 .home-top:not(:has(.home-hint:not([hidden]))) { display: none; }
}

/* UI3 P-05: login centered (D-17). Labels, inputs and error text stay left aligned. */
html.ui2 .auth-shell { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
html.ui2 .auth-card { display: flex; flex-direction: column; }
html.ui2 .auth-card > .auth-head { margin-top: auto; justify-content: center; }
html.ui2 .auth-card > .auth-step { margin-bottom: auto; }
html.ui2 .auth-step h1,
html.ui2 .auth-forgot,
html.ui2 .auth-fine,
html.ui2 .auth-divider,
html.ui2 .auth-foot { text-align: center; }
html.ui2 .auth-privacy-details summary { justify-content: center; gap: var(--sp-3); }
html.ui2 .auth-privacy-details summary::after { margin-left: 0; }
html.ui2 .auth-privacy-details[open] summary { margin-bottom: var(--sp-2); }
@media (max-width: 600px) {
  html.ui2 .auth-card { padding-top: calc(var(--sp-6) + env(safe-area-inset-top, 0px)); }
}

/* UI3 P-07: Reports room capacity legend as chips with one info-tip */
html.ui2 #repSecCapacity .cap-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ui-sp-2); }

/* UI3 P-07: the faint section line under the page title repeats the tab and the section heading. Hidden visually, kept for screen readers (live region) */
html.ui2 .page-header .nav-section-now {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; flex: 0 0 auto;
}

/* UI3 P-08: a click-to-open info-tip has no data-tip text, so the legacy hover bubble (::after) was an empty black box. Never draw it for these tips */
html.ui2 .info-tip:not([data-tip])::after,
html.ui2 .info-tip:not([data-tip]):hover::after,
html.ui2 .info-tip:not([data-tip]):focus::after,
html.ui2 .info-tip:not([data-tip]):focus-within::after { display: none; content: none; }

/* UI3 P-09: faculty leave hint */
html.ui2 .fs-leave-hint { margin-bottom: var(--space-2); font-size: var(--text-base); color: var(--text-muted); }
html.ui2 .fs-leave-hint summary { cursor: pointer; }

/* UI3 P-03 (faculty): the department shows once on desktop, in the top bar (#topDept) */
@media (min-width: 901px) {
  html.ui2 .dept-banner { display: none; }
}

/* U4-04: app pages (Account, Help, About, Settings, Notifications, Appearance) show the same top right cluster as
   the dashboard: A.Y. chip and profile menu (built by assets/js/app-shell.js addTopCluster). Phones keep the old header. */
html.ui2 .app-top-right { display: none; }
@media (min-width: 901px) {
  html.ui2 body.page-app.has-shell .app-top {
    min-height: var(--nav-h);
    gap: var(--sp-4);
    padding-right: var(--gutter);
  }
  html.ui2 body.page-app.has-shell .app-top-right {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    margin-left: auto;
    min-width: 0;
  }
}

/* U4-09: numbers sit under their headers. The base rule left aligns every cap-details header; numeric headers carry
   .txt-center in the markup, and the same alignment is applied to their cells. The Room column stays left aligned. */
html.ui2 .cap-details-table thead th.txt-center,
html.ui2 .cap-details-table tbody td.txt-center { text-align: center; }
html.ui2 .cap-details-table tbody td.txt-center { font-variant-numeric: tabular-nums; }

/* UI4 undo toast (U4-10): a stack at the bottom left with a message, Undo, close and a countdown bar. Colors come from the
   --undo-* tokens in ui2-foundation.css. z-index sits above the sidebar and below dialogs (2147483200) and .toast-notif. */
@keyframes ui4-undo-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes ui4-undo-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px); } }
html.ui2 .undo-stack {
  position: fixed;
  z-index: 2147483300;
  left: var(--space-4);
  bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(26rem, calc(100vw - 2rem));
  pointer-events: none;
}
@media (min-width: 901px) {
  html.ui2 .undo-stack { left: calc(var(--side-w) + var(--space-4)); }
  html.ui2[data-side="collapsed"] .undo-stack { left: calc(var(--side-w-c) + var(--space-4)); }
}
@media (max-width: 900px) {
  html.ui2 .undo-stack { bottom: calc(var(--bottom-nav-h, 3.5rem) + var(--space-3)); }
}
html.ui2 .undo-toast {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  background: var(--undo-bg);
  color: var(--undo-fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-control);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  overflow: hidden;
  pointer-events: auto;
  animation: ui4-undo-in 240ms var(--ease-ui) both;
}
html.ui2 .undo-toast.is-leaving { animation: ui4-undo-out 160ms var(--ease-ui) both; pointer-events: none; }
html.ui2 .undo-toast .undo-msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
html.ui2 .undo-toast .undo-btn {
  flex: 0 0 auto;
  min-height: 2rem;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--undo-action);
  font: inherit;
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-ui);
}
html.ui2 .undo-toast .undo-btn:hover { background: color-mix(in srgb, var(--undo-fg) 14%, transparent); }
html.ui2 .undo-toast .undo-btn:focus-visible,
html.ui2 .undo-toast .undo-close:focus-visible { outline: 2px solid var(--undo-action); outline-offset: 2px; }
html.ui2 .undo-toast .undo-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--undo-fg);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-ui);
}
html.ui2 .undo-toast .undo-close:hover { background: color-mix(in srgb, var(--undo-fg) 14%, transparent); }
html.ui2 .undo-toast .undo-close-ic { position: relative; width: 0.875rem; height: 0.875rem; }
html.ui2 .undo-toast .undo-close-ic::before,
html.ui2 .undo-toast .undo-close-ic::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transform: translate(-50%, -50%) rotate(45deg);
}
html.ui2 .undo-toast .undo-close-ic::after { transform: translate(-50%, -50%) rotate(-45deg); }
html.ui2 .undo-toast .undo-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: color-mix(in srgb, var(--undo-fg) 18%, transparent);
}
html.ui2 .undo-toast .undo-bar { display: block; height: 100%; width: 100%; background: var(--undo-bar); }
html.ui2 .undo-toast.is-paused .undo-bar { opacity: 0.6; }
@media (prefers-reduced-motion: reduce) {
  html.ui2 .undo-toast, html.ui2 .undo-toast.is-leaving { animation: none; }
  html.ui2 .undo-toast .undo-btn, html.ui2 .undo-toast .undo-close { transition: none; }
}
html.ui2[data-motion="reduce"] .undo-toast,
html.ui2[data-motion="reduce"] .undo-toast.is-leaving { animation: none; }
html.ui2[data-motion="reduce"] .undo-toast .undo-btn,
html.ui2[data-motion="reduce"] .undo-toast .undo-close { transition: none; }

/* UI4 skeleton (U4-11): shapes for slow loads. Colours are tokens. The style rules allow no colour ramps, so the shimmer
   is a wave of solid colour: every block eases between a base and a lighter step, a little later than its neighbour to the
   left or above (the --i variable set by shared-ui.js), which reads as a light sweeping across the placeholder. */
html.ui2 {
  --skel-base: var(--bg-surface-3);
  --skel-hi: var(--bg-surface-2);
}
html.ui2[data-theme="dark"] { --skel-hi: var(--border-subtle); }
@keyframes ui4-skel-wave { 0%, 100% { background-color: var(--skel-base); } 45% { background-color: var(--skel-hi); } }

html.ui2 .ui-skel,
html.ui2 .ui-skeleton span {
  display: block; background-color: var(--skel-base); border-radius: var(--r-badge);
  animation: ui4-skel-wave 800ms var(--ease-ui, ease-in-out) infinite;
  animation-delay: calc(var(--i, 0) * 50ms - 800ms);
}
html.ui2 .ui-skel { height: 0.875rem; }
html.ui2 .ui-skeleton span:nth-child(2) { animation-delay: -750ms; }
html.ui2 .ui-skeleton span:nth-child(3) { animation-delay: -700ms; }

html.ui2 .is-skeleton > :not(.ui-skel-layer) { visibility: hidden; }
html.ui2 .ui-skel-layer {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 3; box-sizing: border-box; overflow: hidden;
  padding: var(--sp-3); border-radius: inherit; background: inherit; pointer-events: auto; cursor: progress;
}
html.ui2 .ui-skel-shape { display: flex; flex-direction: column; gap: var(--sp-3); }
html.ui2 .ui-skel-row { display: flex; align-items: center; gap: var(--sp-3); }
html.ui2 .ui-skel-trow { display: grid; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; }
html.ui2 .ui-skel-trow.is-head { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border-subtle); }
html.ui2 .ui-skel-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--sp-4); }
html.ui2 .ui-skel-card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--border-subtle); border-radius: var(--r-card); }
html.ui2 .ui-skel.is-big { height: 2rem; }
html.ui2 .ui-skel-week { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-2); }
html.ui2 .ui-skel.is-cell { height: 2.5rem; }
html.ui2 .ui-skel-bars { display: flex; align-items: flex-end; gap: var(--sp-2); height: 10rem; }
html.ui2 .ui-skel.is-bar { flex: 1 1 0; height: 50%; border-radius: var(--r-badge) var(--r-badge) 0 0; }

@media (prefers-reduced-motion: reduce) {
  html.ui2 .ui-skel, html.ui2 .ui-skeleton span { animation: none; }
}
html.ui2[data-motion="reduce"] .ui-skel,
html.ui2[data-motion="reduce"] .ui-skeleton span { animation: none; }


/* U5-01 sticky sidebar (D-U3). On document scrolling pages (app pages and all admin pages, which carry body.page-app.has-shell
   and add .admin-page) the grid used to stretch the rail to the content height, so sticky had no room and the rail scrolled away.
   The rail is pinned to the top of the window at window height; the collapsed hover peek is fixed so it cannot scroll away either.
   Chairperson and faculty scroll inside .panel, their shell is already window high, so they need nothing here. */
@media (min-width: 901px) {
  html.ui2 body.page-app.has-shell .side-nav,
  html.ui2 body.admin-page .side-nav {
    align-self: start;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
  }
  html.ui2[data-side="collapsed"] body.page-app.has-shell .side-nav.is-peek,
  html.ui2[data-side="collapsed"] body.admin-page .side-nav.is-peek { position: fixed; top: 0; }
}

/* U5-11: phone top bar title uses the same h1 size, line height and tracking as the chairperson title */
@media (max-width: 900px) {
  html.ui2 body.page-app.has-shell .app-title { font-size: var(--text-xl); line-height: var(--lh-tight); letter-spacing: -0.015em; }
}

