/* EMBA Coordination — MeshLinks-branded. Palette tokens first, everything else
   references them by role. Neutrals are Tailwind slate, accent is teal, both
   lifted from meshlinks.net so the two sites read as one family. */

:root {
  color-scheme: light;

  --surface-1:      #ffffff;
  --page:           #f8fafc;   /* slate-50  */
  --text-primary:   #0f172a;   /* slate-900 */
  --text-secondary: #475569;   /* slate-600 */
  --text-muted:     #94a3b8;   /* slate-400 */
  --gridline:       #e2e8f0;   /* slate-200 */
  --baseline:       #cbd5e1;   /* slate-300 */
  --border:         #e2e8f0;
  --wash:           rgba(15, 23, 42, 0.04);

  /* MeshLinks accent — teal. */
  --accent:             #0f766e;  /* teal-700 */
  --accent-hover:       #115e59;  /* teal-800 */
  --accent-bright:      #14b8a6;  /* teal-500 */
  --accent-text:        #0f766e;
  --accent-soft-bg:     #f0fdfa;  /* teal-50  */
  --accent-soft-border: #99f6e4;  /* teal-200 */
  --accent-ink:         #ffffff;  /* text on an --accent fill */

  --nav-bg:     rgba(248, 250, 252, 0.72);
  --nav-height: 60px;

  /* Frosted-glass surfaces, gethomepage.dev style: panels float on the page
     wash rather than sitting on an opaque card. */
  --glass:        rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(15, 23, 42, 0.09);
  --glass-hair:   rgba(15, 23, 42, 0.06);
  --blur:         blur(14px) saturate(1.4);
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:  0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(13, 148, 136, 0.10);
  --shadow-lg:  0 4px 6px rgba(0, 0, 0, 0.04), 0 20px 60px rgba(0, 0, 0, 0.08);

  /* Fixed categorical order — assigned by slot, never cycled. Deliberately NOT
     teal: these encode which course a bar belongs to and must stay mutually
     distinguishable, so brand colour does not get a vote here. */
  --series-1: #2a78d6;  --series-2: #eb6834;
  --series-3: #1baf7a;  --series-4: #eda100;
  --series-5: #e87ba4;  --series-6: #008300;
  --series-7: #4a3aa7;  --series-8: #e34948;
  --series-0: #94a3b8;  /* "Other" — past slot 8 */

  /* Status is reserved: never reused as a series colour. */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  /* #fab219 as ink on a light panel is ~1.8:1. Borders can stay bright; text
     cannot. */
  --warning-text: #b45309;

  --radius: 12px;
  --font:      "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Dark palette, defined once and applied to both the system-preference case and
   the explicit toggle. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #0f172a;   /* slate-900 */
    --page:           #020617;   /* slate-950 */
    --text-primary:   #f8fafc;   /* slate-50  */
    --text-secondary: #cbd5e1;   /* slate-300 */
    --text-muted:     #94a3b8;   /* slate-400 */
    --gridline:       rgba(255, 255, 255, 0.08);
    --baseline:       rgba(255, 255, 255, 0.15);
    --border:         rgba(255, 255, 255, 0.08);
    --wash:           rgba(255, 255, 255, 0.04);

    --accent:             #2dd4bf;  /* teal-400 */
    --accent-hover:       #5eead4;  /* teal-300 */
    --accent-bright:      #14b8a6;
    --accent-text:        #5eead4;
    --accent-soft-bg:     rgba(20, 184, 166, 0.10);
    --accent-soft-border: rgba(20, 184, 166, 0.25);
    --accent-ink:         #042f2e;  /* teal-950 — white on teal-400 is ~1.8:1 */

    --nav-bg:    rgba(2, 6, 23, 0.72);
    --glass:        rgba(255, 255, 255, 0.045);
    --glass-strong: rgba(255, 255, 255, 0.075);
    --glass-border: rgba(255, 255, 255, 0.10);
    --glass-hair:   rgba(255, 255, 255, 0.07);
    --blur:         blur(14px) saturate(1.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(20, 184, 166, 0.15);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.3), 0 20px 60px rgba(0, 0, 0, 0.4);

    --series-1: #3987e5;  --series-2: #d95926;
    --series-3: #199e70;  --series-4: #c98500;
    --series-5: #d55181;  --series-6: #33a033;
    --series-7: #9085e9;  --series-8: #e66767;
    --warning-text: #fab219;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #0f172a;
  --page:           #020617;
  --text-primary:   #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted:     #94a3b8;
  --gridline:       rgba(255, 255, 255, 0.08);
  --baseline:       rgba(255, 255, 255, 0.15);
  --border:         rgba(255, 255, 255, 0.08);
  --wash:           rgba(255, 255, 255, 0.04);

  --accent:             #2dd4bf;
  --accent-hover:       #5eead4;
  --accent-bright:      #14b8a6;
  --accent-text:        #5eead4;
  --accent-soft-bg:     rgba(20, 184, 166, 0.10);
  --accent-soft-border: rgba(20, 184, 166, 0.25);
  --accent-ink:         #042f2e;  /* teal-950 — white on teal-400 is ~1.8:1 */

    --nav-bg:    rgba(2, 6, 23, 0.72);
  --glass:        rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-hair:   rgba(255, 255, 255, 0.07);
  --blur:         blur(14px) saturate(1.3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(20, 184, 166, 0.15);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.3), 0 20px 60px rgba(0, 0, 0, 0.4);

  --series-1: #3987e5;  --series-2: #d95926;
  --series-3: #199e70;  --series-4: #c98500;
  --series-5: #d55181;  --series-6: #33a033;
  --series-7: #9085e9;  --series-8: #e66767;
  --warning-text: #fab219;
}

