/* ═══════════════════════════════════════════════════════════
   Missale Online — Kalender Stylesheet
   Based on alte-messe-heute.de design system
   ═══════════════════════════════════════════════════════════ */

/* fonts.css loaded async via HTML to avoid render-blocking @import */

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

:root {
  --color-bg: #FAFAF8;
  --color-surface: #FFFFFF;
  --color-text: #2C2C2C;
  --color-text-muted: #595959;
  --color-border: #E5E5E0;
  --color-accent: #5B2C6F;
  --color-accent-light: #7D3C98;
  --color-gold: #8B6914;  /* darkened for WCAG AA contrast (4.6:1 on white) */
  --color-surface-alt: #F8F7F4;
  --color-surface-hover: #F0EDE8;
  --color-shadow: rgba(0,0,0,0.1);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: 'EB Garamond', Georgia, "Times New Roman", serif;
  --max-width: 1200px;
  --nav-height: 56px;

  /* Liturgical colors — single source of truth */
  --lit-white: #C8A24E;        /* gold for visibility on light bg */
  --lit-red: #C62828;
  --lit-green: #2E7D32;
  --lit-violet: #5B2C6F;
  --lit-black: #212121;
  --lit-rose: #D81B60;
  --lit-white-text: #3D2B00;   /* dark text on gold banner (7:1 contrast) */
  --lit-black-text: #9E968E;   /* text on black-feast banner (dark) */
}

/* ── Sakraler Dark Mode ──
   Warm, dignified palette inspired by candlelit parchment.
   Not pitch-black — rather a deep warm tone evocative of old missals. */
[data-theme="dark"] {
  --color-bg: #1E1A17;
  --color-surface: #272320;
  --color-text: #E4DDD4;
  --color-text-muted: #A09888;
  --color-border: #3A342E;
  --color-accent: #A87CC0;
  --color-accent-light: #BF9AD4;
  --color-gold: #C8A84E;
  --color-surface-alt: #2D2824;
  --color-surface-hover: #352F2A;
  --color-shadow: rgba(0,0,0,0.45);

  /* Liturgical colors — dark mode */
  --lit-white: #F0E8D0;
  --lit-red: #EF5350;
  --lit-green: #66BB6A;
  --lit-violet: #B388D9;
  --lit-black: #9E968E;
  --lit-rose: #FF39E0;
  --lit-white-text: #1E1A17;   /* dark text on white banner */
  --lit-black-text: #9E968E;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body > .footer {
  margin-top: auto;
}

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

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Navigation ── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-height);
}

.nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.nav__logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav__logo:hover { text-decoration: none; }

.nav__title {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin: 0;
}

.nav__links {
  display: flex;
  list-style: none;
  gap: 4px;
}

.nav__link {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav__link:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.nav__link--active {
  color: var(--color-accent);
  font-weight: 600;
}

.nav__toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 5px;
}

.nav__toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
}

/* ══════════════════════════════════════════════════════════
   Year Overview Mini-Timeline
   ══════════════════════════════════════════════════════════ */
.year-overview {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  min-height: 28px; /* Reserve space to prevent CLS */
  padding: 6px 20px 4px;
  user-select: none;
}

.year-overview__frame {
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  height: 18px;
  overflow-x: clip;
  overflow-y: visible;
  cursor: pointer;
}

.year-overview__track {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  gap: 0;
  transition: transform 0.15s;
}

/* Thin neutral rail – hidden for cleaner look */
.yo-rail {
  display: none;
}

/* Month marker tick + label */
.yo-month {
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: flex-start;
}

