:root {
  --bg: #f7f5f0; --surface: #ffffff; --text: #23211c; --muted: #6b665c; --border: #ddd8cc;
  --accent: #8a5a2b; --accent-text: #ffffff; --ok: #2f6b3a; --err: #9b2c2c; --chip: #efe9dc;
  --radius: 8px; --gap: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1b1a17; --surface: #25231f; --text: #ece7dc; --muted: #a39d90; --border: #3a372f;
          --accent: #d39a5f; --accent-text: #1b1a17; --ok: #7fc28a; --err: #f08a8a; --chip: #322f28; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 0.2em 0 0.4em; } h2 { font-size: 1.15rem; margin: 1.4em 0 0.5em; }
.muted { color: var(--muted); } .small { font-size: 0.85rem; } i.tax { font-style: italic; } i.tax .q { font-style: normal; }

nav.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
nav.top .in { max-width: 1100px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 4px 14px; flex-wrap: wrap; align-items: center; }
nav.top a { text-decoration: none; color: var(--text); padding: 4px 0; }
nav.top a.brand { font-weight: 700; margin-right: auto; }
nav.top a.cta { background: var(--accent); color: var(--accent-text); padding: 4px 10px; border-radius: var(--radius); }
nav.top form { margin: 0; }

.flash { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 10px; background: var(--surface); border-left: 4px solid var(--ok); }
.flash.error { border-left-color: var(--err); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: var(--gap); }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.tile .ph { aspect-ratio: 1; overflow: hidden; background: var(--chip); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; }
.tile .meta { padding: 8px 10px; }
.tile .num { font-weight: 700; font-variant-numeric: tabular-nums; }

form.inline { display: inline; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 2px; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
textarea { min-height: 70px; }
.fields { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
button, .btn { display: inline-block; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--err); }
button.big { width: 100%; padding: 14px; font-size: 1.1rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }

.filters { display: grid; gap: 8px; grid-template-columns: 2fr repeat(4, 1fr) auto; align-items: end; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } .filters .q { grid-column: 1 / -1; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 9px; font-size: 0.8rem; }
.chip.warn { background: #f6e3b4; color: #5c4300; }
.chip.ok { background: #d6ecd9; color: #1f4d29; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }

/* site notes and documents */
.notes { overflow-wrap: break-word; }  /* long URLs in notes and guide sources must not widen the page on phones */
.notes > :first-child { margin-top: 0; }
.notes > :last-child { margin-bottom: 0; }
.notes h2 { font-size: 1.05rem; margin: 1em 0 0.4em; }
.notes ul { padding-left: 20px; }
.docs { display: grid; gap: 10px; }
.doc { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.doc:last-child { border-bottom: 0; padding-bottom: 0; }
details.inline-edit { display: inline-block; }
details.inline-edit[open] { display: block; width: 100%; }
details.inline-edit summary { cursor: pointer; color: var(--accent); }

/* maps */
main.full { max-width: none; padding: 0; }
main.full > .flash { margin: 8px 16px; }
.mapwrap { position: relative; }
#fullmap { width: 100%; min-height: 320px; }
.minimap { height: 320px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.leaflet-container { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
.leaflet-popup-content { color: #23211c; }
.leaflet-popup-content a { color: #8a5a2b; }
.site-pop { min-width: 200px; max-width: 280px; }
.site-pop > a { font-weight: 700; font-size: 1rem; }
.site-pop .links { margin: 6px 0; }
.site-pop button { margin-top: 4px; padding: 4px 10px; color: #23211c; background: #f3efe6; border: 1px solid #ccc; }
.site-pop .muted, .rockbox .muted { color: #6b665c; }
.warntext { color: #8a5a00; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.tiny { font-size: 0.75rem; }
.rockbox .rock { margin: 6px 0; padding-left: 18px; position: relative; }
.rockbox .swatch { position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 3px; background: #ccc; border: 1px solid #888; }
.site-name { background: rgba(255, 255, 255, 0.85); border: 0; box-shadow: none; padding: 1px 5px; font-size: 12px; font-weight: 600; color: #23211c; }
.site-name::before { display: none; }
.map-btn { width: 34px; height: 34px; border-radius: 4px; border: 2px solid rgba(0, 0, 0, 0.2); background: #fff; color: #23211c;
  font-size: 18px; line-height: 1; cursor: pointer; padding: 0; }
.map-panel { position: absolute; left: 10px; bottom: 28px; z-index: 1000; max-width: min(360px, calc(100% - 20px)); max-height: 60%;
  overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.map-panel summary { cursor: pointer; font-weight: 600; }
.map-panel ul.leads { margin: 0; padding-left: 18px; }
.leaflet-control-layers-overlays .dot { width: 9px; height: 9px; }

.photos { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.photo { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo .ctl { padding: 8px; font-size: 0.85rem; }
.photo .ctl form { margin: 4px 0; }
.pick { position: relative; }
.pick input[type=checkbox] { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; }
.pick img { aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.pick input:checked + img { outline: 4px solid var(--accent); }

/* identify page */
.strip { display: flex; gap: 8px; overflow-x: auto; margin-bottom: var(--gap); }
.strip img { height: 110px; width: 110px; object-fit: cover; border-radius: 6px; }
.layout-id { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.layout-id .id-form { position: sticky; top: 60px; }
@media (max-width: 860px) { .layout-id { grid-template-columns: 1fr; } .layout-id .id-form { position: static; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--gap); }
.chip-btn { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.85rem; cursor: pointer; }
.chip-btn span { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip-btn.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip-btn.on span { color: inherit; }
.cands { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.cand, .result { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.cand .sil, .result img, .result .sil-empty { flex: 0 0 56px; height: 56px; }
.cand .sil img, .result img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 6px; }
.cand .body, .result .body { flex: 1; min-width: 0; }
.cand .sp { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.results { display: grid; gap: 8px; margin-top: 10px; }
.result { align-items: center; }

.bignum { font-size: 2.6rem; font-weight: 800; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.saved { text-align: center; border: 2px solid var(--ok); }
.pager { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
/* Guides */
.search-row { display: flex; gap: 8px; align-items: center; margin-bottom: var(--gap); }
.search-row input { flex: 1; max-width: 420px; }
.guide-list { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.guide-card { display: flex; flex-direction: column; gap: 4px; margin: 0; color: inherit; text-decoration: none; }
.guide-card strong { color: var(--accent); }
.guide-card:hover, .guide-card:focus-visible { border-color: var(--accent); }
.lede { color: var(--muted); font-size: 1.05rem; margin: 0 0 var(--gap); max-width: 78ch; }
.article-layout { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 980px) {
  .article-layout.has-toc { grid-template-columns: 240px minmax(0, 1fr); }
  .article-layout .toc { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
}
.toc { margin: 0; font-size: 0.92rem; }
.toc ol { list-style: none; padding: 0; margin: 6px 0 0; }
.toc li { margin: 4px 0; }
.toc .toc-h3 { padding-left: 14px; font-size: 0.88rem; }
.article { margin: 0; line-height: 1.6; }
.article p, .article li, .article blockquote { max-width: 78ch; }
.article h2 { font-size: 1.15rem; margin: 1.4em 0 0.5em; scroll-margin-top: 12px; }
.article h3 { font-size: 1rem; margin: 1.2em 0 0.4em; scroll-margin-top: 12px; }
.article table { display: block; overflow-x: auto; font-size: 0.92rem; margin: 0.6em 0 1em; }
.article ol, .article ul { padding-left: 22px; }
.article code { font-size: 0.9em; background: var(--chip); padding: 0 3px; border-radius: 3px; }
.article blockquote { margin: 0.6em 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--muted); }
h2[id], h3[id] { scroll-margin-top: 12px; }
/* Images in notes and guides */
.figs { display: grid; gap: var(--gap); margin: 0.8em 0 1em; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.figs.one { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
.figs.one img { width: auto; max-width: 100%; max-height: 75vh; }  /* tall maps and sections stay on screen */
.figs figure { margin: 0; }
.figs img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.figs:not(.one) img { aspect-ratio: 4 / 3; object-fit: contain; }
.figs figcaption { font-size: 0.88rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.figs figcaption .credit { display: block; font-size: 0.8rem; opacity: 0.85; }
.missing-image { color: var(--err); font-size: 0.85rem; }
.thumbs { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.thumb code { font-size: 0.75rem; overflow-wrap: anywhere; }
.thumb > .small:first-of-type strong, .thumb > .small.muted:nth-of-type(2) {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
/* Progress */
.stats { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: var(--gap); }
.stat { display: flex; flex-direction: column; gap: 4px; margin: 0; color: inherit; text-decoration: none; }
.stat:hover, .stat:focus-visible { border-color: var(--accent); }
.stat-n { font-size: 1.8rem; font-weight: 600; line-height: 1.1; }
.bar { display: inline-block; vertical-align: middle; width: 100%; max-width: 220px; height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.steps td { vertical-align: middle; }
