/* Gertrude's look. Colors are set once here and reused everywhere. */

:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-muted: #faf8f3;
  --border: #e2dccf;
  --border-strong: #cbc1ae;
  --ink: #1d2330;
  --ink-muted: #5a6170;
  --primary: #1f3a5f;
  --primary-hover: #162c49;
  --primary-soft: #e6ecf4;
  --gold: #b3882a;
  --gold-soft: #f6eed9;
  --danger: #8e2c36;
  --danger-soft: #f7e7e9;
  --success: #2c6a4e;
  --success-soft: #e3f1e9;
  --attention: #85580b;
  --attention-soft: #fbefd6;
  --focus: #2b5c9e;
  --radius: 10px;
  --radius-small: 6px;
  --shadow: 0 1px 2px rgba(29, 35, 48, 0.05), 0 4px 14px rgba(29, 35, 48, 0.04);
  --font-body: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-heading: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  /* Calendar kinds: text color and background for each */
  --no-school: #7c2430;       --no-school-bg: #f6e3e6;
  --mandatory: #58398a;       --mandatory-bg: #ede6f6;
  --schedule: #845708;        --schedule-bg: #fbefd6;
  --grading: #1f3a5f;         --grading-bg: #e2eaf4;
  --exam: #963c14;            --exam-bg: #fae7dc;
  --feast: #6c5610;           --feast-bg: #f4ecd2;
  --event: #235c45;           --event-bg: #e0f0e7;
  --staff: #464e5c;           --staff-bg: #eaecef;
}

/* ---- The Church's seasons -------------------------------------------------------------
   Only the colours change; every page keeps its shape. The dates are worked out in
   src/seasons.js, on the old calendar. The green set is the one in :root above, worn by the
   Time after Epiphany, Septuagesima and the Time after Pentecost, so body.season-green needs
   no block of its own. */

body.season-advent {
  --bg: #f1f0f7;
  --surface-muted: #f7f6fb;
  --border: #ddd9ea;
  --border-strong: #c6c0dc;
  --ink: #1f2233;
  --ink-muted: #5c5e78;
  --primary: #3c3a78;
  --primary-hover: #2e2c61;
  --primary-soft: #e7e5f4;
  --gold: #5878ab;
  --gold-soft: #e2ecf7;
}

body.season-christmas {
  --bg: #f7f4ea;
  --surface-muted: #faf7ef;
  --border: #ddd6c2;
  --border-strong: #c8bfa6;
  --ink: #1c2620;
  --ink-muted: #55605a;
  --primary: #1e4a33;
  --primary-hover: #163726;
  --primary-soft: #e0ece4;
  --gold: #8d1f26;
  --gold-soft: #f3e0e1;
}

/* A thin trail of ivy and berries along the top of the header, only at Christmas. */
body.season-christmas .site-header {
  background-image: url('/static/ivy.svg');
  background-repeat: repeat-x;
  background-position: left top;
}

body.season-christmas .site-header__bar {
  padding-top: 1.4rem;
}

body.season-lent {
  --bg: #f3f0f4;
  --surface: #fbfafc;
  --surface-muted: #f7f4f8;
  --border: #e0d8e4;
  --border-strong: #c9bcd0;
  --ink: #241d2a;
  --ink-muted: #5f5468;
  --primary: #4a2a5a;
  --primary-hover: #381f45;
  --primary-soft: #ece4f0;
  --gold: #7c5f8d;
  --gold-soft: #f0eaf3;
}

body.season-easter {
  --bg: #fffdf3;
  --surface-muted: #fffcf0;
  --border: #eee2c4;
  --border-strong: #dccfa6;
  --ink: #2a2718;
  --ink-muted: #6b6446;
  --primary: #8a6a12;
  --primary-hover: #6d540e;
  --primary-soft: #f7eecf;
  --gold: #e0c34a;
  --gold-soft: #fbf3d8;
}

/* Gaudete and Laetare Sunday */
body.season-rose {
  --bg: #fbf3f4;
  --surface-muted: #fdf8f9;
  --border: #ecdade;
  --border-strong: #d9bec5;
  --ink: #2b1f24;
  --ink-muted: #6b5760;
  --primary: #8a4a5e;
  --primary-hover: #6f3a4b;
  --primary-soft: #f5e6ea;
  --gold: #c98b9c;
  --gold-soft: #f9edf0;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.4rem 1rem;
  background: var(--gold-soft);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}

p {
  margin: 0 0 0.75rem;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--primary);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--primary-hover);
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.35em;
  overflow-wrap: anywhere;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: var(--primary);
  color: #fff;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-small);
  z-index: 10;
}

.skip-link:focus {
  top: 0.5rem;
  color: #fff;
}

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

