:root {
  --bg: #faf8f4; --fg: #2b2620; --muted: #6b6257; --accent: #7a5c2e;
  --accent2: #4a6741; --card: #ffffff; --border: #e2dcd2; --code-bg: #f0ece4;
  --blue: #2a78d6; --blue-deep: #0d366b; --orange: #eb6834;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif; color: var(--fg);
  background: var(--bg); display: flex; flex-direction: column;
}

#topbar {
  display: flex; align-items: center; gap: 1rem; padding: .5rem .9rem;
  background: var(--card); border-bottom: 2px solid var(--accent);
  flex-wrap: wrap; z-index: 30;
}
#brand { font-size: 1.05rem; color: var(--accent2); white-space: nowrap; }
#brand-icon { width: 22px; height: 22px; vertical-align: -5px; }
#brand strong { color: var(--fg); }
#search-wrap { flex: 1 1 220px; max-width: 420px; position: relative; }
#search { width: 100%; padding: .4rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); font-size: .9rem; }
#search-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: 70; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.16);
  max-height: 340px; overflow-y: auto; padding: .3rem; }
.sr-item { padding: .4rem .6rem; border-radius: 6px; cursor: pointer; }
.sr-item.active { background: var(--code-bg); }
.sr-name { display: block; font-size: .88rem; color: var(--fg); }
.sr-where { display: block; font-size: .74rem; color: var(--muted); }
.sr-empty { padding: .45rem .6rem; font-size: .82rem; color: var(--muted); }
#layers { display: flex; gap: .8rem; font-size: .82rem; color: var(--muted);
  flex-wrap: wrap; align-items: center; }

#spinner { width: 16px; height: 16px; flex: 0 0 auto; margin-left: auto;
  border: 2.5px solid var(--border); border-top-color: var(--accent2);
  border-radius: 50%; opacity: 0; transition: opacity .25s; }

#sysmenu-wrap { position: relative; flex: 0 0 auto; }
#sysmenu-btn { border: 1px solid var(--border); background: var(--card);
  color: var(--fg); border-radius: 8px; font-size: 1.05rem; line-height: 1;
  padding: .3rem .55rem; cursor: pointer; }
#sysmenu-btn:hover { border-color: var(--accent2); }
#sysmenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.16); min-width: 160px; padding: .3rem; }
#sysmenu button { display: block; width: 100%; text-align: left; border: none;
  background: none; color: var(--fg); font-size: .88rem; padding: .45rem .6rem;
  border-radius: 6px; cursor: pointer; }
#sysmenu button:hover { background: var(--code-bg); }
#show-pilots-label { display: flex; align-items: center; gap: .4rem;
  font-size: .88rem; padding: .45rem .6rem; border-radius: 6px;
  cursor: pointer; border-top: 1px solid var(--border); margin-top: .2rem; }
#show-pilots-label:hover { background: var(--code-bg); }
#norm-per-label { display: flex; align-items: center; gap: .4rem;
  font-size: .88rem; padding: .45rem .6rem; border-radius: 6px;
  cursor: pointer; }
#norm-per-label:hover { background: var(--code-bg); }
/* display only when shown - a bare display:flex would defeat `hidden` */
#model-label:not([hidden]) { display: flex; }
#model-label { align-items: center; gap: .4rem; font-size: .88rem;
  padding: .45rem .6rem; border-radius: 6px;
  border-top: 1px solid var(--border); margin-top: .2rem; }
#model-sel { font-size: .84rem; padding: .15rem .3rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); }
.model-warn { color: var(--orange); margin-left: .3rem; cursor: help; }

#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 100; align-items: center; justify-content: center; }
/* display set only when shown - a bare `display: flex` on the base rule
   would override the `hidden` attribute and show an empty dialog on load */
#modal-overlay:not([hidden]) { display: flex; }
#modal { background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; max-width: 680px; width: calc(100vw - 40px);
  max-height: 80vh; overflow-y: auto; padding: 1.1rem 1.3rem; position: relative; }
#modal-close { position: absolute; top: .5rem; right: .7rem; border: none;
  background: none; font-size: 1.4rem; color: var(--muted); cursor: pointer; }
#modal h2 { margin: 0 1.5rem .7rem 0; font-size: 1.15rem; }
#modal table { border-collapse: collapse; width: 100%; font-size: .8rem; }
#modal th, #modal td { text-align: left; padding: .35rem .5rem;
  border-bottom: 1px solid var(--border); vertical-align: top; }
#modal th { color: var(--muted); font-weight: 600; }
#modal .verdict-pill { display: inline-block; font-weight: 700;
  border-radius: 99px; padding: .05rem .6rem; font-size: .8rem; }
#modal .v-healthy { color: #3d6b3d; border: 1.5px solid #3d6b3d; }
#modal .v-weak { color: var(--orange); border: 1.5px solid var(--orange); }
#modal .v-inverted { color: #9c4a3a; border: 1.5px solid #9c4a3a; }
#modal .subnote { color: var(--muted); font-size: .74rem; margin-top: .5rem; }
#modal .qbar { height: 9px; border-radius: 5px; background: var(--code-bg);
  border: 1px solid var(--border); overflow: hidden; margin: .25rem 0 .15rem; }
