/* Theme colours and page basics */
:root {
  color-scheme: light dark; /* native inputs, pickers and scrollbars follow the theme */

  /* Neutrals */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-subtle: #fafafa;
  --surface-hover: #f4f4f5;
  --text: #18181b;
  --text-soft: #374151;
  --muted: #52525b;
  --faint: #8b8b94;
  --border: #d4d4d8;
  --border-strong: #c4c4cc;
  --on-accent: #ffffff; /* text on the accent colour and on dark fills */
  --neutral-bg: var(--surface-hover); /* grey tags (skipped, to do) */
  --neutral-text: #4b5563;
  --neutral-text-soft: #6b7280;
  --neutral-edge: #9ca3af;

  /* Brand */
  --accent: #a51c30;
  --accent-hover: #821323;
  --accent-text: var(--accent); /* crimson used as text (lighter in dark mode) */
  --accent-text-hover: var(--accent-hover);
  --accent-tint: #fef2f2;
  --accent-tint-border: #fecaca;
  --accent-wash: #fdf7f8; /* faintest crimson: today's column, enrolled cards */
  --accent-soft: #fbecee; /* class meetings in the calendar, enrolled cards */

  /* Status: danger / warning / success / done (completed blocks) / info */
  --danger-bg: #fef2f2;
  --danger-bg-hover: #fee2e2;
  --danger-border: #fecaca;
  --danger: #b91c1c;
  --danger-dark: #991b1b;
  --danger-solid: var(--danger-dark); /* filled button: Delete -> Confirm? */
  --warning-bg: #fffbeb;
  --warning-border: #fcd34d;
  --warning-border-soft: #fde68a;
  --warning: #b45309;
  --warning-dark: #92400e;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --success-dark: #065f46;
  --done-bg: var(--success-bg);
  --done-border: #bbf7d0;
  --done: #16a34a;
  --done-dark: #166534;
  --done-darker: #14532d;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --info: #1d4ed8;
  --info-dark: #1e40af;

  /* Selection, focus and drag previews */
  --select: #2563eb;
  --select-tint: rgba(37, 99, 235, 0.06);
  --select-tint-strong: rgba(37, 99, 235, 0.14);

  /* Components */
  --meter-track: #e4e4e7;
  --meter-green: #10b981;
  --meter-yellow: #f59e0b;
  --meter-red: #ef4444;
  --grid-line: #ececef;
  --grid-line-half: var(--surface-hover);
  --cal-class-text: #5c1019;
  --cal-block-bg: #e9f0fe;
  --cal-block-text: #1e3a8a;
  --day-empty-bg: rgba(255, 255, 255, 0.85);
  --enrolled-border: #efc9cf;
  --enrolled-text: #6b4b50;
  --enrolled-locked-border: #e3b5bd;
  --enrolled-locked-text: #8a3a47;
  --recurrence-text: #7c2d12;
  --tooltip-bg: #1f2937;
  --flash-bg: #fff4c2;
  --study-planned: #a78bfa; /* work items, between suggested (grey) and scheduled (blue) */

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.06);
  --shadow-md: 0 4px 12px rgba(24, 24, 27, 0.08);
  --shadow-lg: 0 4px 12px rgba(24, 24, 27, 0.14);
  --shadow-popover: 0 6px 18px rgba(0, 0, 0, 0.12);
  --shadow-tooltip: 0 4px 12px rgba(0, 0, 0, 0.15);

  /* Font sizes */
  --text-2xs: 0.68rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8rem;
  --text-base: 0.875rem;
  --text-md: 0.9rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Corner radii */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-pill: 999px;
}

