/* Журнал колледжа — tokens and shared parts of the look; screens.css holds what belongs to one screen.
   Order: fonts, tokens (dark and light), base, layout (sign-in page, student bar, staff shell), components,
   motion. Colours are hex/rgba only: older phone browsers do not understand oklch(). */

/* Fonts: Inter Variable, self-hosted (SIL OFL, see vendor/fonts/OFL.txt). Kyrgyz ң, ө, ү are in Cyrillic Extended. */

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/fonts/inter-cyrillic-ext-wght-normal.woff2") format("woff2-variations"),
    url("../vendor/fonts/inter-cyrillic-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/fonts/inter-cyrillic-wght-normal.woff2") format("woff2-variations"),
    url("../vendor/fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: "Inter Variable";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../vendor/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
    url("../vendor/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Tokens */

:root {
  --font: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Roboto Mono", "Droid Sans Mono", monospace;
  --tracking: -0.011em;
  --tracking-title: -0.025em;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 3rem;

  --radius-card: 12px;
  --radius-control: 10px;
  --radius-inner: 8px;

  --sidebar-w: 16.25rem;
  --topbar-h: 4rem;

  /* Controls on the staff screens (laptop); the sign-in page and the student's phone use larger ones. */
  --control-h: 2.25rem;
  --control-fs: 0.875rem;
  --hint-fs: 0.8125rem;
  --seg-h: 1.875rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080d16;
  --surface: #121824;
  --surface-raised: #18202b;
  --sidebar: #0d141f;
  --muted: #1d2430;
  --secondary: #202938;
  --accent: #253447;
  --nav-hover: rgba(255, 255, 255, 0.04);
  --nav-active: #202938;
  --row-hover: rgba(29, 36, 48, 0.55);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --input-border: rgba(255, 255, 255, 0.12);
  --input-bg: rgba(255, 255, 255, 0.036);
  --text: #ecf3f8;
  --text-muted: #9199a5;

  --primary: #0c84fa;
  --primary-fill: #006de2;
  --primary-fill-hover: #005dd1;
  --on-primary: #fcfcfc;
  --primary-ink: #5fa7ff;
  --primary-wash: rgba(12, 132, 250, 0.15);
  --primary-line: rgba(12, 132, 250, 0.32);
  --ring-soft: rgba(12, 132, 250, 0.35);

  --success: #28bc5e;
  --success-wash: rgba(40, 188, 94, 0.14);
  --success-line: rgba(40, 188, 94, 0.28);
  --warning: #f9b800;
  --warning-wash: rgba(249, 184, 0, 0.14);
  --warning-line: rgba(249, 184, 0, 0.28);
  --danger: #ff5e63;
  --danger-wash: rgba(255, 94, 99, 0.14);
  --danger-line: rgba(255, 94, 99, 0.3);
  --danger-fill: #c2181d;
  --danger-fill-hover: #ac0311;

  --glow: rgba(12, 132, 250, 0.34);
  --topbar-bg: rgba(18, 24, 36, 0.72);
  --seg-track: #1d2430;
  --seg-active: #2b3a50;
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-pop: 0 24px 48px -12px rgba(0, 0, 0, 0.65);
  --shadow-brand: 0 6px 16px -6px rgba(12, 132, 250, 0.65);
  --backdrop: rgba(3, 6, 12, 0.66);

  /* Initials avatars: text colour and a wash of it. */
  --tone-0: #93c7ff; --tone-0-bg: rgba(147, 199, 255, 0.16);
  --tone-1: #8fd89e; --tone-1-bg: rgba(143, 216, 158, 0.16);
  --tone-2: #eeba70; --tone-2-bg: rgba(238, 186, 112, 0.16);
  --tone-3: #ffa6ad; --tone-3-bg: rgba(255, 166, 173, 0.16);
  --tone-4: #cfb4ff; --tone-4-bg: rgba(207, 180, 255, 0.16);
  --tone-5: #63d6f1; --tone-5-bg: rgba(99, 214, 241, 0.16);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f9fcff;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --sidebar: #f5f9fb;
  --muted: #ecf3f8;
  --secondary: #ecf3f8;
  --accent: #e6effc;
  --nav-hover: #ecf3f8;
  --nav-active: #e6effc;
  --row-hover: #f3f7fa;
  --border: #dfe6eb;
  --border-strong: #c9d3da;
  --input-border: #cfd8df;
  --input-bg: #ffffff;
  --text: #0c121a;
  --text-muted: #626975;

  --primary: #0c84fa;
  --primary-fill: #006de2;
  --primary-fill-hover: #005dd1;
  --on-primary: #fcfcfc;
  --primary-ink: #005dd1;
  --primary-wash: rgba(12, 132, 250, 0.1);
  --primary-line: rgba(12, 132, 250, 0.28);
  --ring-soft: rgba(12, 132, 250, 0.3);

  --success: #00792f;
  --success-wash: rgba(40, 188, 94, 0.13);
  --success-line: rgba(0, 121, 47, 0.25);
  --warning: #975800;
  --warning-wash: rgba(249, 184, 0, 0.16);
  --warning-line: rgba(151, 88, 0, 0.25);
  --danger: #c2181d;
  --danger-wash: rgba(255, 94, 99, 0.12);
  --danger-line: rgba(194, 24, 29, 0.25);
  --danger-fill: #c2181d;
  --danger-fill-hover: #ac0311;

  --glow: rgba(12, 132, 250, 0.2);
  --topbar-bg: rgba(255, 255, 255, 0.8);
  --seg-track: #ecf3f8;
  --seg-active: #ffffff;
  --seg-shadow: 0 1px 2px rgba(16, 24, 40, 0.1);
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-pop: 0 24px 48px -12px rgba(16, 24, 40, 0.24);
  --shadow-brand: 0 6px 16px -6px rgba(12, 132, 250, 0.5);
  --backdrop: rgba(15, 23, 42, 0.38);

  --tone-0: #17559b; --tone-0-bg: #daedff;
  --tone-1: #00682a; --tone-1-bg: #d9f3dd;
  --tone-2: #7e4700; --tone-2-bg: #fbe8ce;
  --tone-3: #8f2e3d; --tone-3-bg: #ffe1e3;
  --tone-4: #614092; --tone-4-bg: #efe6ff;
  --tone-5: #006582; --tone-5-bg: #cef3fc;
}

/* Base */

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: var(--tracking);
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }

/* The open list of a <select>. Chrome on Windows paints it with the colours of the options; left alone they took the
   light text of the dark theme on the white of the list, and only the item under the pointer could be read. Every
   option gets the surface and the text of the theme. */
select option,
select optgroup {
  background-color: var(--surface-raised);
  color: var(--text);
}

select option:disabled { color: var(--text-muted); }
button { cursor: pointer; }
a { color: inherit; }
::placeholder { color: var(--text-muted); opacity: 1; }
::selection { background: var(--primary-fill); color: var(--on-primary); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.icon {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
}

.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;
}

.muted { color: var(--text-muted); }

.print-only { display: none; }

.stack {
  display: grid;
  align-content: start;
  gap: var(--space-4);
}

.stack--tight { gap: var(--space-3); }

/* Grid children may shrink below their content: wide tables scroll inside their own frame. */
.stack > *, .content > * { min-width: 0; }

/* Layout: sign-in and password change */

.auth,
.student {
  --control-h: 3rem;
  --control-fs: 1rem;
  --hint-fs: 1rem;
  --seg-h: 2.75rem;
}

.auth {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(40rem 26rem at 50% -6rem, var(--glow), transparent 72%),
    var(--bg);
}

.auth__tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
}

