:root {
  --bg: #f3efe5;
  --paper: #fffdf7;
  --paper-soft: #f8f1e4;
  --ink: #201b16;
  --muted: #6f6556;
  --line: #dacdb8;
  --accent: #7b2f2a;
  --accent-strong: #5c221e;
  --gold: #a87924;
  --sage: #4f6e5b;
  --blue: #315e73;
  --focus: #1b6f9f;
  --shadow: 0 14px 34px rgba(52, 43, 30, 0.09);
  --sans: Arial, Helvetica, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
  font-family: var(--serif);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(122, 47, 42, 0.055) 0 1px, transparent 1px 88px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 340px),
    var(--bg);
}

a {
  color: var(--accent-strong);
  text-underline-offset: 0.18em;
}

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

button,
input,
select {
  font: inherit;
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 3;
  transform: translateY(-150%);
  background: var(--ink);
  color: white;
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  background:
    linear-gradient(90deg, rgba(32, 27, 22, 0.62), rgba(32, 27, 22, 0.06) 44%, rgba(32, 27, 22, 0.52)),
    linear-gradient(120deg, rgba(92, 34, 30, 0.98), rgba(49, 94, 115, 0.92)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.11) 0 1px, transparent 1px 18px);
  color: white;
  border-bottom: 5px solid var(--gold);
}

.header-inner,
.controls-inner,
.quick-actions,
.results,
.site-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.header-inner {
  position: relative;
  padding: 4.25rem 0 3rem;
}

.site-mark {
  display: block;
  width: 125px;
  height: 125px;
  margin-bottom: 1.05rem;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  object-fit: cover;
  object-position: center 38%;
  background: var(--gold);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.24),
    0 0 0 8px rgba(255, 255, 255, 0.08);
}

.eyebrow {
  margin: 0 0 0.65rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.08;
}

h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2.45rem, 6vw, 4.75rem);
  font-weight: 700;
  letter-spacing: 0;
  text-wrap: balance;
}

.lede {
  max-width: 700px;
  margin: 1.1rem 0 0;
  font-size: 1.16rem;
  line-height: 1.62;
}

.source-note {
  max-width: 700px;
  margin: 1rem 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-family: var(--sans);
  font-size: 0.95rem;
  line-height: 1.45;
}

.controls {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.94);
  backdrop-filter: blur(12px);
}

.controls-inner {
  padding: 1.35rem 0;
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.6fr);
  gap: 1.5rem;
  align-items: start;
}

.controls h2::before,
.month-heading h2::before,
.record-article h2::before,
.search-group-heading h2::before {
  content: "";
  display: inline-block;
  width: 0.72rem;
  height: 0.72rem;
  margin-right: 0.5rem;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
  background: rgba(168, 121, 36, 0.16);
  vertical-align: 0.05em;
}

.controls h2 {
  margin: 0 0 0.45rem;
  font-size: 1.35rem;
}

.summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(140px, 0.7fr) minmax(140px, 0.7fr) auto;
  gap: 0.85rem;
  align-items: end;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfc3b2;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.65rem 0.75rem;
}

.view-toggle {
  min-width: 172px;
  margin: 0;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-soft);
  display: flex;
  gap: 0.25rem;
}

.view-toggle legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.view-toggle label {
  flex: 1;
  cursor: pointer;
}

.view-toggle input {
  position: absolute;
  opacity: 0;
}

.view-toggle span {
  display: block;
  min-height: 36px;
  border-radius: 4px;
  padding: 0.55rem 0.75rem;
  text-align: center;
  font-family: var(--sans);
  font-weight: 700;
}

.view-toggle input:checked + span {
  background: var(--accent);
  color: white;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 1rem 0 0;
}

.quick-actions button,
.quick-actions a {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 253, 250, 0.82);
  color: var(--ink);
  padding: 0.6rem 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

.quick-actions button:hover,
.quick-actions a:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.results {
  padding: 1.6rem 0 3.5rem;
}

.month-group {
  margin-top: 1.65rem;
}

.month-group:first-child {
  margin-top: 0;
}

.month-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 0;
  padding: 0.85rem 0;
  position: relative;
}

.month-heading::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold) 34%, var(--line));
}

.month-heading h2 {
  margin: 0 0 0.55rem;
  font-size: 1.45rem;
}

.month-heading span {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.9rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
  gap: 1rem;
}

.entry-card {
  position: relative;
  min-height: 160px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--sage);
  border-radius: 8px;
  background: var(--paper);
  padding: 1.05rem;
  box-shadow: var(--shadow);
}