/* ---- Dark mode: the same tokens, dark values (follows the device setting) ---- */
@media (prefers-color-scheme: dark) {
  :root {
    /* Neutrals */
    --bg: #0f0f12;
    --surface: #18181b;
    --surface-subtle: #1e1e22;
    --surface-hover: #27272a;
    --text: #e4e4e7;
    --text-soft: #d4d4d8;
    --muted: #a1a1aa;
    --faint: #8b8b94;
    --border: #3f3f46;
    --border-strong: #52525b;
    --neutral-text: #c4c4cc;
    --neutral-text-soft: #a1a1aa;
    --neutral-edge: #71717a;

    /* Brand: crimson fills stay; crimson text gets lighter to stay readable */
    --accent: #b3243a;
    --accent-hover: #c9324a;
    --accent-text: #f0788b;
    --accent-text-hover: #f7a1ae;
    --accent-tint: #33141a;
    --accent-tint-border: #5c2530;
    --accent-wash: #1c1215;
    --accent-soft: #3a1820;

    /* Status */
    --danger-bg: #2a1215;
    --danger-bg-hover: #3a171b;
    --danger-border: #5c2328;
    --danger: #f87171;
    --danger-dark: #fca5a5;
    --danger-solid: #b91c1c;
    --warning-bg: #2a2110;
    --warning-border: #6b4f12;
    --warning-border-soft: #574214;
    --warning: #fbbf24;
    --warning-dark: #fcd34d;
    --success-bg: #0f2a1f;
    --success-border: #1f5b43;
    --success-dark: #6ee7b7;
    --done-border: #1f5b3a;
    --done: #22c55e;
    --done-dark: #86efac;
    --done-darker: #bbf7d0;
    --info-bg: #132036;
    --info-border: #1e3a6b;
    --info: #60a5fa;
    --info-dark: #93c5fd;

    /* Selection, focus and drag previews */
    --select: #3b82f6;
    --select-tint: rgba(59, 130, 246, 0.12);
    --select-tint-strong: rgba(59, 130, 246, 0.24);

    /* Components */
    --meter-track: #3f3f46;
    --grid-line: #2c2c31;
    --grid-line-half: #212125;
    --cal-class-text: #f6c9d1;
    --cal-block-bg: #172554;
    --cal-block-text: #c7dbfe;
    --day-empty-bg: rgba(24, 24, 27, 0.85);
    --enrolled-border: #5c2a33;
    --enrolled-text: #d9b8be;
    --enrolled-locked-border: #6b3540;
    --enrolled-locked-text: #f0a5b2;
    --recurrence-text: #fdba74;
    --tooltip-bg: #3f3f46;
    --flash-bg: #4a3f10;
    --study-planned: #9f7aea;

    /* Shadows: darker, since light shadows vanish on a dark page */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-popover: 0 6px 18px rgba(0, 0, 0, 0.5);
    --shadow-tooltip: 0 4px 12px rgba(0, 0, 0, 0.5);
  }

  /* Sign-in and admin form inputs use the browser's default fill; match the other fields */
  .auth-form input {
    background-color: var(--surface);
    color: var(--text);
  }
}

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

/* Hidden means hidden, even for elements whose styles set a display (buttons, .btn) */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* Page header and brand */
.topbar,
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: inherit;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--accent-text);
}

.brand-name {
  font-weight: 700;
  font-size: var(--text-lg);
}

/* Header badges: ADMIN, and the workload status (green / yellow / red) */
.status-badge {
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  background-color: var(--success-bg);
  color: var(--success-dark);
  border: 1px solid var(--success-border);
}

.status-green {
  background-color: var(--success-bg);
  color: var(--success-dark);
  border: 1px solid var(--success-border);
}

.status-yellow {
  background-color: var(--warning-bg);
  color: var(--warning-dark);
  border: 1px solid var(--warning-border-soft);
}

.status-red {
  background-color: var(--danger-bg);
  color: var(--danger-dark);
  border: 1px solid var(--danger-border);
}

/* Pre-auth landing page */
.preauth-main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.hero {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: var(--text-3xl);
}

.hero p {
  margin: 0 auto 1.5rem;
  max-width: 42rem;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.auth-panel {
  max-width: 420px;
  margin: 1.5rem auto 0;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.auth-form h2 {
  margin: 0 0 0.5rem;
  font-size: var(--text-xl);
}

.auth-form label {
  font-size: var(--text-base);
  font-weight: 500;
}

.auth-form input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-md);
}

.form-switch {
  margin: 0.5rem 0 0;
  font-size: var(--text-base);
  color: var(--muted);
  text-align: center;
}

.link-btn {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: underline;
}

.link-btn:hover {
  background: none;
  color: var(--accent-text-hover);
}

.auth-form button[type="submit"] {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.auth-form button[type="submit"]:hover {
  background-color: var(--accent-hover);
}

/* Message banners (hidden while empty) */
.error-banner {
  margin-bottom: 0.85rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
  background-color: var(--danger-bg);
  color: var(--danger-dark);
  font-size: var(--text-base);
}

.info-banner {
  margin-bottom: 0.85rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  background-color: var(--info-bg);
  color: var(--info-dark);
  font-size: var(--text-base);
}

.warning-banner {
  margin-bottom: 0.85rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  background-color: var(--warning-bg);
  color: var(--warning-dark);
  font-size: var(--text-base);
}

.warning-banner:empty {
  display: none;
}

.error-banner:empty,
.info-banner:empty {
  display: none;
}

/* Authenticated workspace: header, sidebar, main area */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.session-bar,
.header-actions,
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.user-label,
.muted-text {
  font-size: var(--text-base);
  color: var(--muted);
}

.app-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 53px);
}

.app-sidebar {
  width: 210px;
  flex-shrink: 0;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
}

.sidebar-nav,
.sidebar-footer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-item {
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: var(--text-md);
  cursor: pointer;
}

.nav-item:hover {
  background-color: var(--surface-hover);
}

.nav-item.active {
  font-weight: 600;
  background-color: var(--accent-tint);
  color: var(--accent-text);
  border-color: var(--accent-tint-border);
}

.sidebar-divider {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.75rem 0;
}

.app-main {
  flex: 1;
  padding: 1.25rem 1.5rem;
}

.workspace-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.workspace-header-row h2 {
  margin: 0 0 0.2rem;
}

.workspace-header-row p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-md);
}

.subview-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