.auth__center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-4) var(--space-8);
}

.auth__center .content {
  width: min(100%, 27rem);
  padding: 0;
}

.auth .brand { font-size: 1.125rem; }

.auth .brand__mark {
  width: 2.5rem;
  height: 2.5rem;
}

@media (min-width: 40rem) {
  .auth__center { padding-top: 6vh; }
}

/* Layout: the student's phone */

.student { min-height: 100vh; }

.student .content {
  max-width: 44rem;
  padding: var(--space-5) var(--space-4) var(--space-8);
}

/* Layout: staff shell — sidebar, top bar, content */

.shell { min-height: 100vh; }

.shell__body {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
}

.content {
  display: grid;
  align-content: start;
  gap: var(--space-6);
  max-width: 80rem;
  margin: 0 auto;
  padding: var(--space-7);
  outline: none;
}

.shell { font-size: 0.875rem; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  background: var(--sidebar);
}

.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  height: var(--topbar-h);
  padding: 0 var(--space-4);
  flex: none;
}

/* Shown only when the sidebar is a drawer (more specific than .icon-button). */
.sidebar__head > .sidebar__close { display: none; }

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
}

.nav-group + .nav-group { margin-top: var(--space-4); }

.nav-group__title {
  display: flex;
  align-items: center;
  height: 2rem;
  padding: 0 var(--space-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.nav-group__list {
  display: grid;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.25rem;
  padding: var(--space-2) 0.625rem;
  border-radius: var(--radius-control);
  color: var(--text);
  text-decoration: none;
  line-height: 1.25;
}

.nav-link .icon { color: var(--text-muted); }

.nav-link:hover { background: var(--nav-hover); }

.nav-link[aria-current="page"] {
  background: var(--nav-active);
  font-weight: 500;
}

.nav-link[aria-current="page"] .icon { color: var(--primary-ink); }

.sidebar__foot {
  display: grid;
  gap: var(--space-3);
  flex: none;
  padding: var(--space-3);
  border-top: 1px solid var(--border);
}

.role-switch {
  display: grid;
  gap: var(--space-2);
  padding: 0 var(--space-1);
}

.role-switch__caption {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

.user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1);
}

.user__text {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.user__name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user__role {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.shell__backdrop { display: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.topbar > .topbar__menu { display: none; }

.topbar__tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  white-space: nowrap;
}

.crumbs__group { color: var(--text-muted); }

.crumbs__sep {
  width: 0.875rem;
  height: 0.875rem;
  color: var(--text-muted);
}

.crumbs__page {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
}

.skip-link {
  position: absolute;
  top: -4rem;
  left: var(--space-3);
  z-index: 60;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-control);
  background: var(--primary-fill);
  color: var(--on-primary);
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus { top: var(--space-3); }

/* Below 900 px the sidebar is a drawer opened from the top bar. Keep in step with WIDE in shell.js. */
@media (max-width: 899.98px) {
  .shell__body { margin-left: 0; }

  .content { padding: var(--space-6) var(--space-4) var(--space-8); }

  .topbar { padding: 0 var(--space-4); }

  .topbar > .topbar__menu { display: inline-grid; }

  .sidebar {
    z-index: 50;
    width: min(var(--sidebar-w), calc(100vw - 3rem));
    box-shadow: var(--shadow-pop);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }

  .sidebar__head > .sidebar__close { display: inline-grid; }

  .shell.is-drawer-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.2s ease;
  }

  .shell.is-drawer-open .shell__backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: var(--backdrop);
  }
}

@media (max-width: 36rem) {
  .crumbs__group, .crumbs__sep { display: none; }
}

/* The student's bar */

.topbar--student {
  padding: 0 var(--space-4);
  gap: var(--space-2);
}

/* Nothing on the student's screens is smaller than 16 px or 44 px to tap. */
.topbar--student .brand { font-size: 1rem; }

.topbar--student .brand__mark {
  width: 2.75rem;
  height: 2.75rem;
}

@media (max-width: 32rem) {
  /* The name stays readable for screen readers; on a narrow phone the mark alone stands for it. */
  .topbar--student .brand__name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Components: brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
  min-height: 2.75rem;
  border-radius: var(--radius-control);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-control);
  background: linear-gradient(135deg, #0c84fa 0%, #00b4f0 100%);
  box-shadow: var(--shadow-brand);
  color: #ffffff;
}

.brand__mark .icon {
  width: 55%;
  height: 55%;
}

/* Components: segmented control (languages, roles, directory choice) */

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-control);
  background: var(--seg-track);
}

