body[data-page="year"] {
  --accent: #4338ca;
  --accent-soft: #edeffb;
  --history: #b45309;
  --history-soft: #fbf1e4;
  --theology: #1d4ed8;
  --theology-soft: #e8eefc;
  --literature: #15803d;
  --literature-soft: #e7f4ec;
  --choir: #7e22ce;
  --choir-soft: #f4ebfb;
}

.year-head {
  background:
    radial-gradient(85% 125% at 0% 0%, var(--history-soft) 0%, transparent 64%),
    radial-gradient(72% 120% at 100% 0%, var(--theology-soft) 0%, transparent 64%),
    radial-gradient(72% 120% at 0% 100%, var(--literature-soft) 0%, transparent 64%),
    radial-gradient(72% 120% at 100% 100%, var(--choir-soft) 0%, transparent 64%),
    var(--bg);
}

.year-map-card {
  overflow: hidden;
}

.year-card-head,
.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.year-card-head h2,
.detail-heading h2 {
  margin-bottom: 0.2rem;
}

.year-updated,
.detail-date {
  flex: 0 0 auto;
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.thread-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  margin: 1rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.thread-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-line {
  width: 19px;
  height: 5px;
  border-radius: 99px;
  background: currentColor;
}

.legend-line.history { color: var(--history); }
.legend-line.theology { color: var(--theology); }
.legend-line.literature { color: var(--literature); }
.legend-line.choir { color: var(--choir); }

.legend-knot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}

.thread-map {
  position: relative;
  margin-top: 0.2rem;
}

.year-axis {
  position: relative;
  height: 28px;
  margin-left: 106px;
  border-bottom: 1px solid var(--border);
}

.axis-month {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.thread-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
}

.thread-links path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.7;
  stroke-linecap: round;
  opacity: 0.58;
  animation: draw-thread 380ms ease-out both;
}

@keyframes draw-thread {
  from { stroke-dasharray: 7 8; opacity: 0.08; }
  to { stroke-dasharray: 1 0; opacity: 0.58; }
}

.thread-lane {
  --course: var(--accent);
  --course-soft: var(--accent-soft);
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr);
  min-height: 117px;
  border-bottom: 1px solid var(--border);
}

.thread-lane:last-child {
  border-bottom: 0;
}

.thread-lane.history { --course: var(--history); --course-soft: var(--history-soft); }
.thread-lane.theology { --course: var(--theology); --course-soft: var(--theology-soft); }
.thread-lane.literature { --course: var(--literature); --course-soft: var(--literature-soft); }
.thread-lane.choir { --course: var(--choir); --course-soft: var(--choir-soft); }

.lane-label {
  align-self: start;
  padding: 1rem 0.65rem 0 0;
}

.lane-label strong {
  display: block;
  color: var(--course);
  font-family: Fraunces, Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.15;
}

.lane-label span {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.25;
}

.lane-track {
  position: relative;
  min-width: 0;
  min-height: 116px;
}

.month-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  opacity: 0.58;
}

.lane-segment {
  position: absolute;
  top: 22px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2px;
  padding: 0 0.3rem;
  overflow: hidden;
  color: var(--course);
  background: var(--course-soft);
  border-radius: 999px;
  font-size: 0.69rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Name for a bar too narrow to hold its own text: sits above the bar so
   every unit on the calendar is named. Placed by placeTags() in year.js. */
.segment-tag {
  position: absolute;
  top: 3px;
  z-index: 1;
  transform: translateX(-50%);
  color: var(--course);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: none;
}

.segment-tag[hidden] { display: none; }

.thread-anchor {
  position: absolute;
  top: 64px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--course);
  cursor: pointer;
  transform: translate(-50%, -50%);
  z-index: 3;
  transition: opacity 150ms ease, transform 150ms ease;
}

.thread-anchor::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px var(--bg);
  transform: translate(-50%, -50%);
  transition: box-shadow 150ms ease, transform 150ms ease;
}