* { box-sizing: border-box; }

/* Author rules like `.login-wrap { display: grid }` outrank the UA stylesheet's
   `[hidden] { display: none }`, so state the intent explicitly. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Atmospheric wash the glass panels sit on. Fixed, so it stays put while the
   dashboard scrolls — the depth cue is the whole point of the treatment.
   Built from gradients rather than a photo: no asset to ship, and it stays in
   MeshLinks teal instead of drifting off-brand. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(58% 44% at 12%  6%, rgba(45, 212, 191, 0.20), transparent 68%),
    radial-gradient(50% 40% at 88%  0%, rgba(56, 189, 248, 0.16), transparent 66%),
    radial-gradient(46% 42% at 76% 62%, rgba(139, 92, 246, 0.13), transparent 68%),
    radial-gradient(60% 50% at 30% 96%, rgba(13, 148, 136, 0.15), transparent 70%);
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 17px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

.shell {
  max-width: 1400px; margin: 0 auto; padding: 0 20px 64px;
  /* The page itself never scrolls sideways — the Gantt and the week table each
     own a scroller and handle their own overflow. Without this the week table's
     720px min-width leaks out through its scroller and stretches the document
     to ~1230px on a phone, leaving a screen and a half of dead space to swipe
     into. `clip` rather than `hidden`: it does not create a scroll container,
     so sticky positioning inside still works. */
  overflow-x: clip;
}

/* ---- top bar ---- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  min-height: var(--nav-height);
  padding: 10px 24px;
  background: var(--nav-bg);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--glass-border);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.topbar .brand .mark { height: 30px; width: auto; border-radius: 6px; flex: none; }
.topbar .brand .titles { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.topbar .today { color: var(--text-muted); font-size: 12px; }

/* meshlinks.net inverts its logo in dark mode rather than shipping two files. */
.logo-theme-filter { filter: none; transition: filter .3s ease; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .logo-theme-filter { filter: invert(1) hue-rotate(180deg); }
}
:root[data-theme="dark"] .logo-theme-filter { filter: invert(1) hue-rotate(180deg); }

/* "Sponsored by" strip — sits under the nav on the app, in the card on login. */
.sponsor-note {
  font-size: 12px; color: var(--text-muted);
}
.sponsor-note a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
.sponsor-note a:hover { text-decoration: underline; }

/* ---- generic surfaces ---- */

.card {
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  margin-top: 14px;
  box-shadow: var(--shadow-sm);
}
.card > header {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--glass-hair);
}
.card > header h2 {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-secondary);
}
.card > header .spacer { margin-left: auto; }
.card > .body { padding: 14px 16px; }

/* ---- stat tiles ---- */

/* ---- sponsor rail --------------------------------------------------------
   Replaces the old stat strip at the top of the page. One always-on sponsor
   card, plus any dated ad from PROMOS in app.js. */

.promos {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px; margin-top: 14px;
}
.promos:empty { display: none; }