.segmented--wrap { flex-wrap: wrap; }

.segmented__button {
  min-width: var(--seg-h);
  min-height: var(--seg-h);
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-inner);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--control-fs);
  font-weight: 500;
  line-height: 1.2;
}

.segmented__button:hover { color: var(--text); }

.segmented__button[aria-pressed="true"] {
  background: var(--seg-active);
  box-shadow: var(--seg-shadow);
  color: var(--text);
}

.segmented__button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.langs .segmented__button {
  padding: 0 var(--space-2);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Components: buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-h);
  padding: var(--space-1) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: var(--control-fs);
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.button .icon {
  width: 1rem;
  height: 1rem;
}

.button--primary {
  background: var(--primary-fill);
  color: var(--on-primary);
}

.button--primary:hover { background: var(--primary-fill-hover); }

.button--secondary {
  border-color: var(--input-border);
  background: var(--input-bg);
  color: var(--text);
}

.button--secondary:hover { background: var(--secondary); }

.button--danger {
  background: var(--danger-fill);
  color: #ffffff;
}

.button--danger:hover { background: var(--danger-fill-hover); }

.button--wide { width: 100%; }

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button--primary:disabled:hover { background: var(--primary-fill); }

.button.is-busy { cursor: progress; }

.button.is-busy::before,
.loading::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-muted);
}