.yo-month__tick {
  position: absolute;
  left: 0;
  top: 4px;
  width: 1px;
  height: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.yo-month__label {
  position: absolute;
  top: -1px;
  left: 4px;
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.2px;
  line-height: 1;
  z-index: 4;
}

.yo-month--jan .yo-month__tick {
  height: 12px;
  top: 2px;
  background: rgba(0, 0, 0, 0.3);
}

.yo-month--jan .yo-month__label {
  font-weight: 700;
  color: var(--color-text);
}

/* Today marker */
.yo-today {
  position: absolute;
  top: 3px;
  width: 2px;
  height: 10px;
  background: var(--color-accent);
  border-radius: 1px;
  z-index: 2;
}

.yo-viewport {
  position: absolute;
  top: 0;
  bottom: 0;
  border: none;
  border-radius: 3px;
  background: rgba(168, 124, 192, 0.15);
  pointer-events: none;
  z-index: 3;
  transition: left 0.15s, width 0.15s;
}
[data-theme="dark"] .yo-viewport {
  background: rgba(168, 124, 192, 0.2);
}

/* ══════════════════════════════════════════════════════════
   Day Strip — continuous horizontal calendar
   ══════════════════════════════════════════════════════════ */
.day-strip-wrap {
  position: sticky;
  top: var(--nav-height);
  z-index: 50;
  background: var(--color-surface);
}

.day-strip {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px 0;
  max-width: var(--max-width);
  margin: 0 auto;
  border-bottom: 1px solid var(--color-border);
  user-select: none;
}

.ds-arrow {
  flex-shrink: 0;
  width: 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 1.2rem;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.ds-arrow:hover {
  background: var(--color-surface-hover);
  color: var(--color-accent);
}

.ds-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 140px; /* Reserve space for day strip + season bars to prevent CLS */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ds-scroll::-webkit-scrollbar {
  display: none;
}

.ds-scroll-inner {
  display: inline-flex;
  flex-direction: column;
  position: relative;
  contain: layout style;
}

.ds-days {
  display: flex;
  gap: 1px;
  padding: 4px 0;
}

/* ── Month separator ── */
.ds-month-sep {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 4px;
}

.ds-month-sep__label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-accent);
  white-space: nowrap;
}

/* ── Day cell ── */
.ds-day {
  flex-shrink: 0;
  width: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 5px;
  border: 2px solid transparent;
  background: none;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  outline: none;
  height: 62px;
}

.ds-day:hover {
  background: var(--color-surface-hover);
}

.ds-day--today {
  border-color: var(--color-accent);
  background: rgba(179, 136, 217, 0.08);
}

.ds-day--active {
  background: rgba(179, 136, 217, 0.15);
  border-color: var(--color-accent);
}

.ds-day--empty {
  opacity: 0.5;
}

.ds-day--sun .ds-day__wd {
  color: var(--color-accent);
}

/* Weekday label */
.ds-day__wd {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  line-height: 1;
}

.ds-day__wd--sun {
  color: var(--color-accent);
}

/* Sunday border */
.ds-day--sun {
  border-color: var(--color-border);
}
.ds-day--sun.ds-day--today,
.ds-day--sun.ds-day--active {
  border-color: var(--color-accent);
}

/* Cross — fixed-height container so date numbers align */
.ds-day__cross {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.6rem;
  line-height: 1;
  font-size: 0.9rem;
}

.ds-day__cross--I  { font-size: 1.65rem; }
.ds-day__cross--II { font-size: 1.35rem; }
.ds-day__cross--III { font-size: 1.05rem; }
.ds-day__cross--IV { font-size: 0.78rem; }

/* Liturgical colors — uses CSS vars, auto-switches with theme */
.ds-day__cross[data-color="white"]  { color: var(--lit-white); }
.ds-day__cross[data-color="red"]    { color: var(--lit-red); }
.ds-day__cross[data-color="green"]  { color: var(--lit-green); }
.ds-day__cross[data-color="violet"] { color: var(--lit-violet); }
.ds-day__cross[data-color="black"]  { color: var(--lit-black); }
.ds-day__cross[data-color="rose"]   { color: var(--lit-rose); }

.detail-color-dot[data-color="white"]  { background: var(--lit-white); }
.detail-color-dot[data-color="red"]    { background: var(--lit-red); }
.detail-color-dot[data-color="green"]  { background: var(--lit-green); }
.detail-color-dot[data-color="violet"] { background: var(--lit-violet); }
.detail-color-dot[data-color="black"]  { background: var(--lit-black); }
.detail-color-dot[data-color="rose"]   { background: var(--lit-rose); }

/* Date number */
.ds-day__num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.ds-day--filtered {
  opacity: 0.15;
  pointer-events: none;
}

.ds-day--dimmed {
  opacity: 0.38;
}

/* ── Season Bars ── */
.ds-bars {
  padding: 2px 0 0;
}

.ds-bar-row {
  position: relative;
  height: 22px;
}