.promo {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  text-decoration: none; color: inherit;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.promo:hover {
  background: var(--glass-strong);
  border-color: var(--accent-soft-border);
  transform: translateY(-1px);
}
.promo-mark { width: 44px; height: 44px; flex: none; }
.promo-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.promo-text strong { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.promo-sub { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }

/* The sponsor card is a placement, not a panel — it gets a solid brand fill so
   it separates from the glass surfaces around it instead of blending in. The
   logo's violet-to-cyan reads well on deep teal. */
.promo.is-sponsor {
  /* Darkest under the text, brightening to teal-700 at the right edge. The
     logo and both lines of copy live in the left half, and white on teal-700
     is only 5.5:1 — over teal-950 it is 14.5:1. The bright end carries the
     brand where nothing has to be read on top of it. */
  background: linear-gradient(100deg, #042f2e 0%, #134e4a 42%, #0f766e 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: var(--shadow-md);
}
.promo.is-sponsor .promo-sub { color: rgba(255, 255, 255, 0.86); }
.promo.is-sponsor:hover {
  background: linear-gradient(100deg, #042f2e 0%, #115e59 42%, #0d9488 100%);
  border-color: transparent;
}
:root[data-theme="dark"] .promo.is-sponsor,
:root:where(:not([data-theme="light"])) .promo.is-sponsor {
  /* Same shape on a near-black page: the right end goes a step brighter so the
     card still separates from the background. */
  background: linear-gradient(100deg, #042f2e 0%, #115e59 45%, #0d9488 100%);
}
:root[data-theme="dark"] .promo.is-sponsor:hover,
:root:where(:not([data-theme="light"])) .promo.is-sponsor:hover {
  background: linear-gradient(100deg, #063d3b 0%, #12736c 45%, #14b8a6 100%);
}

/* The dated ad gets the brand tint so it reads as a message, not furniture. */
.promo.is-ad {
  background:
    linear-gradient(120deg, var(--accent-soft-bg), transparent 60%),
    var(--glass);
  border-color: var(--accent-soft-border);
}
.promo.is-ad strong { color: var(--accent-text); }

/* ---- overflow menu -------------------------------------------------------
   One hamburger at every width rather than two topbar layouts to keep in sync. */

.menu-wrap { position: relative; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0;
  font-size: 15px; line-height: 1;
  border-radius: 8px;
}

.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 232px; padding: 6px;
  /* Opaque, not glass: a menu sits above content rather than over the page
     wash, and the panel behind it is busy enough to make text unreadable. */
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
@media (prefers-reduced-motion: no-preference) {
  .menu { animation: menu-in .12s ease-out both; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }

.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px;
  font: inherit; font-size: 13px; text-align: left; text-decoration: none;
  color: var(--text-primary);
  background: none; border: 0; border-radius: 7px;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--wash); outline: none; }
.mi-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; flex: none; color: var(--text-muted);
}
.mi-ico img { display: block; width: 16px; height: 16px; }
.mi-val { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--glass-hair); }

/* Header tick-boxes for the Schedule tab. */
.tick {
  display: flex; align-items: center; gap: 6px; margin: 0;
  font-size: 12px; white-space: nowrap; color: var(--text-secondary);
}
.tick input { width: auto; }

/* ---- controls ---- */

button, .btn {
  font: inherit; font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 11px;
  cursor: pointer;
}
button:hover, .btn:hover { background: var(--wash); }
button.primary {
  background: var(--accent); border-color: transparent; color: var(--accent-ink);
  font-weight: 600; box-shadow: var(--shadow-md);
}
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--critical); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; border-right: 1px solid var(--border); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--wash); font-weight: 600; }

input, select, textarea {
  font: inherit; font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: -1px; }
label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }

/* ---- gantt ---- */

