:root {
  --paper: #F5F3EE;
  --paper-panel: #EAE7DE;
  --ink: #182B22;
  --ink-soft: #4A5D53;
  --pine: #146B4B;
  --ochre: #E8642A;
  --ochre-dark: #B84518;
  --teal: #1C8088;
  --sage: #9FBB9A;
  --line: rgba(24, 43, 34, 0.14);

  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Work Sans", system-ui, sans-serif;
  --font-stamp: "Special Elite", "Courier New", monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.45;
}

a { color: var(--teal); }
a:hover { color: var(--ochre-dark); }

button, input, textarea {
  font-family: inherit;
  font-size: 1rem;
}

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

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #FAF9F5 0%, var(--paper) 100%);
  border-bottom: 3px solid var(--pine);
  padding: 2.75rem 1.5rem 3.5rem;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: 56rem;
  margin: 0 auto;
  text-align: center;
}

.eyebrow {
  font-family: var(--font-stamp);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--ochre-dark);
  margin: 0 0 0.5rem;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  margin: 0;
  color: var(--pine);
}

.stats {
  display: flex;
  justify-content: center;
  gap: clamp(1.25rem, 4vw, 3rem);
  margin: 1.75rem 0 0;
  flex-wrap: wrap;
}

.stat {
  margin: 0;
  min-width: 6.5rem;
}

.stat dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.stat dd {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 600;
  color: var(--pine);
}

.stat--stamped dd { color: var(--ochre-dark); }

.hero-contours {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.35;
}

.hero-contours path {
  fill: none;
  stroke: var(--sage);
  stroke-width: 2;
}

/* ---------- Layout / toolbar ---------- */

