:root {
  --paper: #faf6ee;
  --ink: #2b2521;
  --ink-soft: #5a4f45;
  --rule: #cfc2ac;
  --accent: #8a5a34;
  --accent-dark: #5f3d22;
  --shadow: rgba(43, 37, 33, 0.12);
  --sidebar-width: 220px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  line-height: 1.6;
}

/* Sidebar (always-visible chronological index) */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem 2rem;
  border-right: 1px solid var(--rule);
  background: var(--paper);
}

.sidebar-title {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
  letter-spacing: 0.01em;
  margin-bottom: 1.5rem;
}

.sidebar-group {
  margin-bottom: 1.25rem;
}

.sidebar-month {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

.sidebar-letters {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}

.sidebar-link {
  display: inline-block;
  min-width: 1.6rem;
  text-align: center;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
}

.sidebar-link:hover {
  border-color: var(--rule);
}

.sidebar-link.active {
  background: var(--accent);
  color: var(--paper);
  font-weight: 600;
}

.sidebar-empty {
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-style: italic;
}

.page {
  margin-left: var(--sidebar-width);
}

@media (max-width: 700px) {
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  .page {
    margin-left: 0;
  }
}

.site-header {
  padding: 2.5rem 1.5rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.site-subtitle {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-style: italic;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.site-footer {
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.85rem;
  padding: 2rem 1rem 3rem;
}

/* Timeline (index page) */

.timeline {
  position: relative;
  padding-left: 1.5rem;
  border-left: 2px solid var(--rule);
}

.timeline-item {
  display: block;
  position: relative;
  margin-bottom: 2.2rem;
  padding-left: 1.5rem;
  text-decoration: none;
  color: inherit;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.62rem;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 2px var(--rule);
}

.timeline-date {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-bottom: 0.2rem;
}

.timeline-body h2 {
  margin: 0 0 0.2rem;
  font-size: 1.25rem;
}

.timeline-location {
  margin: 0 0 0.6rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.timeline-excerpt {
  margin: 0 0 0.8rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--ink-soft);
}

.timeline-thumb {
  max-width: 220px;
  border-radius: 4px;
  box-shadow: 0 2px 10px var(--shadow);
}

.empty-state {
  color: var(--ink-soft);
  font-style: italic;
}

/* Letter page */

.letter-back {
  margin-bottom: 1.5rem;
}

.letter-back a {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 0.9rem;
}

.letter-header h1 {
  margin-bottom: 0.2rem;
}

.letter-meta {
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 0;
}

.letter-scans {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0 1.5rem;
}

.scan-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fffdf8;
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 0.4rem 0.9rem 0.4rem 0.7rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--accent-dark);
  cursor: pointer;
}

.scan-trigger:hover {
  background: var(--rule);
}

.scan-trigger svg {
  flex-shrink: 0;
}

/* PDF modal */

body.modal-open {
  overflow: hidden;
}

.pdf-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(20, 16, 12, 0.65);
}

.pdf-modal[hidden] {
  display: none;
}

.pdf-modal-dialog {
  width: min(900px, 100%);
  height: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
}

.pdf-modal-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: #fffdf8;
}

.pdf-modal-title {
  font-size: 0.95rem;
  color: var(--accent-dark);
  font-weight: 600;
}

.pdf-modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.pdf-modal-close:hover {
  background: var(--rule);
  color: var(--ink);
}

.pdf-modal-frame {
  flex: 1;
  border: none;
  width: 100%;
  background: #525659;
}

@media (max-width: 700px) {
  .pdf-modal {
    padding: 0.75rem;
  }
}

.letter-text {
  background: #fffdf8;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.75rem 2rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 6px var(--shadow);
}

.letter-text p {
  margin: 0 0 1.1em;
}

.letter-text p:last-child {
  margin-bottom: 0;
}

.letter-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 2rem 0;
}

.letter-photo figure {
  margin: 0;
  max-width: 320px;
}

.letter-photo img {
  width: 100%;
  border-radius: 4px;
  box-shadow: 0 2px 10px var(--shadow);
}

.letter-photo figcaption {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
}

.letter-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}

.letter-nav a {
  color: var(--accent-dark);
  text-decoration: none;
}

.letter-nav a:hover {
  text-decoration: underline;
}