.gantt-scroll { overflow-x: auto; }
.gantt-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px 12px; border-top: 1px solid var(--border); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.gantt text { font-family: var(--font); }
.gantt .row-label { font-size: 12px; fill: var(--text-primary); font-weight: 500; }
.gantt .row-label.is-compact { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.gantt .row-sub   { font-size: 11px; fill: var(--text-muted); }
.gantt .lane-label {
  font-size: 10px; fill: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.gantt .gutter-rule { stroke: var(--border); stroke-width: 1; }
.gantt .axis-label { font-size: 11px; fill: var(--text-muted); }
.gantt .grid-line { stroke: var(--gridline); stroke-width: 1; }
.gantt .grid-month { stroke: var(--baseline); stroke-width: 1; }
.gantt .today-line { stroke: var(--critical); stroke-width: 2; }
.gantt .today-flag { font-size: 10px; font-weight: 600; fill: var(--critical); }
.gantt .band { fill: var(--wash); }
.gantt .bar-track { fill: var(--wash); }
.gantt .mark { cursor: pointer; }
.gantt .bar-label { font-size: 11px; font-weight: 500; fill: var(--text-primary); pointer-events: none; }
.gantt .lane-divider { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; }

.tooltip {
  position: fixed; z-index: 90;
  max-width: 320px;
  padding: 9px 11px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.16);
  font-size: 12px; line-height: 1.45;
  pointer-events: none;
}
.tooltip .t-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .t-row { color: var(--text-secondary); }
.tooltip[hidden] { display: none; }

/* ---- schedule ---- */

.day-group { border-top: 1px solid var(--border); padding: 10px 16px; }
.day-group:first-child { border-top: 0; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.day-head .dow { font-weight: 600; font-size: 13px; }
.day-head .rel { font-size: 11px; color: var(--text-muted); }
.day-group.is-today .day-head .dow { color: var(--critical); }
.day-group.is-overdue { background: color-mix(in srgb, var(--critical) 6%, transparent); }
.day-group.is-undated { background: var(--wash); }
.day-group.is-undated .day-head .dow { color: var(--text-secondary); }
.undated-group { margin-top: 8px; }
.undated-group:first-of-type { margin-top: 2px; }
.undated-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-size: 12px; font-weight: 600;
  padding: 4px 0 2px;
  border-top: 1px solid var(--border);
}
.undated-n {
  font-weight: 600; font-size: 11px;
  padding: 0 6px; border-radius: 999px;
  background: var(--wash); color: var(--text-secondary);
}
.undated-hint { font-weight: 400; color: var(--text-muted); }

.item {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0;
}
.item + .item { border-top: 1px solid var(--border); }
.item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.item .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.item.done .title { text-decoration: line-through; color: var(--text-muted); }

/* Status chips pair an icon with a label — colour never carries meaning alone. */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 500;
  padding: 1px 7px 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip .ico { font-size: 10px; line-height: 1; }
.chip.s-overdue     { color: var(--critical); border-color: var(--critical); }
.chip.s-today       { color: var(--critical); border-color: var(--critical); }
.chip.s-soon        { color: var(--text-primary); border-color: var(--warning); }
.chip.s-in_progress { color: var(--text-primary); border-color: var(--warning); }
.chip.s-submitted   { color: var(--text-secondary); }
/* `done` is work you finished; `completed` is a class that has happened. The
   latter is derived from the date for past classes, so it is the quietest chip
   on the page — it appears on every past session and must not shout. */
.chip.s-done        { color: var(--good); border-color: var(--good); }
.chip.s-completed   { color: var(--text-muted); border-style: dashed; }
.chip.s-graded      { color: var(--good); border-color: var(--good); }
.chip.s-not_started { color: var(--text-muted); }
.chip.s-nodate      { color: var(--text-secondary); border-style: dashed; }
.chip.s-inferred    { color: var(--text-secondary); border-style: dashed; border-color: var(--warning); }
.chip.s-derived     { color: var(--text-muted); font-variant: small-caps; }

/* ---- tables ---- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 8px 10px; border-bottom: 1px solid var(--baseline);
  white-space: nowrap;
}
td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: var(--wash); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
/* Read-only session: the edit affordances go away entirely. The API refuses
   these writes too — this is tidiness, not the security boundary. */
.is-viewer .actions { display: none; }
.is-viewer .wk-item[data-id], .is-viewer .item[data-id] { cursor: default; }
td.actions button { padding: 2px 7px; font-size: 12px; }

.tabs { display: flex; gap: 4px; }
.tabs button[aria-selected="true"] { background: var(--wash); font-weight: 600; }

/* ---- modal ---- */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  color: var(--text-primary);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog header, dialog footer { padding: 12px 16px; }
dialog header { border-bottom: 1px solid var(--border); }
dialog footer { border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---- login ---- */

.login-wrap {
  display: grid; place-items: center; min-height: 100vh; padding: 24px;
  position: relative; overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .login-card { animation: login-rise .5s cubic-bezier(.2,.7,.3,1) both; }
}
@keyframes login-rise { from { opacity: 0; transform: translateY(8px); } }

.login-card {
  width: min(380px, 100%); position: relative; z-index: 1;
  background: var(--glass-strong);
  box-shadow: var(--shadow-lg);
  margin-top: 0;
}
.login-card > header {
  display: block; text-align: center;
  padding: 28px 28px 20px;
  border-bottom: 1px solid var(--glass-hair);
}
/* Brand lockup, matching the title slide of the MeshLinks deck: diamond mark,
   then the name in bold caps with wide tracking (the deck sets spc="300" at
   17pt ≈ 0.18em), gap about a fifth of the mark's width. The deck uses Arial
   because that is PowerPoint's default; here it takes the page's own display
   face so it doesn't read as a foreign paste-in. */
.login-card .wordmark {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
  text-decoration: none; color: var(--text-primary);
}
.login-card .wordmark img { width: 34px; height: 34px; display: block; }
.login-card .wordmark span {
  font-size: 17px; font-weight: 700; line-height: 1;
  letter-spacing: 0.18em; text-transform: uppercase;
  /* The tracking adds space after the final S; pull it back so the lockup
     stays optically centred in the card. */
  margin-right: -0.18em;
}
.login-card .wordmark:hover span { color: var(--accent-text); }
.login-card h1 { font-size: 20px; letter-spacing: -0.02em; }
.login-card .tagline {
  margin: 6px 0 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5;
}
.login-card .body { padding: 22px 28px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 11px 13px; font-size: 15px;
  border-radius: 8px; border: 1px solid var(--glass-border);
  background: var(--wash); color: var(--text-primary);
}
.login-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft-bg);
}
.login-card > footer { padding: 0 28px 22px; border-top: 0; }
.login-card button.primary {
  width: 100%; padding: 12px 20px; font-size: 15px; border-radius: 10px;
}
.login-foot {
  padding: 14px 28px 22px; text-align: center;
  border-top: 1px solid var(--glass-hair);
}