/* Workload summary card above Weekly Schedule */
.workload-meter-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background-color: var(--surface-subtle);
}

.workload-meter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
  font-size: var(--text-md);
}

.meter-track {
  position: relative;
  width: 100%;
  height: 10px;
  background-color: var(--meter-track);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.meter-fill {
  position: relative;
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
}

/* Behind the scheduled fill: the week with the suggested study on the calendar */
.meter-fill-projected {
  position: absolute;
  inset: 0 auto 0 0;
  opacity: 0.35;
}

.fill-green {
  background-color: var(--meter-green);
}

.fill-yellow {
  background-color: var(--meter-yellow);
}

.fill-red {
  background-color: var(--meter-red);
}

/* Weekly Schedule Timeline */
.week-timeline-scroll {
  /* ~12 hours visible;
  the rest of the day scrolls */
  max-height: min(700px, 75vh);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background-color: var(--surface);
  box-shadow: var(--shadow-xs);
}

.week-timeline {
  --hour-height: 52px; /* keep in sync with HOUR_HEIGHT_PX in schedule-view.js */
  --axis-width: 60px;
  display: grid;
  grid-template-columns: var(--axis-width) repeat(7, minmax(112px, 1fr));
  min-width: calc(var(--axis-width) + 7 * 112px);
  padding-bottom: 0.75rem;
}

.timeline-corner,
.timeline-day-head {
  position: sticky;
  top: 0;
  z-index: 4;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
}

.timeline-day-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.55rem 0.25rem 0.5rem;
  border-left: 1px solid var(--grid-line);
}

.timeline-day-head .day-name {
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.timeline-day-head .day-date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
}

.timeline-day-head.is-today .day-name {
  color: var(--accent-text);
}

.timeline-day-head.is-today .day-date {
  background-color: var(--accent);
  color: var(--on-accent);
}

.timeline-axis {
  position: relative;
  margin-top: 10px;
}

.timeline-hour {
  position: absolute;
  right: 0.55rem;
  transform: translateY(-50%);
  font-size: var(--text-2xs);
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  white-space: nowrap;
}

.timeline-day {
  position: relative;
  margin-top: 10px;
  border-left: 1px solid var(--grid-line);
}

.timeline-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--grid-line);
  pointer-events: none;
}

.timeline-line.is-half {
  background-color: var(--grid-line-half);
}

.timeline-day.is-today {
  background-color: var(--accent-wash);
}

.day-empty {
  position: absolute;
  z-index: 1;
  left: 0.4rem;
  right: 0.4rem;
  margin: 0;
  padding: 0.35rem 0.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background-color: var(--day-empty-bg);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--muted);
}

.cal-event {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.3rem 0.45rem;
  border-radius: var(--radius);
  border-left: 3px solid;
  overflow: hidden;
  font-size: var(--text-xs);
  line-height: 1.25;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.cal-event:hover {
  z-index: 2;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.cal-class {
  background-color: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--cal-class-text);
}

.cal-block {
  background-color: var(--cal-block-bg);
  border-left-color: var(--select);
  color: var(--cal-block-text);
}

.cal-block.is-completed {
  background-color: var(--done-bg);
  border-left-color: var(--done);
  color: var(--done-darker);
}

.cal-block.is-skipped {
  background-color: var(--neutral-bg);
  border-left-color: var(--neutral-edge);
  color: var(--neutral-text-soft);
  text-decoration: line-through;
}

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

.cal-event-time,
.cal-event-sub {
  font-size: var(--text-2xs);
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event.is-compact .cal-event-sub {
  display: none;
}

.cal-event.is-tiny {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  padding-block: 0.1rem;
}

.cal-event.is-tiny .cal-event-sub {
  display: none;
}

.cal-lock {
  font-size: var(--text-2xs);
}

.timeline-now {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 2;
  height: 2px;
  background-color: var(--accent);
  pointer-events: none;
}

.timeline-now::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: var(--radius-pill);
  background-color: var(--accent);
}

/* Work Items Two-Column Split */
.two-col-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.25rem;
}

.split-pane {
  min-width: 0; /* let wide content (the calendar) scroll inside the pane */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.pane-title {
  margin: 0 0 0.75rem;
  font-size: var(--text-lg);
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.narrow-form {
  max-width: 420px;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 600;
}

.field-input {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.items-table th,
.items-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--border);
}

/* Time / Due: wide enough that "120m / week · until 2027-01-03" and the
   progress lines don't break into one word per line */
.items-table th:nth-child(2),
.items-table td:nth-child(2) {
  min-width: 12.5rem;
}

.row-title {
  font-weight: 600;
}

.row-meta {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Work item / activity rows: actions, block list, inline editors */
/* Buttons wrap to a second line when the table is narrow; each button (or
   the hint wrapper around a disabled one) gets the same spacing. */
.row-actions {
  white-space: normal;
}

.row-actions > * {
  margin: 0.15rem 0.3rem 0.15rem 0;
}

/* Wrapper for a disabled button; data-hint explains why, shown on hover */
.disabled-hint {
  position: relative;
  display: inline-block;
  cursor: not-allowed;
}

/* Let hovers reach the wrapper */
.disabled-hint > button:disabled {
  pointer-events: none;
}

/* Disabled inputs swallow hovers too */
.disabled-hint > input:disabled {
  pointer-events: none;
}

/* Tooltip anchored at the left edge (for controls at the start of a line) */
.disabled-hint.hint-start[data-hint]:hover::after {
  right: auto;
  left: 0;
}

.disabled-hint[data-hint]:hover::after {
  content: attr(data-hint);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius);
  background-color: var(--tooltip-bg);
  color: var(--on-accent);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-tooltip);
  pointer-events: none;
}