.thread-anchor.is-knot::before {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.thread-anchor:hover::before,
.thread-anchor:focus-visible::before,
.thread-anchor.is-selected::before {
  box-shadow: 0 0 0 5px var(--course-soft), 0 0 0 7px currentColor;
  transform: translate(-50%, -50%) scale(1.08);
}

.thread-anchor.is-knot:hover::before,
.thread-anchor.is-knot:focus-visible::before,
.thread-anchor.is-knot.is-selected::before {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.08);
}

.thread-anchor.is-related:not(.is-selected)::before {
  box-shadow: 0 0 0 5px var(--course-soft), 0 0 14px 3px currentColor;
}

.thread-anchor.is-dimmed {
  opacity: 0.4;
}

.anchor-label {
  position: absolute;
  left: 50%;
  top: 27px;
  width: 88px;
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.18;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.thread-anchor.label-low .anchor-label {
  top: 45px;
}

.thread-detail {
  position: relative;
  overflow: hidden;
}

.thread-detail::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: var(--accent);
}

.detail-type,
.prompt-label,
.arc-course {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.detail-summary {
  max-width: 46rem;
  margin: 0.65rem 0 1rem;
  color: var(--text);
}

.connected-moments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.55rem;
  margin: 0 0 1rem;
}

.connected-moment {
  --course: var(--accent);
  min-width: 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--course);
}

.connected-moment.history { --course: var(--history); }
.connected-moment.theology { --course: var(--theology); }
.connected-moment.literature { --course: var(--literature); }
.connected-moment.choir { --course: var(--choir); }

