:root {
  color-scheme: light;
  --ink: #243b32;
  --forest: #203c34;
  --paper: #f8f6ed;
  --muted: #5e695f;
  --line: #d6d6c8;
  --accent: #a3472e;
  --serif: Baskerville, "Iowan Old Style", Georgia, serif;
  --sans: "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, monospace;
  font: 15px/1.45 var(--sans);
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button { display: inline-flex; justify-content: center; align-items: center; gap: 7px; min-height: 37px; padding: 6px 13px; background: var(--paper); border: 1px solid #bdc3b4; border-radius: 4px; }
button:hover, select:hover { border-color: var(--ink); }
button:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid #ae532d; outline-offset: 2px; }
a { color: #345d4c; text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h2, h3 { font-family: var(--serif); font-weight: 500; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mast { display: flex; align-items: center; justify-content: space-between; height: 68px; padding: 0 26px; background: var(--forest); color: var(--paper); }
.brand, .mast-actions { display: flex; align-items: center; }
.brand { gap: 11px; }
.brand > .icon { height: 32px; width: 32px; color: #dfd6af; stroke-width: 1.35; }
.brand h1 { font: italic 600 36px/.95 var(--serif); letter-spacing: -.055em; }
.brand span { border-left: 1px solid #688074; margin-left: 6px; padding-left: 16px; color: #e0e5d9; font: 11px var(--mono); text-transform: uppercase; letter-spacing: .14em; }
.mast-actions { gap: 20px; }
#sync-status { font-size: 12px; color: #e0e5d9; }
#sync-status::before, .badge::before { content: ''; width: 6px; height: 6px; display: inline-block; vertical-align: 2px; border-radius: 50%; margin-right: 7px; background: #d3af78; }
#sync-status.online::before { background: #b1c493; }
.primary, .accent { background: var(--accent); border-color: var(--accent); color: white; font-weight: 600; }
.primary:hover, .accent:hover { background: #843d29; border-color: #843d29; }
#drop { font-size: 13px; padding-inline: 13px 16px; border-color: #c47856; background: #ac5237; }
#drop[aria-pressed=true] { background: #f5d2ab; color: var(--ink); }
main { display: grid; grid-template-columns: clamp(320px,29vw,406px) minmax(0,1fr); height: calc(100dvh - 68px); }
aside { min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid #7f9486; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #c6caba transparent; }
.index-head { padding: 30px 24px 0; border-bottom: 1px solid var(--line); }
.overline, .map-key, .north, #pin-location { font: 10px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.overline { color: #6b6958; }
.index-head h2 { font-size: clamp(35px,3.1vw,47px); line-height: 1.12; letter-spacing: -.045em; margin: 3px 0 21px; }
.search-box { border: 1px solid #b9beaf; border-radius: 4px; min-height: 43px; display: flex; align-items: center; padding: 0 12px; gap: 9px; background: #fffdf5; }
.search-box:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.search-box .icon { width: 17px; color: #657969; }
#search { border: 0; outline: 0; width: 100%; min-width: 0; background: transparent; font-size: 13px; min-height: 40px; }
#tabs { display: flex; gap: 20px; margin-top: 12px; }
#tabs button { min-height: 43px; padding: 0 0 2px; border: 0; background: transparent; border-radius: 0; color: var(--muted); font-size: 13px; position: relative; }
#tabs button[aria-pressed=true] { font-weight: 700; color: var(--ink); }
#tabs button[aria-pressed=true]::after { content: ''; background: var(--accent); height: 3px; position: absolute; inset: auto 0 -1px; }
.index-tools { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px 9px; gap: 10px; }
#status { color: var(--muted); font: 11px/1.4 var(--mono); text-transform: uppercase; letter-spacing: .07em; }
#filter-toggle { padding: 4px 9px; min-height: 30px; font-size: 12px; background: transparent; }
#filter-toggle .icon { width: 14px; height: 14px; }
#filter-toggle.applied, #filter-toggle[aria-expanded=true] { background: #e1e8da; color: #334d3d; border-color: #9aab94; }
#filters { background: #eeeee3; margin: 0 18px 9px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
#filters > label:first-child, dialog label, .confidence-edit label { display: grid; gap: 4px; font-weight: 600; }
#filters fieldset { border: 0; padding: 0; margin: 10px 0; display: flex; flex-wrap: wrap; column-gap: 9px; }
#filters legend { font-weight: 600; margin-bottom: 3px; padding: 0; }
#filters fieldset label, .check { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--forest); margin: 0; }
#results { padding: 0 24px; }
.result { width: 100%; display: grid; grid-template-columns: 35px 1fr 12px; gap: 11px; text-align: left; border: 0; border-top: 1px solid var(--line); border-radius: 0; padding: 13px 0; background: none; min-height: 66px; }
.result:hover { background: #efeee3; }
.row-text { min-width: 0; }
.row-text strong { display: block; font-size: 14px; line-height: 1.32; font-weight: 650; overflow-wrap: anywhere; }
.row-text small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.35; }
.result > .icon { width: 13px; height: 13px; color: #758271; }
.token { width: 35px; height: 35px; display: inline-grid; place-items: center; border-radius: 6px; border: 1px solid #cbd3c1; background: #e5ebde; color: #42634e; }
.token.vehicles { color: #71543f; background: #eee4d7; border-color: #d9cbb8; }
.token.collectibles { color: #735939; background: #f0e8d0; border-color: #dbcfad; }
.token.services { color: #476674; background: #e2ebea; border-color: #c5d4d3; }
.row-tags { display: flex; margin-top: 5px; gap: 8px; }
.badge { display: inline-flex; align-items: center; color: #57645b; font: 10px/1.4 var(--mono); letter-spacing: .02em; }
.badge::before { margin-right: 4px; width: 5px; height: 5px; background: currentColor; }
.badge.confirmed { color: #3e694a; }
.badge.rumor { color: #875b2b; }
.more { margin: 12px 0; width: 100%; }
.empty { padding: 26px 0; }
.empty h3 { font-size: 23px; margin: 6px 0; }
.empty p, footer { font-size: 12px; color: var(--muted); }
footer { margin-top: auto; padding: 18px 24px; }
footer details { border-top: 1px solid var(--line); padding-top: 11px; }
footer p { margin-top: 7px; }
.stage { position: relative; isolation: isolate; min-height: 0; overflow: hidden; }
#map { width: 100%; height: 100%; background: #91b6ad; }
#map.night { background: #020b1b; }
.stage::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 400; background-image: linear-gradient(#34574a0c 1px, transparent 1px),linear-gradient(90deg,#34574a0c 1px,transparent 1px); background-size: 96px 96px; }
.map-toolbar, .north, .map-key, .style-control, #placement { position: absolute; z-index: 550; }
.map-toolbar { top: 18px; left: 18px; }
.map-toolbar button, .style-control, .map-key { background: #f8f6ecf5; border: 1px solid #889d8f; box-shadow: 0 1px 4px #24473a16; border-radius: 4px; }
.map-toolbar button { font-size: 12px; }
.map-toolbar .icon, .style-control .icon { width: 15px; height: 15px; }
.north { right: 24px; top: 19px; display: grid; justify-items: center; gap: 1px; color: #28483f; pointer-events: none; }
.north .icon { width: 21px; height: 21px; fill: #28483f; }
.stage:has(.night) .north { color: white; }
.stage:has(.night) .north .icon { fill: white; }
.style-control { bottom: 25px; left: 18px; display: flex; align-items: center; padding: 0 7px 0 10px; }
.style-control select { background: transparent; border: none; min-height: 33px; font-size: 12px; padding: 3px 4px; width: auto; }
.map-key { bottom: 25px; left: 164px; display: flex; align-items: center; min-height: 35px; padding: 0 10px; gap: 13px; font-size: 9px; letter-spacing: .05em; }
.map-key span { display: inline-flex; align-items: center; gap: 5px; }
.map-key i { width: 18px; border-top: 2px solid #99705a; }
.map-key .rail { border-top: 1px dashed #817e6e; }
.place-name { text-align: center; white-space: nowrap; line-height: 1; color: #3d5045; pointer-events: none; }
.place-name span { font: italic 13px var(--serif); text-shadow: 0 1px 2px #fffbe7,1px 0 2px #fffbe7,-1px 0 2px #fffbe7; }
.place-name.major span { font: 600 16px var(--serif); letter-spacing: .025em; }
.night .place-name span { color: #fff8dd; text-shadow: 0 1px 3px black,1px 0 3px black; }
.leaflet-control-zoom.leaflet-bar { border: 1px solid #839887; box-shadow: none; margin: 0 18px 8px 0; overflow: hidden; }
.leaflet-control-zoom.leaflet-bar a { background: var(--paper); color: var(--forest); width: 34px; height: 34px; line-height: 34px; }
.leaflet-container .leaflet-control-attribution { background: #f8f6eac9; font: 10px/1.5 var(--sans); }
.leaflet-container .leaflet-control-attribution a { color: #34554a; }
.leaflet-tooltip { font: 12px var(--sans); color: var(--ink); border: 1px solid #899b89; background: var(--paper); }
.cluster, .pin-face { display: grid; place-items: center; border-radius: 50%; border: 2px solid #fff8e8; box-shadow: 0 1px 4px #243b3260; }
.cluster { background: var(--forest); color: white; font: 600 11px var(--mono); }
.pin-face { width: 100%; height: 100%; background: #9d4a33; color: #fff9e9; }
.pin-face .icon { width: 16px; height: 16px; }
.map-pin.selected .pin-face { outline: 3px solid #a3472e70; }
.map-pin.rumor .pin-face { border-style: dashed; background: #846833; }
.map-pin.found .pin-face { background: #556c57; }
#detail { padding: 16px 24px 8px; overflow-wrap: anywhere; }
.back { background: transparent; border: none; padding-left: 0; color: var(--muted); font-size: 13px; }
.back .icon { width: 16px; }
.place-nav { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.place-nav > span { color: var(--muted); font: 10px var(--mono); letter-spacing: .035em; }
.detail-head { margin: 18px 0 12px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: start; }
.place-kind { display: flex; align-items: center; gap: 6px; color: #7e4933; font: 600 11px/1.3 var(--sans); }
.place-kind .icon { width: 15px; height: 15px; }
.detail-head h2, dialog h2 { font-size: 31px; line-height: 1.05; letter-spacing: -.035em; }
.detail-head h2 { margin-top: 6px; text-wrap: pretty; }
.place-area { margin-top: 7px; line-height: 1.35; font-size: 13px; }
.place-stamp { display: block; width: 82px; aspect-ratio: 1; padding: 4px; background: #fffdf5; outline: 1px dashed #a9a591; outline-offset: -1px; transform: rotate(2deg); }
.place-stamp img, .stamp-chart { display: block; width: 100%; height: 100%; }
.stamp-chart { position: relative; background: #91b6ad url('/overview.webp') no-repeat; }
.stamp-chart::after { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 7px; height: 7px; border: 2px solid var(--paper); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.location-meta, .note-meta { font-size: 12px; color: var(--muted); }
.location-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.location-meta .badge { border: 1px solid #bfcbb8; border-radius: 3px; padding: 2px 5px; }
.place-actions, .place-sharing { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.place-actions button, .place-sharing button { font-size: 13px; padding-inline: 10px; }
.place-actions .icon { width: 15px; height: 15px; }
.place-actions .found-toggle { background: var(--forest); border-color: var(--forest); color: var(--paper); }
.place-actions .is-found { background: #dee8d6; border-color: #99af95; color: #304c35; }
.place-actions [aria-expanded=true], .place-sharing { background: #efeee3; }
.place-sharing { border-left: 2px solid #95aa98; padding: 8px; }
.rumor-tip, .evidence-copy { color: var(--muted); font-size: 13px; }
.notes h3 { scroll-margin-top: 10px; }
#detail > p, .pin-content { margin: 12px 0; line-height: 1.55; white-space: pre-wrap; }
#detail > a, .actions button, .notes form button, .confidence-edit { font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 15px 0; }
.confidence-edit, .notes { border-top: 1px solid var(--line); margin-top: 15px; padding-top: 13px; }
.notes h3 { font-size: 24px; margin-bottom: 6px; }
.notes form { display: grid; gap: 8px; margin-top: 8px; justify-items: start; }
.note { border-left: 2px solid #94ac8f; padding-left: 9px; margin: 8px 0; }
.note p { white-space: pre-wrap; }
textarea, select, input:not([type=checkbox]):not([type=search]) { width: 100%; padding: 8px; background: #fffdf7; border: 1px solid #b8bdae; border-radius: 4px; font-weight: 400; }
textarea { resize: vertical; }
dialog { width: min(430px,calc(100% - 28px)); max-height: 90dvh; overflow: auto; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 23px; }
dialog label, .confidence-edit label { font-size: 13px; margin: 10px 0; }
dialog h2 { margin: 4px 0 8px; }
dialog::backdrop { background: #142a23a6; }
#pin-error { color: var(--accent); }
#placement, #toast { background: var(--forest); color: white; border-radius: 4px; padding: 9px 12px; font-size: 13px; }
#placement { display: flex; align-items: center; gap: 12px; bottom: 76px; left: 18px; }
#placement button { color: var(--ink); }
#toast { z-index: 1100; position: fixed; bottom: 15px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 20px); }
.leaflet-container.dropmode, .dropmode .leaflet-interactive { cursor: crosshair; }
.dropmode .leaflet-marker-pane, .dropmode .leaflet-overlay-pane { pointer-events: none; }
.dropmode .leaflet-interactive { pointer-events: none !important; }
@media(max-width:720px) {
  .mast { height: 54px; padding: 0 14px; }
  .brand { gap: 7px; }
  .brand h1 { font-size: 30px; }
  .brand > .icon { width: 26px; height: 26px; }
  .brand span { padding-left: 10px; margin-left: 2px; font-size: 9px; }
  .mast-actions { gap: 7px; }
  #sync-status { font-size: 0; }
  #sync-status::before { margin: 0; }
  #drop { min-height: 34px; }
  main { height: calc(100dvh - 54px); grid-template-columns: 1fr; grid-template-rows: minmax(175px,42%) minmax(0,1fr); }
  .stage { grid-row: 1; }
  aside { grid-row: 2; border-right: 0; border-top: 1px solid #7f9486; }
  .index-head { padding: 14px 17px 0; }
  .index-head > .overline { display: none; }
  .index-head h2 { font-size: 30px; margin: 0 0 9px; }
  #tabs { margin-top: 2px; }
  #tabs button { min-height: 38px; }
  .index-tools { padding: 9px 17px; }
  #results { padding: 0 17px; }
  .result { padding: 10px 0; min-height: 54px; }
  #detail { padding: 8px 17px; }
  .detail-head { margin: 12px 0 9px; }
  .place-stamp { width: 68px; }
  .map-toolbar { left: 9px; top: 9px; }
  .north { top: 9px; right: 14px; }
  .map-key { display: none; }
  .style-control { bottom: 17px; left: 9px; }
  .leaflet-control-zoom.leaflet-bar { margin-right: 9px; margin-bottom: 4px; }
  #placement { left: 9px; bottom: 58px; }
  footer { padding-inline: 17px; }
}
.place-name span { position: absolute; transform: translateX(-50%); }
.place-name.landmark span { font: 11px/1.2 var(--sans); color: #526055; }
.night .place-name.landmark span { color: #fff8dd; }
#expand-map { display: none; }
@media(max-width:720px) {
  .map-toolbar { display: flex; gap: 5px; }
  #expand-map { display: inline-flex; }
  .map-expanded main { grid-template-rows: minmax(0,1fr); height: calc(100dvh - 54px); }
  .map-expanded aside { display: none; }
}

.notebook-tools { padding: 12px 24px 0; }
.notebook-tools p { font-size: 13px; color: var(--muted); }
.notebook-tools .actions { margin: 8px 0; }
@media(max-width:720px) { .notebook-tools { padding-inline: 17px; } }

/* Native controls get fast taps. Leaflet owns gestures only inside the map. */
button, summary, label, select, a { touch-action: manipulation; }
@media (pointer:coarse), (max-width:720px) {
  #search, #map-style, select, input:not([type=checkbox]), textarea { font-size: max(16px,1rem); }
  button, #drop, #tabs button, #filter-toggle, .map-toolbar button,
  .style-control select, #filters label:has(input[type=checkbox]), summary { min-height: 44px; }
  summary { align-content: center; }
  .leaflet-control-zoom.leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .map-pin::before, .cluster::before { content: ''; position: absolute; inset: -6px; }
  .mast { padding-left: max(14px,env(safe-area-inset-left)); padding-right: max(14px,env(safe-area-inset-right)); }
  aside { padding-bottom: env(safe-area-inset-bottom); scroll-padding-block: 12px; }
  .leaflet-bottom.leaflet-right { padding-right: env(safe-area-inset-right); }
  .map-key { display: none; }
  #toast { bottom: max(15px,env(safe-area-inset-bottom)); }
  dialog { overscroll-behavior: contain; padding-bottom: max(18px,env(safe-area-inset-bottom)); }
  .keyboard-open dialog { top: calc(var(--visible-top) + 8px); bottom: auto; max-height: calc(var(--visible-height) - 16px); margin-block: 0; }
  .keyboard-open #new-pin { scroll-padding-bottom: 72px; }
  .keyboard-open #pin-form .actions {
    position: sticky;
    bottom: 0;
    margin-bottom: 0;
    padding: 6px 0;
    background: var(--paper);
    border-top: 1px solid var(--line);
  }
}
@media(max-width:720px) {
  .mast { height: calc(54px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top); }
  main, .map-expanded main { height: calc(100dvh - 54px - env(safe-area-inset-top)); }
  .keyboard-open main { height: calc(var(--visible-height) - 54px - env(safe-area-inset-top)); }
  .keyboard-open .stage { visibility: hidden; }
  .keyboard-open:not(.map-expanded) main { grid-template-rows: 0 minmax(0,1fr); }
  .map-expanded .style-control { bottom: max(17px,env(safe-area-inset-bottom)); }
  #expand-map, .map-toolbar button { min-height: 44px; }
}
@media(max-height:460px) and (max-width:720px) {
  main { grid-template-rows: minmax(0,36%) minmax(0,1fr); }
}
@media(pointer:coarse) and (min-width:721px) {
  .keyboard-open main { height: calc(var(--visible-height) - 68px); }
  .index-head, #results, #detail { padding-left: max(24px,env(safe-area-inset-left)); }
}