.btn-danger.is-armed {
  background-color: var(--danger-solid);
  border-color: var(--danger-solid);
  color: var(--on-accent);
}

/* Two columns shared by every block row: when | tags + buttons */
.item-blocks-list {
  margin-top: 0.35rem;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.6rem;
  align-items: center;
}

.item-block-entry {
  display: contents; /* its two parts sit in the list's columns */
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Block checkbox: ticked = completed; disabled until the block starts */
.block-when {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap; /* keep "date · time (mins)" on one line */
  ;
}

.block-check {
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  accent-color: var(--done);
  cursor: pointer;
}

.block-check:disabled {
  cursor: default;
}

.item-block-entry.is-skipped .block-when {
  text-decoration: line-through;
  opacity: 0.7;
}

.item-block-entry.is-completed .block-when {
  color: var(--done-dark);
}

.block-tag {
  padding: 0 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: 600;
}

.block-tag.is-skipped {
  background-color: var(--neutral-bg);
  color: var(--neutral-text);
}

/* Small text buttons inside a block entry (Skip / Undo / Remove) */
.btn-text {
  padding: 0 0.3rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
}

.btn-text:hover:not(:disabled) {
  border-color: var(--border);
  background-color: var(--surface-subtle);
}

.btn-text.is-danger {
  color: var(--danger);
}

.btn-text.is-danger:hover:not(:disabled) {
  border-color: var(--danger-border);
  background-color: var(--danger-bg);
  color: var(--danger-dark);
}

.btn-text:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Work-item status pill (derived from completed blocks) */
.status-pill {
  display: inline-block;
  padding: 0 0.4rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: 600;
  vertical-align: 1px;
}

.status-pill.is-todo {
  background-color: var(--neutral-bg);
  color: var(--neutral-text);
}

.status-pill.is-in_progress {
  background-color: var(--info-bg);
  color: var(--info);
}

.status-pill.is-completed {
  background-color: var(--done-bg);
  color: var(--done-dark);
}

.row-progress {
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Blocks scheduled after the item's due date */
.item-block-entry.is-after-due {
  color: var(--warning-dark);
}

.warn-tag {
  padding: 0 0.35rem;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-pill);
  background-color: var(--warning-bg);
  color: var(--warning-dark);
  font-size: var(--text-2xs);
  font-weight: 600;
}

.row-warning {
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--warning);
}

.inline-row td {
  background-color: var(--surface-subtle);
}

.inline-row td > * + * {
  margin-left: 0.4rem;
}

.inline-row .field-input[type="number"] {
  width: 6.5rem;
}

.inline-row .inline-title-input {
  width: min(14rem, 100%);
}

.inline-row-label {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Courses page */
.term-deadline-banner {
  font-weight: 600;
  font-size: var(--text-md);
  margin-bottom: 0.85rem;
}

.pill-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-sm);
}

.pill-enrolled {
  background-color: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 0.12rem 0.6rem;
}

.course-card-sched {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Courses page: the student's intended fields */
.study-plan-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 1rem;
  margin-bottom: 0.85rem;
}

.study-plan-picker .pair-field {
  flex: 1 1 14rem;
  max-width: 22rem;
}

.study-plan-picker .pair-field:has(.study-plan-year) {
  flex: 0 0 7.5rem;
}

