:root {
  --bg: #f3efe7;
  --surface: rgba(255, 253, 249, .92);
  --surface-solid: #fffdf9;
  --ink: #1d1a17;
  --muted: #6b645b;
  --line: rgba(29, 26, 23, .12);
  --accent: #c2412b;
  --accent-ink: #ffffff;
  --shadow: 0 12px 40px rgba(40, 30, 20, .18);
  --serif: Fraunces, Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f; --surface: rgba(28, 25, 22, .9); --surface-solid: #1c1916; --ink: #f1ece4;
    --muted: #a79f94; --line: rgba(241, 236, 228, .14); --accent: #f07a52; --accent-ink: #14120f;
    --shadow: 0 12px 40px rgba(0, 0, 0, .5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14120f; --surface: rgba(28, 25, 22, .9); --surface-solid: #1c1916; --ink: #f1ece4;
  --muted: #a79f94; --line: rgba(241, 236, 228, .14); --accent: #f07a52; --accent-ink: #14120f;
  --shadow: 0 12px 40px rgba(0, 0, 0, .5); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }

/* ---------- header floats over the map ---------- */
.top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 22px; padding: 14px 22px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink);
  font-weight: 600; letter-spacing: .16em; font-size: 14px;
  background: var(--surface); backdrop-filter: blur(10px); padding: 8px 14px; border-radius: 999px; box-shadow: var(--shadow);
}
.brand svg { width: 22px; height: 22px; fill: var(--accent); }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a {
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: 14px;
  padding: 7px 12px; border-radius: 999px; background: var(--surface); backdrop-filter: blur(10px);
}
.top nav a:hover { color: var(--accent); }
.lang { display: flex; background: var(--surface); backdrop-filter: blur(10px); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.lang button { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 600; border-radius: 999px; cursor: pointer; }
.lang button.on { background: var(--ink); color: var(--surface-solid); }
.login {
  border: 0; background: var(--surface); backdrop-filter: blur(10px); color: var(--muted);
  border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px; box-shadow: var(--shadow); cursor: not-allowed;
}

/* ---------- full-screen map stage ---------- */
.stage { position: relative; height: 100vh; min-height: 620px; overflow: hidden; }
#leaflet { position: absolute; inset: 0; background: #e9e4d8; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, .7) !important; }
.leaflet-top.leaflet-right { top: 64px; }
.leaflet-bar { border: 0 !important; box-shadow: var(--shadow) !important; }
.leaflet-bar a { background: var(--surface-solid); color: var(--ink); border-color: var(--line); }

.card {
  position: absolute; z-index: 500; top: 76px; left: 22px; width: 360px; max-height: calc(100% - 230px);
  overflow-y: auto; padding: 22px 22px 18px;
  background: var(--surface); backdrop-filter: blur(14px); border-radius: 20px; box-shadow: var(--shadow);
}
.card h1 { font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.12; margin: 0 0 8px; letter-spacing: -.01em; }
.lede { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

.species { display: flex; flex-wrap: wrap; gap: 6px; }
.species button {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--ink); cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
  transition: background .15s, border-color .15s;
}
.species button:hover { border-color: var(--ink); }
.species button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface-solid); }

.meta { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.latin { margin: 0; font-family: var(--serif); font-style: italic; font-size: 16px; }
.status { margin: 0; font-size: 12px; color: var(--muted); }

.legend { margin-top: 18px; }
.ramp { height: 8px; border-radius: 4px; background: linear-gradient(90deg, rgba(255, 214, 120, .35), #f7a541, #e4572e, #a4133c, #4a0d4d); }
.ticks { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 5px; text-align: center; }
.toggle { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.note { font-size: 12px; color: var(--muted); border-left: 2px solid var(--accent); padding: 2px 0 2px 10px; margin: 16px 0 0; }
.stats { font-size: 11px; color: var(--muted); margin: 12px 0 0; }

/* ---------- timeline across the bottom ---------- */
.timeline {
  position: absolute; z-index: 500; left: 22px; right: 22px; bottom: 26px;
  display: flex; gap: 16px; align-items: center;
  background: var(--surface); backdrop-filter: blur(14px); border-radius: 20px; box-shadow: var(--shadow);
  padding: 14px 20px 12px 14px;
}
.play {
  flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(194, 65, 43, .35);
}
.play svg { width: 24px; height: 24px; fill: var(--accent-ink); }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.date { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.phenlegend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.phenlegend span::before { content: ""; display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.track { position: relative; height: 44px; margin-top: 4px; }
#phen { position: absolute; inset: 0; width: 100%; height: 100%; }
#phen .area { stroke: none; opacity: .18; }
#phen .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
#phen .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
#week { position: absolute; left: 0; right: 0; bottom: -8px; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; height: 20px; cursor: pointer; }
#week::-webkit-slider-runnable-track { height: 2px; background: var(--line); }
#week::-moz-range-track { height: 2px; background: var(--line); }
#week::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface-solid); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
#week::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface-solid); }
.months { display: flex; justify-content: space-between; margin-top: 8px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.months span { flex: 1; text-align: left; }

/* ---------- text sections ---------- */
.text { max-width: 720px; margin: 0 auto; padding: 72px 22px 8px; }
.text h2 { font-family: var(--serif); font-weight: 600; font-size: 30px; margin: 0 0 18px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.steps li { counter-increment: s; position: relative; padding-left: 46px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--ink); color: var(--surface-solid);
}
.caveat { margin-top: 22px; padding: 14px 16px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--line); color: var(--muted); }
footer { max-width: 720px; margin: 48px auto 0; padding: 22px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .top { position: absolute; padding: 10px 16px; gap: 8px; flex-wrap: wrap; }
  .top nav, .login { display: none; }
  .lang { margin-left: auto; }
  .stage { height: auto; min-height: 0; overflow: visible; display: flex; flex-direction: column; }
  #leaflet { position: relative; height: 64vh; }
  .timeline { order: 2; position: relative; left: auto; right: auto; bottom: auto; margin: 12px 12px 0; padding: 10px 12px; gap: 10px; }
  .months span:nth-child(even) { visibility: hidden; }
  .play { width: 44px; height: 44px; }
  .date { font-size: 18px; }
  .phenlegend { display: none; }
  .card { order: 3; position: relative; top: auto; left: auto; width: auto; max-height: none; margin: 12px; box-shadow: none; background: var(--surface-solid); }
  .card h1 { font-size: 24px; }
  .leaflet-top.leaflet-right { top: 56px; }
}