.moment-course {
  margin: 0;
  color: var(--course);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.moment-title {
  margin: 0.1rem 0 0;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
}

.moment-date {
  color: var(--muted);
  font-weight: 500;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.prompt {
  padding: 0.95rem 1rem;
  border-radius: 12px;
}

.prompt p:last-child {
  margin: 0;
  font-size: 0.92rem;
}

.student-prompt {
  background: var(--accent-soft);
}

.family-prompt {
  background: var(--bg-soft);
}

.detail-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.detail-link[hidden] {
  display: none;
}

.arc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.arc {
  --course: var(--accent);
  --course-soft: var(--accent-soft);
  position: relative;
  overflow: hidden;
  padding: 1.05rem 1.15rem 1rem;
  background: linear-gradient(110deg, var(--course-soft), #fff 68%);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.arc::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--course);
}

.arc.history { --course: var(--history); --course-soft: var(--history-soft); }
.arc.theology { --course: var(--theology); --course-soft: var(--theology-soft); }
.arc.literature { --course: var(--literature); --course-soft: var(--literature-soft); }
.arc.choir { --course: var(--choir); --course-soft: var(--choir-soft); }

.arc .arc-course {
  color: var(--course);
}

.arc h3 {
  margin: 0 0 0.25rem;
  font-size: 1.08rem;
  color: var(--text);
}

.arc p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.year-note {
  margin-top: 1.6rem;
}

@media (prefers-reduced-motion: reduce) {
  .thread-links path,
  .thread-anchor,
  .thread-anchor::before {
    animation: none;
    transition: none;
  }
}

@media (max-width: 760px) {
  .year-card-head,
  .detail-heading {
    display: block;
  }

  .year-updated,
  .detail-date {
    margin-top: 0.25rem;
  }

  .year-axis,
  .thread-links,
  .lane-segment,
  .segment-tag,
  .month-tick {
    display: none;
  }

  .thread-lane {
    display: block;
    min-height: 0;
    padding: 0.75rem 0;
  }

  .lane-label {
    padding: 0 0 0.55rem;
  }

  .lane-label span {
    display: inline;
    margin-left: 0.35rem;
  }

  .lane-track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    min-height: 0;
  }

  .thread-anchor,
  .thread-anchor.label-low {
    position: relative;
    left: auto !important;
    top: auto;
    width: 100%;
    height: auto;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    color: var(--course);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    text-align: left;
    transform: none;
  }

  .thread-anchor::before,
  .thread-anchor.is-knot::before,
  .thread-anchor:hover::before,
  .thread-anchor:focus-visible::before,
  .thread-anchor.is-selected::before,
  .thread-anchor.is-knot:hover::before,
  .thread-anchor.is-knot:focus-visible::before,
  .thread-anchor.is-knot.is-selected::before {
    position: static;
    flex: 0 0 auto;
    width: 11px;
    height: 11px;
    box-shadow: none;
    transform: none;
  }

  .thread-anchor.is-knot::before,
  .thread-anchor.is-knot:hover::before,
  .thread-anchor.is-knot:focus-visible::before,
  .thread-anchor.is-knot.is-selected::before {
    border-radius: 2px;
    transform: rotate(45deg);
  }

  .thread-anchor.is-selected {
    border-color: var(--course);
    background: var(--course-soft);
  }

  .anchor-label,
  .thread-anchor.label-low .anchor-label {
    position: static;
    width: auto;
    color: var(--text);
    font-size: 0.78rem;
    text-align: left;
    transform: none;
  }

  .prompt-grid,
  .arc-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .lane-track {
    grid-template-columns: 1fr;
  }

  .connected-moments {
    grid-template-columns: 1fr;
  }
}

/* ===== Month-by-month calendar ===== */

.mcal-card {
  overflow: hidden;
}

.mcal-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mcal-nav-btn {
  width: 36px;
  height: 36px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 120ms ease;
}

.mcal-nav-btn:hover { background: var(--accent-soft); }

.mcal-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.mcal-month-label {
  margin: 0;
  min-width: 10.5rem;
  color: var(--text);
  font-family: Fraunces, Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 600;
  text-align: center;
}

.mcal-today-btn {
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.mcal-today-btn:hover { text-decoration: underline; }

.mcal-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin: 1rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.mcal-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.mcal-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--course, var(--accent));
}

.mcal-swatch.history { --course: var(--history); }
.mcal-swatch.theology { --course: var(--theology); }
.mcal-swatch.literature { --course: var(--literature); }
.mcal-swatch.choir { --course: var(--choir); }

.mcal-key {
  display: inline-block;
  padding: 2px 6px;
  background: var(--accent);
  border-radius: 6px;
  color: #fff;
  font: 600 0.68rem/1.2 Inter, system-ui, sans-serif;
}

.mcal-key-given {
  padding: 1px 5px;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  color: var(--accent);
}

.mcal-key-quiz { font-weight: 700; }

.mcal-key-event { background: var(--choir); }

.mcal-legend-gap {
  width: 1px;
  height: 16px;
  background: var(--border);
}

.mcal-disclosure {
  margin: 0.35rem 0 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

.mcal-grid-wrap {
  margin-top: 0.9rem;
}

.mcal-weekdays,
.mcal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.mcal-weekdays {
  padding-bottom: 0.35rem;
}

.mcal-weekdays > span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
}

.mcal-weekday-min { display: none; }

.mcal-week {
  display: contents;
}

.mcal-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-height: 92px;
  padding: 5px 5px 7px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color 120ms ease;
}

.mcal-cell:hover { border-color: var(--accent); }

.mcal-cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mcal-cell--pad {
  background: transparent;
  border: 1px dashed var(--border);
  opacity: 0.5;
  cursor: default;
}

.mcal-cell--weekend { background: var(--bg-soft); }

.mcal-cell--weekend .mcal-date { color: var(--muted); }

.mcal-date {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.mcal-cell--today .mcal-date {
  background: var(--accent);
  border-radius: 50%;
  color: #fff;
}

.mcal-cell--selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.mcal-cell--choirweek-flag::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--choir);
  border-radius: 0 0 9px 9px;
  opacity: 0.55;
}