.study-plan-hint {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Courses page: groups (fields, departments) and one-line course rows, both open on click */
.course-groups {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.course-browse-heading {
  margin: 0.8rem 0 0.5rem;
  font-size: var(--text-md);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.course-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  padding: 0.55rem 0.8rem;
}

.course-group.is-area {
  border-style: solid;
  background-color: transparent;
}

.course-group-head,
.course-row-head {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  cursor: pointer;
  list-style: none;
}

.course-group-head::-webkit-details-marker,
.course-row-head::-webkit-details-marker {
  display: none;
}

.course-group-caret,
.course-row-caret {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.course-group[open] > .course-group-head .course-group-caret,
.course-row[open] > .course-row-head .course-row-caret {
  transform: rotate(90deg);
}

.course-group-title {
  font-weight: 600;
}

.course-group-count {
  font-size: var(--text-xs);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 0.45rem;
}

.course-group-note {
  margin: 0.4rem 0 0 1.25rem;
}

.course-group-subhead {
  margin: 0.6rem 0 0.2rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

.course-list {
  display: flex;
  flex-direction: column;
  margin: 0.35rem 0 0 1.25rem;
}

.course-row {
  border-top: 1px solid var(--border);
  padding: 0.4rem 0;
}

.course-row:first-child {
  border-top: 0;
}

.course-row-head {
  flex-wrap: wrap;
}

.course-row-title {
  min-width: 0;
}

.course-row.is-enrolled .course-row-title strong {
  color: var(--accent-text);
}

.course-row-meta {
  color: var(--muted);
  font-size: var(--text-sm);
}

.course-row-head .pill-badge {
  margin-left: auto;
}

.course-row-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.45rem 0 0.2rem 1.25rem;
  max-width: 48rem;
}

.course-row-description {
  margin: 0;
  font-size: var(--text-sm);
}

.course-row-actions .btn {
  min-width: 9rem;
}

/* Expanded course: requirements and first-year eligibility */
.course-reqs {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-left: 3px solid var(--border);
  padding: 0.1rem 0 0.1rem 0.7rem;
  font-size: var(--text-sm);
}

.course-reqs-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.req-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid;
  border-radius: var(--radius-pill);
  padding: 0.05rem 0.5rem;
}

.req-open {
  background-color: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-dark);
}

.req-conditional {
  background-color: var(--warning-bg);
  border-color: var(--warning-border-soft);
  color: var(--warning-dark);
}

.req-first-year {
  background-color: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-dark);
}

.course-reqs-conditions {
  margin: 0;
  padding-left: 1.1rem;
}

.course-reqs-term {
  font-weight: 600;
  margin-right: 0.4rem;
}

.course-reqs-term::after {
  content: ":";
}

.course-reqs-notes summary {
  cursor: pointer;
  color: var(--muted);
}

.course-reqs-notes p {
  margin: 0.3rem 0 0;
  white-space: pre-line;
}

.course-reqs-source {
  color: var(--muted);
}

/* Section picker on a course card (courses with several sections) */
.course-card-section {
  width: 100%;
  font-size: var(--text-sm);
}

.course-card-warning {
  font-size: var(--text-sm);
  color: var(--warning-dark);
  background-color: var(--warning-bg);
  border: 1px solid var(--warning-border-soft);
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
}

/* Buttons & Alerts */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  color: var(--text);
  font-size: var(--text-base);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.btn:hover {
  background-color: var(--surface-hover);
}

.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-danger {
  border-color: var(--danger-border);
  background-color: var(--danger-bg);
  color: var(--danger-dark);
}

.btn-danger:hover {
  background-color: var(--danger-bg-hover);
}

.btn-disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--surface-hover);
  color: var(--muted);
}

@media (max-width: 900px) {
  .two-col-split {
    grid-template-columns: 1fr;
  }
}

/* ---- Recurring items (Repeats weekly) -------------------------------- */
.repeat-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
}

.repeat-pane {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-note {
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Starting / Until: two labelled date fields side by side */
.field-pair {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 11rem));
  gap: 0.5rem;
  vertical-align: bottom;
}

.pair-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.pair-field .field-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.row-recurrence {
  margin-top: 0.15rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--recurrence-text);
}

.blocks-toggle {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 0.15rem;
  color: var(--info);
}

.block-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.1rem 0.35rem;
  font-size: var(--text-sm);
}

/* Remove on a block with weekly copies: this week or all weeks */
.remove-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  font-size: var(--text-xs);
  color: var(--muted);
  flex-wrap: wrap; /* wraps between buttons, not inside them */
  ;
}

.block-actions .btn-text {
  white-space: nowrap;
}

/* Field groups in the Edit row (one-off vs. Repeats weekly) */
.edit-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.inline-row .repeat-toggle {
  margin: 0 0.4rem 0 0.2rem;
}

/* ---- Work Items / Activities: List vs Calendar ------------------------ */
.pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.pane-head .pane-title {
  margin: 0;
}

.layout-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px;
  background-color: var(--surface);
}

.layout-option {
  border: 0;
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.85rem;
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
}

.layout-option.is-active {
  background-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.items-calendar {
  position: relative;
}

.items-calendar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  margin-bottom: 0.6rem;
}

.items-calendar-range {
  margin-left: 0.25rem;
  font-size: var(--text-base);
}

.items-calendar-summary {
  font-size: var(--text-sm);
}

.items-calendar-classes {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: var(--text-sm);
  cursor: pointer;
}

.items-calendar .week-timeline {
  grid-template-columns: var(--axis-width) repeat(7, minmax(84px, 1fr));
  min-width: calc(var(--axis-width) + 7 * 84px);
}

.items-calendar-empty {
  margin: 0;
  padding: 0.6rem 0.9rem 0.8rem;
  font-size: var(--text-sm);
}

.cal-event.is-clickable {
  cursor: pointer;
}

.cal-event.is-clickable:focus-visible {
  outline: 2px solid var(--select);
  outline-offset: 1px;
}