.icon-button:hover {
  background: var(--secondary);
  color: var(--text);
}

.icon-button--outline {
  border-color: var(--input-border);
  background: var(--input-bg);
  color: var(--text);
}

/* Components: fields */

.form {
  display: grid;
  gap: var(--space-4);
}

.field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.field__label {
  font-size: var(--control-fs);
  font-weight: 500;
  line-height: 1.3;
}

.field__hint {
  color: var(--text-muted);
  font-size: var(--hint-fs);
  line-height: 1.4;
}

.field__control { position: relative; }

.field__input {
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-control);
  background: var(--input-bg);
  font-size: var(--control-fs);
  line-height: 1.3;
}

select.field__input { padding-right: var(--space-2); }

.field__input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--ring-soft);
}

.field__input[aria-invalid="true"] { border-color: var(--danger); }

.field__input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-wash); }

.field__input--mono { font-family: var(--font-mono); letter-spacing: 0; }

.field__input--reveal { padding-right: 7rem; }

.field__reveal {
  position: absolute;
  top: 2px;
  right: 2px;
  bottom: 2px;
  min-width: 2.75rem;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-inner);
  background: transparent;
  color: var(--primary-ink);
  font-size: var(--control-fs);
  font-weight: 500;
}

.field__reveal:hover { background: var(--primary-wash); }

.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--danger);
  font-size: var(--hint-fs);
  font-weight: 500;
  line-height: 1.4;
}

.field__error .icon {
  width: 1em;
  height: 1em;
  margin-top: 0.2em;
}

.search {
  position: relative;
  min-width: 0;
}

.search__icon {
  position: absolute;
  top: 50%;
  left: var(--space-3);
  width: 1rem;
  height: 1rem;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search__input { padding-left: 2.25rem; }

.fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.fieldset > legend {
  margin-bottom: var(--space-2);
  padding: 0;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.25rem;
}

.check__input {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  accent-color: var(--primary-fill);
  cursor: pointer;
}

.check__input[aria-invalid="true"] {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}

.check__label { cursor: pointer; }

.check__input--switch {
  position: relative;
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 999px;
  background: var(--accent);
  appearance: none;
  transition: background-color 0.15s;
}

:root[data-theme="light"] .check__input--switch { background: var(--border-strong); }

.check__input--switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(1.375rem - 6px);
  height: calc(1.375rem - 6px);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.check__input--switch:checked,
:root[data-theme="light"] .check__input--switch:checked { background: var(--primary-fill); }

.check__input--switch:checked::before { transform: translateX(1.125rem); }

/* Components: cards, headings, sections */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.card__title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-head__text { min-width: 0; }

.page-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: var(--tracking-title);
  line-height: 1.2;
}

.page-lead {
  margin-top: var(--space-1);
  color: var(--text-muted);
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media (max-width: 36rem) {
  .page-title { font-size: 1.5rem; }
}

.section {
  display: grid;
  gap: var(--space-3);
}

.section__title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Components: messages, badges, avatars, empty states */

.notes:empty { display: none; }

.note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid;
  border-radius: var(--radius-control);
  line-height: 1.45;
}

.note__icon {
  width: 1.125em;
  height: 1.125em;
  margin-top: 0.1em;
}

.note--error { border-color: var(--danger-line); background: var(--danger-wash); color: var(--danger); }
.note--warning { border-color: var(--warning-line); background: var(--warning-wash); color: var(--warning); }
.note--success { border-color: var(--success-line); background: var(--success-wash); color: var(--success); }
.note--info { border-color: var(--primary-line); background: var(--primary-wash); color: var(--primary-ink); }

.badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  vertical-align: middle;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.375rem;
  padding: 0.0625rem var(--space-2);
  border: 1px solid;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  font-variant-numeric: normal;
  white-space: nowrap;
}

.badge__dot {
  flex: none;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: currentColor;
}

.badge--neutral { border-color: var(--border); background: var(--muted); color: var(--text-muted); }
.badge--primary { border-color: var(--primary-line); background: var(--primary-wash); color: var(--primary-ink); }
.badge--success { border-color: var(--success-line); background: var(--success-wash); color: var(--success); }
.badge--warning { border-color: var(--warning-line); background: var(--warning-wash); color: var(--warning); }

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--tone-0-bg);
  color: var(--tone-0);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  user-select: none;
}

.avatar--lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.125rem;
}

.avatar[data-tone="1"] { background: var(--tone-1-bg); color: var(--tone-1); }
.avatar[data-tone="2"] { background: var(--tone-2-bg); color: var(--tone-2); }
.avatar[data-tone="3"] { background: var(--tone-3-bg); color: var(--tone-3); }
.avatar[data-tone="4"] { background: var(--tone-4-bg); color: var(--tone-4); }
.avatar[data-tone="5"] { background: var(--tone-5-bg); color: var(--tone-5); }

.empty {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-card);
  color: var(--text-muted);
}

.empty__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--muted);
}

.empty__body {
  display: grid;
  justify-items: start;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

.empty__title {
  color: var(--text);
  font-weight: 600;
}

.loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
}

/* Components: tables */

.table-scroll {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
}

.table-scroll--framed {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.table__caption {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  text-align: left;
}

.table th,
.table td {
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.table th {
  height: 2.5rem;
  padding-block: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.table th:first-child,
.table td:first-child { padding-left: var(--space-4); }

.table th:last-child,
.table td:last-child { padding-right: var(--space-4); }

.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr:hover td { background-color: var(--row-hover); }

.table .table__num {
  width: 3rem;
  color: var(--text-muted);
  text-align: right;
}

.table .num { text-align: right; }

.table .table__actions {
  width: 1%;
  padding-block: var(--space-1);
  text-align: right;
  white-space: nowrap;
}

.table .table__nothing {
  padding: var(--space-7);
  color: var(--text-muted);
  text-align: center;
}

.table__label { font-weight: 500; }

.row-action {
  width: 2rem;
  height: 2rem;
}

.row-action .icon {
  width: 1rem;
  height: 1rem;
}

.row-action--danger:hover {
  background: var(--danger-wash);
  color: var(--danger);
}

.table tr.is-inactive td { color: var(--text-muted); }

.table tr.is-inactive .person__name { color: var(--text-muted); }

/* The record saved last: a primary bar on its first cell and a wash that fades out. */
.table tr.is-fresh td:first-child { box-shadow: inset 3px 0 0 var(--primary); }

/* Components: dialogs */

.dialog {
  width: min(calc(100% - 2rem), 32rem);
  max-width: none;
  max-height: calc(100% - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}

.dialog::backdrop { background: rgba(3, 6, 12, 0.6); }

:root[data-theme="light"] .dialog::backdrop { background: rgba(15, 23, 42, 0.38); }

.dialog--confirm { width: min(calc(100% - 2rem), 28rem); }

.dialog__body {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.dialog__kicker {
  margin-bottom: calc(-1 * var(--space-3));
  color: var(--text-muted);
  font-size: var(--hint-fs);
  font-weight: 500;
}

.dialog__title {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.dialog__note {
  color: var(--text-muted);
  font-size: var(--hint-fs);
}

.dialog__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* Motion: a screen fades in when it replaces another; nothing moves when motion is unwanted. */

@media (prefers-reduced-motion: no-preference) {
  .content.is-entering { animation: appear 0.2s ease-out both; }

  .table tr.is-fresh td { animation: fresh 2.4s ease-out both; }
}

@keyframes appear {
  from { opacity: 0; }
}

@keyframes fresh {
  from { background-color: var(--primary-wash); }
  to { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .button.is-busy::before,
  .loading::before { animation: none; opacity: 0.6; }

  .sidebar,
  .shell.is-drawer-open .sidebar,
  .check__input--switch,
  .check__input--switch::before { transition: none; }
}
