:root {
  --ink: #141b20; --panel: #1d272b; --ivory: #f0e5cd; --muted: #b8b7aa;
  --gold: #d6b77d; --teal: #79b4ad; --line: rgba(184, 183, 170, 0.18); --field: #182226;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Trebuchet MS", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; font-family: var(--sans); background: var(--ink); color: var(--ivory); }
h1, h2, h3 { font-family: var(--serif); }
a { color: var(--teal); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
button, select, input[type="search"] { min-height: 44px; font: inherit; color: var(--ivory); border-radius: 6px; }
button { cursor: pointer; padding: 0 14px; background: transparent; border: 1px solid rgba(214, 183, 125, 0.5); }
button:hover { border-color: var(--teal); }
select, input[type="search"] { width: 100%; padding: 0 10px; background: var(--field); border: 1px solid var(--line); }
select option { background: var(--panel); color: var(--ivory); } ::placeholder { color: var(--muted); }
.masthead { flex: 0 0 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px; background: linear-gradient(180deg, #243036, var(--panel)); border-bottom: 1px solid rgba(214, 183, 125, 0.32); }
.masthead h1 { margin: 0; font-size: 1.34rem; letter-spacing: 0.02em; }
.kicker { margin: 2px 0 0; font-size: 0.7rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--gold); }
#toggleSidebar { flex: 0 0 auto; }
.workspace { flex: 1; display: flex; min-height: 0; position: relative; }
#sidebar { flex: 0 0 336px; display: flex; flex-direction: column; gap: 12px; min-height: 0; padding: 16px; overflow-y: auto; border-right: 1px solid var(--line); background: repeating-linear-gradient(0deg, transparent 0 27px, rgba(240, 229, 205, 0.04) 27px 28px), var(--panel); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .side-heading { margin: 0; font-family: var(--sans); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
#progressSummary { min-height: 1.4em; font-size: 0.92rem; color: var(--muted); }
progress { width: 100%; height: 8px; accent-color: var(--gold); }
.filter-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.filter-actions { display: flex; gap: 6px; } .filter-actions button { font-size: 0.82rem; padding: 0 10px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); }
#categoryFilters h2 { margin: 18px 0 6px; font-family: var(--sans); font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.category-option { display: grid; grid-template-columns: 18px 18px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 44px; cursor: pointer; font-size: 13px; }
.category-option input { width: 17px; height: 17px; accent-color: var(--gold); }
.category-symbol { text-align: center; }
.category-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
#resultSummary { font-size: 0.85rem; color: var(--muted); }
#searchResults { list-style: none; margin: 0; padding: 0; }
#searchResults li { border-top: 1px solid var(--line); }
#searchResults button { display: flex; flex-direction: column; gap: 3px; width: 100%; min-height: 48px; padding: 8px 10px; text-align: left; border: 0; border-radius: 0; }
#searchResults button span { line-height: 1.35; }
#searchResults button small { font-size: 11px; color: var(--muted); }
#searchResults:empty, #resultSummary:empty, #categoryFilters:empty, #mapCaption:empty, #mapLoading:empty, #notice:empty { display: none; }
.progress-tools { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.progress-tools > * { flex: 1 1 auto; }
.progress-tools button { font-size: 0.82rem; padding: 0 10px; }
.import-button { display: inline-flex; align-items: center; justify-content: center; position: relative; min-height: 44px; padding: 0 10px; text-align: center; font-size: 0.82rem; border: 1px solid rgba(214, 183, 125, 0.5); border-radius: 6px; cursor: pointer; }
.import-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-button:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.map-stage { flex: 1; min-width: 0; min-height: 0; position: relative; }
#map { height: 100%; min-height: 0; background: #0d1316; }
#mapLoading { position: absolute; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 1.05rem; letter-spacing: 0.1em; color: var(--muted); background: var(--ink); }
#mapCaption { position: absolute; left: 14px; bottom: 12px; z-index: 500; max-width: calc(100% - 28px); padding: 4px 10px; font-size: 0.76rem; color: var(--muted); background: rgba(20, 27, 32, 0.85); border: 1px solid var(--line); border-radius: 6px; pointer-events: none; }
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--ivory); border: 1px solid rgba(214, 183, 125, 0.45); border-radius: 8px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 12px 14px; font-family: var(--sans); }
.map-popup h3 { margin: 0 0 4px; font-size: 1.02rem; }
.map-popup p { margin: 0 0 10px; font-size: 0.86rem; line-height: 1.45; color: var(--muted); }
.map-popup a { color: var(--teal); }
.popup-category { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold); }
.popup-source { display: inline-block; margin-top: 10px; font-size: 12px; }
.map-popup-stack { max-height: 340px; overflow-y: auto; padding-right: 4px; }
.map-popup-stack .map-popup + .map-popup { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.map-popup.is-focused { outline: 1px solid var(--gold); outline-offset: 3px; }
.marker-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 2px solid var(--ink); border-radius: 50%; background: var(--marker-color, var(--gold)); color: #10191b; font-size: 13px; font-weight: bold; line-height: 1; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65); }
.marker-icon.is-collected { background: var(--teal); opacity: 0.55; }
.marker-label { position: absolute; left: calc(100% + 7px); top: 50%; transform: translateY(-50%); display: none; padding: 3px 6px; font-size: 11px; white-space: nowrap; color: var(--ivory); background: rgba(10, 16, 18, 0.92); border-radius: 3px; pointer-events: none; }
.show-labels .marker-label { display: block; }
.collect-button { width: 100%; border-color: var(--teal); color: var(--teal); }
.collect-button.is-collected { background: rgba(121, 180, 173, 0.18); color: var(--ivory); }
dialog { width: calc(100vw - 32px); max-width: 460px; padding: 22px; background: var(--panel); color: var(--ivory); border: 1px solid var(--gold); border-radius: 10px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65); }
dialog::backdrop { background: #0a0e10; }
dialog h2 { margin: 0 0 10px; font-size: 1.24rem; }
dialog p { margin: 0 0 12px; font-size: 0.92rem; line-height: 1.5; color: var(--muted); }
.source-links a { color: var(--teal); } #closeAbout { margin-top: 16px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dialog-actions button { flex: 1 1 auto; font-size: 0.84rem; }
#notice { position: fixed; right: 16px; bottom: 16px; z-index: 1300; max-width: min(360px, calc(100vw - 32px)); padding: 10px 14px; font-size: 0.9rem; background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity 0.15s ease, transform 0.15s ease; }
#notice.visible { opacity: 1; transform: none; }
.popup-items { list-style: none; padding: 0; margin: 6px 0; }
.popup-items a { display: block; min-height: 32px; padding: 6px 0; font-size: 12px; line-height: 1.3; }
.map-popup details summary { cursor: pointer; padding: 8px 0; color: var(--muted); font-size: 12px; }
.leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; background: var(--panel); color: var(--ivory); border-color: var(--line); }
.leaflet-control-zoom a:hover { background: var(--field); color: var(--gold); }
@media (min-width: 761px) {
  body.sidebar-closed #sidebar { display: none; }
}
@media (max-width: 760px) {
  #sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 1100; width: 336px; max-width: calc(100vw - 48px); box-shadow: 16px 0 44px rgba(0, 0, 0, 0.55); transition: transform 0.2s ease; }
  body.sidebar-closed #sidebar { transform: translateX(-104%); visibility: hidden; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

#inventoryList { max-height: 55vh; overflow-y: auto; margin-bottom: 16px; }
.inventory-entry { border-bottom: 1px solid var(--line); padding: 14px 3px; }
.inventory-entry h3 { margin: 0 0 8px; font-size: 1.05rem; }
.inventory-entry p { color: var(--muted); font-size: .9rem; }