.ds-bar {
  position: absolute;
  height: 18px;
  border-radius: 4px;
  top: 2px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.ds-bar__label {
  position: absolute;
  /* top/left will be managed mostly by JS for sticky centering, but provide defaults */
  top: 0;
  left: 4px;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* White season bars (Easter + Christmas): light bg → dark text */
.ds-bar[data-season="easter"],
.ds-bar[data-season="christmas"] {
  background: var(--lit-white);
  border: 1px solid #D5D0C5;
}
.ds-bar[data-season="easter"] .ds-bar__label,
.ds-bar[data-season="christmas"] .ds-bar__label {
  color: var(--lit-white-text);
  text-shadow: none;
}
[data-theme="dark"] .ds-bar[data-season="easter"],
[data-theme="dark"] .ds-bar[data-season="christmas"] {
  border-color: var(--color-border);
}

/* Violet season bars */
.ds-bar[data-season="advent"],
.ds-bar[data-season="septuagesima"],
.ds-bar[data-season="lent"],
.ds-bar[data-season="passiontide"],
.ds-bar[data-season="holy_week"] {
  background: var(--lit-violet);
}

/* Green season bars */
.ds-bar[data-season="epiphany"],
.ds-bar[data-season="pentecost"] {
  background: var(--lit-green);
}

/* ── Rank Filter ── */
.rank-filter {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 20px;
  max-width: var(--max-width);
  margin: 0 auto;
}

.rank-btn {
  padding: 5px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.rank-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

.rank-btn--active {
  background: var(--color-surface-hover);
  color: var(--color-text);
  border-color: var(--color-text-muted);
  font-weight: 700;
}

.rank-btn--active:hover {
  background: var(--color-surface-hover);
}

.loading {
  text-align: center;
  color: var(--color-text-muted);
  padding: 40px;
}

/* ── Day Detail ── */
.day-detail {
  padding: 16px 0 48px;
}

/* ── Mobile Context Banner (Liturgical color/season) ── */
.mobile-context-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: -16px -20px 16px -20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
}

.mobile-context-banner--white { background-color: var(--lit-white); color: var(--lit-white-text); }
.mobile-context-banner--red { background-color: var(--lit-red); }
.mobile-context-banner--green { background-color: var(--lit-green); }
.mobile-context-banner--violet { background-color: var(--lit-violet); }
.mobile-context-banner--black { background-color: var(--lit-black); }
.mobile-context-banner--rose { background-color: var(--lit-rose); }

/* Toolbar: back + rank filter + settings on one line */
.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
  gap: 8px;
}

.detail-toolbar .rank-filter {
  display: flex;
  gap: 2px;
  padding: 0;
  margin: 0;
  flex: 0 1 auto;
}

.detail-toolbar__back {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 12px 8px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.detail-toolbar__back:hover {
  color: var(--color-accent);
}

/* Settings — inline toggle buttons */
.settings-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-text-muted);
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
}

.settings-toggle:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.settings-toggle:has(input:checked) {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.settings-toggle input[type="checkbox"] {
  display: none;
}

.settings-inline .settings-select {
  width: auto;
  min-width: 120px;
}

.settings-divider {
  border-top: 1px solid var(--color-border);
  margin: 8px 0;
}

.settings-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.settings-select {
  width: 100%;
  padding: 4px 6px;
  font-size: 0.82rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}

.settings-dropdown__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.settings-dropdown__options {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.day-detail__header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.detail-title {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-latin {
  font-size: 1rem;
  font-style: italic;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.detail-meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-meta__item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.detail-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.15);
}

/* ── Share Buttons ── */
@media (min-width: 769px) {
  .share-buttons {
    position: absolute;
    top: 0;
    right: 0;
  }
}

.share-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
  padding: 0;
}

.share-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}

.share-btn--pdf {
  width: auto;
  border-radius: 4px;
  padding: 0 10px;
  gap: 5px;
  font-size: 0.78rem;
  color: #c0392b;
  border-color: #c0392b40;
}
.share-btn--pdf::after {
  content: "PDF";
  font-weight: 600;
  letter-spacing: 0.02em;
}
.share-btn--pdf:hover {
  background: #c0392b10;
  border-color: #c0392b;
  color: #c0392b;
}

.detail-desc {
  margin-top: 12px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.detail-commem {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.mass-switch-btn {
  display: inline-block;
  vertical-align: middle;
  background: none;
  border: 1px solid var(--color-accent);
  border-radius: 6px;
  color: var(--color-accent);
  cursor: pointer;
  font-size: 0.5em;
  font-weight: 400;
  font-style: normal;
  padding: 4px 10px;
  margin-left: 12px;
  line-height: 1.4;
  letter-spacing: 0;
  transition: background 0.15s, color 0.15s;
  position: relative;
  top: -2px;
}
.mass-switch-btn:hover {
  background: var(--color-accent);
  color: var(--color-bg, #1a1a2e);
}

/* ── Detail wrap with TOC sidebar ── */
.detail-wrap {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0 20px;
  align-items: start;
  grid-template-rows: auto 1fr;
}

/* ── Inline Column Controls ── */
.detail-col-controls {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 4px 16px 0;
}

.col-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.col-control__sel {
  padding: 3px 20px 3px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%236B6B6B'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  line-height: 1.4;
}

.col-control__sel:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.col-control__sel--source {
  font-weight: 400;
  text-transform: none;
}

/* ── TOC Navigation ── */
.toc-nav {
  grid-column: 1;
  grid-row: 1 / -1;
  position: sticky;
  top: 250px;
  align-self: start;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 4px 0;
}

.toc-nav:empty {
  display: none;
}

.toc-nav__head {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-gold);
  border-left: 3px solid var(--color-gold);
  padding: 3px 0 3px 8px;
  margin: 10px 0 3px;
}

.toc-nav__head:first-child {
  margin-top: 0;
}

.toc-nav__link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 4px 6px 12px;
  min-height: 32px;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  line-height: 1.3;
}

.toc-nav__link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.toc-nav__link--active {
  color: var(--color-text);
  font-weight: 600;
  background: rgba(0, 0, 0, 0.04);
}

.toc-nav__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
}