.entry-card::before {
  content: attr(data-day);
  position: absolute;
  right: 0.85rem;
  top: 0.65rem;
  color: rgba(122, 47, 42, 0.11);
  font-size: 3.3rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.entry-card.movable {
  border-top-color: var(--gold);
}

.entry-card h3 {
  position: relative;
  padding-right: 3.1rem;
  margin: 0.45rem 0 0;
  font-size: 1.16rem;
  line-height: 1.2;
}

.entry-summary {
  margin: 0.7rem 0 0;
  color: var(--muted);
  line-height: 1.58;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #efe6d8;
  padding: 0.28rem 0.55rem;
  color: #443b2d;
}

.local-pill {
  background: #d9eadf;
  color: #254936;
}

.entry-card a,
.related-links a {
  display: inline-block;
  font-family: var(--sans);
  font-weight: 700;
}

.related-links {
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.related-links h4 {
  margin: 0 0 0.45rem;
  font-family: var(--sans);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.related-links ul {
  margin: 0;
  padding-left: 1.1rem;
}

.related-links li + li {
  margin-top: 0.3rem;
}

.related-links p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.local-record {
  margin-top: 0.9rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.local-record summary {
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  color: var(--accent-strong);
}

.local-record div {
  margin-top: 0.75rem;
  max-height: 420px;
  overflow: auto;
  border-left: 3px solid var(--line);
  padding-left: 0.85rem;
}

.local-record p {
  margin: 0 0 0.7rem;
  line-height: 1.5;
}

.source-link {
  margin-top: 0.85rem;
  color: var(--muted);
}

.primary-local-link {
  min-height: 38px;
  border-radius: 5px;
  background: var(--accent);
  color: white;
  padding: 0.55rem 0.75rem;
  text-decoration: none;
}

.primary-local-link:hover {
  color: white;
  background: var(--accent-strong);
}

.compact-header .header-inner {
  padding: 2.7rem 0 2.1rem;
}

.record-page {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 1.25rem 0 4rem;
}

.record-page > p:first-child a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.78);
  padding: 0.45rem 0.75rem;
  font-family: var(--sans);
  font-weight: 700;
  text-decoration: none;
}

.record-article {
  background: transparent;
  padding: 0;
}

.record-article h2 {
  margin: 0 0 0.45rem;
  font-size: 1.5rem;
}

.record-section {
  margin-top: 2rem;
}

.record-article p,
.record-article li {
  line-height: 1.72;
}

.record-list {
  margin: 0;
  padding-left: 1.25rem;
}

.record-list li + li {
  margin-top: 0.28rem;
}

.commemoration-list {
  columns: 2 300px;
  column-gap: 2.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(168, 121, 36, 0.08), transparent 28%),
    var(--paper);
  padding: 1.05rem 1.15rem 1.05rem 2.2rem;
  box-shadow: 0 10px 24px rgba(52, 43, 30, 0.06);
}

.record-summary {
  max-width: 70ch;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.section-note {
  margin: -0.25rem 0 1rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.95rem;
}

.captured-article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  margin-top: 0.85rem;
  overflow: clip;
  box-shadow: 0 10px 24px rgba(52, 43, 30, 0.055);
}

.article-topic {
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  background: var(--paper);
  overflow: clip;
  box-shadow: 0 10px 24px rgba(52, 43, 30, 0.055);
}

.article-topic-summary {
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
  padding: 1rem 1.1rem;
  background:
    linear-gradient(90deg, rgba(168, 121, 36, 0.16), transparent 46%),
    var(--paper-soft);
}

.article-topic-title {
  display: block;
  margin-top: 0.2rem;
  color: var(--accent-strong);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
}

.article-topic-summary small {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92rem;
  white-space: nowrap;
}

.article-topic-body {
  padding: 0.85rem 1rem 1.1rem;
}

.article-topic-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92rem;
}

.article-topic .captured-article {
  margin-top: 0.65rem;
  box-shadow: 0 8px 20px rgba(52, 43, 30, 0.045);
}

.captured-article:last-child {
  border-bottom: 1px solid var(--line);
}

.captured-article summary {
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: baseline;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 700;
  padding: 0.95rem 1.05rem;
  background:
    linear-gradient(90deg, rgba(122, 47, 42, 0.08), transparent 45%),
    var(--paper-soft);
}

.captured-article summary small {
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
}

.captured-article-body {
  max-width: 76ch;
  padding: 1.35rem min(6vw, 3.25rem) 1.65rem;
}

.captured-article-body p {
  margin: 0 0 1.05rem;
  font-size: 1.08rem;
  line-height: 1.82;
}

.captured-article-body h4 {
  margin: 1.35rem 0 0.55rem;
  color: var(--accent-strong);
  font-size: 1.08rem;
  line-height: 1.3;
}

.article-header {
  margin-bottom: 1.15rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}

.article-kicker {
  margin: 0 0 0.35rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.article-header h3 {
  margin: 0;
  font-size: 1.62rem;
  line-height: 1.2;
  text-wrap: balance;
}

.article-date {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.92rem;
}

.article-summary-title {
  line-height: 1.35;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #efe6d5;
  font-family: var(--sans);
  font-size: 0.86rem;
}

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

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 2rem;
  text-align: center;
}

.search-results {
  display: grid;
  gap: 1.5rem;
}

.search-group {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

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

.search-group-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.search-group-heading h2 {
  margin: 0;
  font-size: 1.35rem;
}

.search-group-heading span {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.9rem;
}

.search-result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85rem;
}

.search-result-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  padding: 1rem;
  border-left: 4px solid rgba(168, 121, 36, 0.75);
}

.search-result-item h3 {
  margin: 0.55rem 0 0;
  font-size: 1.08rem;
}

.search-result-item p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.site-footer {
  padding: 1.5rem 0 2.2rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

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

@media (max-width: 900px) {
  .controls-inner,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .view-toggle {
    width: 100%;
  }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .controls-inner {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .view-toggle {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .header-inner {
    padding: 3rem 0 2.3rem;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .month-heading {
    display: block;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .entry-card,
  .quick-actions button,
  .quick-actions a {
    transition: transform 160ms ease, border-color 160ms ease, color 160ms ease;
  }

  .entry-card:hover {
    transform: translateY(-2px);
  }
}