.small {
  font-size: 0.875rem;
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.keep-lines {
  white-space: pre-line;
}

/* ---- Header and menu ---------------------------------------------------------------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
}

.brand:hover {
  color: var(--ink);
}

.brand__logo {
  display: block;
  width: 44px;
  height: 44px;
}

.brand__words {
  display: flex;
  flex-direction: column;
}

.brand__name {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.01em;
}

.brand__school {
  font-size: 0.8rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.account__name {
  font-weight: 600;
}

.account__signout {
  margin: 0;
}

.link-button {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.main-nav {
  border-top: 1px solid var(--border);
}

.main-nav__list {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav__list::-webkit-scrollbar {
  display: none;
}

.main-nav a {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 0.8rem 0.6rem;
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.main-nav a:hover {
  color: var(--ink);
}

.main-nav a[aria-current="page"] {
  color: var(--primary);
  border-bottom-color: var(--gold);
}

.nav-badge {
  min-width: 1.35rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}

.main {
  padding-top: 1.75rem;
  padding-bottom: 3rem;
  min-height: 60vh;
}

.site-footer {
  padding-top: 1.25rem;
  padding-bottom: 2rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ---- Page headers, cards, messages -------------------------------------------------- */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 2rem;
}

.page-header__subtitle {
  color: var(--ink-muted);
  margin: 0.3rem 0 0;
}

.page-header__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card--narrow {
  max-width: 34rem;
}

.card--form {
  max-width: 44rem;
}

.card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.card__header .card__title {
  margin-bottom: 0;
}

.card__title {
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}

.card__title + .card__title,
p + .card__title,
ul + .card__title {
  margin-top: 1.1rem;
}

.card__footer {
  margin-top: 0.9rem;
  font-size: 0.9rem;
}

.danger-zone {
  border-color: #e7c9cd;
}

.flash {
  border-radius: var(--radius-small);
  padding: 0.8rem 1rem;
  margin-bottom: 1.25rem;
  border-left: 4px solid;
}

.flash--success {
  background: var(--success-soft);
  border-color: var(--success);
}

.flash--error {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.flash--info {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--ink-muted);
  background: var(--surface-muted);
}

.empty-state .button {
  margin-top: 0.9rem;
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill--neutral {
  background: #eceef1;
  color: #464e5c;
}

.pill--success {
  background: var(--success-soft);
  color: var(--success);
}

.pill--attention {
  background: var(--attention-soft);
  color: var(--attention);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  margin: 0 0.3rem 0.3rem 0;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
}

.tag__grade {
  font-weight: 700;
}

/* ---- Buttons ------------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-small);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button--primary {
  background: var(--primary);
  color: #fff;
}

.button--primary:hover {
  background: var(--primary-hover);
  color: #fff;
}

.button--secondary {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border-strong);
}

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

.button--danger {
  background: var(--surface);
  color: var(--danger);
  border-color: #dcb3b9;
}

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

.button--small {
  min-height: 2rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.875rem;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

form.is-sending button[type="submit"] {
  opacity: 0.6;
  cursor: progress;
}

/* ---- Forms ---------------------------------------------------------------------------- */

.stack > * + * {
  margin-top: 1.1rem;
}

.field {
  margin: 0;
}

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

.field__label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  padding: 0;
}

.field__optional {
  font-weight: 400;
  color: var(--ink-muted);
}

.field__hint {
  color: var(--ink-muted);
  font-size: 0.9rem;
  margin: -0.1rem 0 0.35rem;
}

.field__error {
  color: var(--danger);
  font-weight: 600;
  font-size: 0.92rem;
  margin: 0 0 0.35rem;
}

.input {
  display: block;
  width: 100%;
  min-height: 2.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-small);
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.input:focus {
  border-color: var(--focus);
}

.field--invalid .input {
  border-color: var(--danger);
  border-width: 2px;
}

textarea.input {
  resize: vertical;
}

.input--file {
  padding: 0.45rem;
  background: var(--surface-muted);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.35rem 0;
  cursor: pointer;
}

.choice input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.2rem 0 0;
  flex: none;
  accent-color: var(--primary);
}

.choice__label {
  display: block;
  font-weight: 500;
}

.choice:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.65;
}

.table-note {
  margin: 0.75rem 0 0;
}

.choice__description {
  display: block;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 0.3rem;
}

.error-summary {
  border: 2px solid var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-small);
  padding: 0.8rem 1rem;
  margin-bottom: 1.1rem;
}