.layout {
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.view-switch {
  display: inline-flex;
  background: var(--paper-panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem;
}

.view-btn {
  border: none;
  background: none;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
}

.view-btn.is-active {
  background: var(--pine);
  color: var(--paper);
}

.search {
  flex: 1 1 14rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.ghost-btn {
  border: 1px dashed var(--ink-soft);
  background: transparent;
  color: var(--ink-soft);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-btn:hover { border-color: var(--ochre-dark); color: var(--ochre-dark); }

/* ---------- Map ---------- */

.map-pane { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
#map { height: min(65vh, 640px); width: 100%; background: var(--paper-panel); }
.leaflet-tile-pane { filter: saturate(0.9) brightness(1.02); }

.stamp-marker {
  border-radius: 50%;
  width: 22px;
  height: 22px;
  border: 3px solid var(--ochre-dark);
  background: var(--ochre);
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.stamp-marker.is-history { background: transparent; border: 2px dashed var(--ink-soft); opacity: 0.6; }

.leaflet-popup-content { font-family: var(--font-body); }
.popup-title { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.15rem; }
.popup-edit { display: inline-block; margin-top: 0.35rem; font-size: 0.85rem; }

/* ---------- Timeline ---------- */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.timeline-year {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--pine);
  border-bottom: 2px solid var(--line);
  padding-bottom: 0.35rem;
  margin: 0 0 0.9rem;
}

.timeline-group + .timeline-group { margin-top: 0; }

.timeline-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 0.9rem;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1rem 0.9rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  cursor: pointer;
  animation: card-in 0.4s ease both;
}

.card:hover { border-color: var(--ochre); }

.stamp {
  flex: none;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-family: var(--font-stamp);
  font-size: 0.62rem;
  line-height: 1.05;
  text-align: center;
  border: 2px solid var(--ochre-dark);
  color: var(--ochre-dark);
  transform: rotate(-6deg);
  background: rgba(232, 100, 42, 0.08);
}

.stamp.is-open {
  border-style: dashed;
  border-color: var(--ink-soft);
  color: var(--ink-soft);
  background: transparent;
}

.card-body { min-width: 0; }
.card-name {
  font-weight: 600;
  margin: 0 0 0.15rem;
  overflow-wrap: anywhere;
}
.card-address {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0;
  overflow-wrap: anywhere;
}
.card-note {
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
  color: var(--ink);
  font-style: italic;
}
.card-badge {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sage);
}

.empty-state { text-align: center; color: var(--ink-soft); padding: 3rem 0; }
.no-entries { text-align: center; color: var(--ink-soft); padding: 1rem; margin: 0 0 1rem; border: 1px dashed currentColor; border-radius: 8px; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(24, 43, 34, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

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

.modal {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.75rem;
  max-width: 26rem;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}

.modal-eyebrow {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin: 0 0 0.15rem;
}

#modal-title {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  color: var(--pine);
}

.modal-maps-link {
  display: inline-block;
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.field span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--ink-soft);
}

.field span small {
  font-weight: 400;
  font-size: 0.85em;
}

.field input, .field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.field-error {
  margin: -0.6rem 0 1rem;
  font-size: 0.82rem;
  color: #C0392B;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.photo-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper-panel);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-thumb-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  line-height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(24, 43, 34, 0.65);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.photo-thumb-delete:hover {
  background: var(--ochre-dark);
}

/* ---------- Cover-Thumbnails (Karte/Zeitleiste/Tabelle) ---------- */

.card-thumb {
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.row-thumb {
  display: inline-block;
  vertical-align: middle;
  width: 32px;
  height: 32px;
  margin-right: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.popup-photo {
  display: block;
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  margin: 0 0 0.4rem;
  cursor: pointer;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 88vh;
}

.lightbox img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  display: block;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(24, 43, 34, 0.55);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-nav:hover { background: var(--ochre-dark); }
.lightbox-prev { left: -0.5rem; }
.lightbox-next { right: -0.5rem; }
.lightbox-nav[hidden] { display: none; }

.lightbox-index {
  position: absolute;
  bottom: -1.8rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--paper);
  font-size: 0.85rem;
  margin: 0;
}

.stamp-btn {
  background: var(--pine);
  color: var(--paper);
  border: none;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.stamp-btn:hover { background: var(--ochre-dark); }

.stamp-btn.is-stamping { animation: stamp-hit 0.35s ease; }

@keyframes stamp-hit {
  0% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.15) rotate(-4deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ---------- Tabelle ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.75rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.data-table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  background: var(--paper-panel);
}

.data-table td:last-child,
.data-table th:last-child {
  white-space: nowrap;
  width: 1%;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background: var(--paper-panel);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .row-name {
  font-weight: 600;
  color: var(--ink);
}

.data-table .row-address {
  display: block;
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}

.data-table .row-date {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--pine);
}

.data-table .row-date.is-unknown {
  font-family: var(--font-body);
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
}

/* ---------- Statistik ---------- */

.chart-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.5rem 1.5rem 1.75rem;
}

.chart-title {
  font-family: var(--font-display);
  color: var(--pine);
  margin: 0 0 1.25rem;
  font-size: 1.3rem;
}

.chart-wrap {
  width: 100%;
  overflow-x: auto;
}

.chart-wrap svg { display: block; }

.chart-gridline { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }

.chart-axis-label {
  fill: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 0.72rem;
}

.chart-value-label {
  fill: var(--ink);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
}

.chart-bar { fill: var(--ochre); transition: fill 0.15s ease; }

.chart-bar-group:hover .chart-bar,
.chart-bar-group:focus-visible .chart-bar {
  fill: var(--ochre-dark);
}

.chart-bar-hit { fill: transparent; cursor: pointer; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--pine);
  color: var(--paper);
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  opacity: 0;
  transition: opacity 0.1s ease;
  z-index: 5;
}

.chart-tooltip.is-visible { opacity: 1; }
.chart-tooltip strong { font-family: var(--font-display); }

.chart-note {
  margin: 0.9rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.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;
}

/* ---------- Footer ---------- */

.site-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-soft);
  padding: 1.5rem 1rem 2.5rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 40rem) {
  .stats { gap: 1.25rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
  .stamp-btn.is-stamping { animation: none; }
}