#modal .qfill { height: 100%; border-radius: 4px; background: #3d6b3d; }
#modal .qfill.warn { background: var(--orange); }
#modal .qfill.crit { background: #9c4a3a; }
#modal .qtext { font-size: .74rem; font-variant-numeric: tabular-nums; }
#modal .qdesc { font-size: .72rem; color: var(--muted); }
#spinner.on { opacity: 1; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#layers label { display: flex; align-items: center; gap: .25rem; cursor: pointer; }

#heat-label { position: relative; }
#heat-legend {
  display: none; position: absolute; top: calc(100% + 8px); right: -10px;
  width: 240px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: .65rem .75rem; z-index: 60;
  box-shadow: 0 6px 24px rgba(0,0,0,.16); cursor: default;
}
#heat-label:hover #heat-legend, #heat-label:focus-within #heat-legend { display: block; }
#heat-legend .lg-title { font-weight: 600; font-size: .78rem; color: var(--fg);
  margin-bottom: .1rem; }
#heat-legend .lg-updated { font-size: .68rem; color: var(--muted); margin-bottom: .4rem; }
#heat-legend .lg-updated.old { color: var(--orange); font-weight: 600; }
#heat-stale { font-size: .68rem; font-weight: 700; color: var(--orange);
  border: 1px solid var(--orange); border-radius: 99px; padding: 0 .45rem; }
#heat-opacity { width: 70px; accent-color: var(--accent2); }
#species-sel { font-size: .78rem; padding: .15rem .3rem; max-width: 190px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--card);
  color: var(--fg); }
#heat-legend .lg-bar { height: 12px; border-radius: 6px; border: 1px solid var(--border);
  background: linear-gradient(to right,
    rgba(230,216,250,0) 0%, #e6d8fa 10%, #c9aef3 30%,
    #9a5ce8 50%, #8a2be2 70%, #4c1780 90%, #4c1780 100%); }
#heat-legend .lg-ticks { display: flex; justify-content: space-between;
  font-size: .66rem; color: var(--muted); margin: .15rem 0 .4rem;
  font-variant-numeric: tabular-nums; }
#heat-legend .lg-note { font-size: .7rem; color: var(--muted); line-height: 1.45;
  font-weight: 400; }

#daybar { display: flex; align-items: center; gap: .6rem; padding: .35rem .9rem;
  background: var(--code-bg); border-bottom: 1px solid var(--border);
  overflow-x: auto; z-index: 25; }
#daybar-label { font-size: .78rem; color: var(--muted); white-space: nowrap; }
#day-chips { display: flex; gap: .3rem; }
.chip { border: 1px solid var(--border); background: var(--card); border-radius: 99px;
  padding: .15rem .6rem; font-size: .78rem; cursor: pointer; white-space: nowrap; }
.chip.past { color: var(--muted); }
.chip.active { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 600; }

#main-row { flex: 1; min-height: 0; display: flex; }
#map { flex: 1; min-height: 0; }

/* ---------- favorites ---------- */
#fav-btn { border: 1px solid var(--border); background: var(--card);
  color: var(--fg); border-radius: 8px; font-size: .82rem; line-height: 1;
  padding: .38rem .6rem; cursor: pointer; white-space: nowrap; }
#fav-btn:hover { border-color: var(--accent2); }
#fav-btn.on { border-color: #eab308; color: var(--fg); }
#favbar { flex: 0 0 252px; width: 252px; background: var(--card);
  border-right: 1px solid var(--border); overflow-y: auto;
  padding: .7rem .8rem; position: relative; }
#favbar-close { position: absolute; top: .35rem; right: .5rem; border: none;
  background: none; font-size: 1.3rem; color: var(--muted); cursor: pointer;
  line-height: 1; padding: .1rem .3rem; border-radius: 6px; }
#favbar-close:hover { background: var(--code-bg); color: var(--fg); }
#favbar h3 { margin: .1rem 0 .55rem; font-size: .82rem; color: var(--accent2); }
#fav-empty { font-size: .8rem; color: var(--muted); line-height: 1.5; }
.fav-item { display: flex; align-items: center; gap: .45rem;
  padding: .42rem .5rem; border-radius: 6px; cursor: pointer; }
.fav-item:hover { background: var(--code-bg); }
.fav-name { flex: 1; font-size: .86rem; min-width: 0;
  overflow-wrap: anywhere; }
.fav-coords { display: block; font-size: .7rem; color: var(--muted); }
.fav-del { border: none; background: none; cursor: pointer; flex: 0 0 auto;
  color: var(--muted); padding: .2rem .3rem; border-radius: 5px;
  display: flex; align-items: center; }
#fav-io { display: flex; gap: .7rem; margin-top: .65rem; padding-top: .55rem;
  border-top: 1px solid var(--border); }
.fav-io-btn { border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: .78rem; display: flex;
  align-items: center; gap: .32rem; padding: .25rem .4rem;
  border-radius: 5px; }
