:root {
  --paper: #f4f1ea;
  --paper-2: #ece6da;
  --card: #fbf9f4;
  --ink: #23201b;
  --muted: #6f675b;
  --line: #d9d2c4;
  --moss: #4f6f52;     /* LIVE */
  --amber: #b07d2f;    /* QUIET — warm, never alarm */
  --slate: #5a6b73;    /* RESOLVED */
  --rose: #8a5a64;     /* resolved-unknown accent */
  --shadow: 0 1px 2px rgba(35, 32, 27, 0.06), 0 8px 24px rgba(35, 32, 27, 0.07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--paper), var(--paper-2));
}
.brand { display: flex; flex-direction: column; }
.mark { font-family: var(--serif); font-size: 1.55rem; letter-spacing: 0.01em; }
.tagline { font-size: 0.82rem; color: var(--muted); }
nav { display: flex; gap: 0.4rem; }
.nav-btn {
  font: inherit; font-size: 0.85rem; padding: 0.35rem 0.8rem; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.nav-btn.is-active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---- layout ---- */
.layout { display: grid; grid-template-columns: 300px 1fr; gap: 1.6rem; padding: 1.6rem; max-width: 1180px; margin: 0 auto; }
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

.roster h2 { font-family: var(--serif); font-weight: 500; margin: 0 0 0.1rem; }
.roster-note { color: var(--muted); font-size: 0.82rem; margin: 0 0 0.9rem; }
.roster-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.roster-card {
  text-align: left; width: 100%; cursor: pointer; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 0.6rem 0.7rem; box-shadow: var(--shadow);
  display: flex; flex-direction: row; align-items: center; gap: 0.7rem; transition: transform .08s ease, border-color .08s ease;
}
.roster-card:hover { transform: translateY(-1px); border-color: #c7bda9; }
.roster-card.is-active { border-color: var(--ink); }
/* Species portrait — recognise the animal at a glance (illustrative, not the individual). */
.rc-thumb { flex: none; width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); background: var(--paper-2); }
.rc-thumb--empty { border-style: dashed; }
.rc-info { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; flex: 1 1 auto; }
.roster-card .nm { font-family: var(--serif); font-size: 1.05rem; }
.roster-card .sp { font-size: 0.78rem; color: var(--muted); }
.roster-card .meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.15rem; }

/* ---- state pills ---- */
.pill { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.12rem 0.5rem; border-radius: 999px; border: 1px solid; }
.pill.LIVE { color: var(--moss); border-color: color-mix(in srgb, var(--moss) 40%, var(--line)); background: color-mix(in srgb, var(--moss) 8%, var(--card)); }
.pill.QUIET { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); background: color-mix(in srgb, var(--amber) 8%, var(--card)); }
.pill.RESOLVED_KNOWN, .pill.RESOLVED_UNKNOWN { color: var(--slate); border-color: color-mix(in srgb, var(--slate) 40%, var(--line)); background: color-mix(in srgb, var(--slate) 8%, var(--card)); }

/* ---- stage (follow view) ---- */
.stage { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; min-height: 460px; }
.stage .empty { color: var(--muted); padding: 3rem; text-align: center; }

.hero { padding: 1.4rem 1.6rem 0.4rem; display: flex; align-items: center; gap: 1.2rem; }
/* Species portrait beside the name — illustrative of the species, not the individual. */
.hero-portrait { flex: none; width: 92px; height: 92px; border-radius: 50%; object-fit: cover; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line), var(--shadow); }
.hero-text { min-width: 0; }
@media (max-width: 480px) { .hero-portrait { width: 64px; height: 64px; } }
.hero .kicker { font-size: 0.8rem; color: var(--muted); }
.hero h1 { font-family: var(--serif); font-weight: 500; font-size: 2.3rem; margin: 0.1rem 0 0.2rem; line-height: 1.05; }
.hero .assigned { font-size: 0.74rem; color: var(--muted); font-style: italic; }
.ribbon { display: inline-flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }

.map-wrap { margin: 0.9rem 0 0; background: #dde3e3; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#journey-map { width: 100%; height: 360px; background: #dde3e3; z-index: 0; }
/* Data points and the route are clickable — they seek the timeline to that date. */
#journey-map .leaflet-interactive { cursor: pointer; }
.map-fallback { display: flex; align-items: center; justify-content: center; height: 360px; color: var(--muted); font-size: 0.9rem; }

/* End-of-track marker. A static dot; LIVE tracks add a slow pulse ring. */
.end-dot { position: absolute; inset: 0; margin: auto; width: 11px; height: 11px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #fff; }
.end-dot.is-live::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 2px solid var(--c); animation: pulse-ring 2.4s ease-out infinite; }
@keyframes pulse-ring { 0% { transform: scale(0.7); opacity: 0.6; } 100% { transform: scale(2.2); opacity: 0; } }
.landmark-tip.leaflet-tooltip { font-family: var(--serif); font-weight: 600; color: #3f3c34; }

/* Time scrubber — a FIXED, uniform time axis: drag through real time, ▶ to replay it. */
.map-scrubber { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; padding: 0.5rem 0.9rem; background: var(--card); border-top: 1px solid var(--line); font-family: var(--sans); }
.map-scrubber:empty { display: none; }
.scrub-play { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; font-size: 0.68rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.scrub-play:hover { background: var(--paper-2); }
.scrub-play.is-playing { color: var(--moss); border-color: var(--moss); }
.scrub-track { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scrub-range { flex: none; width: 100%; accent-color: var(--moss); cursor: pointer; }
.scrub-readout { flex: none; min-width: 13.5rem; text-align: right; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.scrub-readout strong { color: var(--ink); font-weight: 600; }

/* Fixed-scale month/year ticks, positioned by real time fraction. */
.scrub-axis { position: relative; height: 1.1rem; margin: 0 7px; }
.scrub-tick { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; font-size: 0.6rem; line-height: 1.15; color: var(--muted); white-space: nowrap; pointer-events: none; }
.scrub-tick::before { content: ""; width: 1px; height: 4px; background: var(--line); }
.scrub-tick.is-year { color: var(--ink); }
.scrub-tick.is-year::before { height: 6px; background: var(--muted); }

/* Local conditions at the scrubbed moment — its own line below the controls. */
.scrub-conditions { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 1.3rem; margin-top: 0.2rem; padding-top: 0.35rem; border-top: 1px dashed var(--line); font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.scrub-conditions:empty { display: none; }
.scrub-conditions .cond { display: inline-flex; align-items: baseline; gap: 0.38rem; }
.cond-ico { font-size: 0.92rem; line-height: 1; align-self: center; }
.cond-txt strong { color: var(--ink); font-weight: 600; }
.cond-src { font-size: 0.72rem; opacity: 0.85; }
.cond-na { font-style: italic; }

/* The scrubber's moving position marker (sits above the track). */
.scrub-dot { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.4); }

@media (max-width: 640px) {
  .scrub-readout { min-width: 0; flex: 1 1 100%; text-align: left; order: 3; }
}

.body { padding: 1.2rem 1.6rem 1.6rem; }
.narrative { font-family: var(--serif); font-size: 1.22rem; line-height: 1.55; margin: 0 0 1rem; }
.control-line { font-size: 1rem; color: var(--ink); margin: 0 0 1rem; }
.control-tag { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.stats { display: flex; flex-wrap: wrap; gap: 1.2rem; padding: 0.6rem 0 1rem; border-top: 1px dashed var(--line); }
.stat .k { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .v { font-family: var(--serif); font-size: 1.25rem; }

/* ---- action bridge ---- */
.action { background: color-mix(in srgb, var(--moss) 8%, var(--card)); border: 1px solid color-mix(in srgb, var(--moss) 30%, var(--line)); border-radius: 12px; padding: 1rem 1.1rem; margin: 0.4rem 0 1rem; }
.action h3 { margin: 0 0 0.5rem; font-size: 0.95rem; }
.action .cta { font: inherit; font-weight: 600; cursor: pointer; border: none; border-radius: 999px; padding: 0.6rem 1.1rem; background: var(--moss); color: #fff; }
.action .cta:disabled { background: var(--slate); cursor: default; }
.action .share { margin-top: 0.7rem; font-size: 0.9rem; color: var(--muted); }
.action textarea { width: 100%; font: inherit; font-size: 0.9rem; margin-top: 0.4rem; border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem; background: var(--paper); }

/* ---- successor + provenance ---- */
.successor { border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem 1rem; margin: 0.4rem 0 1rem; background: var(--paper); }
.successor .nm { font-family: var(--serif); font-size: 1.1rem; }
.successor .bridge { font-family: var(--serif); font-size: 1.04rem; line-height: 1.5; margin: 0.35rem 0 0; color: var(--ink); }
.successor button { font: inherit; cursor: pointer; margin-top: 0.6rem; border: 1px solid var(--ink); background: transparent; border-radius: 999px; padding: 0.4rem 0.9rem; }

.provenance { font-size: 0.78rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 0.9rem; }
.synthetic-banner { font-size: 0.78rem; color: #7a5a1f; background: color-mix(in srgb, var(--amber) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--amber) 35%, var(--line)); border-radius: 8px; padding: 0.5rem 0.7rem; margin: 0.8rem 1.6rem 0; }
.unverified-banner { font-size: 0.78rem; color: #4a5b50; background: color-mix(in srgb, var(--green, #4f6f52) 9%, var(--card)); border: 1px solid color-mix(in srgb, var(--green, #4f6f52) 28%, var(--line)); border-radius: 8px; padding: 0.5rem 0.7rem; margin: 0.8rem 1.6rem 0; }
.continued-banner { font-size: 0.82rem; color: var(--muted); background: color-mix(in srgb, var(--ink) 4%, var(--card)); border: 1px solid var(--line); border-left: 3px solid color-mix(in srgb, var(--green, #4f6f52) 55%, var(--line)); border-radius: 8px; padding: 0.5rem 0.7rem; margin: 0.8rem 1.6rem 0; }
.continued-banner strong { font-family: var(--serif); color: var(--ink); }

/* ---- experiment ---- */
.experiment { max-width: 880px; margin: 0 auto; padding: 1.8rem 1.6rem; }
.experiment h2 { font-family: var(--serif); font-weight: 500; }
.experiment .lede { color: var(--muted); max-width: 60ch; }
.funnel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-top: 1rem; }
@media (max-width: 700px) { .funnel-grid { grid-template-columns: 1fr; } }
.arm-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem; box-shadow: var(--shadow); }
.arm-card h3 { margin: 0 0 0.6rem; font-family: var(--serif); font-weight: 500; }
.bar { margin: 0.35rem 0; }
.bar .lab { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--muted); }
.bar .track { height: 9px; background: var(--paper-2); border-radius: 999px; overflow: hidden; margin-top: 2px; }
.bar .fill { height: 100%; background: var(--moss); }
.lift { font-family: var(--serif); font-size: 1.3rem; margin-top: 1rem; }
.lift .num { font-size: 2rem; }
