/* ── Design tokens ──────────────────────────────────────── */
:root {
  --cream: oklch(96% 0.015 80);
  --cream-2: oklch(92% 0.02 80);
  --paper: oklch(98% 0.008 80);
  --ink: oklch(20% 0.02 60);
  --ink-2: oklch(36% 0.02 60);
  --forest: oklch(35% 0.06 150);
  --forest-2: oklch(45% 0.07 150);
  --rust: oklch(58% 0.16 40);
  --rust-2: oklch(50% 0.18 35);
  --line: oklch(85% 0.02 80);
  --shadow: 0 1px 2px rgba(40, 30, 20, 0.06), 0 8px 24px rgba(40, 30, 20, 0.08);

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', system-ui, sans-serif;

  --topbar-h: 76px;
  --sidebar-w: 320px;

  --r: 8px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: transparent;
  cursor: pointer;
}

a { color: var(--rust-2); }

/* ── Layout grid ────────────────────────────────────────── */
body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "top top"
    "side map";
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar { grid-area: top; }
.sidebar { grid-area: side; }
.map-wrap { grid-area: map; position: relative; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  z-index: 1100;
}
.topbar__title h1 {
  font-size: 26px;
  line-height: 1;
}
.topbar__title h1 span {
  font-style: italic;
  color: var(--rust-2);
  font-weight: 400;
}
.topbar__title p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar__nav { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn--ghost {
  border-color: var(--line);
  background: var(--paper);
  color: var(--ink-2);
}
.btn--ghost:hover { background: var(--cream-2); color: var(--ink); }
.btn--primary {
  background: var(--forest);
  color: var(--paper);
}
.btn--primary:hover { background: var(--forest-2); }
.btn--primary:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 18px 18px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.sidebar__section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  font-family: var(--sans);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.badge {
  background: var(--rust);
  color: var(--paper);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  letter-spacing: 0;
}

.day-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.day-pill {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r);
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.day-pill strong {
  display: block;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}
.day-pill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.day-pill:hover { border-color: var(--ink-2); }

.range-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-2);
}

.layer-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.layer-list label,
.tag-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.tag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.tag-grid label { font-size: 12px; }
.tag-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.fav-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fav-list__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--cream);
  border-radius: var(--r);
  font-size: 12px;
}
.fav-list__item .when {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--rust-2);
}
.fav-list__item .title { color: var(--ink); line-height: 1.3; }
.fav-list__empty {
  font-size: 12px;
  color: var(--ink-2);
  padding: 8px;
  background: var(--cream);
  border-radius: var(--r);
  text-align: center;
}
.fav-list__group {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  padding: 8px 2px 4px;
  font-weight: 600;
  list-style: none;
}
.fav-list__item .when { white-space: nowrap; }
.fav-list__item { cursor: pointer; transition: background 120ms; }
.fav-list__item:hover { background: var(--cream-2); }

/* ── Map ────────────────────────────────────────────────── */
#map {
  height: 100%;
  width: 100%;
  background: var(--cream-2);
}

.leaflet-container {
  font-family: var(--sans);
  background: var(--cream-2);
}

.legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  gap: 16px;
  z-index: 700;
  box-shadow: var(--shadow);
}
.legend__group { display: flex; align-items: center; gap: 6px; }
.legend__marker {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink-2);
}