.fav-io-btn:hover { background: var(--code-bg); color: var(--fg); }
.fav-del:hover { background: var(--bg); color: var(--orange); }
#fav-star { position: absolute; top: .78rem; left: .75rem; border: none;
  background: none; padding: 0; font-size: 1.3rem; line-height: 1;
  cursor: pointer; color: var(--muted); }
#fav-star.faved { color: #eab308; }
/* observation-popup close button (MapLibre built-in), styled to match */
.maplibregl-popup-close-button { top: 2px; right: 4px; font-size: 1.15rem;
  line-height: 1; padding: 2px 5px; border-radius: 6px;
  color: var(--muted); }
.maplibregl-popup-close-button:hover { background: var(--code-bg);
  color: var(--fg); }
.sp-fit { color: var(--accent2); font-size: .68em; margin-left: .15rem;
  cursor: help; }
#fav-star:hover { transform: scale(1.15); }
#panel.pointmode #p-name { padding-left: 1.5rem; }

#panel {
  position: absolute; top: 96px; right: 12px; width: 330px; max-width: calc(100vw - 24px);
  max-height: calc(100% - 150px); overflow-y: auto; background: var(--card);
  border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem;
  box-shadow: 0 6px 24px rgba(0,0,0,.14); z-index: 20;
}
#panel.hidden { display: none; }
#panel-close { position: absolute; top: .4rem; right: .6rem; border: none;
  background: none; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
#panel h2 { margin: 0 1rem .3rem 0; font-size: 1.05rem; }
#p-name .p-sub { display: block; font-size: .78rem; font-weight: 400;
  color: var(--muted); margin-top: .12rem; }
#p-name .p-place { font-size: .72rem; font-style: italic; }
#p-name .p-place:empty { display: none; }
#panel h3 { margin: 1rem 0 .35rem; font-size: .82rem; color: var(--accent2);
  text-transform: uppercase; letter-spacing: .04em; }
#p-badges { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .6rem; }
.badge { font-size: .7rem; border: 1px solid var(--border); border-radius: 99px;
  padding: .1rem .5rem; color: var(--muted); }
.badge.warn { color: var(--orange); border-color: var(--orange); }
#p-score-row { display: flex; align-items: center; gap: .9rem; }
#p-score { font-size: 2.6rem; font-weight: 700; color: #4c1780; line-height: 1; }
#p-score-sub { font-size: .82rem; color: var(--muted); }
#p-rate { white-space: pre-line; }
#p-rate { color: var(--fg); cursor: help; }
#p-outlook { margin-top: .7rem; }
#p-outlook svg { display: block; width: 100%; height: auto; }
#p-why { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
#p-why li { padding: .18rem 0; border-bottom: 1px dashed var(--border); display: flex;
  justify-content: space-between; gap: .6rem; }
#p-why li:last-child { border-bottom: none; }
#p-why .v { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
#p-season { font-size: .82rem; color: var(--muted); }
#p-species { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
#p-species li { padding: .18rem 0; border-bottom: 1px dashed var(--border);
  display: flex; align-items: center; gap: .45rem; }
#p-species li:last-child { border-bottom: none; }
#p-species .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto;
  border: 1px solid var(--border); }
#p-species .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#p-species .val { color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
#p-sightings { list-style: none; margin: 0; padding: 0; font-size: .8rem; }
#p-sightings li { padding: .16rem 0; border-bottom: 1px dashed var(--border);
  display: flex; justify-content: space-between; gap: .5rem; }
#p-sightings li:last-child { border-bottom: none; }
#p-sightings .sp { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#p-sightings .sp.target { color: var(--accent); font-weight: 600; }
#p-sightings .sp-empty { color: var(--muted); white-space: normal;
  overflow-wrap: break-word; line-height: 1.4; }
#p-sightings .meta { color: var(--muted); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
#p-sightings a { color: inherit; text-decoration: none; }
#p-sightings a:hover { text-decoration: underline; }
#p-disclaimer { margin-top: .9rem; font-size: .75rem; background: var(--code-bg);
  border-left: 3px solid var(--orange); border-radius: 0 6px 6px 0; padding: .5rem .6rem; }

#status { position: absolute; left: 50%; transform: translateX(-50%); bottom: 44px;
  background: var(--card); border: 1px solid var(--border); border-radius: 99px;
  padding: .25rem .9rem; font-size: .8rem; color: var(--muted); z-index: 40;
  box-shadow: 0 2px 10px rgba(0,0,0,.10); }
#status.hidden { display: none; }

#attrib { padding: .25rem .9rem; font-size: .68rem; color: var(--muted);
  background: var(--card); border-top: 1px solid var(--border); }
#attrib a { color: var(--accent); }

.maplibregl-popup-content { font-family: inherit; font-size: .8rem; border-radius: 8px; }
.obs-pop { padding-right: 16px; }   /* keep first line clear of the × */
.obs-pop strong { font-size: .88rem; }
.obs-thumb { display: block; max-width: 100%; max-height: 150px; object-fit: cover;
  border-radius: 6px; margin-top: .4rem; }