/* Free-for-the-cohort badge, in MeshLinks' soft-accent chip style. */
.badge-free {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent-text);
  background: var(--accent-soft-bg);
  border: 1px solid var(--accent-soft-border);
}

/* Page footer under the app itself. */
.site-foot {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex-wrap: wrap; text-align: center;
  padding: 28px 20px 36px; margin-top: 8px;
  border-top: 1px solid var(--glass-hair);
}
.site-foot .mark { height: 20px; width: auto; border-radius: 4px; }

.empty { padding: 28px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 100; padding: 9px 16px; border-radius: 6px; font-size: 13px;
  background: var(--text-primary); color: var(--surface-1);
}
.toast[hidden] { display: none; }
.toast.error { background: var(--critical); color: #fff; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .shell { padding: 0 12px 48px; }

  /* Topbar wraps instead of pushing its buttons off-screen. */
  .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px 10px; }
  .topbar .brand { margin-right: auto; min-width: 0; }
  .topbar .brand .titles { flex-direction: column; gap: 0; }
  .topbar .brand h1 { font-size: 15px; }
  .topbar .today { font-size: 11px; }
  .topbar button { font-size: 12px; padding: 5px 9px; }

  .promos { grid-template-columns: 1fr; gap: 10px; }
  .promo { padding: 12px 13px; gap: 11px; }
  .promo-mark { width: 36px; height: 36px; }

  /* The tab strip is the primary control on a phone: let it own the first line
     and scroll sideways rather than wrapping into a ragged block. */
  .tabs { order: -1; flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }

  /* Card headers stack their controls rather than overflowing. */
  .card > header { flex-wrap: wrap; padding: 10px 12px; }
  .card > header .spacer { flex-basis: 100%; margin-left: 0; }

  .gantt-scroll { -webkit-overflow-scrolling: touch; }
  .gantt-legend { padding: 10px 12px; }
}

/* ---- weekly schedule table ---- */

.week-table { table-layout: fixed; }
/* The Status column and this inline chip are the same information shown two
   ways: the column keeps rows aligned on desktop, the inline chip keeps each
   chip next to its own deliverable once the row stacks on a phone. Exactly one
   is visible at a time. */
.wk-status-inline { display: none; }
.week-table td { vertical-align: top; padding: 9px 10px; }
.week-table tbody tr.is-current { background: color-mix(in srgb, var(--series-1) 6%, transparent); }
.week-table tbody tr.is-current:hover { background: color-mix(in srgb, var(--series-1) 9%, transparent); }

