/* ---------- Tokens ---------- */
:root {
  --navy: #173b60;
  --navy-600: #102d4b;
  --navy-100: #edf2f7;
  --accent: #245b91;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --border: #607d9b;
  --control-border: #345b80;
  --text: #202832;
  --muted: #56616f;
  --danger: #b42318;
  --danger-bg: #fee2e2;
  --warn: #925700;
  --warn-bg: #fef3c7;
  --ok: #237346;
  --ok-bg: #dcfce7;
  --info: #245b91;
  --info-bg: #edf2f7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 30, 40, .035);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; justify-content: center; padding: 10px 16px; border-radius: 6px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; line-height: 1;
  transition: background .15s, box-shadow .15s, transform .15s ease-out;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--control-border); }
.btn-secondary:hover { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--navy-100); color: var(--navy); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.input, .select {
  width: 100%; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--control-border); background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.row { display: flex; gap: 12px; align-items: center; }
.row > * { flex: 1; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s;
}
.switch .slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--navy); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch input:focus-visible + .slider { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
#dow-chips { margin-bottom: 12px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip:hover:not(.active) { background: var(--navy-100); color: var(--navy); }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth-hero {
  background: var(--navy);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-hero::after {
  content: ""; position: absolute; width: 80px; height: 4px;
  background: #a9bfd3; left: 56px; bottom: 56px;
}
.auth-hero h1 { font-size: clamp(32px, 3.3vw, 48px); line-height: 1.15; max-width: 460px; margin-top: 24px; }
.auth-hero p { color: rgba(255,255,255,.8); margin-top: 16px; max-width: 420px; font-size: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 6px; background: #fff; color: var(--navy);
  display: grid; place-items: center; font-weight: 800;
}
.source-dot { width: 8px; height: 8px; border-radius: 50%; }
.auth-panel { background: var(--surface); display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 26px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 28px; }
.auth-footer { margin-top: 20px; text-align: center; color: var(--muted); font-size: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Sign in: full-window desktop layout and stacked mobile introduction. */
.auth-login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: 48px 28px;
  background: radial-gradient(ellipse at top left, #e2ebf4, transparent 65%), #f3f5f8;
}
.login-shell {
  width: 100%; max-width: 1040px; display: grid; grid-template-columns: 1fr 1fr;
  border: 1px solid #dce4ec; border-radius: 24px; overflow: hidden;
  background: #fff; box-shadow: 0 24px 80px -32px rgba(16, 45, 75, .3);
}
.login-intro {
  display: flex; flex-direction: column; padding: 40px; color: #fff;
  background: radial-gradient(ellipse at bottom left, #285d84, transparent 75%), var(--navy-600);
}
.login-intro .brand { font-size: 23px; gap: 12px; }
.login-intro .brand-mark { width: 40px; height: 40px; border-radius: 11px; font-size: 22px; }
.login-intro-copy { margin: 36px 0 28px; }
/* The dashboard illustration sits under the intro copy; it fades in after
   the rest of the page (see the page-enter rules near the end). */
.login-art { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; flex: none; filter: drop-shadow(0 22px 28px rgba(0, 0, 0, .45)); }
.login-intro h1 { margin: 14px 0 20px; font-size: clamp(30px, 3vw, 40px); line-height: 1.15; letter-spacing: -.04em; }
.login-description { color: #d5e3ef; font-size: 15px; line-height: 1.75; }
.canvas-dot { background: #ff9994; }
.ls-dot { background: #84c7ff; }
/* "Supports" list: plain words with a coloured dot, nothing that looks clickable */
.login-supports { margin-top: 22px; display: flex; align-items: baseline; gap: 14px; }
.login-supports-label { color: #b5d5ec; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.login-supports ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.login-supports li { display: flex; align-items: center; gap: 9px; color: #d5e3ef; font-size: 14px; }
.auth-login .auth-panel { padding: 48px 44px; min-width: 0; }
.auth-login .auth-card h2 { font-size: 28px; letter-spacing: -.035em; }
.auth-login .auth-card .sub { font-size: 14px; margin-bottom: 28px; }
.auth-login .field { margin-bottom: 18px; }
.auth-login .input { min-height: 48px; font-size: 16px; border-color: #a6b7c8; border-radius: 9px; }
.login-forgot { font-size: 12px; }
.login-remember { margin-bottom: 20px; }
.login-remember label { display: flex; align-items: center; gap: 9px; min-height: 28px; font-size: 13px; color: var(--muted); cursor: pointer; }
.login-remember input { width: 17px; height: 17px; margin: 0; }
.auth-login .btn { min-height: 48px; border-radius: 9px; }
.auth-login .btn-secondary { border-color: #c7d3df; color: var(--navy); }
.auth-login .divider { margin: 20px 0; }
.auth-login .divider::before, .auth-login .divider::after { background: #dce4ec; }
.auth-login .auth-footer { font-size: 12px; margin-top: 24px; }
@media (min-width: 761px) {
  .auth-login { padding: 0; background: #fff; align-items: stretch; }
  /* The shell is exactly one screen tall, and the illustration shrinks to
     whatever is left under the intro copy, so a short laptop screen never
     has to scroll. */
  .login-shell {
    max-width: none; height: 100vh; height: 100dvh; grid-template-rows: minmax(0, 1fr);
    /* minmax(0, …) keeps the split fixed: the illustration's intrinsic width
       must not widen the blue column once it appears */
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); border: 0; border-radius: 0; box-shadow: none;
  }
  .login-intro { --intro-pad: clamp(32px, 4.5vw, 80px); padding: var(--intro-pad); min-height: 0; }
  /* Centred in the space under the copy, and allowed to bleed half the
     column padding on each side so it reads larger than the text block. */
  .login-art {
    flex: 1 1 auto; min-height: 0; align-self: center;
    width: calc(100% + var(--intro-pad)); max-width: 760px;
    margin: 0 calc(var(--intro-pad) * -0.5) calc(var(--intro-pad) * -0.5);
    object-fit: contain; object-position: center;
  }
  /* Short laptop screens: a tighter heading and paddings leave room for the illustration */
  @media (max-height: 840px) {
    .login-intro { --intro-pad: clamp(28px, 3vw, 48px); }
    .login-intro-copy { padding: 14px 0 10px; }
    .login-intro h1 { margin: 10px 0 14px; font-size: clamp(28px, 2.8vw, 42px); }
    .login-description { font-size: 15px; line-height: 1.6; }
    .login-supports { margin-top: 14px; }
  }
  .login-intro .brand { font-size: 26px; }
  .login-intro .brand-mark { width: 44px; height: 44px; }
  .login-intro-copy { margin: 0; padding: 28px 0 20px; max-width: 600px; }
  .login-intro h1 { font-size: clamp(32px, 3.6vw, 60px); }
  .login-description { max-width: 500px; font-size: clamp(15px, 1.2vw, 18px); }
  /* The page itself never scrolls: the entrance animations slide the page
     and the illustration down 32px, which would flash a scrollbar and nudge
     the column divider. A viewport too short for the form scrolls the form
     panel instead. */
  body:has(.auth-login) { overflow: hidden; }
  .auth-login .auth-panel { padding: 48px clamp(32px, 5vw, 96px); min-height: 0; overflow-y: auto; }
  .auth-login .auth-card { max-width: 440px; margin: auto; }
  .auth-login .auth-card h2 { font-size: 34px; }
}
@media (max-width: 760px) {
  .auth-login { padding: 12px 20px; }
  .login-shell { max-width: 480px; grid-template-columns: minmax(0, 1fr); border-radius: 20px; }
  .login-intro { padding: 18px 24px; }
  .login-intro-copy { margin: 12px 0 0; }
  .login-intro h1 { font-size: 24px; margin: 0 0 8px; }
  .login-description { font-size: 13px; line-height: 1.5; }
  .login-supports { margin-top: 10px; gap: 10px; }
  .login-supports ul { flex-direction: row; gap: 14px; }
  .auth-login .auth-panel { padding: 18px 24px; min-height: auto; }
  .auth-login .auth-card h2 { font-size: 23px; margin-bottom: 14px; }
  .auth-login .auth-card .sub, .auth-login .auth-footer { display: none; }
  .auth-login .field { gap: 4px; margin-bottom: 12px; }
  .auth-login .input, .auth-login .btn { min-height: 44px; }
  .login-remember { margin-bottom: 12px; }
  .auth-login .divider { margin: 12px 0; }
}
@media (max-width: 480px) {
  .auth-login { padding: 0; display: block; background: #fff; }
  .login-art { display: none; }
  .login-shell { max-width: none; border: 0; border-radius: 0; box-shadow: none; }
  .login-intro { padding: 16px max(20px, env(safe-area-inset-right)) 16px max(20px, env(safe-area-inset-left)); }
  .login-intro .brand { font-size: 20px; }
  .login-intro .brand-mark { width: 34px; height: 34px; border-radius: 9px; font-size: 19px; }
  .login-intro-copy { margin-top: 12px; }
  .login-intro h1 { font-size: 24px; }
  .auth-login .auth-panel { padding: 18px 20px max(16px, env(safe-area-inset-bottom)); }
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 22px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: var(--navy); padding: 0 8px 22px; }
.sidebar .brand-mark { background: var(--navy); color: #fff; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 6px;
  color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a svg { width: 20px; height: 20px; }
.nav a:hover { background: var(--navy-100); color: var(--navy); }
.nav a.active { background: var(--navy-100); color: var(--navy); box-shadow: inset 3px 0 0 var(--navy); }
.sidebar-bottom { margin-top: auto; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 6px;
  border: 1px solid var(--border);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy-100); color: var(--navy);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.user-chip .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Sits just under the Sync button, with clear space before the user chip */
.sync-note { font-size: 11px; color: var(--muted); padding: 2px 12px 14px; line-height: 1.5; }
.sync-note .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 4px; vertical-align: middle; }
.sync-note .dot.off { background: #cbd5e1; }
.sync-note .dot.bad { background: var(--danger); }
.sync-note a { text-decoration: underline; }

.main { padding: 40px 40px 64px; max-width: 1400px; width: 100%; min-width: 0; margin-inline: auto; }
/* The dashboard reveals its content after the initial data load. */
.main.is-loading > * { visibility: hidden; }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-header h1 { font-size: 30px; letter-spacing: -.035em; line-height: 1.2; }
.page-header .sub { color: var(--muted); margin-top: 4px; }
.page-header #today-line { color: #334155; font-size: 16px; font-weight: 500; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-header h2, .card-header h3 { font-size: 16px; }
.settings-grid .card-header h3 { font-size: 20px; }
.card-header .sub { color: var(--muted); font-size: 13px; }

/* Stat widgets */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(0, auto); gap: 12px 16px; margin-bottom: 16px; }
.stat {
  display: flex; flex-direction: column; gap: 10px; cursor: pointer; text-decoration: none; color: inherit;
  transition: transform .12s, box-shadow .12s;
}
.stat:hover { border-color: var(--control-border); background: #fafbfc; text-decoration: none; }
.stat .label { font-size: 13px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stat .label .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.stat .label .ico svg { width: 15px; height: 15px; }
.stat .value { font-size: 34px; font-weight: 700; line-height: 1; }
.stat .foot { font-size: 13px; font-weight: 500; color: #334155; }
.stat.danger .ico { background: var(--danger-bg); color: var(--danger); }
.stat.warn .ico { background: var(--warn-bg); color: var(--warn); }
.stat.info .ico { background: var(--info-bg); color: var(--info); }
.stat.ok .ico { background: var(--ok-bg); color: var(--ok); }
.stat.danger .value { color: var(--danger); }



.tag {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; background: var(--navy-100); color: var(--navy);
}
.tag.type { background: #f1f5f9; color: #475569; }
.tag.canvas { background: #dbeafe; color: #1e40af; }
.tag.ls { background: #dbeafe; color: #1d4ed8; }
button.tag { border: 0; font-family: inherit; line-height: 1.3; }
.tag.clickable { cursor: pointer; transition: filter .12s, box-shadow .12s; }
.tag.clickable:hover { filter: brightness(.92); box-shadow: 0 0 0 2px rgba(15,23,42,.08); }
.tag.link { gap: 4px; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; cursor: pointer; }
.tag.link:hover { text-decoration-style: solid; filter: brightness(.92); }
.tag.link svg { width: 11px; height: 11px; }

/* Inline notes on each card */

/* Detail modal */
.modal.modal-wide { max-width: 700px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; padding: 14px 16px; background: var(--bg); border-radius: 8px; }
.detail-grid .k { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-grid .v { font-weight: 600; margin-top: 3px; font-size: 14px; }
textarea.input { resize: vertical; line-height: 1.5; }

/* Filter bar */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg); border-radius: 8px; margin-bottom: 14px; }
.filter-bar .label { font-size: 13px; color: var(--muted); font-weight: 600; }
.filter-bar .select { width: auto; padding: 7px 10px; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 11px; border-radius: 999px;
  background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 600;
}
.filter-chip.type { background: #475569; }
.filter-chip button {
  border: 0; background: rgba(255,255,255,.2); color: #fff; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; padding: 0;
}
.filter-chip button:hover { background: rgba(255,255,255,.4); }
.filter-chip button svg { width: 10px; height: 10px; }
.filter-count { font-size: 13px; color: var(--muted); margin-left: auto; }

/* Sidebar sync */
.sidebar-bottom #sync-btn { margin-bottom: 4px; }
.syncing svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--border); border-radius: 8px; }

/* ---------- Calendar ---------- */
.cal-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-head h3 { font-size: 18px; }
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 0; text-transform: uppercase; letter-spacing: .04em; }
.cal-day {
  min-height: 84px; border: 1px solid var(--border); border-radius: 6px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; background: var(--surface); transition: background .12s, border-color .12s;
}
.cal-day:hover { background: #f8fafc; border-color: var(--navy); }
.cal-day.muted { background: transparent; border-color: transparent; color: var(--muted); cursor: default; }
.cal-day.muted:hover { background: transparent; }
.cal-day .n { font-size: 13px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .n { background: var(--navy); color: #fff; }
.cal-day.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.cal-day .dots { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; align-items: center; }
.cal-day .dots span { width: 11px; height: 11px; border-radius: 50%; }
.cal-day .dots .more { font-size: 10px; color: var(--muted); font-weight: 600; width: auto; height: auto; border-radius: 0; }
.day-panel .day-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.day-panel .day-nav h3 { font-size: 16px; }
.day-panel .day-nav .sub { font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-size: 13px; font-weight: 600; color: var(--navy); box-shadow: var(--shadow); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* ---------- Assignments page ---------- */
.class-grid { display: flex; flex-direction: column; gap: 16px; }
.class-card .class-title { display: flex; align-items: center; gap: 12px; }
.class-card .swatch { width: 12px; height: 34px; border-radius: 4px; }
.class-card .code { font-weight: 700; font-size: 16px; }
.class-card .class-code { font-weight: 700; }
.class-card .cname { font-size: 13px; color: var(--muted); }
.class-actions { display: flex; gap: 8px; align-items: center; }
.class-actions .add-assignment-btn { font-weight: 500; }
#add-class-btn { background: #fff; border-color: var(--border); color: var(--navy); }
#add-class-btn:hover { background: #f8fafc; }
.class-body { margin-top: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 820px; }
.settings-actions { max-width: 820px; margin-top: 18px; display: flex; justify-content: flex-start; }
.canvas-token-note { display: block; margin-top: 8px; }
.setting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 16px 0; border-top: 1px solid var(--border); }
.setting-row:first-of-type { border-top: 0; }
.setting-row .info { flex: 1; }
.setting-row .info .t { font-weight: 600; }
.setting-row .info .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.setting-row .control { flex: none; display: flex; align-items: center; gap: 10px; }
.setting-row .control .input, .setting-row .control .select { width: auto; }
.callout {
  margin-top: 12px; padding: 14px 16px; border-radius: 8px; background: var(--info-bg); color: #1e3a8a; font-size: 13.5px;
  display: flex; gap: 12px; align-items: flex-start;
}
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.callout strong { font-weight: 700; }
.timeline { display: flex; align-items: center; gap: 0; margin-top: 14px; }
.timeline .seg { height: 10px; flex: 1; border-radius: 4px; position: relative; }
.timeline .seg.count { background: var(--accent); }
.timeline .seg.dnd { background: #cbd5e1; background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.7) 4px 8px); }
.timeline-labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; z-index: 50;
}
.modal-backdrop { padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { width: 100%; max-width: 460px; max-height: calc(100dvh - 40px); overflow-y: auto; background: var(--surface); border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.onboarding-modal { max-width: 560px; }
.onboarding-modal.onboarding-wide { max-width: 940px; }
.onboarding-modal.onboarding-class-editor { max-width: 460px; }
.onboarding-modal.onboarding-wide.onboarding-class-editor { max-width: 940px; }
.onboarding-kicker { color: var(--navy); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 8px; }
.onboarding-modal h3 { margin-bottom: 12px; }
.onboarding-body { color: var(--muted); line-height: 1.55; }
.onboarding-body p { margin: 0 0 12px; }
.onboarding-body strong { color: var(--text); }
.onboarding-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; border-top:1px solid var(--border); margin-top:18px; padding-top:14px; }
.onboarding-actions { display:flex; justify-content:flex-end; gap:8px; flex-wrap:wrap; }
.onboarding-form { display:grid; gap:9px; margin-top:14px; }
.onboarding-form label { color:var(--text); font-size:13px; font-weight:600; }
.onboarding-form .form-error { margin:0; }
.onboarding-account-box { border:1px solid var(--border); border-radius:10px; padding:12px 14px; margin:0 0 14px; color:var(--text); }
.onboarding-account-box > strong { display:block; margin-bottom:2px; }
.onboarding-account-box > p { color:var(--muted); font-size:13px; margin:0 0 10px; }
.onboarding-account-box > div { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:8px; }
.onboarding-account-box > div p { color:var(--muted); width:100%; margin:0; font-size:13px; }
.onboarding-class-list { display:grid; gap:8px; max-height:min(48vh, 480px); overflow:auto; margin:14px 0; }
.onboarding-class-row { display:flex; align-items:center; gap:12px; min-width:0; padding:10px 12px; border:1px solid var(--border); border-radius:9px; background:var(--surface); color:var(--text); }
.onboarding-class-pick { display:flex; align-items:center; gap:10px; min-width:0; flex:1; color:var(--text); font-weight:600; cursor:pointer; }
.onboarding-class-pick span { overflow-wrap:anywhere; }
.onboarding-class-pick input, .onboarding-canvas-row input { width:17px; height:17px; flex:none; accent-color:var(--accent); }
.onboarding-config-status { flex:none; font-size:11px; font-weight:700; color:var(--danger); white-space:nowrap; }
.onboarding-config-status.is-configured { color:var(--ok); }
.onboarding-class-row small { color:var(--muted); font-weight:400; }
.onboarding-canvas-row { justify-content:space-between; }
.onboarding-config-intro { margin-bottom:14px !important; }
.onboarding-class-edit { display:grid; grid-template-columns:1fr 1.5fr 100px; gap:10px; margin:0 0 16px; color:var(--text); }
.onboarding-class-edit label { display:grid; gap:5px; font-size:12px; font-weight:600; }
.onboarding-class-edit input[type="color"] { width:100%; height:38px; padding:3px; border:1px solid var(--border); border-radius:7px; background:var(--surface); }
.class-edit-form { gap:10px; margin-top:4px; }
.onboarding-source-chips { margin:0 0 4px; }
.onboarding-source-fields { display:grid; gap:8px; margin:0 0 4px; }
.onboarding-ics-row { display:flex; align-items:center; gap:8px; }
.onboarding-ics-row .input { min-width:0; flex:1; }
.onboarding-edit-swatches { margin:0 0 4px; }
.onboarding-modal .cat-table { min-width:650px; }
.onboarding-modal .onboarding-category-hint { display:block; margin-top:8px; }
.onboarding-sync-state { text-align:center; padding:24px 12px 18px; color:var(--text); }
.onboarding-sync-icon { display:inline-grid; place-items:center; width:66px; height:66px; border:3px solid var(--border); border-top-color:var(--accent); border-radius:50%; color:var(--accent); font-size:38px; line-height:1; animation:spin 1s linear infinite; }
.onboarding-sync-state p { margin:14px 0 4px; font-weight:700; }
.onboarding-sync-progress { color:var(--muted); font-size:13px; }
.onboarding-error:not(.show) { display:none; }
.onboarding-spotlight, .overview-app .nav a.onboarding-spotlight { position:relative; z-index:51; outline:3px solid #fbbf24 !important; outline-offset:3px; border-radius:8px; background:var(--surface) !important; color:var(--navy) !important; box-shadow:0 2px 14px rgba(15,23,42,.22) !important; }
.onboarding-spotlight svg { color:var(--navy) !important; }
/* Keep the sidebar above the scrim, then tint its contents independently. The
   current tab is raised above this tint so only that tab stays bright. */
.onboarding-modal .color-swatches { margin:0 0 4px; }
@media (max-width:520px) { .onboarding-footer { align-items:flex-start; flex-direction:column-reverse; } .onboarding-actions { width:100%; } .onboarding-actions .btn { flex:1; } }
@media (max-width:640px) { .onboarding-class-row { flex-wrap:wrap; } .onboarding-class-pick { flex-basis:calc(100% - 20px); } .onboarding-class-row > .tag { margin-left:27px; } .onboarding-class-row > button { margin-left:auto; } .onboarding-class-edit { grid-template-columns:1fr 1fr; } .onboarding-class-edit label:nth-child(2) { grid-column:1 / -1; } }
@media (max-width:760px) {
  .overview-app .nav a.onboarding-spotlight span { display:inline !important; }
}
/* View-only assignment modal */
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.view-head h3 { margin-bottom: 0; line-height: 1.3; }
.view-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--navy-100); color: var(--navy); white-space: nowrap; }
.view-pill.done { background: var(--ok-bg); color: var(--ok); }
.view-pill.overdue { background: var(--danger-bg); color: var(--danger); }
.view-pill.today { background: var(--warn-bg); color: var(--warn); }
#assignment-view .detail-grid .v { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.view-sub { font-weight: 500; color: var(--muted); }
.view-notes { margin-top: 12px; padding: 12px 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; }
.view-notes .k { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.view-notes .text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
#assignment-view .modal-actions { margin-top: 18px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  display: flex; align-items: center; justify-content: center; gap: 9px; max-width: min(90vw, 760px);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 6px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--danger); }
.toast-success { background: #15803d; }
.toast-icon { display: inline-flex; align-items: center; flex: none; }
.toast-icon svg { width: 18px; height: 18px; }
.toast-interactive { pointer-events: auto; }
.toast-message { min-width: 0; }
.toast-link { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.toast-dismiss { flex: none; border: 0; padding: 0 0 1px 4px; background: transparent; color: inherit; font: inherit; font-size: 20px; line-height: 1; cursor: pointer; }

/* ---------- Form errors ---------- */
.field .error { font-size: 12px; color: var(--danger); font-weight: 600; display: none; }
.field.invalid .error { display: block; }
.field.invalid .input, .field.invalid .select { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.form-error {
  display: none; padding: 10px 12px; border-radius: 6px; background: var(--danger-bg); color: #991b1b;
  font-size: 13px; font-weight: 600; margin-bottom: 14px;
}
.form-error.show { display: block; }
.btn[disabled] { opacity: .6; cursor: default; }
/* A sync button inside its cooldown: greyed out, still hoverable for the tooltip */
.btn.cooldown { opacity: .55; cursor: not-allowed; }
.btn[data-tip], .help-tip[data-tip] { position: relative; }
.btn[data-tip]::after, .help-tip[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: 230px; white-space: normal; text-align: center;
  background: var(--navy); color: #fff; font-size: 12px; font-weight: 500; line-height: 1.35; padding: 6px 9px; border-radius: 7px;
  box-shadow: 0 4px 14px rgba(15,23,42,.2); opacity: 0; visibility: hidden; transition: opacity .15s, visibility .15s; pointer-events: none; z-index: 70;
}
.btn[data-tip]:hover::after, .btn[data-tip]:focus-visible::after,
.help-tip[data-tip]:hover::after, .help-tip[data-tip]:focus-visible::after { opacity: 1; visibility: visible; transition-delay: .3s; }

/* ---------- Help lightbulb & tours ----------
   A quiet amber bulb fixed in the top-right corner: hover for the data-tip
   hint, click for the tour chooser. .help-tip is generic so other pages can
   place one inline too. */
.help-tip {
  width: 28px; height: 28px; border-radius: 50%; border: 0; background: transparent; color: #d97706; opacity: .75;
  display: inline-grid; place-items: center; cursor: pointer; transition: opacity .12s, background .12s;
}
.help-tip svg { width: 18px; height: 18px; }
.help-tip:hover, .help-tip:focus-visible { opacity: 1; background: #fef3c7; }
.help-tip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.help-corner, .help-corner[data-tip] { position: fixed; top: 12px; right: 14px; z-index: 40; width: 34px; height: 34px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 10px rgba(15,23,42,.12); opacity: .9; }
.help-corner:hover, .help-corner:focus-visible { background: #fef3c7; }
/* Header buttons on pages that have them step left of the corner lightbulb */
.dashboard-main .page-header .toolbar, .calendar-main .page-header .toolbar { padding-right: 44px; }
/* A tour step can pin a row's hover actions open */
.dashboard-main .compact-assignment.tour-actions .row-actions { display: flex; opacity: 1; }
.help-corner[data-tip]::after { left: auto; right: 0; bottom: auto; top: calc(100% + 8px); transform: none; text-align: left; max-width: 200px; }
body.navigation-open .help-corner { visibility: hidden; }

/* Tour chooser modal */
.tour-chooser h3 { margin-bottom: 14px; }
.tour-options { display: grid; gap: 10px; }
.tour-option { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.tour-option:hover, .tour-option:focus-visible { background: var(--navy-100); border-color: #c7d7e7; }
.tour-option:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tour-option strong { color: var(--navy); font-size: 15px; }
.tour-option span { color: var(--muted); font-size: 13px; }
.tour-chooser-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

/* Walkthrough: a blocker locks the page, the mask dims everything except
   the target (its shadow does the dimming, so no z-index games with page
   elements), and one callout moves from target to target. */
.walk-blocker { position: fixed; inset: 0; z-index: 990; background: transparent; }
.walk-mask { position: fixed; z-index: 991; border-radius: 10px; box-shadow: 0 0 0 200vmax rgba(15,23,42,.45); outline: 3px solid #fbbf24; pointer-events: none; }
.walk-mask[hidden] { display: none; }
.walk-mask.full { top: -20px !important; left: -20px !important; width: 0 !important; height: 0 !important; outline: 0; }
.walk-callout { position: fixed; z-index: 992; width: min(380px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 38px 12px 16px; box-shadow: 0 8px 28px rgba(15,23,42,.18); color: var(--text); font-size: 13.5px; line-height: 1.45; }
.walk-callout::before { content: ""; position: absolute; width: 18px; height: 18px; background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.walk-callout.side-left::before { left: -10px; top: var(--arrow-y, 50%); transform: translateY(-50%) rotate(45deg); }
.walk-callout.side-right::before { right: -10px; top: var(--arrow-y, 50%); transform: translateY(-50%) rotate(225deg); }
.walk-callout.side-top::before { top: -10px; left: var(--arrow-x, 32px); transform: translateX(-50%) rotate(135deg); }
.walk-callout.side-bottom::before { bottom: -10px; left: var(--arrow-x, 32px); transform: translateX(-50%) rotate(-45deg); }
.walk-callout.centered { max-width: 440px; }
.walk-callout.centered::before { display: none; }
.walk-callout .walk-kicker { color: var(--navy); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 4px; }
.walk-callout h3 { font-size: 16px; margin: 0 0 4px; color: var(--navy); }
.walk-callout p { margin: 0; color: var(--muted); }
.walk-callout p + p { margin-top: 8px; }
.walk-callout .walk-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.walk-callout .walk-foot .step-tag { margin: 0 auto 0 0; }
.walk-callout .callout-close { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px; }
.walk-callout .callout-close:hover { background: var(--navy-100); color: var(--navy); }
@media (max-width: 760px) {
  .help-corner, .help-corner[data-tip] { position: absolute; top: calc(max(12px, env(safe-area-inset-top)) + 7px); right: 16px; width: 36px; height: 36px; }
  .dashboard-main .page-header .toolbar, .calendar-main .page-header .toolbar { padding-right: 0; }
  .walk-callout { width: calc(100vw - 32px); }
}

/* ---------- Dashboard: next up + progress (structure borrowed from Danny's mockup) ---------- */
.next-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.next-card { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-top: 3px solid var(--navy); }
.next-card .eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.next-card h3 { font-size: 20px; margin-top: 8px; }
.next-card .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.next-card .tag { background: var(--navy-100); color: var(--navy); }
.next-card .actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.next-card .btn-light { background: var(--navy); color: #fff; }
.next-card .btn-light:hover { background: var(--navy-600); }
.next-card .btn-outline { background: var(--surface); color: var(--text); border-color: var(--control-border); }
.next-card .btn-outline:hover { background: var(--bg); }
.next-card .empty-next { color: var(--muted); margin-top: 8px; }
.progress-card .num { font-size: 30px; font-weight: 700; line-height: 1; margin-top: 8px; }
.progress-card .num small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 6px; }
.progress-track { height: 8px; background: var(--navy-100); border-radius: 999px; margin-top: 14px; overflow: hidden; }
.progress-track div { height: 100%; background: var(--ok); border-radius: 999px; transition: width .3s; }
.progress-card .foot { font-size: 13px; font-weight: 500; color: #334155; margin-top: 8px; }

/* ---------- Class modal: source chips + color swatches ---------- */
.source-chips .chip { display: inline-flex; align-items: center; gap: 6px; }
.source-chips .chip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.source-section { display: none; }
.source-section.show { display: block; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 2px 0; }
.color-swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent; transition: transform .1s, box-shadow .1s;
  display: grid; place-items: center; color: #fff;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.color-swatch svg { width: 14px; height: 14px; display: none; }
.color-swatch.active svg { display: block; }

/* ---------- Class modal step 2: category mapping table ---------- */
.step-tag { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 10px; }
.cat-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cat-table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px 8px; }
.cat-table td { padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: middle; }
.cat-table td.name { font-weight: 600; }
.cat-table td .n { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.cat-table .select, .cat-table .input { padding: 7px 9px; font-size: 13px; }
.cat-table tr.excluded td.name { color: var(--muted); text-decoration: line-through; }
.cat-table td.kw .input { min-width: 160px; }
/* Sync reminder: a callout beside the sidebar's Sync button */
.sync-callout { position: fixed; z-index: 60; width: min(340px, calc(100vw - 300px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 38px 14px 16px; box-shadow: 0 8px 28px rgba(15,23,42,.18); color: var(--text); font-size: 13.5px; line-height: 1.45; }
.sync-callout::before { content: ""; position: absolute; left: -10px; top: var(--arrow-y, 50%); width: 18px; height: 18px; background: var(--surface); border-left: 1px solid var(--border); border-bottom: 1px solid var(--border); transform: translateY(-50%) rotate(45deg); }
.sync-callout strong { display: block; margin-bottom: 4px; color: var(--navy); }
.sync-callout p { margin: 0; color: var(--muted); }
.sync-callout .callout-close { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px; }
.sync-callout .callout-close:hover { background: var(--navy-100); color: var(--text); }
@media (max-width: 760px) { .sync-callout { display: none; } }
.cat-tools { display: flex; justify-content: flex-end; margin-bottom: 10px; }
/* Learning Suite: how to group the schedule */
.cat-choice { display: grid; gap: 10px; }
.cat-option { text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: transparent; cursor: pointer; font: inherit; color: inherit; }
.cat-option:hover:not(:disabled), .cat-option:focus-visible { border-color: var(--navy); outline: none; }
.cat-option:disabled { opacity: .6; cursor: default; }
.cat-option .t { display: block; font-weight: 600; margin-bottom: 3px; }
.cat-option .d { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.cat-table td.inc { text-align: center; width: 70px; }
.cat-table td.inc input { width: 18px; height: 18px; accent-color: var(--navy); }
/* Phones: each category becomes a stacked card, labelled from the cell classes, so
   the mapping step (Category / Show as / Keywords / Due time / Include) never scrolls sideways */
@media (max-width: 760px) {
  .cat-table, .cat-table tbody, .cat-table tr, .cat-table td { display: block; width: auto; }
  .cat-table thead { display: none; }
  .onboarding-modal .cat-table { min-width: 0; }
  .cat-table tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; margin-bottom: 10px; background: var(--surface); }
  .cat-table td { border-top: 0; padding: 6px 0 0; }
  .cat-table td.name { padding-top: 0; font-size: 15px; }
  .cat-table td .n { display: inline; margin-left: 6px; }
  .cat-table td.type::before, .cat-table td.kw::before, .cat-table td.time::before, .cat-table td.inc::before {
    display: block; margin: 4px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
  }
  .cat-table td.type::before { content: "Show as"; }
  .cat-table td.kw::before { content: "Keywords"; }
  .cat-table td.time::before { content: "Due time"; }
  .cat-table td.inc { display: flex; align-items: center; gap: 10px; width: auto; text-align: left; padding-top: 10px; }
  .cat-table td.inc::before { content: "Include this category"; margin: 0; order: 2; text-transform: none; font-size: 13px; font-weight: 500; color: var(--text); }
  .cat-table td.inc input { width: 20px; height: 20px; order: 1; }
  .cat-table .select, .cat-table .input, .cat-table td.kw .input { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; font-size: 16px; }
  /* iOS sizes time inputs to their content and ignores width unless the native look is turned off */
  .cat-table td { min-width: 0; overflow: hidden; }
  .cat-table td.time .input { display: block; width: 100%; max-width: 100%; -webkit-appearance: none; appearance: none; }
  .cat-table td.time .input::-webkit-date-and-time-value { text-align: left; }
  .cat-table tr.excluded { background: #f8fafc; }
  .cat-tools { justify-content: flex-start; }
}

/* ---------- Auth page errors ---------- */
.auth-card .form-error { margin-bottom: 16px; }

/* ---------- Confirm modal ---------- */
.modal p.confirm-text { color: var(--muted); font-size: 14px; margin-bottom: 18px; line-height: 1.5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-large, .stat-small { grid-column: span 1; }
  .cal-layout { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .next-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 12px 16px; }
  .sidebar .brand { padding: 0; }
  .nav { flex-direction: row; flex: 1; justify-content: center; }
  .nav a span { display: none; }
  .sidebar-bottom { display: none; }
  .main { padding: 20px 16px; }
}

/* Interaction and readable course colors */
a { text-underline-offset: 3px; }
a.btn:hover { text-decoration: none; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--navy); }
.switch .slider { background: var(--muted); }
.switch input:focus-visible + .slider { outline: 3px solid var(--accent); outline-offset: 3px; }
.chip { border-color: var(--control-border); border-radius: 6px; }
.tag { border-radius: 4px; }
.tag.course { background: #f0f2f4; color: var(--text); gap: 6px; }
.tag.course::before, .filter-chip.course::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px;
  background: var(--course-color); flex: none;
}
.filter-chip.course { background: var(--navy); }
.card-header, .toolbar, .class-actions { flex-wrap: wrap; }
.stat .value, .progress-card .num, .streak-mini .num { font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.class-card > .card-header { padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.class-card .swatch { width: 4px; border-radius: 2px; }
.callout { background: #f2f5f8; color: var(--navy); border-left: 3px solid var(--navy); }
.auth-footer a, .auth-card .between a { text-decoration: underline; }
.toast { max-width: calc(100vw - 32px); }
@media (max-width: 760px) {
  .sidebar { flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav { justify-content: flex-end; gap: 2px; }
  .nav a { padding: 10px; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--navy); }
  .page-header { align-items: flex-start; flex-wrap: wrap; }
  .page-header h1 { font-size: 26px; }
  .card { padding: 16px; }
  .setting-row { flex-wrap: wrap; gap: 12px; }
  .setting-row .info { min-width: 180px; }
}
@media (max-width: 480px) {
  .sidebar .brand { font-size: 16px; gap: 6px; }
  .sidebar .brand-mark { width: 28px; height: 28px; }
  .nav a { padding: 9px; }
  .stat-grid { gap: 10px; }
  .cal-grid { gap: 3px; }
  .cal-day { min-height: 64px; padding: 4px; }
  .cal-day .n { width: 22px; height: 22px; }
  .detail-grid { grid-template-columns: 1fr; }
  .filter-bar .select { width: 100%; }
  .auth-panel { padding: 40px 24px; min-height: 100dvh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}

/* ---------- Dashboard and calendar workspace ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.overview-app { grid-template-columns: 240px minmax(0, 1fr); background: #f0f5fc; }
.sidebar .nav a.active { background: var(--navy); color: #fff; box-shadow: none; }
.overview-main { max-width: none; padding: 28px 32px 32px; }
.overview-main .page-header { margin-bottom: 20px; align-items: center; }
.overview-main .page-header h1 { font-size: 32px; }
.overview-main .page-header .sub { font-size: 15px; }
.overview-main h2 { font-size: 19px; letter-spacing: -.015em; }
.overview-main .card { box-shadow: 0 3px 12px rgba(23, 59, 96, .05); padding: 22px; border-radius: 12px; }
.overview-main .card-header { margin-bottom: 14px; }
.overview-main .btn-sm { min-height: 40px; font-size: 14px; padding: 10px 14px; border-radius: 8px; }
.overview-main .check-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.overview-main .check-label input { margin: 0; width: 15px; height: 15px; }
.overview-main .subtle-link { font-size: 14px; font-weight: 600; }
.text-button { padding: 3px 0; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 600; text-underline-offset: 3px; }
.text-button:hover { text-decoration: underline; }
.overview-main .eyebrow { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; }

/* Summary buttons: one compact row, with the count separated from its label. */
.overview-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.overview-stats .stat { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 20px; text-align: left; font-family: inherit; }
.overview-stats .stat-copy { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 3px 10px; }
.overview-stats .stat-copy .label, .overview-stats .stat-copy .foot { grid-column: 2; }
.overview-stats .label { color: inherit; font-size: 15px; }
.overview-stats .foot { font-size: 13px; font-weight: 400; color: inherit; }
.overview-stats .value { font-size: 38px; }
.overview-stats .stat.is-selected { outline: 2px solid var(--navy); outline-offset: 3px; }
.overview-stats .stat.danger { background: #fff0ef; color: #9f2821; border-color: #bc5750; }
.overview-stats .stat.warn { background: #fff5df; color: #80500b; border-color: #aa791d; }
.overview-stats .stat.info { background: #e9f2ff; color: #204e87; border-color: #497cb4; }
.overview-stats .stat.ok { background: #e8f6ef; color: #216543; border-color: #458263; }
.overview-stats .stat .value { color: inherit; }
.overview-stats .stat:hover { filter: brightness(.97); }
.stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: rgba(255,255,255,.7); grid-row: 1 / 3; align-self: center; }
.stat-icon svg { width: 20px; height: 20px; }
/* The queue card is given the rail's height from dashboard.js so both columns end on the same line */
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 29%); gap: 22px; align-items: start; }
.queue-panel { min-width: 0; display: flex; flex-direction: column; min-height: 420px; }
/* The list scrolls inside the card instead of paging. The top padding leaves
   room for the drop line above the first row. */
.queue-panel > .compact-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 2px 0; scrollbar-gutter: stable; }
.queue-panel .compact-assignment { min-height: 54px; padding: 7px 10px; margin-bottom: 6px; }
.queue-panel .assignment-open { gap: 1px; }
.queue-panel .assignment-name { font-size: 14px; }
.queue-panel .assignment-meta { font-size: 12px; }
.queue-panel .assignment-deadline { gap: 2px; font-size: 12.5px; }
.queue-heading { display: flex; align-items: center; gap: 12px; }
.queue-heading .text-button[aria-pressed="true"] { color: var(--muted); }
.queue-controls { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(80px, .55fr) minmax(75px, .45fr) 125px; gap: 8px; }
.queue-controls .input, .queue-controls .select { padding: 10px; font-size: 14px; min-width: 0; height: 42px; border-radius: 8px; }
.queue-context { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 14px 0 12px; font-size: 13px; color: var(--muted); }
.active-filters:empty { display: none; }
.removable-filter { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--control-border); border-radius: 4px; padding: 2px 5px; background: var(--navy-100); color: var(--navy); font-size: 11px; }
.removable-filter svg { width: 12px; height: 12px; }
.compact-list { display: flex; flex-direction: column; }
/* The list can be height-limited and scroll; rows must never shrink to fit */
.compact-list > .compact-assignment { flex: none; }
.compact-assignment { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; min-height: 78px; padding: 12px 10px; border: 1px solid #b4c7dc; border-left: 4px solid var(--course-color, var(--navy)); border-radius: 9px; background: color-mix(in srgb, var(--course-color, #245b91) 5%, white); margin-bottom: 8px; }
.compact-assignment.sortable { grid-template-columns: 12px 22px minmax(0, 1fr) auto auto; gap: 8px; }
.compact-assignment:hover { background: #f6f8fa; }
.compact-assignment.dragging { opacity: .5; }
/* Drop target: a line in the gap above or below the row, not on the row itself */
.compact-assignment { position: relative; }
.compact-assignment.drop-before::after, .compact-assignment.drop-after::after {
  content: ""; position: absolute; left: 8px; right: 8px; height: 3px; border-radius: 2px;
  background: var(--accent); pointer-events: none;
}
.compact-assignment.drop-before::after { top: -6px; }
.compact-assignment.drop-after::after { bottom: -6px; }
/* Rows keep the handle's column even when dragging is off, so the content doesn't shift between sort modes */
.drag-handle.spacer { visibility: hidden; }
mark.hl { background: #fef08a; color: inherit; border-radius: 3px; padding: 0 1px; }
.queue-context .reset-order { margin-left: auto; min-height: 0; padding: 4px 10px; font-size: 13px; }
.drag-handle { display: grid; place-items: center; cursor: grab; color: var(--muted); }
.drag-handle svg { width: 13px; height: 16px; }
.assignment-toggle { display: grid; place-items: center; width: 23px; height: 23px; padding: 0; background: var(--surface); border: 1.5px solid var(--control-border); border-radius: 4px; color: white; }
.assignment-toggle:hover { box-shadow: 0 0 0 3px var(--navy-100); border-color: var(--navy); }
.assignment-toggle.on { background: var(--ok); border-color: var(--ok); }
.assignment-toggle svg { width: 13px; height: 13px; }
.assignment-open { display: flex; flex-direction: column; gap: 3px; border: 0; padding: 2px 0; min-width: 0; background: transparent; text-align: left; color: var(--text); line-height: 1.4; }
.assignment-open:hover .assignment-name { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.assignment-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.assignment-meta { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-marker { width: 9px; height: 9px; border-radius: 2px; background: var(--course-color); flex: none; }
.assignment-deadline { display: flex; flex-direction: column; gap: 4px; text-align: right; font-size: 13px; font-weight: 800; white-space: nowrap; }
.assignment-deadline small { font-size: 12px; font-weight: 600; color: var(--muted); }
.assignment-deadline.overdue, .assignment-deadline.overdue small { color: var(--danger); }
.assignment-deadline.today > span { color: var(--warn); }
.compact-assignment.done .assignment-name { text-decoration: line-through; color: var(--muted); }
/* One line of notes under the details, never wrapped */
.assignment-notes { font-size: 12px; color: var(--muted); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-panel .assignment-notes { font-size: 11.5px; }
/* Hover actions: open at the source, edit. Shown on hover or keyboard focus. */
.row-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .12s; }
.compact-assignment:hover .row-actions, .compact-assignment:focus-within .row-actions { opacity: 1; }
.row-action { position: relative; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.row-action:hover, .row-action:focus-visible { background: var(--navy-100); color: var(--navy); }
.row-action svg { width: 15px; height: 15px; }
/* Tooltip from data-tip, after a one-second hover */
.row-action[data-tip]::after {
  content: attr(data-tip); position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5;
  padding: 5px 8px; border-radius: 6px; background: var(--text); color: #fff; font-size: 12px; font-weight: 500; line-height: 1.2;
  white-space: nowrap; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .12s, visibility 0s .12s;
}
.row-action[data-tip]:hover::after, .row-action[data-tip]:focus-visible::after { opacity: 1; visibility: visible; transition-delay: 1s; }
.list-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; font-size: 13px; color: var(--muted); }
.list-footer[hidden] { display: none; }
.pager { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.overview-main .pager .btn { font-size: 13px; padding: 9px 12px; min-height: 36px; }
.queue-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #789abd; border-radius: 10px; background: #edf4ff; padding: 40px 20px; margin-bottom: 16px; min-height: 240px; }
.queue-empty strong, .agenda-empty strong { display: block; color: var(--text); font-weight: 600; font-size: 18px; }
.queue-empty p, .agenda-empty p { font-size: 14px; margin: 6px 0 14px; }
/* The rail is stretched to the room left under the stat cards (dashboard.js
   sets its min-height); its three cards share any extra height. */
.dashboard-rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dashboard-rail > * { flex: 1 1 auto; min-height: 0; }
.overview-main .focus-card { background: linear-gradient(130deg, #173b60, #245b91); color: #fff; border: 1px solid #173b60; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; padding: 16px 18px; }
.focus-card::after { content: ""; position: absolute; width: 140px; height: 140px; border: 24px solid rgba(255,255,255,.055); border-radius: 50%; right: -55px; top: -50px; pointer-events: none; }
.focus-card > * { position: relative; z-index: 1; }
.overview-main .focus-card .eyebrow, .focus-card .focus-meta { color: #e0edfc; }
.focus-card .subtle-link { color: #fff; text-decoration: underline; margin-top: 16px; }
.focus-card .btn-primary { background: white; color: #173b60; }
.focus-card .btn-secondary { color: white; border-color: #b9d3ef; background: transparent; }
.focus-card .btn-primary:hover { background: #e9f2ff; }
.focus-card .btn-secondary:hover { background: #173b60; }
.focus-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.status-past { color: var(--danger); background: var(--danger-bg); border-radius: 3px; padding: 2px 6px; font-size: 10px; font-weight: 600; }
.focus-card h2 { font-size: 18px; line-height: 1.2; margin-top: 0; }
.focus-title { color: inherit; font-size: inherit; font-weight: inherit; line-height: inherit; text-align: left; border: 0; background: transparent; padding: 0; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.focus-title:hover { color: #fff; text-decoration: underline; }
.focus-meta { font-size: 13px; color: var(--muted); margin-top: 3px; }
.focus-due { font-size: 13px; font-weight: 600; margin-top: 2px; }
.focus-actions { display: flex; gap: 8px; margin-top: 8px; }
.focus-card .btn-sm { min-height: 32px; font-size: 13px; padding: 6px 11px; }
.overview-main .week-card { padding: 14px 18px 12px; display: flex; flex-direction: column; }
/* Streaks: two small cards side by side under the week card */
.streak-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.overview-main .streak-mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-width: 0; }
.streak-mini .streak-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; background: #e9f6ee; color: var(--ok); }
.streak-mini .streak-icon svg { width: 18px; height: 18px; }
.streak-mini.off .streak-icon { background: var(--navy-100); color: var(--muted); }
.streak-mini .num { font-size: 22px; font-weight: 700; line-height: 1; }
.streak-mini .num small { font-size: 11px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.streak-mini .label { font-size: 12px; font-weight: 600; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.streak-mini .best { font-size: 11px; color: var(--muted); margin-top: 1px; }
.week-card .card-header { margin-bottom: 6px; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 1px; border: 1px solid transparent; border-radius: 4px; font-size: 12px; color: var(--muted); background: #eef4fc; }
.week-day strong { color: var(--text); font-size: 17px; }
.week-day:hover { background: var(--bg); border-color: var(--control-border); }
.week-day.is-today { background: #245b91; color: white; }
.week-day.is-today strong { color: white; }
.week-day.is-today .week-count { color: white; background: #173b60; }
.week-day[aria-pressed="true"], .week-day.is-today:hover { background: var(--navy); color: white; border-color: var(--navy); }
.week-day[aria-pressed="true"] strong { color: white; }
.week-day[aria-pressed="true"] .week-count { background: #245b91; color: white; }
.week-count { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 4px; font-size: 11px; }
.week-count.has-work { background: var(--navy-100); color: var(--navy); font-weight: 600; }
.workload-summary { color: var(--muted); font-size: 12.5px; line-height: 1.4; margin: 6px 0; }
.week-progress { margin-top: auto; padding-top: 6px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.week-progress strong { font-weight: 600; color: var(--text); }
.week-progress .progress-track { height: 8px; margin-top: 9px; }

/* Calendar uses the available desktop height, with a fixed, readable minimum. */
.calendar-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.calendar-toolbar .select { width: auto; min-width: 160px; font-size: 14px; padding: 8px 10px; }
.calendar-toolbar > p { color: var(--muted); font-size: 14px; }
.overview-main .cal-layout { grid-template-columns: minmax(0, 1fr) minmax(320px, 29%); gap: 22px; align-items: stretch; }
.month-panel { display: flex; flex-direction: column; min-width: 0; height: max(570px, calc(100dvh - 200px)); }
.overview-main .month-panel { padding: 0; overflow: hidden; }
.month-panel .cal-head { margin: 0 0 16px; padding: 18px 22px; flex: none; background: var(--navy); color: white; }
.month-panel .cal-head .btn { background: #fff; color: var(--navy); }
.month-panel .cal-head h2 { font-size: 23px; }
.overview-main .btn-icon { min-height: 30px; padding: 6px; }
.month-panel .cal-grid { gap: 0; flex: 1; min-height: 0; grid-template-rows: 32px repeat(var(--calendar-weeks, 6), minmax(0, 1fr)); border-left: 1px solid var(--border); margin: 0 20px; }
.month-panel .cal-dow { background: #e8f0fb; color: var(--navy); font-size: 12px; padding: 7px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); }
.month-panel .cal-day { min-width: 0; min-height: 0; border: 0; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 0; gap: 4px; padding: 6px; text-align: left; color: var(--text); overflow: hidden; }
.month-panel .cal-day.muted { background: #f7f8f9; color: var(--muted); }
.month-panel .cal-day:hover:not(.muted) { background: #f1f5f9; box-shadow: inset 0 0 0 1px var(--navy); }
.month-panel .cal-day.selected { background: #deebff; box-shadow: inset 0 0 0 2px #245b91; }
.month-panel .cal-day.has-assignments:not(.selected) { background: #f3f7ff; }
.month-panel .cal-day:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.cal-date-line { flex: none; display: flex; justify-content: space-between; align-items: center; width: 100%; }
.month-panel .cal-day .n { width: 28px; height: 28px; font-size: 14px; }
.cal-count { color: var(--navy); background: #dceafd; padding: 1px 6px; border-radius: 5px; font-size: 12px; font-weight: 600; }
.cal-preview { flex: none; display: block; max-width: 100%; padding: 3px 5px; border-left: 3px solid var(--course-color); background: color-mix(in srgb, var(--course-color) 12%, white); border-radius: 3px; color: var(--text); font-size: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-preview.is-complete { text-decoration: line-through; color: var(--muted); }
.cal-more { display: none; color: var(--muted); font-size: 11px; line-height: 1.2; padding-left: 8px; white-space: nowrap; }
.calendar-key { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 14px 20px; font-size: 12px; color: var(--muted); }
.calendar-key span { display: inline-flex; align-items: center; gap: 5px; }
.calendar-key i { width: 9px; height: 9px; display: inline-block; }
.today-key { border-radius: 50%; background: var(--navy); }
.selected-key { border: 1px solid var(--navy); background: var(--navy-100); }
.day-panel { min-width: 0; }
.day-panel .day-nav { align-items: center; margin-bottom: 14px; }
.day-panel .day-nav h2 { font-size: 23px; }
.day-panel .day-nav .sub { font-size: 14px; margin-top: 2px; }
.day-summary { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; margin-bottom: 16px; color: var(--muted); }
.day-summary strong { color: var(--navy); font-size: 15px; }
.agenda-list .compact-assignment { grid-template-columns: 20px minmax(0, 1fr) auto auto; gap: 10px; min-height: 86px; }
.agenda-list .assignment-name { font-size: 15px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; }
.agenda-list .assignment-meta { font-size: 12px; }
.agenda-list .assignment-deadline { font-size: 12px; }
.agenda-list .assignment-deadline small:empty { display: none; }
.agenda-empty { padding: 36px 10px; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; color: #245b91; background: #dceaff; border-radius: 18px; margin-bottom: 18px; }
.empty-icon svg { width: 30px; height: 30px; }

@media (max-width: 1300px) {
  .overview-stats .stat-copy { grid-template-columns: minmax(0, 1fr); }
  .overview-stats .stat-copy .label, .overview-stats .stat-copy .foot { grid-column: auto; }
  .stat-icon { display: none; }
}
@media (min-width: 1500px) {
  .dashboard-layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 29%); }
  .overview-main .cal-layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 29%); }
  .compact-assignment { min-height: 86px; }
  .cal-preview { font-size: 13px; }
}
@media (min-width: 761px) and (max-width: 1180px) {
  .overview-app { grid-template-columns: 180px minmax(0, 1fr); }
  .overview-app .sidebar { padding: 22px 10px; }
  .overview-app .sidebar .brand { font-size: 17px; }
  .overview-main { padding: 24px 20px; }
  .dashboard-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 14px; }
  .overview-main .card { padding: 18px; }
  .queue-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .queue-heading { gap: 8px; }
  .queue-panel .card-header { gap: 8px; }
  .overview-main .cal-layout { grid-template-columns: minmax(0, 1fr) 270px; gap: 14px; }
  .month-panel .cal-day { padding: 5px; }
  .calendar-key { gap: 8px; }
}
@media (min-width: 761px) and (max-width: 960px) {
  .overview-app { grid-template-columns: 76px minmax(0, 1fr); }
  .overview-app .sidebar { align-items: center; }
  .overview-app .sidebar .brand { padding: 0 0 22px; }
  .overview-app .sidebar .brand > span:last-child, .overview-app .nav a span { display: none; }
  .overview-app .nav a { padding: 12px; }
  .overview-app .sidebar-bottom { width: 44px; }
  .overview-app .sidebar-bottom #sync-btn { font-size: 0; gap: 0; padding: 10px; }
  .overview-app .sidebar-bottom .sync-note, .overview-app .user-chip > div { display: none; }
  .overview-app .user-chip { padding: 0; border: 0; justify-content: center; margin-top: 8px; }
  .overview-stats { gap: 8px; }
  .overview-stats .stat { padding: 12px; }
}
@media (max-width: 760px) {
  .overview-app { grid-template-columns: minmax(0, 1fr); }
  .overview-main { padding: 20px 16px 28px; }
  .overview-main .page-header { gap: 12px; margin-bottom: 16px; }
  .overview-main .page-header h1 { font-size: 28px; }
  .overview-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .overview-stats .stat { padding: 12px; gap: 8px; }
  .overview-stats .foot { display: none; }
  .overview-stats .value { font-size: 32px; }
  .overview-stats .label { font-size: 14px; }
  .dashboard-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .dashboard-rail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  /* One column: let the page scroll instead of a box inside it */
  .queue-panel { max-height: none; }
  .queue-panel > .compact-list { overflow: visible; }
  .streak-row { grid-column: 1 / -1; }
  .overview-main .card { padding: 18px; }
  .overview-main .cal-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .month-panel { height: 590px; }
  .calendar-toolbar > p { font-size: 11px; }
  .queue-controls { grid-template-columns: minmax(100px, 1fr) repeat(3, minmax(70px, .6fr)); }
  .agenda-list .assignment-name { font-size: 15px; }
  .day-panel .compact-assignment { min-height: 78px; }
}
@media (max-width: 480px) {
  .overview-main .page-header { align-items: flex-start; }
  .overview-main .page-header .toolbar { gap: 6px; }
  .overview-main .page-header .btn { font-size: 13px; padding: 10px; }
  .overview-main .page-header h1 { font-size: 27px; }
  .overview-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-stats .stat { padding: 10px 12px; }
  .dashboard-rail { grid-template-columns: minmax(0, 1fr); }
  .queue-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .queue-controls .input { grid-column: 1 / -1; }
  .compact-assignment, .agenda-list .compact-assignment { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .compact-assignment.sortable { grid-template-columns: 20px minmax(0, 1fr) auto; }
  .compact-assignment .drag-handle, .row-actions { display: none; }
  .assignment-meta { display: block; font-size: 12px; }
  .assignment-meta .course-marker { display: inline-block; margin-right: 4px; }
  .assignment-name { font-size: 14px; }
  .assignment-deadline { font-size: 12px; }
  .month-panel { height: 540px; }
  .month-panel .cal-day { padding: 3px; gap: 2px; }
  .month-panel .cal-day .n { width: 19px; height: 19px; font-size: 10px; }
  .cal-preview { font-size: 10px; line-height: 1.4; padding-left: 3px; border-left-width: 2px; flex: none; }
  .cal-more { display: none; }
  .calendar-key { gap: 10px; font-size: 11px; }
  .calendar-key > span:last-child { flex-basis: 100%; }
  .calendar-toolbar .toolbar { flex-wrap: wrap; }
}

/* Assignments page */
.assignments-page .class-card { padding: 0; overflow: hidden; border-color: #d4dfe9; }
.assignments-page .class-heading { padding: 18px 20px; background: #fff; }
.class-toggle { border: 0; background: transparent; padding: 0; min-width: 0; text-align: left; color: var(--navy); flex: 1; }
.class-toggle > span:last-child { min-width: 0; }
.class-toggle .code, .class-toggle .cname { display: block; }
.class-toggle .swatch { flex: none; }
.class-chevron { width: 20px; height: 20px; flex: none; transition: transform .24s ease; }
.is-collapsed .class-chevron { transform: rotate(-90deg); }
.class-collapse { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .24s ease; }
.is-collapsed .class-collapse { grid-template-rows: 0fr; }
.class-collapse-inner { min-height: 0; overflow: hidden; }
.assignments-page .class-body { margin: 0; padding: 4px 20px 20px; gap: 10px; }
.assignments-page .a-row { grid-template-columns: 22px 4px minmax(0, 1fr) minmax(130px, .6fr) auto 110px; gap: 14px; padding: 16px; border-color: #dce4ec; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s; }
.assignments-page .a-row:hover { background: #f8fbff; border-color: #8ca9c4; box-shadow: 0 2px 8px #173b600a; }
.assignments-page .a-row .bar { width: 4px; }
.assignments-page .a-row .body { min-width: 0; }
.assignment-title-button { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-align: left; overflow-wrap: anywhere; }
.assignment-title-button:hover { color: var(--accent); text-decoration: underline; }
.assignments-page .a-row .check { padding: 0; background: #fff; }
.assignments-page .a-row .check.on { background: var(--ok); }
.assignments-page .a-row .notes { cursor: default; }
.assignments-page :is(button, a, textarea):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.assignments-skeleton { padding: 24px; }
.skeleton-heading, .skeleton-row { background: linear-gradient(100deg, #edf2f7 25%, #f8fafc 45%, #edf2f7 65%); background-size: 250% 100%; animation: assignment-shimmer 1.8s ease-in-out infinite; border-radius: 6px; }
.skeleton-heading { width: 40%; height: 36px; margin-bottom: 22px; }
.skeleton-row { height: 94px; margin-top: 10px; }
#v-description .text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow-y: auto; }
@keyframes assignment-shimmer { to { background-position: -200% 0; } }
@media (max-width: 1100px) {
  .assignments-page .class-heading { align-items: flex-start; flex-wrap: wrap; }
  .assignments-page .class-actions { width: 100%; padding-left: 32px; }
  .assignments-page .a-row { grid-template-columns: 22px 4px minmax(0, 1fr) auto; }
  .assignments-page .a-row .due { grid-column: 4; grid-row: 1; }
  .assignments-page .a-row .notes { grid-column: 3; grid-row: 2; }
  .assignments-page .assignment-edit { grid-column: 4; grid-row: 2; }
}
@media (max-width: 600px) {
  .assignments-page .page-header { align-items: flex-start; flex-direction: column; }
  .assignments-page .class-heading { padding: 16px 12px; }
  .assignments-page .class-body { padding: 0 10px 12px; }
  .assignments-page .a-row { padding: 12px 10px; gap: 10px; grid-template-columns: 22px minmax(0, 1fr) auto; }
  .assignments-page .a-row .bar { display: none; }
  .assignments-page .a-row .due { grid-column: 3; font-size: 12px; }
  .assignments-page .a-row .notes { grid-column: 2; }
  .assignments-page .assignment-edit { grid-column: 3; }
  .assignments-page .class-actions { gap: 4px; padding-left: 0; }
  .assignments-page .class-actions .btn { padding: 9px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .class-chevron, .class-collapse { transition: none; }
  .assignments-skeleton * { animation: none; }
}

.assignments-page .class-remaining { color: var(--navy); font-weight: 600; }

/* Compact phone layout, scoped to Assignments only. */
@media (max-width: 600px) {
  .main.assignments-page { padding: 20px 12px 32px; }
  .assignments-page .page-header { gap: 12px; margin-bottom: 16px; }
  .assignments-page .page-header h1 { font-size: 26px; line-height: 1.2; }
  .assignments-page .page-header .sub { font-size: 12px; line-height: 1.45; margin-top: 5px; }
  .assignments-page .page-header .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px; width: 100%; }
  .assignments-page .page-header .toolbar label { min-height: 40px; }
  .assignments-page .page-header .btn { min-height: 40px; padding: 8px; font-size: 12px; white-space: nowrap; }
  .assignments-page .class-grid { gap: 12px; }
  .assignments-page .class-heading { padding: 12px; gap: 10px; }
  .assignments-page .class-toggle { gap: 8px; min-height: 40px; }
  .assignments-page .class-chevron { width: 18px; height: 18px; }
  .assignments-page .class-toggle .code { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
  .assignments-page .class-toggle .cname { font-size: 12px; margin-top: 3px; }
  .assignments-page .class-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; }
  .assignments-page .class-actions .btn { min-height: 40px; padding: 8px; font-size: 12px; gap: 5px; }
  .assignments-page .class-actions .btn svg { width: 14px; height: 14px; }
  .assignments-page .class-body { padding: 0 8px 8px; gap: 8px; }
  .assignments-page .a-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 6px 8px; padding: 12px 10px; align-items: start; border-radius: 7px; }
  .assignments-page .a-row .check { grid-column: 1; grid-row: 1; width: 24px; height: 24px; margin-top: 2px; }
  .assignments-page .a-row .body { grid-column: 2 / -1; grid-row: 1; }
  .assignments-page .assignment-title-button { font-size: 14px; line-height: 1.4; min-height: 28px; }
  .assignments-page .a-row .meta { gap: 4px; margin-top: 4px; font-size: 11px; }
  .assignments-page .a-row .tag { font-size: 10px; padding: 3px 6px; }
  .assignments-page .a-row .due { grid-column: 2 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; text-align: left; }
  .assignments-page .a-row .due .d { font-size: 12px; }
  .assignments-page .a-row .due .t { font-size: 11px; }
  .assignments-page .a-row .notes { grid-column: 2; grid-row: 3; min-width: 0; padding: 6px 8px; font-size: 12px; align-self: center; }
  .assignments-page .a-row .notes-add { min-height: 26px; text-align: left; }
  .assignments-page .assignment-edit { grid-column: 3; grid-row: 3; min-height: 40px; padding: 8px 10px; font-size: 12px; align-self: center; }
  .assignments-page .assignments-skeleton { padding: 16px; }
  .assignments-page .skeleton-heading { width: 65%; height: 30px; margin-bottom: 14px; }
  .assignments-page .skeleton-row { height: 110px; margin-top: 8px; }
}

/* Calendar workspace: flexible columns and readable daily agendas. */
.main.calendar-main { max-width: none; padding: 24px clamp(12px, 2vw, 32px) 32px; min-width: 0; }
.calendar-main .page-header { margin-bottom: 18px; }
.calendar-search-wrap { margin-bottom: 14px; }
.calendar-search-box { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 14px; border: 1px solid #a6b7c8; border-radius: 9px; background: #fff; max-width: 560px; min-height: 44px; }
.calendar-search-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.calendar-search-box > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.calendar-search-box input { flex: 1; min-width: 0; padding: 8px 0; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; }
.calendar-search-box input::-webkit-search-cancel-button { display: none; }
.calendar-search-box [hidden] { display: none; }
#calendar-search-status { font-size: 13px; color: var(--muted); }
#calendar-search-status:not(:empty) { margin-top: 8px; }
.calendar-main .cal-layout { grid-template-columns: minmax(0, 1fr) minmax(280px, 28%); gap: 16px; align-items: start; }
.calendar-main .month-panel { height: auto; min-width: 0; }
.calendar-main .month-panel .cal-head { padding: 16px; margin-bottom: 0; }
.calendar-main .month-panel .cal-grid { margin: 0 12px; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: 32px repeat(var(--calendar-weeks, 6), minmax(158px, 1fr)); flex: none; }
.calendar-main .month-panel .cal-day { padding: 5px; gap: 4px; }
.calendar-main .cal-preview { width: 100%; padding: 3px 4px; font-size: 11px; line-height: 1.4; }
.calendar-main .cal-more { display: block; margin-top: auto; padding: 3px 0; font-size: 11px; font-weight: 600; color: var(--navy); text-decoration: underline; text-underline-offset: 2px; }
.calendar-main .calendar-key { padding: 12px; gap: 12px; }
.calendar-main .day-panel { padding: 16px; min-width: 0; }
.calendar-main .day-nav { flex-wrap: wrap; gap: 10px; }
.calendar-main .day-nav h2 { font-size: 21px; }
.calendar-main .agenda-list { gap: 6px; }
/* Day list fills the panel and scrolls; rows are the dashboard's compact rows, slimmed for the narrow panel */
.calendar-main .day-panel { display: flex; flex-direction: column; }
.calendar-main #day-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.calendar-main .agenda-list .compact-assignment { gap: 8px; padding: 7px 8px; min-height: 54px; }
.calendar-main .agenda-list .assignment-name { font-size: 14px; }
.calendar-main .agenda-list .row-action { width: 30px; height: 30px; }
/* The panel is narrow, so the hover buttons float over the time instead of reserving a column */
.calendar-main .agenda-list .compact-assignment { grid-template-columns: 20px minmax(0, 1fr) auto; }
.calendar-main .agenda-list .row-actions { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); padding: 2px; border-radius: 8px; background: var(--surface); box-shadow: 0 1px 6px rgba(15,23,42,.15); }
.calendar-main .list-footer { flex-wrap: wrap; }
.calendar-main :is(button, a):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.calendar-main .calendar-skeleton-cell { background: #edf2f7; border: 4px solid #fff; min-width: 0; }
.calendar-main.calendar-loading .month-panel .cal-grid { grid-template-rows: repeat(6, minmax(0, 1fr)); }
.calendar-loading .day-summary { display: none; }
.calendar-loading .day-list { min-height: 240px; border-radius: 8px; background: repeating-linear-gradient(to bottom, #edf2f7 0 68px, transparent 68px 80px); }
@media (max-width: 1100px) {
  .calendar-main .cal-layout { grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; }
  .calendar-main .day-panel { padding: 12px; }
}
@media (max-width: 760px) {
  .calendar-main .cal-layout { grid-template-columns: minmax(0, 1fr); }
  .calendar-main .month-panel .cal-grid { margin: 0 6px; grid-template-rows: 28px repeat(var(--calendar-weeks, 6), minmax(138px, 1fr)); }
  .calendar-main .month-panel .cal-day { padding: 3px; gap: 3px; }
  .calendar-main .cal-preview { padding: 3px 2px; font-size: 10px; }
  .calendar-main .month-panel .cal-day .n { width: 22px; height: 22px; font-size: 12px; }
  .calendar-main .cal-count { font-size: 10px; padding: 1px 3px; }
  .calendar-main .cal-more { font-size: 10px; }
  .calendar-main .calendar-toolbar .toolbar { flex-wrap: wrap; gap: 10px; }
  .calendar-main .calendar-toolbar .select { min-width: 0; max-width: 100%; }
  .calendar-main .calendar-key { font-size: 11px; gap: 8px; }
  .calendar-main .calendar-key > span:last-child { flex-basis: auto; }
  .calendar-main .page-header { flex-wrap: wrap; }
}

/* Calendar viewport layout. Short windows retain natural page scrolling. */
.main.calendar-main { padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.calendar-main .page-header { margin: 0; gap: 12px; }
.calendar-main .page-header h1 { font-size: 26px; }
.calendar-main .page-header .sub { display: none; }
.calendar-main .page-header .btn { min-height: 36px; padding: 8px 12px; font-size: 13px; }
.calendar-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.calendar-main .calendar-search-wrap { flex: 1 1 240px; margin: 0; }
.calendar-main .calendar-search-box { max-width: none; min-height: 38px; padding-top: 0; padding-bottom: 0; }
.calendar-main .calendar-search-box input { font-size: 14px; padding: 8px 0; }
.calendar-main .calendar-toolbar { margin: 0; }
.calendar-main .calendar-toolbar .select { max-width: 200px; min-width: 130px; padding: 7px 10px; }
.calendar-main .calendar-toolbar .check-label { font-size: 12px; }
.calendar-status { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 12px; }
.calendar-main #calendar-search-status { margin: 0; font-size: 12px; }
.calendar-main .cal-layout { min-height: 0; }
.calendar-main .month-panel .cal-head { padding: 10px 12px; }
.calendar-main .month-panel .cal-head h2 { font-size: 20px; }
.calendar-main .month-panel .cal-grid { grid-template-rows: 28px repeat(var(--calendar-weeks, 6), minmax(0, 1fr)); }
.calendar-main .month-panel .cal-day { gap: 2px; }
.calendar-main .month-panel .cal-day .n { width: 22px; height: 22px; font-size: 12px; }
.calendar-main .cal-preview { padding: 2px 4px; line-height: 16px; font-size: 11px; }
.calendar-main .cal-more { line-height: 14px; padding: 0; }
.calendar-main .calendar-key { padding: 8px 12px; font-size: 11px; }
.calendar-main .day-summary { margin-bottom: 10px; font-size: 12px; }
.calendar-main .day-nav { margin-bottom: 10px; }
.calendar-main .agenda-empty { padding: 20px 8px; }
.calendar-main .agenda-empty .empty-icon { width: 40px; height: 40px; margin-bottom: 10px; border-radius: 12px; }
.calendar-main .agenda-list .compact-assignment:hover { background: #f3f7fc; }
@media (min-width: 761px) {
  .main.calendar-main { height: 100dvh; min-height: 620px; }
  .calendar-main .cal-layout { flex: 1; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
  .calendar-main .month-panel { height: 100%; min-height: 0; }
  .calendar-main .month-panel .cal-grid { flex: 1; min-height: 0; }
  .calendar-main .day-panel { height: 100%; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior: contain; }
}
@media (max-width: 760px) {
  .main.calendar-main { padding: 16px 12px 24px; }
  .calendar-main .calendar-controls { gap: 10px; }
  .calendar-main .calendar-search-wrap { flex-basis: 100%; }
  .calendar-main .calendar-toolbar { width: 100%; }
  .calendar-main .month-panel { height: 650px; }
  .calendar-main .month-panel .cal-grid { flex: 1; min-height: 0; grid-template-rows: 28px repeat(var(--calendar-weeks, 6), minmax(0, 1fr)); }
}

/* Calendar phone/tablet layout; desktop rules remain unchanged. */
@media (max-width: 760px) {
  .main.calendar-main { padding: 16px 10px 28px; gap: 12px; }
  .calendar-main .page-header { align-items: center; gap: 10px; }
  .calendar-main .page-header h1 { font-size: 24px; }
  .calendar-main .page-header .toolbar { gap: 6px; }
  .calendar-main .page-header .btn { min-height: 44px; padding: 10px; font-size: 12px; }
  .calendar-main .calendar-controls { width: 100%; gap: 8px; }
  .calendar-main .calendar-search-box { min-height: 46px; border-radius: 10px; }
  .calendar-main .calendar-search-box input { font-size: 16px; }
  .calendar-main .calendar-search-box .btn { min-height: 40px; }
  .calendar-main .calendar-toolbar .toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; width: 100%; }
  .calendar-main .calendar-toolbar .select { width: 100%; max-width: none; min-height: 44px; font-size: 16px; padding: 8px; }
  .calendar-main .calendar-toolbar .check-label { min-height: 44px; font-size: 12px; gap: 7px; }
  .calendar-main .calendar-toolbar .check-label input { width: 18px; height: 18px; }
  .calendar-main .calendar-status { font-size: 12px; line-height: 1.5; }
  .calendar-main .cal-layout { gap: 14px; }
  .calendar-main .month-panel { height: 560px; border-radius: 10px; }
  .calendar-main .month-panel .cal-head { padding: 10px; gap: 8px; }
  .calendar-main .month-panel .cal-head h2 { font-size: 19px; }
  .calendar-main .cal-nav { gap: 6px; }
  .calendar-main .cal-nav .btn-icon { width: 44px; min-height: 44px; padding: 10px; }
  .calendar-main .month-panel .cal-grid { margin: 0 4px; }
  .calendar-main .month-panel .cal-dow { font-size: 10px; letter-spacing: 0; padding: 6px 0; }
  .calendar-main .month-panel .cal-day { padding: 3px 2px; gap: 3px; }
  .calendar-main .cal-date-line { gap: 1px; }
  .calendar-main .month-panel .cal-day .n { width: 20px; height: 22px; font-size: 12px; flex: none; }
  .calendar-main .cal-count { padding: 1px 2px; font-size: 10px; line-height: 1.4; }
  .calendar-main .cal-preview { font-size: 11px; padding: 2px; border-left-width: 2px; }
  .calendar-main .cal-more { font-size: 10px; white-space: normal; line-height: 1.3; }
  .calendar-main .calendar-key { padding: 10px 8px; gap: 6px 10px; font-size: 11px; }
  .calendar-main .day-panel { padding: 14px 12px; border-radius: 10px; height: auto; overflow: visible; }
  .calendar-main .day-nav { align-items: center; gap: 8px; }
  .calendar-main .day-nav h2 { font-size: 21px; }
  .calendar-main .day-nav .sub { font-size: 13px; }
  .calendar-main .day-summary { font-size: 13px; gap: 6px; margin-bottom: 10px; }
  .calendar-main .agenda-list .compact-assignment { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 6px 8px; padding: 12px 4px; }
  .calendar-main .agenda-list .assignment-toggle { width: 28px; height: 28px; }
  .calendar-main .agenda-list .assignment-name { font-size: 15px; line-height: 1.45; }
  .calendar-main .agenda-list .assignment-meta { font-size: 12px; line-height: 1.6; }
  .calendar-main .agenda-list .assignment-deadline { font-size: 13px; }
  .calendar-main .agenda-list .row-action { width: 44px; height: 44px; }
  .calendar-main .agenda-list .row-actions { gap: 2px; }
  .calendar-main .list-footer { gap: 10px; font-size: 12px; }
  .calendar-main .pager { margin-left: auto; }
  .calendar-main .pager .btn { min-height: 44px; padding: 10px 12px; font-size: 12px; }
}

/* Settings category workspace */
.main.settings-page { max-width: 1240px; padding: 28px 32px; }
.settings-page .page-header { margin-bottom: 20px; }
.settings-page .page-header h1 { font-size: 28px; }
.settings-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid #d4dfe9; border-radius: 12px; background: #fff; }
.settings-nav a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px; border-radius: 7px; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; }
.settings-nav a:hover { background: var(--navy-100); }
.settings-nav a.active { background: var(--navy); color: white; }
.settings-nav a > span:first-child { width: 18px; text-align: center; }
.settings-category-arrow { margin-left: auto; }
.settings-detail { min-width: 0; }
.settings-page .settings-grid { display: block; max-width: none; }
.settings-category { display: grid; gap: 12px; }
.settings-page [hidden], .inline-class-create[hidden] { display: none; }
/* Assignments page: each class lists the dashboard's compact rows, with its own search and type filter */
.class-list .compact-assignment { min-height: 54px; padding: 7px 10px; margin-bottom: 6px; }
.class-filters { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; }
.class-filters .input { flex: 1 1 200px; min-width: 0; padding: 7px 10px; font-size: 13px; }
.class-filters .select { flex: none; width: auto; padding: 7px 28px 7px 10px; font-size: 13px; }
.class-filters .btn { flex: none; white-space: nowrap; }
.class-filter-count { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 760px) {
  .class-filters { flex-wrap: wrap; }
  .class-filters .input { flex-basis: 100%; }
}
.settings-page .card { padding: 18px; border-color: #d4dfe9; box-shadow: none; border-radius: 10px; }
.settings-page .card-header { margin-bottom: 12px; align-items: flex-start; }
.settings-page .card-header h3 { font-size: 18px; }
.settings-page .setting-row { padding: 12px 0; gap: 14px; border-color: #e2e8ef; }
.settings-page .setting-row .info { min-width: 0; }
.settings-page .setting-row .d { line-height: 1.5; overflow-wrap: anywhere; }
.settings-page .setting-row .control { flex-wrap: wrap; justify-content: flex-end; }
.settings-page .field { margin-bottom: 12px; }
.settings-page .chip { padding: 7px 11px; font-size: 12px; }
.settings-page .callout { margin-top: 12px; font-size: 12px; }
.settings-page .settings-actions { margin-top: 14px; }
.settings-page .account-details { margin: 0; }
.account-details > div { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid #e2e8ef; }
.account-details > div:last-child { border-bottom: 0; }
.account-details dt { font-size: 13px; color: var(--muted); }
.account-details dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.settings-back { display: none; }
.settings-page a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.inline-class-create { padding: 16px; margin-bottom: 16px; border: 1px solid #c7d7e7; border-radius: 8px; background: #f5f8fc; }
.inline-class-create .hint { font-size: 12px; color: var(--muted); margin: 6px 0 12px; }
@media (max-width: 1000px) {
  .main.settings-page { padding: 24px 18px; }
  .settings-shell { grid-template-columns: 175px minmax(0, 1fr); gap: 12px; }
  .settings-page .setting-row { flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .main.settings-page { padding: 20px 12px 32px; }
  .settings-shell { display: block; }
  .settings-nav { position: static; }
  .settings-detail { display: none; }
  .settings-shell.show-detail .settings-nav { display: none; }
  .settings-shell.show-detail .settings-detail { display: block; }
  .settings-back { display: inline-flex; margin-bottom: 12px; min-height: 44px; }
  .settings-page .card { padding: 16px 12px; }
  .settings-page .setting-row .control { justify-content: flex-start; max-width: 100%; }
  .settings-page .row { flex-wrap: wrap; }
  .settings-page .row > * { min-width: 0; }
  .settings-page .input, .settings-page .select { font-size: 16px; }
}

/* Settings visual polish */
.main.settings-page { max-width: none; background: radial-gradient(ellipse at top right, #e8f0f9 0, transparent 60%); }
.settings-page .settings-shell { grid-template-columns: 230px minmax(0, 1fr); gap: 24px; }
.settings-page .settings-nav { padding: 10px; border-color: #cedceb; box-shadow: 0 4px 18px #173b6006; }
.settings-page .settings-nav a { padding: 12px; gap: 12px; min-height: 52px; }
.settings-page .settings-nav .settings-category-icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 8px; background: #eaf1f9; color: #245b91; }
.settings-category-icon svg { width: 19px; height: 19px; }
.settings-page .settings-nav a.active { background: linear-gradient(110deg, #173b60, #245b91); box-shadow: 0 3px 8px #173b601a; }
.settings-page .settings-nav a.active .settings-category-icon { background: #ffffff1f; color: #fff; }
.settings-page .card { padding: 24px; border-color: #cedceb; box-shadow: 0 5px 20px #173b6006; border-radius: 14px; }
.settings-page .card-header { padding-bottom: 16px; border-bottom: 1px solid #dce7f2; margin-bottom: 18px; }
.settings-page .card-header h3 { color: var(--navy); font-size: 21px; }
.settings-page .settings-category > .card:only-child { min-height: clamp(380px, calc(100dvh - 190px), 580px); }
.settings-page .settings-category { gap: 18px; }
.settings-page .setting-row { padding: 16px 0; }
.settings-page .setting-row .t { color: var(--navy); }
.settings-page .input, .settings-page .select { border-color: #a8bdd1; border-radius: 8px; background: #fbfdff; }
.settings-page .input:focus, .settings-page .select:focus { background: #fff; }
.settings-page .callout { background: #eaf3ff; border-color: #c6dbf0; color: #234e78; border-radius: 10px; }
.settings-page .chip { border-color: #adbed1; background: #f2f6fb; }
.settings-page .chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.settings-profile-banner { display: flex; align-items: center; gap: 16px; padding: 22px; margin-bottom: 20px; border-radius: 12px; border: 1px solid #d4e3f2; background: linear-gradient(115deg, #e7f0fa, #f5f9fd); color: var(--navy); }
.settings-profile-avatar { display: grid; place-items: center; width: 60px; height: 60px; flex: none; border-radius: 16px; background: var(--navy); color: white; }
.settings-profile-avatar svg { width: 30px; height: 30px; }
.settings-profile-banner strong { font-size: 18px; }
.settings-profile-banner p { margin-top: 4px; font-size: 13px; color: #496883; }
.settings-page .account-details > div { grid-template-columns: 140px minmax(0, 1fr); padding: 20px 12px; border-radius: 6px; }
.settings-page .account-details > div:nth-child(odd) { background: #f6f9fd; }
.settings-page .account-details dd { font-weight: 500; }
.settings-password-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; }
.settings-password-form > .setting-row, .settings-password-form > .form-error, .settings-password-form > .field:has(#pw-current) { grid-column: 1 / -1; }
.settings-password-form > button { grid-column: 1 / -1; justify-self: start; margin-top: 8px; background: var(--navy); color: white; border-color: var(--navy); }
.settings-page .settings-actions { padding: 14px 18px; background: #eaf1fa; border: 1px solid #d1deed; border-radius: 10px; }
.settings-page #settings-class-list .setting-row { align-items: center; }
@media (max-width: 1000px) {
  .settings-page .settings-shell { grid-template-columns: 200px minmax(0, 1fr); gap: 16px; }
  .settings-page .card { padding: 20px; }
  .settings-password-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .settings-page .settings-shell { display: block; }
  .settings-page .card { padding: 18px 14px; }
  .settings-page .settings-category > .card:only-child { min-height: 0; }
  .settings-profile-banner { padding: 16px; gap: 12px; }
  .settings-profile-avatar { width: 46px; height: 46px; border-radius: 12px; }
  .settings-profile-banner strong { font-size: 16px; }
  .settings-page .account-details > div { grid-template-columns: 85px minmax(0, 1fr); gap: 12px; padding: 16px 8px; }
}

/* Shared mobile layout and accessible navigation. */
.mobile-header, .mobile-menu-close { display: none; }
.nav-scrim[hidden] { display: none; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; transform: translateY(-160%); padding: 12px 18px; background: var(--surface); color: var(--navy); border: 2px solid var(--navy); border-radius: 8px; }
.skip-link:focus { transform: none; }
@media (max-width: 760px) {
  .app, .overview-app { display: block; min-height: 100dvh; }
  .mobile-header { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-height: 72px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); background: var(--surface); }
  .mobile-header .brand { color: var(--navy); font-size: 20px; }
  .mobile-header .brand-mark { background: var(--navy); color: white; width: 34px; height: 34px; }
  .mobile-header .menu-open { width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; color: var(--navy); }
  .mobile-header .menu-open svg { width: 24px; height: 24px; }
  body.navigation-open { overflow: hidden; }
  .nav-scrim { position: fixed; inset: 0; z-index: 60; background: rgb(15 23 42 / 48%); }
  .app .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 61; width: min(320px, calc(100vw - 32px)); height: 100dvh; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 16px; overflow-y: auto; overscroll-behavior: contain; border: 0; border-right: 1px solid var(--border); visibility: hidden; transform: translateX(-100%); transition: transform .2s ease, visibility .2s; }
  .app .sidebar.is-open { visibility: visible; transform: translateX(0); }
  .app .sidebar .mobile-menu-close { display: inline-grid; place-items: center; align-self: flex-end; width: 44px; height: 44px; padding: 0; color: var(--navy); }
  .app .sidebar .mobile-menu-close svg { width: 22px; height: 22px; }
  .app .sidebar .brand { padding: 0 8px 12px; font-size: 22px; gap: 10px; }
  .app .sidebar .brand-mark { width: 36px; height: 36px; }
  .app .sidebar .nav { flex: none; flex-direction: column; justify-content: flex-start; gap: 6px; }
  .app .sidebar .nav a { padding: 14px; min-height: 48px; font-size: 16px; gap: 12px; }
  .app .sidebar .nav a span { display: inline; }
  .app .sidebar .nav a.active { box-shadow: none; }
  .app .sidebar .sidebar-bottom { display: block; margin-top: auto; padding-top: 16px; }
  .app .sidebar .user-chip { padding: 12px; }
  .app .sidebar .user-chip .name, .app .sidebar .user-chip .email { white-space: normal; overflow-wrap: anywhere; }
  .main, .overview-main, .main.assignments-page, .main.calendar-main, .main.settings-page { padding: 20px 16px max(32px, env(safe-area-inset-bottom)); }
  .main .page-header { align-items: flex-start; gap: 16px; margin-bottom: 20px; }
  .main .page-header > div { min-width: 0; }
  .main .page-header h1 { font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
  .main .page-header .sub { font-size: 14px; line-height: 1.6; }
  .main .page-header > .toolbar { width: 100%; gap: 8px; }
  .main .page-header .toolbar .btn { min-height: 44px; padding: 10px 14px; font-size: 14px; }
  .btn, .chip, .text-button { min-height: 44px; }
  .btn-icon, .row-action { min-width: 44px; min-height: 44px; }
  .input, .select, textarea { font-size: 16px; min-height: 44px; max-width: 100%; }
  .card, .class-card, .modal, .setting-row .info, .setting-row .control { min-width: 0; }
  .card h2, .card h3, .assignment-name, .class-name, .setting-row .d, .callout, .account-details dd { overflow-wrap: anywhere; }
  .queue-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .queue-controls .input { grid-column: 1 / -1; }
  .queue-controls #sort { grid-column: 1 / -1; }
  .overview-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-rail { grid-template-columns: minmax(0, 1fr); }
  .queue-context, .list-footer, .day-nav, .cal-head { flex-wrap: wrap; gap: 10px; }
  .assignment-name { white-space: normal; line-height: 1.5; }
  .assignment-meta { line-height: 1.6; }
  .calendar-main .calendar-toolbar .toolbar { grid-template-columns: minmax(0, 1fr); }
  .calendar-main .calendar-toolbar .check-label { font-size: 14px; }
  .calendar-main .month-panel { height: clamp(420px, 76svh, 560px); }
  .calendar-main .month-panel .cal-day { min-height: 44px; }
  .calendar-main .month-panel .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .calendar-main .calendar-key { line-height: 1.5; }
  .settings-page .setting-row .info { min-width: 0; flex-basis: 100%; }
  .settings-page .setting-row .control { flex-wrap: wrap; gap: 12px; }
  .settings-page .account-details > div { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .settings-page .settings-save-actions { position: static; }
  .settings-page #save { width: 100%; white-space: normal; }
  .settings-page .row > .field { flex-basis: 100%; }
  .modal-backdrop { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .modal { max-width: 100%; max-height: calc(100dvh - 32px); overflow-y: auto; padding: 20px 16px; }
  .modal .row { flex-wrap: wrap; }
  .modal .row > .field { flex-basis: 100%; }
  .modal-actions { flex-wrap: wrap; gap: 10px; }
  .modal-actions .btn { flex: 1 1 auto; }
  .auth-panel { padding: 32px 20px; }
  .auth-card { min-width: 0; width: 100%; }
  .auth-card > .sub { line-height: 1.6; }
  .auth-card .row { flex-wrap: wrap; }
  .auth-card .row > .field { flex-basis: 100%; }
  .auth-card .between { flex-wrap: wrap; gap: 12px; }
  .auth-footer { line-height: 1.7; }
}
@media (prefers-reduced-motion: reduce) {
  .app .sidebar { transition: none; }
}

/* Dashboard only: a short, task-first phone view. Desktop retains its layout. */
.mobile-dashboard-control { display: none; }
.dashboard-filters { display: contents; }
@media (max-width: 760px) {
  .dashboard-main .mobile-dashboard-control { display: inline-flex; }
  .dashboard-main .mobile-dashboard-control[hidden] { display: none; }
  .dashboard-main .page-header { gap: 10px; margin-bottom: 14px; }
  .dashboard-main .page-header h1 { font-size: 22px; line-height: 1.3; }
  .dashboard-main .page-header #today-line { font-size: 13px; margin-top: 4px; }
  .dashboard-main .page-header .toolbar { width: auto; }
  .dashboard-main .page-header .toolbar a { display: none; }
  .dashboard-main .page-header .toolbar .btn { padding: 8px 12px; }
  .dashboard-main .overview-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 16px; }
  .dashboard-main .overview-stats .stat { flex-direction: column-reverse; justify-content: center; align-items: center; padding: 10px 3px; gap: 4px; min-height: 72px; border-radius: 8px; box-shadow: none; }
  .dashboard-main .overview-stats .stat-copy { display: block; text-align: center; }
  .dashboard-main .overview-stats .label { font-size: 11px; line-height: 1.3; white-space: normal; }
  .dashboard-main .overview-stats .value { font-size: 24px; line-height: 1; }
  .dashboard-main .overview-stats .stat-icon, .dashboard-main .overview-stats .foot { display: none; }
  .dashboard-main .queue-panel { padding: 14px 12px; border-radius: 12px; }
  .dashboard-main .queue-panel > .card-header { gap: 8px; margin-bottom: 8px; align-items: center; }
  .dashboard-main .queue-heading { gap: 8px; }
  .dashboard-main .queue-heading h2 { font-size: 19px; }
  .dashboard-main #toggle-dashboard-filters { flex-basis: 100%; order: 2; justify-content: space-between; padding: 10px 12px; font-size: 13px; }
  .dashboard-main .dashboard-filters { display: none; padding: 12px 10px; margin: -9px 0 10px; border: 1px solid var(--navy); border-top: 0; border-radius: 0 0 10px 10px; background: #f6f9fd; }
  .dashboard-main .dashboard-filters.is-open { display: block; }
  .dashboard-main .dashboard-completed { display: none; }
  .dashboard-main .queue-panel:has(.dashboard-filters.is-open) .dashboard-completed { display: flex; flex-basis: 100%; order: 3; min-height: 44px; margin: -8px 0 0; padding: 8px 12px 0; border: 1px solid var(--navy); border-top: 0; border-bottom: 0; background: #f6f9fd; }
  .dashboard-main .queue-panel:has(.dashboard-filters.is-open) > .card-header { margin-bottom: 0; }
  .dashboard-main .dashboard-filters { margin-top: 0; }
  .dashboard-main .queue-controls { margin: 0; }
  .dashboard-main .queue-context { font-size: 12px; margin-bottom: 10px; }
  .dashboard-main .compact-assignment, .dashboard-main .compact-assignment.sortable { grid-template-columns: 32px minmax(0, 1fr); gap: 4px 10px; padding: 12px 8px; min-height: 0; }
  .dashboard-main .assignment-toggle { grid-column: 1; grid-row: 1 / 3; align-self: center; width: 30px; height: 30px; }
  .dashboard-main .assignment-open { grid-column: 2; min-width: 0; }
  .dashboard-main .assignment-name { font-size: 14px; line-height: 1.4; }
  .dashboard-main .assignment-meta { font-size: 12px; line-height: 1.5; }
  .dashboard-main .assignment-deadline { grid-column: 2; text-align: left; font-size: 12px; display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; align-items: baseline; }
  .dashboard-main .assignment-deadline > * { font-size: inherit; }
  .dashboard-main .row-actions, .dashboard-main .drag-handle { display: none; }
  .dashboard-main .list-footer { padding-top: 12px; font-size: 12px; }
  .dashboard-main #dashboard-show-more { margin-left: auto; }
  .dashboard-main .dashboard-rail { display: grid; margin-top: 12px; }
}

/* Phone disclosures ("Search & filters"): the chevron flips and the button
   turns solid while open, with the panel attached underneath. */
@media (max-width: 760px) {
  .disclosure-toggle { display: inline-flex; align-items: center; gap: 8px; }
  .disclosure-toggle .chev { width: 16px; height: 16px; flex: none; transition: transform .15s; }
  .disclosure-toggle[aria-expanded="true"] { background: var(--navy); border-color: var(--navy); color: #fff; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .disclosure-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
}

/* Compact secondary pages on phones; desktop controls keep their original flow. */
.mobile-disclosure { display: none; }
.mobile-filter-panel, .class-list-options { display: contents; }
@media (max-width: 760px) {
  .mobile-disclosure { display: inline-flex; width: 100%; justify-content: space-between; padding: 10px 12px; font-size: 13px; }
  .mobile-filter-panel { display: none; padding: 12px 10px; margin-top: -1px; border: 1px solid var(--navy); border-top: 0; border-radius: 0 0 10px 10px; background: #f6f9fd; }
  .mobile-filter-panel.is-open { display: block; }
  .main:not(.dashboard-main) { padding-top: 16px; }
  .main:not(.dashboard-main) .page-header { gap: 10px; margin-bottom: 14px; }
  .main:not(.dashboard-main) .page-header h1 { font-size: 24px; }
  .main:not(.dashboard-main) .page-header .sub { font-size: 13px; line-height: 1.5; margin-top: 4px; }
  .main:not(.dashboard-main) .page-header > .toolbar { gap: 8px; }
  .main:not(.dashboard-main) .page-header .toolbar .btn { padding: 8px 12px; }
  /* Calendar: dates and counts first; full assignment titles are in the daily agenda. */
  .calendar-main .calendar-controls { margin: 0; }
  /* The open filters panel hangs off the disclosure button like the dashboard's */
  /* The page is a flex column with a 12px gap; pull the open panel up over it so it touches the button */
  .calendar-main #calendar-filters { padding: 12px 12px 4px; margin: -13px 0 0; }
  .calendar-main #calendar-filters .calendar-controls { gap: 10px; }
  .calendar-main #calendar-filters .calendar-search-box { background: #fff; }
  .calendar-main #calendar-filters .calendar-toolbar .toolbar { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .calendar-main #calendar-filters .check-label { min-height: 40px; }
  .calendar-main .mobile-disclosure { margin-bottom: 10px; }
  .calendar-main .mobile-disclosure[aria-expanded="true"] { margin-bottom: 0; }
  .calendar-main .calendar-status { gap: 4px; margin-bottom: 10px; }
  .calendar-main .calendar-status p:empty { display: none; }
  .calendar-main .month-panel { height: auto; }
  .calendar-main .month-panel .cal-grid { flex: none; grid-template-rows: 24px repeat(var(--calendar-weeks, 6), minmax(44px, auto)); gap: 2px; }
  .calendar-main .month-panel .cal-day { min-height: 44px; padding: 4px 2px; justify-content: center; }
  .calendar-main .cal-date-line { flex-wrap: wrap; justify-content: center; gap: 2px 4px; }
  .calendar-main .month-panel .cal-day .n { font-size: 13px; width: 24px; height: 24px; }
  .calendar-main .cal-count { font-size: 11px; padding: 1px 3px; }
  .calendar-main .cal-preview, .calendar-main .cal-more { display: none; }
  .calendar-main .calendar-key { padding: 8px; gap: 4px 12px; font-size: 12px; }
  .calendar-main .day-panel { padding: 14px 12px; }
  .calendar-main .day-nav h2 { font-size: 19px; }
  .calendar-main .agenda-list .compact-assignment { grid-template-columns: 30px minmax(0, 1fr); gap: 4px 8px; padding: 10px 4px; min-height: 0; }
  .calendar-main .agenda-list .assignment-toggle { grid-column: 1; grid-row: 1 / 3; align-self: center; }
  .calendar-main .agenda-list .assignment-open { grid-column: 2; }
  .calendar-main .agenda-list .assignment-name { font-size: 14px; line-height: 1.4; }
  .calendar-main .agenda-list .assignment-deadline { grid-column: 2; grid-row: 2; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .calendar-main .agenda-list .row-actions { display: none; }
  /* Classes retain their labeled collapse controls and management actions. */
  .assignments-page .page-header .toolbar { display: flex; flex-wrap: wrap; }
  .assignments-page #class-list-options { display: flex; flex-basis: 100%; flex-wrap: wrap; align-items: center; gap: 8px 14px; order: 3; }
  .assignments-page #class-list-options label { min-height: 44px; }
  .assignments-page .class-grid { gap: 12px; }
  .assignments-page .class-heading { padding: 12px; gap: 8px; }
  .assignments-page .class-toggle { min-height: 44px; }
  .assignments-page .class-toggle .code { font-size: 15px; line-height: 1.4; }
  .assignments-page .class-toggle .cname { font-size: 12px; }
  .assignments-page .class-actions { padding-left: 0; gap: 6px; }
  .assignments-page .class-actions .btn { min-height: 44px; padding: 8px; font-size: 12px; }
  .assignments-page .class-body { padding: 0 10px 10px; gap: 8px; }
  .assignments-page .a-row { padding: 10px 8px; }
  .assignments-page .a-row .meta { font-size: 12px; line-height: 1.5; }
  .assignments-page .a-row .tag { font-size: 11px; }
  .assignments-page .assignment-edit, .assignments-page .notes-add { min-height: 44px; }
  /* Settings: compact categories and short, readable form groups. */
  .settings-page .settings-nav { padding: 6px; }
  .settings-page .settings-nav a { min-height: 48px; padding: 8px 10px; font-size: 14px; gap: 10px; }
  .settings-page .settings-category { gap: 12px; }
  .settings-page .settings-back { padding: 8px 0; margin-bottom: 8px; }
  .settings-page .card { padding: 14px 12px; border-radius: 10px; }
  .settings-page .card-header { padding-bottom: 10px; margin-bottom: 10px; gap: 10px; }
  .settings-page .card-header h3 { font-size: 18px; }
  .settings-page .card-header .sub, .settings-page .setting-row .d { font-size: 13px; line-height: 1.5; }
  .settings-page .setting-row { padding: 10px 0; gap: 8px; }
  .settings-page .setting-row .t { font-size: 14px; }
  .settings-page .settings-profile-banner { padding: 12px; margin-bottom: 12px; gap: 10px; }
  .settings-page .settings-profile-banner p { font-size: 12px; }
  .settings-page .account-details > div { padding: 12px 8px; gap: 4px; }
  .settings-page .field { margin-bottom: 10px; }
  .settings-page .callout { padding: 10px 12px; font-size: 13px; line-height: 1.5; }
  .settings-page .settings-actions { padding: 12px; margin-top: 12px; }
  /* Authentication and error pages use the same readable form rhythm. */
  .auth-wrap .auth-panel { padding: 24px 20px; min-height: 100dvh; }
  .auth-card h2 { font-size: 24px; line-height: 1.3; }
  .auth-card .field { margin-bottom: 12px; }
  .auth-card .row { gap: 0 12px; }
  .auth-card .field label { font-size: 14px; }
  .auth-card .hint { font-size: 12px; line-height: 1.5; }
  .auth-login .login-intro h1 { font-size: 21px; margin-bottom: 6px; }
  .auth-login .login-intro { padding-top: 14px; padding-bottom: 12px; }
  .auth-login .login-intro-copy { margin-top: 10px; }
  .auth-login .login-supports { margin-top: 8px; }
  .auth-login .auth-panel { padding-top: 14px; padding-bottom: 20px; }
  .modal .field { margin-bottom: 12px; }
  .modal h3 { font-size: 20px; line-height: 1.3; }
}

/* Admin page: OKR tiles, charts, meters, user list.
   Compact on purpose: at desktop widths each panel fits one screen. */
.admin-page .page-header { margin-bottom: 14px; }
.admin-page .settings-grid .card { padding: 12px 16px; }
.admin-page .card-header { margin-bottom: 10px; }
.admin-page .card-header .sub { font-size: 12px; line-height: 1.4; }
/* OKRs: two cards stacked, sharing the height left under the page header */
#admin-okrs:not([hidden]) { display: flex; flex-direction: column; gap: 8px; min-height: calc(100vh - 150px); }
.okr-objective { flex: none; display: flex; align-items: center; gap: 10px; padding: 2px 2px 0; }
.okr-kicker { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--navy); padding: 3px 8px; border-radius: 999px; }
.okr-objective h4 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.okr-pair { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.okr-card { min-height: 0; display: flex; flex-direction: column; }
.okr-card .card-header { flex: none; flex-wrap: nowrap; align-items: center; gap: 10px; padding-bottom: 6px; margin-bottom: 6px; }
.okr-card .card-header h3 { font-size: 17px; min-width: 0; }
.okr-target { flex: none; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--navy-100); color: var(--navy); white-space: nowrap; }
.okr-target.met { background: var(--ok-bg); color: var(--ok); }
.okr-target.missed { background: var(--warn-bg); color: var(--warn); }
.okr-charts.single { grid-template-columns: 1fr; }
.okr-toolbar { flex: none; }
.okr-toolbar .select { width: auto; padding: 6px 28px 6px 10px; font-size: 13px; }
.okr-tiles { flex: none; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; margin-bottom: 6px; }
.okr-tiles .stat { cursor: default; gap: 3px; padding: 8px 12px; }
.okr-tiles .stat:hover { border-color: var(--border); background: var(--surface); }
.okr-tiles .stat .label { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.okr-tiles .stat .value { font-size: 21px; white-space: nowrap; }
.okr-tiles .stat .foot { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.okr-charts { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); gap: 14px; }
.okr-chart { margin: 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; transition: opacity .15s; }
.okr-chart.loading { opacity: .5; }
.okr-chart figcaption { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
/* The SVG is absolutely positioned so its size never feeds back into the
   box it is measured from; the box grows with the card. */
.okr-chart-body { flex: 1 1 auto; min-height: 120px; position: relative; }
.chart-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; outline: none; }
.chart-svg:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.chart-grid { stroke: #e2e8ef; stroke-width: 1; }
.chart-axis { font-size: 11px; fill: var(--muted); }
.chart-end-label { font-size: 12px; font-weight: 600; fill: var(--text); }
.chart-hair { stroke: #94a3b8; stroke-width: 1; }
.chart-tip { position: absolute; transform: translate(12px, -50%); background: #fff; border: 1px solid #cedceb; border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--muted); box-shadow: 0 6px 18px #173b601a; pointer-events: none; white-space: nowrap; z-index: 2; }
.chart-tip.flip { transform: translate(calc(-100% - 12px), -50%); }
.chart-tip strong { display: block; font-size: 18px; color: var(--text); line-height: 1.2; }
.chart-tip-date { font-weight: 600; }
.okr-subhead { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.meter-list { flex: 1 1 auto; min-height: 0; display: grid; gap: 4px; align-content: space-evenly; }
.meter-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 60px; align-items: center; gap: 10px; font-size: 12px; }
.meter-label { color: var(--text); }
.meter-track { height: 7px; border-radius: 4px; background: #e6edf5; overflow: hidden; }
.meter-fill { height: 100%; min-width: 0; border-radius: 0 4px 4px 0; background: #245b91; }
.meter-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Users panel: search + filter row, then a list that scrolls inside the card
   on desktop so the page itself fits the screen. */
.user-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.user-tools .input { flex: 1 1 220px; min-width: 0; padding: 7px 10px; font-size: 13px; }
.user-tools .chip { padding: 6px 12px; font-size: 12px; cursor: pointer; }
.admin-user-list { max-height: calc(100vh - 290px); min-height: 160px; overflow-y: auto; border-top: 1px solid #e2e8ef; }
.admin-user-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #e2e8ef; }
.admin-user-row .info { min-width: 0; }
.admin-user-row .t { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.admin-user-row .d { font-size: 12px; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.admin-username { font-size: 12px; font-weight: 500; color: var(--muted); }
.admin-user-row .control { display: flex; align-items: center; gap: 8px; flex: none; }
.admin-user-row .btn-sm { padding: 5px 10px; font-size: 12px; }
.admin-empty { padding: 16px 0; }
.tag.admin-tag { background: #e0ecf8; color: #1e4a76; }
.users-card .card-header, .types-card .card-header { align-items: flex-start; }
.users-card .card-header .btn { flex: none; }
.admin-user-row .btn.danger-text { color: var(--danger); }
.admin-user-row .btn.danger-text:hover { background: var(--danger-bg, #fee2e2); color: var(--danger); }
/* Assignment types: an add row above the list, inline rename inside a row */
.type-add { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.type-add .input { flex: 1 1 220px; min-width: 0; padding: 7px 10px; font-size: 13px; }
.type-add .btn { flex: none; }
#type-error { margin-bottom: 8px; }
.type-row .info { flex: 1 1 auto; }
.type-rename { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.type-rename .input { flex: 1 1 160px; min-width: 0; padding: 6px 10px; font-size: 13px; }
/* Add / edit user modal */
.user-name-row { align-items: flex-start; }
.user-name-row .field { flex: 1 1 0; min-width: 0; }
.admin-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-switch-row .hint { display: block; margin-top: 2px; }
.admin-switch-row .switch input:disabled + .slider { opacity: .45; cursor: not-allowed; }
@media (max-width: 1000px) {
  .okr-pair { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .admin-page .settings-grid .card { padding: 14px 12px; }
  #admin-okrs { min-height: 0; }
  .okr-pair { grid-template-columns: 1fr; flex: none; }
  .okr-card { flex: none; }
  .okr-card .card-header { flex-wrap: wrap; }
  .okr-objective { flex-wrap: wrap; }
  .okr-charts { flex: none; grid-template-columns: 1fr; grid-template-rows: none; }
  .okr-chart-body { flex: none; height: 150px; }
  .meter-row { grid-template-columns: 1fr; gap: 3px; }
  .meter-value { text-align: left; }
  .admin-user-list { max-height: none; min-height: 0; overflow: visible; }
  .admin-user-row { flex-wrap: wrap; }
  .admin-user-row .control { width: 100%; justify-content: flex-start; }
  .user-tools .input { flex-basis: 100%; }
  .users-card .card-header { flex-wrap: wrap; }
  .type-add { flex-wrap: wrap; }
  .type-add .input { flex-basis: 100%; }
  .user-name-row { flex-direction: column; gap: 0; }
}
@media (max-width: 600px) {
  .okr-tiles { grid-template-columns: 1fr 1fr; }
  .okr-tiles .stat:first-child { grid-column: 1 / -1; }
}

/* Bulk assignment time estimates */
.estimate-item { min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 16px 0; }
.estimate-item legend { max-width: 100%; overflow-wrap: anywhere; font-size: 14px; font-weight: 600; padding: 0 4px; }
.estimate-options { display: flex; flex-wrap: wrap; gap: 6px; }
.estimate-options [aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.estimate-custom { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.estimate-custom .input { width: 140px; max-width: 50%; }
.estimate-total { margin: 16px 0; }


/* Notifications read as one ordered settings panel at every desktop width. */
.settings-page #settings-notifications { grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 900px; }
.settings-page #settings-notifications > .card { min-width: 0; padding: 20px 24px; }
.settings-page #settings-notifications .card-header { flex-wrap: nowrap; align-items: flex-start; gap: 20px; padding-bottom: 14px; margin-bottom: 0; }
.settings-page #settings-notifications .card-header > div { min-width: 0; }
.settings-page #settings-notifications .card-header h3 { font-size: 18px; line-height: 1.4; }
.settings-page #settings-notifications .card-header .sub { margin-top: 4px; font-size: 13px; line-height: 1.5; }
.settings-page #settings-notifications .card-header > .switch { margin-top: 2px; }
.settings-page #settings-notifications .setting-row { padding: 14px 0; align-items: center; gap: 16px; }
.settings-page #settings-notifications .card-header + .setting-row,
.settings-page #settings-notifications .card-header + div > .setting-row:first-child { border-top: 0; }
.settings-page #settings-notifications .setting-row .t { font-size: 14px; }
.settings-page #settings-notifications .setting-row .d { font-size: 13px; line-height: 1.5; }
.settings-page #settings-notifications .chips { gap: 8px; margin-bottom: 12px; }
.settings-page #settings-notifications .callout { padding: 12px 14px; margin-top: 14px; line-height: 1.6; }
.settings-page #settings-save-actions { max-width: 900px; box-sizing: border-box; }
@media (max-width: 760px) {
  .settings-page #settings-notifications > .card { padding: 16px; }
  .settings-page #settings-notifications .card-header { gap: 12px; }
  .settings-page #settings-notifications .setting-row { gap: 10px; }
  .settings-page #settings-notifications .setting-row .control { width: 100%; justify-content: flex-start; }
  .settings-page #settings-notifications .setting-row .control .input,
  .settings-page #settings-notifications .setting-row .control .select { max-width: 100%; }
}


/* Cross-document transitions preserve normal links and browser history. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }

  ::view-transition-old(root) {
    animation: page-leave 1050ms cubic-bezier(.2,.65,.3,1) both;
  }
  ::view-transition-new(root) {
    animation: navigation-enter 1150ms cubic-bezier(.2,.65,.3,1) both;
  }
  ::view-transition { pointer-events: none; }
}

/* Page entrances and control feedback. */
.assignment-completion-burst { display: none; }
@media (prefers-reduced-motion: no-preference) {
  /* The incoming snapshot supplies the entrance on animated navigation. */
  html:not(.animated-navigation) .main:not(.dashboard-main) > .page-header,
  html:not(.animated-navigation) .main > :is(.class-grid, .cal-layout, .settings-shell),
  html:not(.animated-navigation) .main.reveal > *,
  html:not(.animated-navigation) :is(.auth-login, .auth-wrap) {
    animation: page-enter 1150ms cubic-bezier(.2,.65,.3,1);
  }
  /* The sign-in page's illustration follows the rest of the page in */
  html:not(.animated-navigation) .login-art {
    animation: page-enter 1150ms cubic-bezier(.2,.65,.3,1) 650ms both;
  }

  .btn {
    transition: background 1050ms ease-out, box-shadow 1050ms ease-out, transform 1050ms ease-out;
  }

  @media (hover: hover) and (pointer: fine) {
    .btn:hover:not(:disabled) { transform: translateY(-5px); }
  }

  .btn:active:not(:disabled), .tour-option:active, .help-tip:active {
    transform: translateY(3px) scale(.92);
  }

  .tour-option, .help-tip {
    transition: background-color 1050ms ease-out, border-color 1050ms ease-out, opacity 1050ms ease-out, transform 1050ms ease-out;
  }

  .btn:active:not(:disabled) { transition-duration: 1050ms, 1050ms, 0s; }
  .assignment-completion-burst {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    border-radius: inherit;
    overflow: hidden;
    color: white;
    pointer-events: none;
    animation: completion-burst 320ms linear both;
  }
  .assignment-completion-burst::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, var(--ok), #299957);
    transform-origin: left center;
    animation: completion-expand 155ms cubic-bezier(.18,.8,.28,1) both;
  }
  .assignment-completion-burst svg {
    position: relative;
    width: 30px;
    height: 30px;
    animation: check-pop 280ms ease-out both;
  }
  .assignment-completing .assignment-completion-burst { animation: none; }
  .assignment-completing { animation: assignment-exit 320ms ease-out both; }
  .onboarding-body, #onboarding-content > h3, #onboarding-actions > .btn, .walk-callout > h3,
  .walk-callout > p:not(.walk-kicker) {
    animation: page-enter 1050ms ease-out;
  }

  @supports not ((transition-behavior: allow-discrete) and (interactivity: inert)) {
    .modal-backdrop.open { animation: surface-enter 1050ms ease-out; }
    .modal-backdrop.open > .modal { animation: page-enter 1050ms ease-out; }

    @media (max-width: 760px) {
      .dashboard-main .dashboard-filters.is-open, .mobile-filter-panel.is-open {
        animation: panel-enter 1050ms ease-out;
      }
    }
  }

  /* Discrete display transitions preserve the closed layout. Closing
     surfaces release pointer and keyboard interaction immediately. */
  @supports (transition-behavior: allow-discrete) and (interactivity: inert) {
    .modal-backdrop {
      opacity: 0;
      interactivity: inert;
      pointer-events: none;
      transition: opacity 1050ms ease-out, display 1050ms allow-discrete;
    }
    .modal-backdrop.open {
      opacity: 1;
      interactivity: auto;
      pointer-events: auto;
    }
    .modal-backdrop > .modal {
      transform: translateY(32px) scale(.93);
      transition: transform 1050ms ease-out;
    }
    .modal-backdrop.open > .modal { transform: none; }

    @starting-style {
      .modal-backdrop.open { opacity: 0; }
      .modal-backdrop.open > .modal { transform: translateY(32px) scale(.93); }
    }

    @media (max-width: 760px) {
      .dashboard-main .dashboard-filters, .mobile-filter-panel {
        opacity: 0;
        interactivity: inert;
        pointer-events: none;
        transform: translateY(-20px);
        transition: opacity 1050ms ease-out, transform 1050ms ease-out, display 1050ms allow-discrete;
      }
      .dashboard-main .dashboard-filters.is-open, .mobile-filter-panel.is-open {
        opacity: 1;
        transform: none;
        interactivity: auto;
        pointer-events: auto;
      }

      @starting-style {
        .dashboard-main .dashboard-filters.is-open, .mobile-filter-panel.is-open {
          opacity: 0;
          transform: translateY(-20px);
        }
      }
    }
  }
}

@keyframes page-enter {
  from { opacity: 0; transform: translateY(32px); }
  60% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
@keyframes surface-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-enter {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: none; }
}
@keyframes completion-expand {
  from { transform: scale(.06,.35); }
  to { transform: none; }
}
@keyframes completion-burst {
  50% { opacity: 1; }
  to { opacity: 0; }
}
@keyframes check-pop {
  from, 16% { opacity: 0; transform: scale(.25) rotate(-15deg); }
  55% { opacity: 1; transform: scale(1.4) rotate(4deg); }
  to { opacity: 1; transform: none; }
}
@keyframes assignment-exit {
  52% { opacity: 1; transform: none; animation-timing-function: ease-in-out; }
  to { opacity: 0; transform: translateY(-6px) scale(.99); }
}
@keyframes page-leave {
  from { opacity: 1; transform: none; }
  45%, to { opacity: 0; transform: translateY(-18px) scale(.99); }
}
@keyframes navigation-enter {
  from { opacity: 0; transform: translateY(30px) scale(.98); }
  72% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