/* ── Custom markers ─────────────────────────────────────── */
.marker-pin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper);
  font-size: 11px;
  font-weight: 700;
}
.marker-hike {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  background: var(--forest);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.marker-hike.is-cz { background: var(--rust-2); }
.marker-pin.is-fav {
  box-shadow: 0 0 0 3px rgba(196, 74, 42, 0.55), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.marker-hike.is-fav {
  box-shadow: 0 0 0 3px rgba(196, 74, 42, 0.55), 0 1px 3px rgba(0, 0, 0, 0.3);
}
.marker-attraction {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  transform: rotate(45deg);
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow);
}
.marker-attraction.is-cz { background: oklch(95% 0.04 30); }
.marker-attraction.is-fav {
  background: var(--rust);
  border-color: var(--paper);
  box-shadow: 0 0 0 3px rgba(196, 74, 42, 0.55), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 12px 14px; font-family: var(--sans); }
.popup__title { font-family: var(--serif); font-size: 16px; margin: 0 0 4px; }
.popup__meta { color: var(--ink-2); font-size: 12px; margin: 0 0 8px; }
.popup__list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.popup__event {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  align-items: start;
}
.popup__event .when { font-weight: 600; color: var(--rust-2); font-variant-numeric: tabular-nums; }
.popup__event .title { color: var(--ink); line-height: 1.3; }
.popup__star {
  font-size: 18px;
  color: var(--ink-2);
  cursor: pointer;
  line-height: 1;
  user-select: none;
}
.popup__star.is-active { color: var(--rust); }
.popup__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.popup__head .popup__title { margin: 0; }

/* ── List panel (slide-in) ──────────────────────────────── */
.list-panel {
  position: absolute;
  top: var(--topbar-h);
  right: 0;
  width: 380px;
  max-width: 100vw;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  background: var(--paper);
  border-left: 1px solid var(--line);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms ease;
  box-shadow: var(--shadow);
}
.list-panel.is-open { transform: translateX(0); }
.list-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.list-panel__head h2 { font-size: 18px; }
.list-panel__body { padding: 0 14px 14px; overflow-y: auto; flex: 1; }

.event-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--line);
  align-items: start;
  cursor: pointer;
}
.event-card:hover { background: var(--cream); }
.event-card .when {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--rust-2);
  font-size: 13px;
}
.event-card .when small {
  display: block;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.event-card .title {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.3;
  margin: 0 0 4px;
}
.event-card .meta {
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.event-card .star {
  font-size: 18px;
  color: var(--line);
  cursor: pointer;
  align-self: center;
  line-height: 1;
}
.event-card .star.is-active { color: var(--rust); }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ink-2);
  background: transparent;
}
.icon-btn:hover { background: var(--cream-2); color: var(--ink); }
.icon-btn--top {
  position: absolute;
  top: 12px;
  right: 12px;
}

/* ── Dialogs ────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px 28px 24px;
  background: var(--paper);
  color: var(--ink);
  max-width: 620px;
  width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(40, 30, 20, 0.25);
}
dialog::backdrop { background: rgba(20, 16, 12, 0.45); backdrop-filter: blur(2px); }
dialog h2 { font-size: 24px; margin: 0 0 16px; }

.planner-section { margin-bottom: 18px; }
.planner-section h3 {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.planner-range {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--ink);
}
.planner-range em {
  display: block;
  font-style: normal;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 2px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.planner-days { display: flex; flex-direction: column; gap: 10px; }
.planner-day {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
}
.planner-day h4 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}
.planner-day ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.planner-suggestion {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
}

.planner-extras {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.planner-extras div {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
}
.planner-extras h4 {
  font-family: var(--sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  margin: 0 0 6px;
}
.planner-extras ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}
.planner-extras li small { color: var(--ink-2); }

.planner-picked {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.planner-picked li {
  padding: 8px 10px;
  background: var(--cream);
  border-radius: var(--r);
  font-size: 13px;
  line-height: 1.4;
}
.planner-picked li small {
  display: block;
  color: var(--ink-2);
  font-size: 12px;
  margin-top: 2px;
}

.planner-section--cta {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 6px;
}

.btn--block {
  width: 100%;
  justify-content: center;
  padding: 12px 14px;
  font-size: 14px;
}

.event-dialog .event-dialog__when {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--rust-2);
  font-weight: 600;
  margin-bottom: 6px;
}
.event-dialog__title { font-size: 24px; margin: 0 0 12px; }
.event-dialog__who { color: var(--ink-2); font-size: 14px; margin: 0 0 6px; }
.event-dialog__place { font-size: 13px; }
.event-dialog__actions { margin-top: 18px; display: flex; gap: 8px; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) auto 1fr;
    grid-template-areas:
      "top"
      "side"
      "map";
    overflow: auto;
  }
  .sidebar {
    max-height: 38vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .map-wrap { min-height: 60vh; }
  .list-panel { width: 100vw; }
  .legend { font-size: 11px; flex-wrap: wrap; }
}