.mcal-marks {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.mcal-chip {
  display: block;
  overflow: hidden;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  font: 600 0.68rem/1.2 Inter, system-ui, sans-serif;
}

.mcal-chip.history { --course: var(--history); --course-soft: var(--history-soft); }
.mcal-chip.theology { --course: var(--theology); --course-soft: var(--theology-soft); }
.mcal-chip.literature { --course: var(--literature); --course-soft: var(--literature-soft); }
.mcal-chip.choir { --course: var(--choir); --course-soft: var(--choir-soft); }

.mcal-chip--due {
  background: var(--course);
  color: #fff;
}

.mcal-chip--given {
  padding: 1px 5px;
  background: var(--course-soft);
  border: 1px dashed var(--course);
  color: var(--course);
}

.mcal-chip--quiz {
  background: var(--course);
  color: #fff;
  font-weight: 700;
}

.mcal-chip--event {
  background: var(--choir);
  color: #fff;
}

.mcal-marks--overflow .mcal-chip:nth-child(n+4) {
  display: none;
}

.mcal-more {
  display: block;
  padding: 1px 6px;
  color: var(--muted);
  font: 600 0.66rem/1.2 Inter, system-ui, sans-serif;
}

.mcal-load-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.mcal-detail {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
}

.mcal-detail-empty {
  margin: 0;
  color: var(--muted);
}

.mcal-detail-date {
  margin: 0;
  font-family: Fraunces, Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 600;
}

.mcal-detail-count {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.mcal-detail-item {
  --course: var(--accent);
  margin: 0.65rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--course);
}

.mcal-detail-item.history { --course: var(--history); }
.mcal-detail-item.theology { --course: var(--theology); }
.mcal-detail-item.literature { --course: var(--literature); }
.mcal-detail-item.choir { --course: var(--choir); }

.mcal-detail-line1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.mcal-detail-course {
  color: var(--course);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mcal-detail-item .mcal-chip {
  display: inline-block;
}

.mcal-detail-phrase {
  color: var(--muted);
  font-size: 0.8rem;
}

.mcal-detail-text {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.mcal-detail-choirweek,
.mcal-detail-choirflag {
  margin: 0.65rem 0 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--choir);
  color: var(--muted);
  font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
  .mcal-nav-btn,
  .mcal-cell {
    transition: none;
  }
}

@media (max-width: 760px) {
  .mcal-legend-gap {
    flex-basis: 100%;
  }

  .mcal-month-label {
    font-size: 1.05rem;
  }

  .mcal-cell {
    min-height: 56px;
    padding: 4px;
    border-radius: 8px;
    gap: 3px;
  }

  .mcal-date {
    font-size: 0.7rem;
  }

  .mcal-marks {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
  }

  .mcal-chip {
    width: 9px;
    height: 9px;
    flex: none;
    padding: 0;
    font-size: 0;
  }

  .mcal-chip--due {
    border-radius: 50%;
  }

  .mcal-chip--given {
    background: #fff;
    border: 2px solid var(--course);
    border-radius: 50%;
  }

  .mcal-chip--quiz {
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
  }

  .mcal-chip--event {
    border-radius: 2px;
  }

  .mcal-marks--overflow .mcal-chip:nth-child(n+4) {
    display: block;
  }

  .mcal-more {
    display: none;
  }

  .mcal-detail-text {
    font-size: 0.95rem;
  }
}

@media (max-width: 430px) {
  .mcal-weekday-full { display: none; }
  .mcal-weekday-min { display: inline; }

  .mcal-weekdays,
  .mcal-grid {
    gap: 2px;
  }

  .mcal-cell {
    min-height: 48px;
  }

  .mcal-date {
    font-size: 0.68rem;
  }

  .mcal-cell--today .mcal-date {
    width: 16px;
    height: 16px;
  }

  .mcal-chip {
    width: 8px;
    height: 8px;
  }

  .mcal-chip--quiz {
    width: 9px;
    height: 9px;
  }
}