.toc-nav__link--active .toc-nav__dot {
  background: var(--color-accent);
}

/* ── Mass Texts ── */
.day-detail__texts {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 8px;
}

.text-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  scroll-margin-top: 140px;
}

.text-section__header {
  padding: 10px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

.text-section__origin {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: #7986CB;
  margin-top: 2px;
}

.text-section__rubric {
  font-weight: 400;
  font-size: 0.72rem;
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  color: #C62828;
  margin-left: 0.5em;
}

.text-section--inherited {
  border-left: 3px solid #B0BEC5;
}

.text-section--inherited .text-section__header {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-style: italic;
}

.text-section__body {
  padding: 16px;
}

.text-bilingual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.text-col--left {
  font-style: italic;
  color: var(--color-text);
}

.text-col--right {
  color: var(--color-text);
}

.text-col p {
  margin-bottom: 10px;
  white-space: pre-line;
  line-height: 1.7;
  font-size: 0.92rem;
}

/* ── Column Headers ── */
.text-col-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 2px 16px;
  margin-bottom: 0;
}

.text-col-header {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-muted);
}

/* ── Annotation blocks ── */
.annotation-block {
  padding: 2px 0 6px;
  margin-bottom: 4px;
}

.annotation-item {
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--color-text-muted);
  white-space: pre-line;
  font-style: italic;
}

.annotation-item--rubric {
  color: #D32F2F;
  font-style: italic;
}

.annotation-item--instruction {
  color: #5D4037;
}

.annotation-item--commentary {
  color: var(--color-text-muted);
  font-style: italic;
}

.annotation-item + .annotation-item {
  margin-top: 4px;
}

/* ── Mass Section Dividers ── */
.mass-section-divider {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 0 6px;
  margin-top: 8px;
  border-bottom: 1px solid var(--color-border);
  scroll-margin-top: 140px;
}

/* ── Ordinarium distinction ── */
.text-section--ord {
  border-color: rgba(212, 160, 23, 0.25);
  background: var(--color-surface);
}

.text-section--ord .text-section__header {
  background: var(--color-surface-alt);
  color: var(--color-gold);
  border-bottom-color: rgba(212, 160, 23, 0.25);
}

[data-theme="dark"] .text-section--ord {
  border-color: rgba(212, 168, 67, 0.2);
}

[data-theme="dark"] .text-section--ord .text-section__header {
  border-bottom-color: rgba(212, 168, 67, 0.2);
}

/* Settings panel — kept for shared sub-styles */

.settings-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--color-text-muted);
}

.settings-select {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
}

/* (moved to .settings-dropdown__options above) */

.settings-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
}

.settings-check input { cursor: pointer; }

.no-texts {
  text-align: center;
  color: var(--color-text-muted);
  padding: 40px;
  font-style: italic;
}

/* ── Footer ── */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.footer__text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.footer__text--small { font-size: 0.78rem; }