.error-summary__title {
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.error-summary ul {
  margin: 0;
  padding-left: 1.2rem;
}

/* Resource form: show only the file or the link field, matching the choice. */
.resource-form:has(input[name="kind"][value="link"]:checked) .kind-file,
.resource-form:has(input[name="kind"][value="file"]:checked) .kind-link {
  display: none;
}

/* ---- Sign in -------------------------------------------------------------------------- */

.auth {
  display: flex;
  justify-content: center;
  padding-top: 1.5rem;
}

.auth__card {
  width: 100%;
  max-width: 25rem;
  padding: 2rem 1.75rem;
}

.auth__logo {
  display: block;
  margin: 0 auto 0.9rem;
}

.auth__title {
  text-align: center;
  font-size: 1.6rem;
}

.auth__school {
  text-align: center;
  color: var(--ink-muted);
  margin: 0.25rem 0 1.4rem;
}

.auth .button {
  width: 100%;
}

.auth__help {
  margin-top: 1.2rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

/* ---- Home page ------------------------------------------------------------------------ */

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
  align-items: start;
}

.dashboard .card {
  margin-bottom: 0;
}

.dashboard-card__big {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.dashboard-card--warning {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.upcoming {
  list-style: none;
  margin: 0;
  padding: 0;
}

.upcoming__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

.upcoming__item:first-child {
  border-top: 0;
  padding-top: 0;
}

.upcoming__when {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.compact-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.compact-list li {
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}

.compact-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.grade-counts {
  margin-top: 0.4rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-decoration: none;
  color: var(--ink);
  margin: 0;
}

.tile:hover {
  border-color: var(--primary);
  color: var(--ink);
}

.tile__title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.tile__text {
  color: var(--ink-muted);
}

/* ---- Calendar ------------------------------------------------------------------------- */

.chip {
  display: block;
  padding: 0.12rem 0.45rem;
  margin-top: 0.2rem;
  border-radius: 4px;
  border-left: 3px solid;
  font-size: 0.78rem;
  line-height: 1.3;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip:hover {
  filter: brightness(0.96);
  text-decoration: underline;
}

.chip--static {
  display: inline-block;
  font-size: 0.9rem;
  margin: 0;
}

.chip__time {
  font-weight: 700;
}

.chip--no-school { color: var(--no-school); background: var(--no-school-bg); border-color: var(--no-school); }
.chip--mandatory { color: var(--mandatory); background: var(--mandatory-bg); border-color: var(--mandatory); }
.chip--schedule { color: var(--schedule); background: var(--schedule-bg); border-color: var(--schedule); }
.chip--grading { color: var(--grading); background: var(--grading-bg); border-color: var(--grading); }
.chip--exam { color: var(--exam); background: var(--exam-bg); border-color: var(--exam); }
.chip--feast { color: var(--feast); background: var(--feast-bg); border-color: var(--feast); }
.chip--event { color: var(--event); background: var(--event-bg); border-color: var(--event); }
.chip--staff { color: var(--staff); background: var(--staff-bg); border-color: var(--staff); }

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

.month__table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.month__table th {
  padding: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

.month__day {
  height: 7.5rem;
  vertical-align: top;
  padding: 0.35rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.month__day:last-child {
  border-right: 0;
}

.month__table tbody tr:last-child .month__day {
  border-bottom: 0;
}

.month__day--outside {
  background: var(--surface-muted);
}

.month__day--outside .month__number {
  color: #a5a9b1;
}

.month__date {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.6rem;
}

.month__number {
  font-weight: 600;
  font-size: 0.9rem;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  border-radius: 50%;
}

.month__day--today .month__number {
  background: var(--primary);
  color: #fff;
}

.month__add {
  width: 1.5rem;
  height: 1.5rem;
  line-height: 1.4rem;
  text-align: center;
  border-radius: 50%;
  text-decoration: none;
  color: var(--ink-muted);
  opacity: 0;
}

.month__day:hover .month__add,
.month__add:focus-visible {
  opacity: 1;
}

.month__add:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.agenda {
  display: none;
}

.agenda__day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.6rem;
}

.agenda__day--today {
  border-color: var(--primary);
  border-width: 2px;
}

.agenda__date {
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.agenda__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.agenda .chip {
  display: inline-block;
  font-size: 0.9rem;
}

.agenda__through {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend__swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  border-left: 3px solid;
}

.details {
  margin: 0;
}

.details > div {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--border);
}

.details > div:first-child {
  border-top: 0;
  padding-top: 0;
}

.details dt {
  font-weight: 600;
  color: var(--ink-muted);
}

.details dd {
  margin: 0;
}

/* ---- Resources ---------------------------------------------------------------------- */

.search {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  max-width: 34rem;
}

.search__clear {
  font-size: 0.9rem;
  white-space: nowrap;
}

.resource-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.resource {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.resource:first-child {
  border-top: 0;
  padding-top: 0;
}

.resource__title {
  font-weight: 600;
  font-size: 1.05rem;
}

.resource__description {
  margin: 0.2rem 0 0;
}

.resource__meta {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.resource__actions {
  flex: none;
}

.category-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
}

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

.category-row__form {
  display: flex;
  gap: 0.5rem;
  flex: 1 1 18rem;
  margin: 0;
}

.category-row__count {
  color: var(--ink-muted);
  font-size: 0.88rem;
  min-width: 6rem;
}

.add-category {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
}

/* ---- Tables, documents, students --------------------------------------------------- */

/* ---- Student notes ---------------------------------------------------------------------- */

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.note {
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}

.note:first-child {
  border-top: 0;
  padding-top: 0;
}

.note__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.note__when {
  font-weight: 600;
}

.note__edit {
  margin-left: auto;
}

.year-heading {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin: 1.1rem 0 0.4rem;
}

.year-heading:first-of-type {
  margin-top: 0.2rem;
}

/* ---- Grades --------------------------------------------------------------------------- */

.grade-card .card__header {
  align-items: baseline;
}

.grade-card .card__title a {
  text-decoration: none;
}

.grade-card .card__title a:hover {
  text-decoration: underline;
}

.grade-average {
  font-weight: 600;
  color: var(--ink-muted);
  white-space: nowrap;
}

.grade-table td {
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.change {
  font-weight: 600;
}

.change--up {
  color: var(--success);
}

.change--down {
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: 0.5rem 0.6rem;
  border-bottom: 2px solid var(--border);
}

.table td {
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.strong-link {
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
}

.tabs__tab {
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.tabs__tab[aria-current="page"] {
  background: var(--primary);
  color: #fff;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-list__item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  align-items: baseline;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

.file-list__item:first-child {
  border-top: 0;
}

.reply {
  background: var(--surface-muted);
  border-left: 3px solid var(--gold);
  padding: 0.6rem 0.8rem;
  margin-top: 0.6rem;
}

.list-toggle {
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.grade-grid .card {
  margin-bottom: 0;
}

.count {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: middle;
}

.student-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.student {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 0.75rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
}

.student:first-child {
  border-top: 0;
  padding-top: 0;
}

.student__name {
  font-weight: 500;
}

.student__family {
  grid-column: 1;
}

.student__edit {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.family-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.family {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid var(--border);
}

.family:first-child {
  border-top: 0;
  padding-top: 0;
}

.family__main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 1rem;
}

.family__name {
  font-weight: 600;
  min-width: 9rem;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.9rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.temp-password {
  font-size: 1.3rem;
  letter-spacing: 0.06em;
  padding: 0.2em 0.5em;
}

/* ---- Phones --------------------------------------------------------------------------- */

@media (max-width: 760px) {
  .page-header h1 {
    font-size: 1.6rem;
  }

  .month {
    display: none;
  }

  .agenda {
    display: block;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .details > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.1rem;
  }

  .account__name {
    display: none;
  }

  /* Wrap the menu onto two lines rather than hiding items off the edge. */
  .main-nav__list {
    flex-wrap: wrap;
    gap: 0;
  }

  .main-nav a {
    padding: 0.55rem 0.65rem 0.45rem;
  }

  .resource {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ---- Printing: just the content --------------------------------------------------- */

@media print {
  .site-header .account,
  .main-nav,
  .page-header__actions,
  .site-footer,
  .month__add,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .card,
  .month {
    box-shadow: none;
  }
}

/* ---- Grades: choosing a school year -------------------------------------------------- */

.year-chooser {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.year-chooser label {
  font-weight: 600;
}

/* ---- Export: records laid out for printing, or saving as a PDF ---------------------- */

.print-page {
  background: #fff;
  color: var(--ink);
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
}

.print-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.print-header h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  margin: 0.1rem 0 0.25rem;
}

.print-header__school {
  margin: 0;
  color: var(--ink-muted);
}

.print-student {
  padding-top: 1.25rem;
  margin-top: 1.25rem;
  border-top: 2px solid var(--border-strong);
}

.print-student h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  margin: 0;
}

.print-year {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin: 1rem 0 0.4rem;
}

.print-grades {
  width: 100%;
  font-size: 0.9rem;
}

.print-grades th,
.print-grades td {
  vertical-align: top;
}

.print-notes {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
}

.print-notes li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
}

.print-notes p {
  margin: 0.2rem 0 0;
}

@media print {
  .print-toolbar {
    display: none !important;
  }

  .print-page {
    padding: 0;
    max-width: none;
  }

  /* Each student starts a new page. */
  .print-student {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    break-before: page;
  }

  .print-header + .print-student {
    break-before: auto;
  }

  .print-grades tr,
  .print-notes li {
    break-inside: avoid;
  }
}