.cal-event.is-selected {
  z-index: 3;
  box-shadow: 0 0 0 2px var(--select), var(--shadow-lg);
}

.cal-class.is-context {
  opacity: 0.55;
}

.items-calendar-detail {
  margin-top: 0.6rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--text-base);
}

.items-calendar-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.items-calendar-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  margin-top: 0.2rem;
}

.items-table tr.is-flash td {
  animation: row-flash 1.6s ease-out;
}

@keyframes row-flash {
  0%,
  30% {
    background-color: var(--flash-bg);
  }
  100% {
    background-color: transparent;
  }
}

.block-tag.is-completed {
  background-color: var(--done-bg);
  border-color: var(--done-border);
  color: var(--done-dark);
}

/* Calendar: click an empty time to schedule */
.timeline-day.is-pickable {
  cursor: copy;
}

.timeline-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  z-index: 1;
  box-sizing: border-box;
  padding: 0.2rem 0.4rem;
  border: 1.5px dashed var(--select);
  border-radius: var(--radius);
  background-color: var(--select-tint);
  color: var(--info);
  font-size: var(--text-xs);
  font-weight: 600;
  pointer-events: none;
}

.items-calendar-hint {
  margin: -0.2rem 0 0.5rem;
}

.items-calendar-new {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: flex-end;
}

.items-calendar-new .pair-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.items-calendar-new select.field-input {
  min-width: 12rem;
  max-width: 100%;
}

/* Calendar: drag a block to move it */
.cal-event.is-draggable {
  cursor: grab;
  user-select: none;
}

.cal-event.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.cal-event.is-pending {
  opacity: 0.7;
}

body.is-dragging-block,
body.is-dragging-block * {
  cursor: grabbing !important;
  user-select: none;
}

body.is-dragging-block .timeline-ghost:not(.is-move) {
  display: none;
}

.timeline-ghost.is-move {
  z-index: 4;
  border-style: solid;
  background-color: var(--select-tint-strong);
}

/* Calendar: drag a block's bottom edge to change its length */
.cal-resize {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
  touch-action: none;
}

.cal-resize::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 18px;
  height: 3px;
  margin-left: -9px;
  border-radius: var(--radius-xs);
  background-color: currentColor;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.cal-event.is-resizable:hover .cal-resize::after,
.cal-event.is-resizing .cal-resize::after {
  opacity: 0.45;
}

.cal-event.is-resizing {
  z-index: 4;
  overflow: visible;
  box-shadow: 0 0 0 2px var(--select), var(--shadow-lg);
}

body.is-resizing-block,
body.is-resizing-block * {
  cursor: ns-resize !important;
  user-select: none;
}

body.is-resizing-block .timeline-ghost:not(.is-move) {
  display: none;
}

/* Collapsible block list under each item */
.blocks-header {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 0.35rem;
  line-height: 1.45;
  padding: 0.1rem 0.4rem 0.1rem 0.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.blocks-header:hover {
  border-color: var(--border);
  background-color: var(--surface-subtle);
  color: var(--text);
}

.blocks-header:focus-visible {
  outline: 2px solid var(--select);
  outline-offset: 1px;
}

.blocks-caret {
  display: inline-block;
  width: 0.9em;
  color: var(--text);
}

.blocks-attention {
  color: var(--warning);
  font-weight: 600;
  white-space: nowrap;
}

.blocks-header + .item-blocks-list {
  margin-top: 0.2rem;
}

/* Tall rows (an open block list): keep time and actions next to the title */
.items-table > tbody > tr > td {
  vertical-align: top;
}

/* Admin: course list beside the course form (sections + weekly meetings) */
.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 960px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

/* Admin: one tab per academic term above the course list */
.admin-term-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.admin-term-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}

.admin-term-tab:hover {
  border-color: var(--accent);
}

.admin-term-tab.is-selected {
  border-color: var(--accent);
  background-color: var(--accent);
  color: var(--on-accent);
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.admin-card-head h3 {
  margin: 0;
}

.admin-course-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 70vh;
  overflow-y: auto;
}

.admin-course {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  font-size: var(--text-base);
}

.admin-course.is-selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.admin-course-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* The compact line: click to show meetings, workload and subjects */
.admin-course-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start; /* the global button style centres content */
  gap: 0.45rem;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.admin-course-toggle:hover {
  background: none;
}

.admin-course-summary {
  min-width: 0;
}

.admin-course-caret {
  color: var(--muted);
  transition: transform 0.15s ease;
}

.admin-course.is-open .admin-course-caret {
  transform: rotate(90deg);
}

.admin-course-details {
  margin: 0.4rem 0 0 1.25rem;
}

.admin-flag {
  color: var(--warning-dark);
  font-weight: 600;
}

.admin-course-head .btn {
  flex-shrink: 0;
}

.admin-course-meta,
.admin-hint {
  color: var(--muted);
  font-size: var(--text-sm);
}

.admin-hint {
  margin: 0 0 0.5rem;
}

.admin-course-meetings {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  font-size: var(--text-sm);
}

