@font-face {
  font-family: Cantarell;
  src: url('/fonts/cantarell.otf');
  font-display: swap;
}

@font-face {
  font-family: Quicksand;
  src: url('/fonts/quicksand.woff2');
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: Cantarell, system-ui, sans-serif;
  font-synthesis: weight;
  --font-display: Quicksand, Avenir, sans-serif;
  --display-weight: 700;
  --display-spacing: -0.035em;
  --bg: #f5f8f7;
  --surface: #ffffff;
  --ink: #16324a;
  --muted: #607483;
  --accent: #058789;
  --accent-ink: #ffffff;
  --tint: #dbeeed;
  --line: #b8d1d0;
  --nav: #ffffff;
  --navtext: #16324a;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

button, input, select, textarea {
  font: inherit;
}

button, a, input, select, summary, textarea {
  -webkit-tap-highlight-color: transparent;
}

button, select, summary {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

input, select, textarea {
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--ink);
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-spacing);
}

h2 {
  font-size: 1.3rem;
  line-height: 1.15;
}

h3 {
  font-size: 1.12rem;
  line-height: 1.25;
}

p {
  line-height: 1.6;
}

small {
  font-size: 0.75rem;
}

strong {
  font-weight: 700;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 12px;
  z-index: 100;
  padding: 12px 16px;
  border: 2px solid var(--accent);
  background: var(--surface);
}

.skip-link:focus {
  top: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-size: 1.03rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.sidebar nav a:hover {
  opacity: 1;
}

.connection-open {
  font-size: 0.75rem;
}

main {
  position: relative;
  min-width: 0;
}

.sync-drawer {
  position: fixed;
  top: 132px;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.sync-toggle {
  display: grid;
  width: 44px;
  min-height: 48px;
  flex: 0 0 auto;
  order: 2;
  place-items: center;
  padding: 0;
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--ink) 8%, transparent);
}

.sync-toggle svg {
  transition: transform 160ms ease;
}

.sync-toggle[aria-expanded='true'] svg {
  transform: rotate(180deg);
}

.topbar {
  display: flex;
  width: min(440px, calc(100vw - 68px));
  max-height: calc(100dvh - 152px);
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  margin: 0;
  padding: 16px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 5px 18px color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--muted);
  font-size: 0.72rem;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.quiet-button {
  min-height: 34px;
  padding: 5px 7px;
  border-color: transparent;
  background: transparent;
  font-size: 0.72rem;
}

.quiet-button span {
  margin-right: 4px;
  font-size: 1rem;
}

.mode-toggle {
  display: flex;
  visibility: hidden;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 4px 7px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
}

.mode-toggle[data-mode-ready] {
  visibility: visible;
}

.mode-toggle:hover {
  border-color: transparent;
  color: var(--ink);
}

.mode-track {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex: 0 0 auto;
  border: 2px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
}

.mode-track::before {
  position: absolute;
  top: 8px;
  right: 5px;
  left: 5px;
  border-top: 2px solid #f5c84b;
  content: '';
}

.mode-track > span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.mode-toggle[data-mode-animated] .mode-track > span {
  transition: transform 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.data-label {
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.66rem;
}

.page-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1520px;
  margin: auto;
  padding: 38px 42px 22px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 32px;
}

.page-heading > div:first-child, .mini-course > div, .course-card > *, .sync-note > div, .dialog-heading h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.page-heading p {
  max-width: 60ch;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.87rem;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
  align-items: start;
  gap: 28px;
}

.schedule-now {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.6fr);
}

.schedule-clock {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 32px 28px;
  border-right: 1px solid var(--line);
  background: var(--tint);
}

.schedule-timer {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: var(--display-weight);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--display-spacing);
  line-height: 1;
}

