/* Default theme: "sepia". Other themes (parchment, midnight, ink) override
   these variables via html[data-theme="..."] selectors in themes.css. */
:root {
  --color-bg: #faf7f2;
  --color-ink: #2b2621;
  --color-muted: #776f64;
  --color-accent: #7a3b2e;
  --color-accent-dark: #5c2c22;
  --color-border: #ddd3c4;
  --color-card-bg: #ffffff;
  --font-serif: 'PT Serif', Georgia, 'Times New Roman', serif;
  --font-sans: 'PT Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'PT Mono', 'Courier New', monospace;
  --font-hand: 'Caveat', 'Segoe Script', cursive;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-ink);
  background: var(--color-bg);
  line-height: 1.55;
}

h1, h2, h3 { font-family: var(--font-serif); }

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

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; }
.container.narrow { max-width: 560px; }

/* ---- Header ---- */
.site-header {
  background: var(--color-card-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 0;
}
.header-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; }
.brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 4px; /* placeholder logo has a solid background block - soften its corners slightly */
}
.main-nav { display: flex; gap: 1rem; flex: 1; }
.main-nav a { color: var(--color-ink); font-size: 0.95rem; }
.main-nav a.active { color: var(--color-accent); font-weight: bold; }
.nav-search input { padding: 0.4rem 0.6rem; border: 1px solid var(--color-border); border-radius: 4px; width: 220px; }
.nav-lang { display: flex; gap: 0.4rem; font-size: 0.8rem; }
.lang-link { color: var(--color-muted); }
.lang-link.active { color: var(--color-accent); font-weight: bold; }
.nav-theme { display: flex; gap: 0.4rem; align-items: center; }
.theme-link {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}
.theme-link.active { border-color: var(--color-accent); }
.theme-swatch-sepia { background: linear-gradient(135deg, #faf7f2 50%, #7a3b2e 50%); }
.theme-swatch-parchment { background: linear-gradient(135deg, #f4ecd8 50%, #9c6b30 50%); }
.theme-swatch-midnight { background: linear-gradient(135deg, #1b1a17 50%, #d99a5b 50%); }
.theme-swatch-ink { background: linear-gradient(135deg, #ffffff 50%, #111111 50%); }
.nav-auth { display: flex; gap: 0.75rem; align-items: center; font-size: 0.9rem; }
.nav-user { color: var(--color-muted); }
.nav-admin { display: flex; gap: 0.6rem; align-items: center; background: #f1e6d8; padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.85rem; }
.nav-admin-label { color: var(--color-accent-dark); font-weight: bold; }
.link-button { background: none; border: none; color: var(--color-accent); cursor: pointer; font: inherit; padding: 0; }

/* ---- Footer ---- */
.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.85rem;
}

/* ---- Cards ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}
.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  display: block;
  color: var(--color-ink);
}
.card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.card-body { padding: 0.75rem 1rem; }
.card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.muted { color: var(--color-muted); font-size: 0.85rem; }
.badge {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  background: #f1e6d8;
  color: var(--color-accent-dark);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

/* ---- Diary / entry ---- */
.diary-header { margin-bottom: 2rem; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 1rem 0; }
.meta-list dt { color: var(--color-muted); font-size: 0.85rem; }
.meta-list dd { margin: 0; }
.tag-list { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.75rem 0; }
.tag {
  display: inline-block;
  background: #f1e6d8;
  color: var(--color-accent-dark);
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  font-size: 0.8rem;
}
a.tag.active { background: var(--color-accent); color: #fff; }
.entry-list ul { list-style: none; padding: 0; }
.entry-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--color-border); }
.entry-date { color: var(--color-muted); margin-right: 0.75rem; font-size: 0.85rem; }
.entry-body { margin-top: 1.5rem; font-family: var(--font-serif); font-size: 1.05rem; }
.entry-body p { margin: 0 0 1rem; }

/* ---- Notes ---- */
.notes-section { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }
.note { background: #fff; border: 1px solid var(--color-border); border-radius: 4px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; }
.note-anchor { font-size: 0.75rem; color: var(--color-muted); }

/* ---- Forms ---- */
.stacked-form { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.stacked-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.9rem; }
.stacked-form input, .stacked-form select, .stacked-form textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font: inherit;
}
.stacked-form textarea { min-height: 6rem; resize: vertical; }
.stacked-form button, .inline-form-block button, .inline-form button, .button {
  background: var(--color-accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  width: fit-content;
  display: inline-block;
}
.button.secondary { background: var(--color-muted); margin-left: 0.5rem; }
.inline-form { display: inline-block; margin-right: 0.4rem; }
.inline-form-block { display: flex; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.inline-form-block input, .inline-form-block textarea { padding: 0.4rem; border: 1px solid var(--color-border); border-radius: 4px; }
.form-error { color: #a33; }
button.danger { background: #a33; }
.stacked-form fieldset { border: 1px solid var(--color-border); border-radius: 4px; padding: 0.75rem 1rem; }
.stacked-form legend { font-size: 0.85rem; color: var(--color-muted); padding: 0 0.3rem; }
.radio-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; font-weight: normal; }
.import-notes { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--color-border); }
.import-notes ul { padding-left: 1.2rem; }
.import-notes li { margin-bottom: 0.4rem; }

/* ---- Photos ---- */
.tag-filter { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.photo-item img { width: 100%; height: 180px; object-fit: cover; border-radius: 4px; }
.photo-item figcaption { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.25rem; }

/* ---- Map / timeline ---- */
.map-canvas { height: 500px; border: 1px solid var(--color-border); border-radius: 6px; margin-top: 1rem; }
.map-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; font-size: 0.85rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend-swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
/* ---- Vertical timeline ---- */
.vtimeline {
  position: relative;
  margin: 2rem 0;
  padding-left: 2rem;
}
/* the continuous vertical line */
.vtimeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background: var(--color-border);
}
.vtimeline-year {
  position: relative;
  font-family: var(--font-serif);
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--color-accent);
  margin: 1.75rem 0 0.75rem;
}
.vtimeline-year:first-child { margin-top: 0; }
.vtimeline-item {
  position: relative;
  margin-bottom: 1rem;
}
.vtimeline-dot {
  position: absolute;
  left: -2rem;
  top: 1.1rem;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-card-bg);
  border: 3px solid var(--color-muted);
}
.vtimeline-dot-event { border-color: var(--color-accent); background: var(--color-accent); }
.vtimeline-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.75rem 1.1rem;
  font: inherit;
  color: var(--color-ink);
}
.vtimeline-card-clickable { cursor: pointer; }
.vtimeline-card-clickable:hover { border-color: var(--color-accent); }
.vtimeline-card-clickable.active { border-color: var(--color-accent); }
.vtimeline-card h3 { margin: 0.1rem 0 0.25rem; font-size: 1.05rem; }
.vtimeline-card p { margin: 0; }
.vtimeline-date { font-size: 0.78rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.vtimeline-hint { font-size: 0.8rem; margin-top: 0.15rem; }
.vtimeline-panel {
  margin: 0.5rem 0 0 0;
  padding: 0.75rem 1.1rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
}
.vtimeline-panel ul { margin: 0; padding-left: 1.1rem; }
.vtimeline-panel li { margin-bottom: 0.3rem; }

/* ---- Admin ---- */
.admin-table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; font-size: 0.9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--color-border); }

/* ---- Search ---- */
.search-results { list-style: none; padding: 0; }
.search-result { padding: 1rem 0; border-bottom: 1px solid var(--color-border); }
.snippet { color: var(--color-muted); margin: 0.25rem 0 0; }
.snippet mark { background: #f1e6d8; }

/* ---- Author ---- */
.author-header { margin-bottom: 2rem; }
.author-photo { max-width: 200px; border-radius: 6px; float: right; margin-left: 1.5rem; }

.author-image-preview { display: block; max-width: 200px; max-height: 250px; margin-top: .5rem; border-radius: 6px; }

.search-section { margin-bottom: 2rem; }
.search-section h2 { margin-bottom: 0.25rem; }
.search-result-author { display: flex; align-items: center; gap: 0.75rem; }
.search-author-photo { width: 48px; height: 48px; object-fit: cover; border-radius: 50%; flex-shrink: 0; }

.photo-item a img { transition: opacity 0.15s; }
.photo-item a:hover img { opacity: 0.85; }
.photo-diary-link { display: block; }
.back-link { margin-bottom: 0.5rem; }

/* ---- People index ---- */
.alphabet { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.75rem 0; }
.alphabet-letter {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 2rem; padding: 0 0.3rem;
  border: 1px solid var(--color-border); border-radius: 4px;
  color: var(--color-accent-dark); text-decoration: none; font-weight: 600;
}
a.alphabet-letter:hover { background: var(--color-card-bg); }
.alphabet-letter.active { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.alphabet-letter.empty { color: var(--color-border); border-style: dashed; font-weight: 400; }
.alphabet-heading { font-size: 2rem; margin: 1.5rem 0 0.5rem; }
.people-list { list-style: none; padding: 0; columns: 2 22rem; column-gap: 2rem; }
.people-list li { padding: 0.35rem 0; break-inside: avoid; }
.people-list .badge, .person-diary + .badge { margin-top: 0; }
.lead { font-size: 1.1rem; }
.person-diary h3 { margin-bottom: 0.25rem; }
.mention-list { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.mention-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--color-border); }
.admin-box { margin-top: 2.5rem; padding: 1rem 1.25rem; border: 1px dashed var(--color-border); border-radius: 6px; }
.admin-box h3 { margin: 1.5rem 0 0.25rem; }
.inline-form .link-button, .inline-form .link-button:hover {
  background: none; color: var(--color-accent); padding: 0; width: auto; font-size: 0.8rem;
}
.inline-form .danger-link { color: #a33; }
.entry-people { margin-top: 2rem; }
.entry-people a { margin-right: 0.25rem; }