.admin-warning {
  margin-top: 0.35rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--warning-border-soft);
  border-radius: var(--radius-sm);
  background-color: var(--warning-bg);
  color: var(--warning-dark);
  font-size: var(--text-sm);
}

.admin-sections {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin: 0.5rem 0;
}

.admin-sections legend {
  padding: 0 0.3rem;
  font-size: var(--text-base);
  font-weight: 600;
}

.admin-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  margin-bottom: 0.6rem;
  background-color: var(--surface-subtle);
}

.admin-section-head,
.admin-meeting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.admin-section-head {
  margin-bottom: 0.5rem;
}

.admin-section-head .field-input {
  flex: 1 1 8rem;
}

.admin-meetings {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.admin-meeting .field-input {
  padding: 0.35rem 0.45rem;
}

/* Location: wide enough that it wraps to its own line together with the remove button */
.admin-meeting input[type="text"] {
  flex: 1 1 10rem;
  min-width: 0;
}

.admin-meeting-dash {
  color: var(--muted);
}

/* Admin: Q report workload numbers, and subject weights */
.admin-workload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.5rem 0.6rem;
}

.admin-workload-grid .field-input {
  width: 100%;
  min-width: 0;
}

.admin-weight-input {
  width: 5.5rem;
}

#course-subjects {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

/* Time field: type a time or pick one from the list (date-utils.js TimeField) */
.time-field {
  display: inline-block;
}

.time-field-input {
  width: 7.25rem;
}

.time-field-list {
  position: fixed;
  z-index: 1000;
  max-height: 240px;
  margin: 0;
  padding: 0.25rem 0;
  overflow-y: auto;
  list-style: none;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popover);
  font-size: var(--text-base);
}

