:root {
  --bg: #12140f;
  --panel: rgba(24, 27, 21, .93);
  --edge: #33382c;
  --ink: #eceadf;
  --muted: #9aa08c;
  --accent: #d97a2b;
  --accent-soft: rgba(217, 122, 43, .16);
  --radius: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
#map { position: absolute; inset: 0; }

.panel {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  width: 340px; max-height: calc(100% - 24px);
  display: flex; flex-direction: column;
  background: var(--panel); backdrop-filter: blur(14px);
  border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px; border-bottom: 1px solid var(--edge); }
.brand-text { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-button { background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.icon-button:hover { background: rgba(255,255,255,.06); color: var(--ink); }
.panel-body { overflow-y: auto; padding: 12px; display: grid; gap: 14px; }
.panel.collapsed .panel-body { display: none; }

.field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
select, input[type=text], input:not([type]) {
  width: 100%; padding: 8px 10px; font: inherit; font-size: 13px;
  color: var(--ink); background: #1d211a; border: 1px solid var(--edge); border-radius: 8px;
}
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.days button {
  padding: 6px 2px; font: inherit; font-size: 11px; line-height: 1.15; cursor: pointer;
  background: #1d211a; color: var(--muted); border: 1px solid var(--edge); border-radius: 7px;
}
.days button b { display: block; font-size: 13px; color: var(--ink); font-weight: 600; }
.days button[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.days button[aria-pressed=true] b { color: var(--accent); }

.species-card { font-size: 12px; border: 1px solid var(--edge); border-radius: 10px; padding: 10px; background: rgba(255,255,255,.02); }
.species-card h3 { margin: 0 0 2px; font-size: 13px; }
.species-card .latin { color: var(--muted); font-style: italic; font-size: 11px; margin: 0 0 8px; }
.species-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
.species-card dt { color: var(--muted); }
.species-card dd { margin: 0; }
.species-card .off { color: #c98; margin: 8px 0 0; }

.block h2 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.hint { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.45; }

.top-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; }
.top-list li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center;
  padding: 5px 6px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.top-list li:hover { background: rgba(255,255,255,.05); }
.top-list .rank { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 11px; }
.top-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-list .score { font-variant-numeric: tabular-nums; font-weight: 600; }

.legend-bar { height: 9px; border-radius: 5px;
  background: linear-gradient(90deg, #48544e, #687642, #9ea244, #ce942e, #e2792a, #c8451b, #a92e14); }
.legend-ticks { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 4px; }

.secondary, .primary {
  font: inherit; font-size: 12px; padding: 7px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--edge); background: #1d211a; color: var(--ink);
}
.primary { background: var(--accent); border-color: var(--accent); color: #1a1206; font-weight: 600; }
.secondary:hover { border-color: var(--muted); }

.sources { font-size: 10px; color: var(--muted); line-height: 1.5; border-top: 1px solid var(--edge); padding-top: 10px; }
.sources a { color: var(--muted); }

.map-tools { position: absolute; right: 12px; top: 12px; z-index: 3; display: grid; gap: 8px; justify-items: end; }
.switch { display: flex; background: var(--panel); border: 1px solid var(--edge); border-radius: 9px; overflow: hidden; box-shadow: var(--shadow); }
.switch button { font: inherit; font-size: 11px; padding: 6px 11px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.switch button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); }
.opacity { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 9px; padding: 5px 10px; box-shadow: var(--shadow); }
.opacity input { width: 96px; accent-color: var(--accent); }
.opacity output { font-variant-numeric: tabular-nums; width: 32px; text-align: right; }

/* Popup */
.maplibregl-popup-content { background: var(--panel); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 11px; padding: 12px; box-shadow: var(--shadow); font-size: 12px; max-width: 290px; }
.maplibregl-popup-tip { border-top-color: var(--panel) !important; border-bottom-color: var(--panel) !important; }
.pop h3 { margin: 0; font-size: 13px; }
.pop .place { color: var(--muted); font-size: 11px; margin: 1px 0 9px; }
.pop-score { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.pop-score .big { font-size: 25px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.pop-score .rate { font-size: 12px; }
.pop-score .advice { color: var(--muted); font-size: 11px; }
.bars { display: grid; gap: 4px; margin-bottom: 9px; }
.bar { display: grid; grid-template-columns: 62px 1fr 34px; gap: 7px; align-items: center; font-size: 11px; }
.bar .k { color: var(--muted); }
.bar .t { height: 5px; background: rgba(255,255,255,.09); border-radius: 3px; overflow: hidden; }
.bar .t i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.pop-facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 9px; font-size: 11px;
  border-top: 1px solid var(--edge); padding-top: 8px; margin-top: 2px; }
.pop-facts dt { color: var(--muted); }
.pop-facts dd { margin: 0; }
.pop-actions { display: flex; gap: 6px; margin-top: 10px; }
.pop-actions a, .pop-actions button { flex: 1; text-align: center; text-decoration: none;
  font: inherit; font-size: 11px; padding: 6px; border-radius: 7px; border: 1px solid var(--edge);
  background: #1d211a; color: var(--ink); cursor: pointer; }
.warn { color: #d9a44a; font-size: 11px; margin: 8px 0 0; }

dialog { background: var(--panel); color: var(--ink); border: 1px solid var(--edge);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; width: min(360px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin: 0 0 4px; font-size: 15px; }
#obsForm { display: grid; gap: 11px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 720px) {
  .panel { left: 8px; right: 8px; width: auto; top: 8px; max-height: 48%; }
  .map-tools { top: auto; bottom: 30px; right: 8px; left: 8px; justify-items: stretch; }
  .switch button { flex: 1; padding: 8px 6px; }
  .opacity { display: none; }
  .maplibregl-popup-content { max-height: 58vh; }
}

.limiting { margin: 9px 0 0; font-size: 11px; color: #d9c08a; }
.spark { margin-top: 9px; border-top: 1px solid var(--edge); padding-top: 8px; }
.spark-bars { display: flex; align-items: flex-end; gap: 5px; height: 40px; }
.spark-col { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1; justify-content: flex-end; }
.spark-col i { display: block; width: 100%; border-radius: 2px 2px 0 0; }
.spark-col em { font-style: normal; font-size: 9px; color: var(--muted); }
.spark .hint { margin-top: 6px; }
.maplibregl-popup-content { max-height: min(72vh, 620px); overflow-y: auto; }

.pop-detail { margin-top: 9px; border-top: 1px solid var(--edge); padding-top: 7px; }
.pop-detail summary { cursor: pointer; font-size: 11px; color: var(--muted); list-style: none; }
.pop-detail summary::-webkit-details-marker { display: none; }
.pop-detail summary::before { content: '＋ '; }
.pop-detail[open] summary::before { content: '－ '; }
.pop-detail .bars { margin-top: 7px; }

.banner { margin: 0; padding: 8px 10px; border-radius: 8px; font-size: 11px; line-height: 1.45;
  background: rgba(217, 164, 74, .12); border: 1px solid rgba(217, 164, 74, .35); color: #e2bd76; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { flex: 1; }
.check { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--accent); }
.switch.inline { border-radius: 8px; box-shadow: none; }
.switch.inline button { flex: 1; padding: 7px 10px; font-size: 12px; }
.top-list .meta { grid-column: 2 / -1; font-size: 10px; color: var(--muted); margin-top: -2px; }
.top-list li.rows { grid-template-columns: 18px 1fr auto; row-gap: 0; }
.spot-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; }
.spot-list li { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center;
  font-size: 12px; padding: 5px 6px; border-radius: 7px; cursor: pointer; }
.spot-list li:hover { background: rgba(255,255,255,.05); }
.spot-list .when { font-size: 10px; color: var(--muted); }
.spot-list button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 4px; }
.spot-list button:hover { color: #e08; }
.pop-nearby { margin-top: 9px; border-top: 1px solid var(--edge); padding-top: 8px; font-size: 11px; }
.pop-nearby h4 { margin: 0 0 4px; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.pop-nearby ul { margin: 0; padding-left: 15px; }
.pop-nearby li { margin-bottom: 2px; }

.recovery { margin-top: 10px; border-top: 1px solid var(--edge); padding-top: 8px; }
.recovery summary { cursor: pointer; font-size: 11px; color: var(--muted); list-style: none; }
.recovery summary::-webkit-details-marker { display: none; }
.recovery summary::before { content: '＋ '; }
.recovery[open] summary::before { content: '－ '; }
.recovery .hint { margin: 6px 0; }
.recovery .row-actions { margin-bottom: 6px; }
.recovery input { font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.recovery button { flex: 0 0 auto; }