.wk-label strong { display: block; font-size: 13px; }
.wk-range  { color: var(--text-muted); font-size: 12px; }
.wk-effort { display: block; margin-top: 3px; font-size: 11px; color: var(--text-muted); }

.wk-day { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 3px; }
.wk-day:last-child { margin-bottom: 0; }

.wk-class { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.wk-topic {
  flex: 1; min-width: 0;
  font-size: 12px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wk-dow {
  width: 50px; flex: none;
  font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.code-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-variant-numeric: tabular-nums;
  padding: 1px 6px 1px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.code-pill:hover { background: var(--wash); }
.code-pill .swatch { width: 7px; height: 7px; border-radius: 2px; flex: none; }

/* Deliverables and Status render one .wk-item per row so the columns align. */
.wk-item {
  display: flex; align-items: center; gap: 6px;
  min-height: 22px;
  font-size: 12.5px;
}
.wk-item[data-id] { cursor: pointer; border-radius: 4px; }
.wk-item[data-id]:hover { background: var(--wash); }
.wk-item .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.wk-when  { color: var(--text-muted); font-size: 11px; width: 44px; flex: none; font-variant-numeric: tabular-nums; }
.wk-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-weight {
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; flex: none;
}
.wk-none { color: var(--text-muted); }

.wk-read .wk-title { font-size: 12px; }
.wk-title.is-done { text-decoration: line-through; color: var(--text-muted); }
.wk-case {
  flex: none;
  font-size: 10px; font-weight: 600; letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0 4px; border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
/* A Moodle link reads as ordinary text until hovered — a table full of blue
   underlines is unreadable — but always carries its type icon so it is
   discoverable without hovering. */
a.moodle-a {
  color: inherit; text-decoration: none;
  border-bottom: 1px solid transparent;
}
a.moodle-a:hover, a.moodle-a:focus-visible {
  color: var(--series-1); border-bottom-color: currentColor;
}
a.moodle-a:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; border-radius: 2px; }
.moodle-ico {
  display: inline-flex; align-items: center;
  margin-left: 5px; opacity: 0.5;
  vertical-align: -1px;
}
a.moodle-a:hover .moodle-ico { opacity: 1; }
/* The title is a flex child in the week table, so the anchor needs the ellipsis. */
a.wk-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wk-days { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-unit { font-size: 11px; font-weight: 400; color: var(--text-muted); margin-left: 1px; }
.wk-now  { font-size: 12px; font-weight: 600; color: var(--series-1); }

/* Between tablet and desktop the table still works, it just needs more room
   than the viewport — so it scrolls inside its own container. */
@media (min-width: 721px) and (max-width: 900px) {
  #schedule { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .week-table { table-layout: auto; min-width: 720px; }
}

/* On a phone a six-column table is unusable however you scroll it, so each week
   becomes a stacked card: week and countdown on a header line, then only the
   sections that actually have something in them. */
@media (max-width: 720px) {
  #schedule > div { overflow-x: visible; }
  .week-table { min-width: 0; table-layout: auto; display: block; }
  .week-table thead { display: none; }
  .week-table tbody { display: block; }

  .week-table tr {
    display: grid; grid-template-columns: 1fr auto;
    gap: 2px 10px; align-items: baseline;
    padding: 12px 12px 14px;
    border-bottom: 1px solid var(--glass-hair);
  }
  .week-table td { display: block; padding: 0; border: 0; }
  .week-table td.wk-label { grid-column: 1; grid-row: 1; }
  .week-table td.wk-days  { grid-column: 2; grid-row: 1; text-align: right; }
  .week-table td:not(.wk-label):not(.wk-days) { grid-column: 1 / -1; margin-top: 9px; }

  /* A cell holding only the em-dash placeholder is noise on a small screen. */
  .week-table td:has(> .wk-none:only-child) { display: none; }

  .week-table td[data-label]::before {
    content: attr(data-label);
    display: block; margin-bottom: 4px;
    font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--text-muted);
  }

  /* Stacked: chips ride along with their deliverable, so the separate Status
     block would be a dangling list of countdowns with nothing to attach to. */
  .week-table td[data-label="Status"] { display: none; }
  .wk-status-inline { display: inline-flex; margin-left: auto; }

  .wk-label strong { font-size: 15px; }
  .wk-range { font-size: 12px; }
  .wk-days { font-size: 14px; }
}