.time-field-option {
  padding: 0.3rem 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

.time-field-option.is-active {
  background-color: var(--surface-hover);
}

.time-field-option[aria-selected="true"] {
  color: var(--accent-text);
  font-weight: 600;
}

.time-field-length {
  color: var(--muted);
  font-weight: 400;
}

/* A course's only section: no box around it, just its fields */
.admin-section.is-only {
  padding: 0;
  border: 0;
  background-color: transparent;
}

/* ---- Phones and narrow windows ---------------------------------------
   Only below 768px wide; the desktop layout above is unchanged. The sidebar
   becomes a row of tabs that scrolls sideways, panes stack, and the item
   tables show each item as a card. */
@media (max-width: 768px) {
  .topbar,
  .app-header {
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  .brand-lockup {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .brand-name {
    white-space: nowrap;
  }

  /* The sidebar's "Account & Auth" tab does the same */
  #account-nav-btn {
    display: none;
  }

  .app-body {
    flex-direction: column;
    min-height: 0;
  }

  .app-sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar-nav,
  .sidebar-footer-nav {
    flex-direction: row;
    flex-shrink: 0;
  }

  .nav-item {
    width: auto;
    padding: 0.4rem 0.65rem;
    white-space: nowrap;
  }

  .sidebar-divider {
    flex-shrink: 0;
    width: 0;
    height: 1.4rem;
    margin: 0 0.25rem;
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .app-main {
    min-width: 0;
    padding: 0.75rem;
  }

  .workspace-header-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .subview-card,
  .split-pane,
  .auth-panel {
    padding: 0.75rem;
  }

  .preauth-main {
    margin: 1rem auto;
    padding: 0 0.75rem;
  }

  .hero {
    padding: 1.5rem 1rem;
  }

  .hero h1 {
    font-size: var(--text-2xl);
  }

  /* Item tables: one card per item (title, then time / due, then buttons) */
  .items-table thead {
    display: none;
  }

  .items-table,
  .items-table tbody,
  .items-table tr,
  .items-table td {
    display: block;
    width: 100%;
  }

  .items-table > tbody > tr > td {
    padding: 0.2rem 0;
    border-bottom: 0;
  }

  .items-table th:nth-child(2),
  .items-table td:nth-child(2) {
    min-width: 0;
  }

  .items-table > tbody > tr {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
  }

  .items-table > tbody > tr.inline-row {
    padding: 0.5rem;
  }

  /* Work Items / Activities: the list first, the create form below it */
  .two-col-split > .split-pane:last-child {
    order: -1;
  }

  /* Keep a meeting's day, start and end on one line */
  .admin-sections {
    padding: 0.5rem;
  }

  .admin-meeting .time-field-input {
    width: 5.9rem;
  }

  /* Profile: subject above its choice */
  .skills-list .skill-row {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Estimated weekly hours on the Courses page */
.course-card-workload {
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.course-card-basis {
  font-size: var(--text-2xs);
  color: var(--muted);
}

/* Profile and Account pages: one titled section after another */
.profile-section + .profile-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.meter-note {
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  color: var(--muted);
}

/* Profile: Strong / Average / Not my area per subject; the ones that matter for
   the intended fields come first, marked */
.skills-list {
  display: flex;
  flex-direction: column;
  max-width: 40rem;
}

.skill-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.skill-label {
  font-size: var(--text-base);
}

.skill-choice {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background-color: var(--surface);
}

.skill-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.skill-option span {
  display: inline-block;
  padding: 0.2rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  color: var(--muted);
  cursor: pointer;
}

.skill-option input:checked + span {
  background-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.skill-option input:focus-visible + span {
  outline: 2px solid var(--select);
  outline-offset: 1px;
}

.skills-list .btn-primary {
  align-self: flex-start;
  margin-top: 0.75rem;
}

.skill-row.is-focus .skill-label {
  font-weight: 600;
}

.skill-row.is-focus .skill-label::after {
  content: "for your plan";
  margin-left: 0.5rem;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--info-dark);
  background-color: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-pill);
  padding: 0 0.4rem;
}

.skill-focus-note {
  margin: 0 0 0.4rem;
  font-size: var(--text-sm);
  color: var(--info-dark);
}

.course-card-adjusted {
  font-size: var(--text-2xs);
  color: var(--info);
}

/* Courses page: the enrolled courses' weekly total */
.course-group-total {
  margin: 0.4rem 0 0 1.25rem;
  font-size: var(--text-sm);
  font-weight: 600;
}

.skill-suggestion {
  margin: 0.25rem 0 0.35rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  background-color: var(--info-bg);
  color: var(--info-dark);
  font-size: var(--text-sm);
}

.skill-suggestion .btn-text {
  color: var(--info);
  font-size: var(--text-sm);
}

/* Above the calendar: per course, suggested / planned / scheduled study this week */
.study-plan {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface-subtle);
  font-size: var(--text-base);
}

.study-plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.5rem;
}

.study-plan-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.study-plan-nav .btn-text {
  font-size: var(--text-lg);
  line-height: 1;
}

.study-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(7rem, 1fr) minmax(0, 1.6fr);
  align-items: center;
  gap: 0.3rem 0.9rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}

.study-bars {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.study-track {
  height: 5px;
  border-radius: var(--radius-pill);
  background-color: var(--meter-track);
  overflow: hidden;
}

.study-fill {
  height: 100%;
  border-radius: var(--radius-pill);
}

.study-fill.is-suggested {
  background-color: var(--neutral-edge);
}

.study-fill.is-planned {
  background-color: var(--study-planned);
}

.study-fill.is-scheduled {
  background-color: var(--select);
}

.study-numbers {
  font-size: var(--text-sm);
  color: var(--text-soft);
}

.study-plan-note {
  margin-top: 0.4rem;
  font-size: var(--text-xs);
  color: var(--muted);
}

@media (max-width: 768px) {
  .study-row {
    grid-template-columns: 1fr;
  }
}

.meter-study-link {
  color: var(--info);
  font-size: var(--text-sm);
}

.study-course.btn-text {
  justify-self: start;
  padding: 0;
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 700;
  text-align: left;
}

.study-course.btn-text:hover:not(:disabled) {
  color: var(--accent-text);
  border-color: transparent;
  background: none;
  text-decoration: underline;
}

.meter-projected-text {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-soft);
}

/* Schedule meter: tick marks at the comfortable week and the maximum week */
.meter-bar {
  position: relative;
}

.meter-tick {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background-color: var(--text-soft);
  pointer-events: auto;
}

.meter-scale {
  position: relative;
  height: 1.1rem;
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  color: var(--muted);
}

.meter-tick-label {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.meter-foot .meter-study-link {
  padding: 0;
}

/* Workload tab: comfortable / maximum week on one bar with two handles */
.zone-slider-wrap {
  margin: 0.4rem 0 0.2rem;
}

.zone-slider {
  position: relative;
  height: 1.6rem;
}

.zone-track {
  --comfortable: 60%;
  --maximum: 80%;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 8px;
  transform: translateY(-50%);
  border-radius: var(--radius-pill);
  background: linear-gradient(
    to right,
    var(--meter-green) 0 var(--comfortable),
    var(--meter-yellow) var(--comfortable) var(--maximum),
    var(--meter-red) var(--maximum) 100%
  );
}

.zone-handle {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.zone-handle::-webkit-slider-runnable-track {
  background: transparent;
}

.zone-handle::-moz-range-track {
  background: transparent;
}

.zone-handle::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-soft);
  border-radius: 50%;
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
}

.zone-handle::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-soft);
  border-radius: 50%;
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  pointer-events: auto;
}

.zone-handle:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--select);
  outline-offset: 2px;
}

.zone-handle:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--select);
  outline-offset: 2px;
}

.zone-scale {
  font-size: var(--text-2xs);
  color: var(--muted);
  text-align: right;
}

/* Work Items / Activities list: overdue, and items no longer active (completed) */
.status-pill.is-overdue {
  background-color: var(--danger-bg);
  color: var(--danger-dark);
}

.items-table tr.is-inactive > td {
  opacity: 0.65;
}

.list-more {
  font-size: var(--text-sm);
  color: var(--muted);
}

.list-more .btn-text {
  font-size: var(--text-sm);
  color: var(--info);
}