.schedule-timer[data-tone='soon'] { color: #c26a00; }
.schedule-timer[data-tone='idle'] { color: var(--muted); }
body[data-mode='dark'] .schedule-timer[data-tone='soon'] { color: #ffc266; }

.schedule-subtitle {
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1.45;
}

.schedule-today {
  margin: 0;
  padding: 10px 0;
  list-style: none;
}

.schedule-item {
  display: grid;
  grid-template-columns: 9.5em minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
  margin: 0 14px;
  padding: 11px 12px;
  border-left: 4px solid var(--course-hue, transparent);
  border-radius: 8px;
}

.schedule-item + .schedule-item { margin-top: 3px; }
.schedule-item time { color: var(--muted); font-size: 0.7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.schedule-item span { display: block; color: var(--muted); font-size: 0.66rem; }
.schedule-item strong { display: block; margin-top: 2px; font-size: 0.86rem; }
.schedule-item small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.7rem; }
.schedule-item a, .schedule-rotation a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
.schedule-advisory strong { color: var(--muted); font-weight: 400; }
.schedule-lunch { border-left: 4px dashed #d69e2e; }
.schedule-lunch strong { color: #b7791f; }
body[data-mode='dark'] .schedule-lunch strong { color: #f6c453; }
.schedule-rotation thead small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.62rem; font-weight: 400; }

.schedule-current {
  background: color-mix(in srgb, var(--course-hue, var(--accent)) 16%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--course-hue, var(--accent)) 45%, transparent);
}

.schedule-current time { color: var(--ink); font-weight: 700; }
.schedule-rotation-panel { margin-top: 24px; }
.schedule-rotation { min-width: 860px; table-layout: fixed; }
.schedule-rotation th:first-child { width: 84px; }
.schedule-rotation thead th { text-align: center; }
.schedule-rotation tbody th { vertical-align: middle; white-space: nowrap; }

.schedule-rotation td {
  padding: 10px 11px;
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--course-hue) 22%, var(--surface));
  box-shadow: inset 0 3px var(--course-hue);
  text-align: center;
  vertical-align: middle;
}

.schedule-rotation td strong { display: block; font-size: 0.74rem; line-height: 1.3; }
.schedule-rotation td small { display: block; margin-top: 3px; color: var(--muted); font-size: 0.66rem; }
.schedule-rotation td.schedule-free { background: var(--surface); box-shadow: none; color: var(--muted); }
.schedule-rotation tbody tr:last-child td { border-bottom: 1px solid var(--line); }
.schedule-rotation th.schedule-rotation-today { color: var(--accent); font-weight: 700; }
.schedule-rotation td.schedule-rotation-today { outline: 2px solid var(--accent); outline-offset: -2px; }

.schedule-color-0 { --course-hue: #f59e0b; }
.schedule-color-1 { --course-hue: #06b6d4; }
.schedule-color-2 { --course-hue: #ec4899; }
.schedule-color-3 { --course-hue: #22c55e; }
.schedule-color-4 { --course-hue: #8b5cf6; }
.schedule-color-5 { --course-hue: #ef4444; }
.schedule-color-6 { --course-hue: #a8835a; }
.schedule-color-7 { --course-hue: #3b82f6; }

@media (max-width: 760px) {
  .schedule-now { grid-template-columns: 1fr; }
  .schedule-clock { padding: 24px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .schedule-item { grid-template-columns: 1fr; gap: 4px; margin: 0 8px; }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 23px 24px 18px;
}

.section-heading p {
  max-width: 62ch;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

#activity-notifications {
  flex: 0 0 auto;
}

.section-heading > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.68rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 20px;
}

.filter-row select {
  min-width: 0;
  font-size: 0.75rem;
}

.search-field {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 7px;
  padding-left: 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 9px 7px;
  border: 0;
  background: transparent;
  font-size: 0.76rem;
}

.search-field span {
  font-size: 1.1rem;
}

.activity-list {
  padding: 0 24px;
}

.activity-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: start;
  gap: 13px;
  padding: 19px 0;
  border-bottom: 1px solid var(--line);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item h3 {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
}

.activity-item h3 a {
  color: var(--ink);
}

.activity-item h3 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.activity-item p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.activity-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.64rem;
}

.event-values {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
}

.event-value {
  padding-top: 1px;
  color: var(--ink);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
}

.event-value small {
  font-weight: 400;
  text-align: right;
}

.table-footnote, .source-note {
  padding: 11px 24px;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.55;
}

.source-note {
  padding-top: 0;
  padding-bottom: 18px;
}

.table-footnote {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.feed-more {
  margin: 0 24px 14px;
  font-size: 0.73rem;
}

.text-link {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.73rem;
  white-space: nowrap;
}

.mini-course:hover {
  background: var(--tint);
}

.mini-course strong {
  font-size: 0.79rem;
}

.mini-course small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.66rem;
}

.mini-course .mini-grade {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: var(--display-weight);
}

.mini-grade, .course-bottom strong, .detail-grade strong {
  color: var(--grade-color, var(--accent));
}

.sync-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.sync-note > span {
  line-height: 1;
  color: var(--accent);
  font-size: 1.45rem;
}

.sync-note strong {
  color: var(--ink);
  font-size: 0.75rem;
}

.sync-note p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.67rem;
}

.grades-toolbar .search-field {
  max-width: 350px;
}

.grades-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.grade-period-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.grade-period-controls select {
  min-width: 160px;
  max-width: 100%;
}

.grade-period-status {
  margin: -10px 0 24px;
  color: var(--muted);
  font-size: 0.75rem;
}

.grade-period-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  flex: 1;
}

.course-card:hover {
  border-color: var(--accent);
  border-left-color: var(--route);
  background: var(--tint);
}

.course-card h3 {
  margin-bottom: 8px;
}

.course-card p {
  color: var(--muted);
  font-size: 0.73rem;
}

.course-bottom strong {
  font-size: 1.9rem;
  letter-spacing: -0.04em;
}

.back-link {
  display: inline-block;
  margin-bottom: 25px;
  font-size: 0.78rem;
}

.detail-grade {
  flex: 0 0 auto;
  text-align: right;
}

.detail-grade strong {
  display: block;
  font-size: 2.7rem;
  line-height: 1;
}

.assignment-panel {
  margin-bottom: 24px;
}

.term-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  white-space: nowrap;
}

.table-scroll {
  overflow: auto;
}

.mobile-table-hint {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
  text-align: left;
}

th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 400;
}

th, td {
  padding: 14px 19px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

td {
  font-variant-numeric: tabular-nums;
}

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

.assignment-table {
  min-width: 900px;
}

.assignment-table td:first-child {
  min-width: 175px;
  font-weight: 700;
}

.assignment-table td:nth-child(6) {
  font-weight: 700;
}

.assignment-table tr:is(.grade-a, .grade-a-minus, .grade-b, .grade-low, .grade-none) td:first-child {
  border-left: 4px solid var(--route);
  color: var(--grade-color);
}

.assignment-table tr:is(.grade-a, .grade-a-minus, .grade-b, .grade-low, .grade-none) td:nth-child(6),
.assignment-table tr:is(.grade-a, .grade-a-minus, .grade-b, .grade-low, .grade-none) td:nth-child(8) {
  color: var(--grade-color);
  font-weight: 700;
}

.assignment-table details p {
  min-width: 150px;
  max-width: 280px;
  margin-top: 8px;
  color: var(--muted);
}

.comment-link {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: inherit;
}

.comment-link:hover {
  border-color: transparent;
  color: var(--ink);
  text-decoration: underline;
}

summary {
  color: var(--accent);
}

.empty-result {
  padding: 28px 24px;
  color: var(--muted);
  font-size: 0.78rem;
}

.attendance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
  align-items: start;
  gap: 24px;
}

.attendance-layout table {
  min-width: 310px;
}

.attendance-layout .attendance-unexcused {
  background: color-mix(in srgb, #e05b52 12%, var(--surface));
}

body[data-mode='dark'] .attendance-layout .attendance-unexcused {
  background: color-mix(in srgb, #ff8175 15%, var(--surface));
}

.empty-welcome {
  max-width: 700px;
  padding: 72px 20px 100px 0;
}

.empty-welcome h1 {
  max-width: 13ch;
  font-size: clamp(3rem, 6vw, 5.7rem);
}

.empty-welcome > div {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 29px;
}

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

.primary:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  filter: brightness(0.92);
}

.notice {
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.73rem;
}

.notice summary {
  color: var(--muted);
}

.notice ul {
  padding-left: 20px;
  line-height: 1.7;
}

dialog {
  width: min(560px, calc(100% - 32px));
  max-height: 86vh;
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
}

dialog::backdrop {
  background: #08141fb8;
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.dialog-heading button {
  border: 0;
}

.dialog-heading h2 {
  font-size: 1.65rem;
}

dialog p {
  margin: 14px 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.78rem;
}

.comment-dialog {
  width: min(420px, calc(100% - 32px));
}

.comment-dialog #comment-content {
  white-space: pre-wrap;
}

dialog details {
  padding: 16px 0;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
}

.google-connection {
  padding: 24px 0 14px;
  border-top: 1px solid var(--line);
}

.google-button {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid #747775;
  border-radius: 3px;
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 600;
}

.google-button[aria-disabled='true'] {
  cursor: default;
  opacity: 0.55;
}

.google-button:hover {
  background: #f3f6fc;
  color: #1f1f1f;
}

.google-button svg {
  flex: 0 0 auto;
}

.cookie-form {
  display: grid;
  gap: 10px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.cookie-form label {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
}

.cookie-form label span {
  color: var(--muted);
  font-weight: 400;
}

.cookie-form input {
  width: 100%;
  min-width: 0;
}

.cookie-form p {
  margin: 0 0 8px;
  line-height: 1.6;
}

.cookie-form a {
  color: var(--accent);
  text-decoration: underline;
}

.manage-data button {
  font-size: 0.72rem;
}

.connection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 22px;
}

.app-shell {
  display: block;
  min-height: 100vh;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  z-index: 2;
  display: grid;
  flex-direction: column;
  gap: 25px;
  padding: 19px 32px;
  background: var(--nav);
  color: var(--navtext);
  min-height: 112px;
  grid-template-columns: 250px minmax(390px, 1fr) 250px;
  align-items: center;
  border-bottom: 1px solid #b8d1d0;
  box-shadow: 0 7px 0 #dbeeed;
}

.sidebar nav {
  display: flex;
  flex-direction: row;
  gap: 38px;
  position: relative;
  grid-column: 2;
  justify-content: center;
}

.sidebar nav::before {
  position: absolute;
  top: 18px;
  right: 12%;
  left: 12%;
  height: 6px;
  border-top: 2px solid #058789;
  border-bottom: 2px solid #f5c84b;
  content: '';
}

.sidebar nav a {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border: 1px solid transparent;
  color: inherit;
  font-size: 0.72rem;
  opacity: 1;
  z-index: 1;
  min-width: 82px;
  flex-direction: column;
  background: #ffffff;
}

.sidebar nav a[aria-current='page'] {
  border-color: transparent;
  background: #ffffff;
  opacity: 1;
  color: #ef6a5b;
}

.sidebar nav:not([data-ready]) .nav-icon {
  visibility: hidden;
}

.sidebar nav[data-animated] a {
  transition: color 160ms ease;
}

.sidebar nav[data-animated] .nav-icon {
  transition: background-color 160ms ease, box-shadow 160ms ease;
}

.nav-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 4px solid #058789;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 50%;
  background: #ffffff;
}

.sidebar nav a:nth-child(2) .nav-icon {
  border-color: #f5c84b;
}

.sidebar nav a:nth-child(3) .nav-icon {
  border-color: #ef6a5b;
}

.sidebar nav a[aria-current='page'] .nav-icon {
  box-shadow: inset 0 0 0 5px #ffffff;
  background: currentColor;
  font-size: 0;
}

.sidebar nav a[data-view='home'][aria-current='page'] .nav-icon {
  background: #f6d26a;
}

.sidebar nav a[data-view='attendance'][aria-current='page'] .nav-icon {
  background: #65aaf2;
}

/* Navigation uses the same four-color order as the school-day overview. */
.sidebar nav a, .sidebar nav a[aria-current='page'] { color: #fff !important; }
.sidebar nav a[data-view='home'] .nav-icon { border-color: #20c4c7; }
.sidebar nav a[data-view='grades'] .nav-icon { border-color: #f5c84b; }
.sidebar nav a[data-view='schedule'] .nav-icon { border-color: #ef6a5b; }
.sidebar nav a[data-view='attendance'] .nav-icon { border-color: #58b57b; }
.sidebar nav a[data-view='home'][aria-current='page'] .nav-icon { background: #f5c84b; }
.sidebar nav a[data-view='grades'][aria-current='page'] .nav-icon { background: #ef6a5b; }
.sidebar nav a[data-view='schedule'][aria-current='page'] .nav-icon { background: #58b57b; }
.sidebar nav a[data-view='attendance'][aria-current='page'] .nav-icon { background: #20c4c7; }
.sidebar nav a[data-view='home'][aria-current='page'] .nav-icon { background: #f5c84b; }
.sidebar nav a[data-view='grades'][aria-current='page'] .nav-icon { background: #ef6a5b; }
.sidebar nav a[data-view='schedule'][aria-current='page'] .nav-icon { background: #58b57b; }
.sidebar nav a[data-view='attendance'][aria-current='page'] .nav-icon { background: #20c4c7; }

h1 {
  max-width: 18ch;
  font-size: clamp(2.35rem, 4vw, 4rem);
  line-height: 0.98;
  color: #16324a;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.date-heading {
  margin: 0 -24px;
  padding: 8px 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #dbeeed;
  color: #16324a;
  font-family: inherit;
  font-size: 0.71rem;
  font-weight: 400;
  letter-spacing: 0;
  border-color: #b8d1d0;
}

.event-icon {
  display: grid;
  width: 33px;
  height: 33px;
  place-items: center;
  border: 4px solid #058789;
  background: #ffffff;
  color: var(--accent);
  font-size: 0.82rem;
  border-radius: 50%;
}

.event-icon.attendance {
  background: var(--surface);
  color: var(--muted);
  border-color: #ef6a5b;
}

.mini-course {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  position: relative;
  padding-left: 52px;
}

.mini-course::before {
  position: absolute;
  z-index: 1;
  left: 22px;
  width: 15px;
  height: 15px;
  border: 4px solid var(--route, #058789);
  border-radius: 50%;
  background: #ffffff;
  content: '';
}

.mini-course::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 31px;
  width: 3px;
  background: var(--route, #058789);
  content: '';
}

.course-grid {
  display: block;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  padding-left: 42px;
}

.course-card {
  position: relative;
  display: grid;
  min-height: 126px;
  grid-column: span 4;
  flex-direction: column;
  padding: 20px 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  --route-axis: -37px;
  --station-size: 28px;
  --course-gap: 14px;
  grid-template-columns: minmax(190px, 1.2fr) minmax(190px, 0.8fr) 180px;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
  border-left: 9px solid var(--route);
  border-radius: 0 12px 12px 0;
  box-shadow: 0 5px 0 #dbeeed;
}

.grade-a, .attendance-excused {
  --route: #2c9a66;
  --grade-color: #157148;
}

.grade-a-minus {
  --route: #058789;
  --grade-color: #056f71;
}

.grade-b {
  --route: #e3b934;
  --grade-color: #7a5700;
}

.grade-low {
  --route: #e05b52;
  --grade-color: #a9322b;
}

.grade-none {
  --route: #2c9a66;
  --grade-color: #157148;
}

.course-card::before {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: calc(var(--route-axis) - var(--station-size) / 2);
  box-sizing: border-box;
  width: var(--station-size);
  height: var(--station-size);
  border: 5px solid var(--route);
  border-radius: 50%;
  background: var(--surface);
  content: '';
  transform: translateY(-50%);
}

.course-card::after {
  position: absolute;
  top: -1px;
  bottom: calc(-1 * var(--course-gap) - 1px);
  left: calc(var(--route-axis) - 2px);
  width: 4px;
  background: var(--route);
  content: '';
}

.course-card:first-child::after {
  top: 50%;
}

.course-card:last-child::after {
  bottom: 50%;
}

.course-card h3, .course-card p, .course-bottom {
  margin: 0;
}

.course-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 14px;
  margin-top: auto;
  padding-top: 22px;
  grid-column: -2 / -1;
  justify-self: end;
  margin: 0;
  padding: 0 0 0 24px;
  border: 0;
  background-image: linear-gradient(var(--line), var(--line));
  background-position: left top;
  background-size: 1px 100%;
  background-repeat: no-repeat;
}

.course-bottom strong, .detail-grade strong {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: var(--display-weight);
  white-space: nowrap;
  color: var(--grade-color, #056f71);
}

body[data-mode='dark'] {
  color-scheme: dark;
  --bg: #0d2231;
  --surface: #163747;
  --ink: #eef6f3;
  --muted: #a8bec3;
  --accent: #55c4c2;
  --accent-ink: #0d2231;
  --tint: #1d4855;
  --line: #365a68;
  --nav: #102a39;
  --navtext: #eef6f3;
}

body[data-mode='dark'] .mode-track {
  border-color: #55c4c2;
  background: #163747;
}

body[data-mode='dark'] .mode-track::before {
  border-color: #ff887c;
}

body[data-mode='dark'] .mode-track > span {
  background: #f6d26a;
  box-shadow: 0 0 0 1px #f6d26a;
  transform: translateX(18px);
}

body[data-mode='dark'] .sidebar {
  border-color: #365a68;
  box-shadow: 0 7px 0 #183b4b;
}

body[data-mode='dark'] .sidebar nav::before {
  border-top-color: #55c4c2;
  border-bottom-color: #f6d26a;
}

body[data-mode='dark'] .sidebar nav a, body[data-mode='dark'] .sidebar nav a[aria-current='page'] {
  background: #102a39;
}

body[data-mode='dark'] .sidebar nav a[aria-current='page'] {
  color: #ff887c;
}

body[data-mode='dark'] .nav-icon {
  border-color: #55c4c2;
  background: #102a39;
}

body[data-mode='dark'] .sidebar nav a:nth-child(2) .nav-icon {
  border-color: #f6d26a;
}

body[data-mode='dark'] .sidebar nav a:nth-child(3) .nav-icon {
  border-color: #ff887c;
}

body[data-mode='dark'] .sidebar nav a, body[data-mode='dark'] .sidebar nav a[aria-current='page'] { color: #fff !important; }
body[data-mode='dark'] .sidebar nav a[data-view='home'] .nav-icon { border-color: #55e0df; }
body[data-mode='dark'] .sidebar nav a[data-view='grades'] .nav-icon { border-color: #f6d26a; }
body[data-mode='dark'] .sidebar nav a[data-view='schedule'] .nav-icon { border-color: #ff887c; }
body[data-mode='dark'] .sidebar nav a[data-view='attendance'] .nav-icon { border-color: #69ce91; }
body[data-mode='dark'] .sidebar nav a[data-view='home'][aria-current='page'] .nav-icon { background: #f6d26a; }
body[data-mode='dark'] .sidebar nav a[data-view='grades'][aria-current='page'] .nav-icon { background: #ff887c; }
body[data-mode='dark'] .sidebar nav a[data-view='schedule'][aria-current='page'] .nav-icon { background: #69ce91; }
body[data-mode='dark'] .sidebar nav a[data-view='attendance'][aria-current='page'] .nav-icon { background: #55e0df; }
body[data-mode='dark'] .sidebar nav a[data-view='home'][aria-current='page'] .nav-icon { background: #f6d26a; }
body[data-mode='dark'] .sidebar nav a[data-view='grades'][aria-current='page'] .nav-icon { background: #ff887c; }
body[data-mode='dark'] .sidebar nav a[data-view='schedule'][aria-current='page'] .nav-icon { background: #69ce91; }
body[data-mode='dark'] .sidebar nav a[data-view='attendance'][aria-current='page'] .nav-icon { background: #55e0df; }

body[data-mode='dark'] .sidebar nav a[aria-current='page'] .nav-icon {
  box-shadow: inset 0 0 0 5px #102a39;
}

body[data-mode='dark'] h1, body[data-mode='dark'] .date-heading {
  color: #eef6f3;
}

body[data-mode='dark'] .date-heading {
  border-color: #365a68;
  background: #1d4855;
}

body[data-mode='dark'] .event-icon, body[data-mode='dark'] .mini-course::before, body[data-mode='dark'] .course-card::before {
  background: #163747;
}

body[data-mode='dark'] .event-icon {
  border-color: #55c4c2;
}

body[data-mode='dark'] .event-icon.attendance {
  border-color: #ff887c;
}

body[data-mode='dark'] .grade-a, body[data-mode='dark'] .attendance-excused {
  --route: #5ed39a;
  --grade-color: #5ed39a;
}

body[data-mode='dark'] .grade-a-minus {
  --route: #55c4c2;
  --grade-color: #55c4c2;
}

body[data-mode='dark'] .grade-b {
  --route: #f6d26a;
  --grade-color: #f6d26a;
}

body[data-mode='dark'] .grade-low {
  --route: #ff8175;
  --grade-color: #ff8175;
}

body[data-mode='dark'] .grade-none {
  --route: #5ed39a;
  --grade-color: #5ed39a;
}

.activity-item:is(.grade-a, .grade-a-minus, .grade-b, .grade-low, .grade-none, .attendance-excused) :is(h3, h3 a, .event-value, .event-icon) {
  color: var(--grade-color);
}

.activity-item:is(.grade-a, .grade-a-minus, .grade-b, .grade-low, .grade-none, .attendance-excused) .event-icon,
.activity-item:is(.grade-a, .grade-a-minus, .grade-b, .grade-low, .grade-none, .attendance-excused) .event-icon.attendance {
  border-color: var(--route);
}

body[data-mode='dark'] .course-card {
  box-shadow: 0 5px 0 #183b4b;
}

@media (min-width: 1700px) {
  .page-content {
    padding-right: 58px;
    padding-left: 58px;
  }
}

@media (max-width: 1180px) {
  .sidebar {
    grid-template-columns: 220px minmax(320px, 1fr) 220px;
  }

  .course-card {
    grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.8fr) 170px;
  }
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
    min-height: 0;
  }

  .sidebar {
    display: grid;
    min-height: auto;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    padding: 15px 22px;
    border-right: 0;
    border-bottom: 2px solid var(--line);
    box-shadow: none;
  }

  .sidebar nav {
    grid-column: 1;
    flex-direction: row;
    justify-content: center;
    gap: 5px;
  }

  .sidebar nav::before {
    display: none;
  }

  .sidebar nav a {
    min-width: 0;
    min-height: 40px;
    flex-direction: row;
    gap: 7px;
    padding: 5px 9px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.75rem;
  }

  body[data-mode='dark'] .sidebar nav a, body[data-mode='dark'] .sidebar nav a[aria-current='page'] {
    background: transparent;
  }

  .nav-icon {
    width: 28px;
    height: 28px;
    border-width: 3px;
  }

  .sync-drawer {
    top: 146px;
  }

  .topbar {
    max-height: calc(100dvh - 166px);
  }

  .page-content {
    padding-right: 24px;
    padding-left: 24px;
  }

  .home-layout, .attendance-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .home-aside {
    display: block;
  }

  .course-card {
    grid-template-columns: minmax(150px, 1fr) 155px;
  }

  .course-card p {
    display: none;
  }
}

@media (max-width: 650px) {
  .sidebar {
    display: block;
    padding: 12px;
  }

  .brand {
    display: none;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2px;
  }

  .sidebar nav a, .sidebar nav a[aria-current='page'] {
    justify-content: center;
    min-height: 44px;
    padding: 6px 4px;
    font-size: 0.68rem;
    background: transparent;
  }

  .nav-icon {
    width: 25px;
    height: 25px;
    border-width: 1px;
  }

  .sync-drawer {
    top: 82px;
  }

  .topbar {
    max-height: calc(100dvh - 102px);
    padding: 14px 12px 10px;
  }

  .topbar-controls {
    gap: 4px;
  }

  button, .quiet-button, .mode-toggle, input, select {
    min-height: 44px;
  }

  input, select, .search-field input, .filter-row select {
    font-size: 16px;
  }

  .page-content {
    padding: 28px 15px 18px;
  }

  .page-heading {
    display: block;
    margin-bottom: 25px;
  }

  h1 {
    font-size: clamp(2.4rem, 13vw, 4rem);
  }

  .home-aside {
    display: block;
  }

  .filter-row {
    align-items: stretch;
    flex-direction: column;
    padding-right: 15px;
    padding-left: 15px;
  }

  .filter-row select, .term-label select {
    width: 100%;
  }

  .activity-list {
    padding-right: 15px;
    padding-left: 15px;
  }

  .date-heading {
    margin-right: -15px;
    margin-left: -15px;
    padding-right: 15px;
    padding-left: 15px;
  }

  .activity-item {
    grid-template-columns: 32px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .event-icon {
    width: 30px;
    height: 30px;
  }

  .event-values {
    grid-column: 2 / -1;
    flex-wrap: wrap;
  }

  .section-heading {
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 19px 15px 16px;
  }

  .section-heading > h2 {
    flex: 1 1 180px;
  }

  .term-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    white-space: normal;
  }

  .mobile-table-hint {
    display: block;
    padding: 0 15px 12px;
    color: var(--muted);
    font-size: 0.75rem;
  }

  .source-note, .table-footnote {
    padding-right: 15px;
    padding-left: 15px;
  }

  .grades-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .grades-toolbar .search-field {
    max-width: none;
  }

  .course-grid {
    display: block;
    padding-left: 42px;
  }

  .course-card {
    display: flex;
    min-height: 190px;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0 0 14px;
    padding: 20px;
  }

  .course-card h3 {
    display: block;
    margin-bottom: 7px;
  }

  .course-card p {
    display: block;
  }

  .course-bottom {
    display: flex;
    margin-top: auto;
    padding: 20px 0 0;
    border: 0;
    background-image: none;
  }

  .detail-heading {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
  }

  .detail-grade {
    text-align: left;
  }

  .detail-heading h1 {
    font-size: 2.3rem;
  }

  .detail-grade strong {
    font-size: 2.2rem;
  }

  .empty-welcome {
    padding: 50px 3px 70px;
  }

  .empty-welcome h1 {
    font-size: clamp(2.8rem, 14vw, 4.2rem);
  }

  dialog {
    padding: 22px;
  }
}

@media (max-width: 390px) {
  #mode-label {
    display: none;
  }

  .page-content {
    padding-right: 12px;
    padding-left: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.ai-chat {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom) + var(--chat-keyboard-offset, 0px));
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  width: min(420px, calc(100% - 36px));
  pointer-events: none;
}

.chat-panel, .chat-toggle {
  pointer-events: auto;
}

.ai-chat[hidden], .chat-panel[hidden] {
  display: none;
}

.chat-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 18px;
  border: 1px solid var(--accent);
  border-radius: 18px 18px 5px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 5px 20px color-mix(in srgb, var(--ink) 16%, transparent);
}

.chat-toggle:hover, .chat-toggle[aria-expanded='true'] {
  background: var(--surface);
  color: var(--accent);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 600px;
  max-height: calc(var(--chat-viewport-height, 100dvh) - 108px - env(safe-area-inset-bottom));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 40px color-mix(in srgb, var(--ink) 18%, transparent);
}

.chat-heading {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 14px 20px;
  border-bottom: 1px solid var(--line);
}

.chat-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.chat-heading-actions {
  display: flex;
  gap: 4px;
}

.chat-heading-actions button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  font-size: 1.2rem;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
}

.chat-message {
  margin-bottom: 20px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.chat-message-label {
  display: block;
  margin-bottom: 5px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--muted);
}

.chat-message p {
  margin: 0;
  font-size: .95rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.chat-message-user {
  margin-left: 30px;
  padding: 12px 14px;
  border-radius: 14px 14px 4px 14px;
  background: var(--tint);
}

.chat-message-assistant {
  padding-right: 8px;
}

.chat-status {
  flex-shrink: 0;
  margin: 0;
  padding: 8px 20px;
  font-size: .85rem;
  line-height: 1.5;
}

.chat-status {
  color: var(--muted);
}

.chat-form {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  align-items: flex-end;
  margin: 0 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--bg);
}

.chat-form:focus-within {
  border-color: var(--accent);
}

.chat-form textarea {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  max-height: 120px;
  resize: vertical;
  margin: 0;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
}

.chat-form button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
  border-radius: 11px;
}

.chat-footnote {
  flex-shrink: 0;
  margin: 0;
  padding: 9px 18px 12px;
  color: var(--muted);
  font-size: .68rem;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 600px) {
  .ai-chat {
    width: calc(100% - 24px);
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom) + var(--chat-keyboard-offset, 0px));
  }

  .chat-toggle {
    min-height: 48px;
    padding: 10px 15px;
  }

  .ai-chat.is-open .chat-toggle {
    display: none;
  }

  .chat-panel {
    height: 680px;
    max-height: calc(var(--chat-viewport-height, 100dvh) - 24px - env(safe-area-inset-bottom) - env(safe-area-inset-top));
    border-radius: 20px;
  }

  .chat-heading {
    padding: 12px 12px 12px 16px;
  }

  .chat-messages {
    padding: 16px;
  }
}