.footer__link {
  color: var(--color-text-muted);
  text-decoration: none;
}
.footer__link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* ── Mobile Global Language Switch ── */
.mobile-lang-switch {
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.mobile-lang-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 0;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mobile-lang-btn--active {
  background: var(--color-accent);
  color: #fff;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav__toggle { display: flex; }

  .mobile-lang-switch {
    display: flex;
  }

  .mobile-context-banner {
    display: flex;
    margin-top: -16px; /* align flush with top */
  }

  .nav__links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: 8px 20px;
  }

  .nav__links--open { display: flex; }

  .day-strip-wrap {
    position: relative;
    top: 0;
  }

  .page-header--compact__inner {
    flex-direction: column;
    gap: 4px;
  }

  .text-section__body {
    padding: 16px; /* Keep some padding inside the card */
  }

  .text-bilingual {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .detail-wrap {
    grid-template-columns: 1fr;
  }

  .day-detail__texts {
    grid-column: 1;
  }

  .detail-col-controls {
    grid-column: 1;
  }

  .toc-nav {
    display: none;
  }

  .detail-col-controls {
    grid-template-columns: 1fr;
  }

  .detail-col-controls {
    display: none; /* Hide column controls on mobile */
  }

  .col-control:last-child {
    display: none;
  }

  .col-control__sel {
    width: 100%;
    padding: 8px 30px 8px 12px;
    font-size: 0.8rem;
    background-position: right 12px center;
  }

  /* Single-column text display based on mobile toggle state */
  .text-bilingual {
    display: block; /* Overrides the grid */
  }

  .text-col--left {
    padding-bottom: 0;
    border-bottom: none;
    display: none; /* Hidden by default or toggled via JS */
  }

  .text-col--right {
    display: none; /* Hidden by default or toggled via JS */
  }

  /* Active state for columns handled by JS adding a class */
  .day-detail__texts--show-left .text-col--left {
    display: block;
  }

  .day-detail__texts--show-right .text-col--right {
    display: block;
  }

  .text-col-headers {
    display: none;
  }

  .settings-panel__columns {
    grid-template-columns: 1fr;
  }

  /* Hide Year overview (timeline) on mobile */
  .year-overview {
    display: none;
  }

  /* Day strip mobile */
  .ds-day {
    width: 48px;
    height: 62px;
  }

  .ds-arrow {
    width: 32px;
    font-size: 1.2rem;
  }

  .ds-month-sep__label {
    font-size: 0.65rem;
  }

  .day-strip {
    flex-wrap: nowrap;
  }

  .rank-filter {
    padding: 0;
  }

  .rank-btn {
    padding: 4px 8px;
    font-size: 0.62rem;
  }

  .detail-toolbar {
    flex-wrap: wrap;
  }

  .detail-toolbar .rank-filter {
    order: 3;
    width: 100%;
    justify-content: center;
    padding-top: 4px;
  }

  .ds-bar-row {
    height: 20px;
  }

  .ds-bar__label {
    font-size: 0.55rem;
    letter-spacing: 0.4px;
  }

  .nav__title { display: none; }
}

/* ══════════════════════════════════════════════════════════
   Dark Mode — Deep overrides for elements not using variables
   ══════════════════════════════════════════════════════════ */

/* Theme toggle button in nav */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 8px;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.15rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.theme-toggle:hover,
.theme-toggle:active {
  background: var(--color-surface-hover);
  border-color: var(--color-accent);
}

[data-theme="dark"] .yo-month__tick {
  background: rgba(255,255,255,0.15);
}

[data-theme="dark"] .yo-month--jan .yo-month__tick {
  background: rgba(255,255,255,0.3);
}

[data-theme="dark"] .yo-month--jan .yo-month__label {
  color: var(--color-text);
}

[data-theme="dark"] .ds-day--today {
  background: rgba(168, 124, 192, 0.12);
}

[data-theme="dark"] .ds-day--active {
  background: rgba(168, 124, 192, 0.2);
}

/* Cross/dot colors are now in the centralized data-color rules above */

[data-theme="dark"] .nav__toggle span {
  background: var(--color-text);
}

[data-theme="dark"] .detail-color-dot {
  border-color: rgba(255,255,255,0.15);
}

/* Banner colors auto-switch via --lit-* vars; only black needs extra text color */
[data-theme="dark"] .mobile-context-banner--black { color: var(--lit-black-text); }

[data-theme="dark"] .annotation-item--rubric {
  color: #EF5350;
}

[data-theme="dark"] .annotation-item--instruction {
  color: #A1887F;
}

[data-theme="dark"] .text-section__origin {
  color: #9FA8DA;
}

[data-theme="dark"] .text-section__rubric {
  color: #EF5350;
}

[data-theme="dark"] .ds-bar__label {
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

[data-theme="dark"] .yo-rail {
  background: var(--color-border);
}

[data-theme="dark"] .col-control__sel {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%239E9A92'/%3E%3C/svg%3E");
}

/* Inherited text section — warm border in dark mode */
[data-theme="dark"] .text-section--inherited {
  border-left-color: #5C5046;
}

/* Year-overview ticks already overridden above */

/* TOC active link bg visible in dark mode */
[data-theme="dark"] .toc-nav__link--active {
  background: rgba(255, 255, 255, 0.06);
}

/* Rank filter wrapper — hidden since filter is now in the toolbar */
.rank-filter-wrap {
  display: none;
}

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