@font-face {
  font-family: "Roboto Slab";
  src: url("assets/fonts/roboto-slab-latin-900.ttf") format("truetype");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root, html[data-theme="dark"] {
  color-scheme: dark;
  --explorer-accent: #500000;
  --bg: #181818;
  --bg-2: #202020;
  --surface: #202020;
  --surface-raised: #2b2b2b;
  --input-bg: #242424;
  --text: #f5f5f5;
  --muted: #bcbcbc;
  --border: #737373;
  --border-soft: #424242;
  --photo-bg: #333333;
  --map-bg: #292929;
  --accent: var(--explorer-accent);
  --accent-ink: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Roboto Slab", Rockwell, Georgia, serif;
}
html[data-theme="light"] {
  color-scheme: light;
  --explorer-accent: #500000;
  --bg: #fafafa;
  --bg-2: #eeeeee;
  --surface: #ffffff;
  --surface-raised: #eeeeee;
  --input-bg: #ffffff;
  --text: #202020;
  --muted: #595959;
  --border: #898989;
  --border-soft: #d4d4d4;
  --photo-bg: #e5e5e5;
  --map-bg: #e5e5e5;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { width: 100%; min-width: 0; max-width: 100%; overflow-x: clip; background: var(--bg); -webkit-text-size-adjust: 100%; }
body { width: 100%; min-width: 0; max-width: 100%; overflow-x: clip; margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, input, select, textarea, a { -webkit-tap-highlight-color: transparent; }
button, select, summary { touch-action: manipulation; }
button, .btn { min-width: 44px; min-height: 44px; border: 1px solid transparent; border-radius: 4px; padding: 9px 14px; background: transparent; color: var(--text); font-weight: 600; line-height: 1.3; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
button:hover, .btn:hover { background: var(--surface-raised); }
button:disabled, input:disabled, select:disabled, .btn[aria-disabled="true"] { color: var(--muted); background: var(--bg-2); border-color: var(--border-soft); cursor: not-allowed; opacity: .65; }
input, select, textarea { min-width: 0; max-width: 100%; min-height: 44px; border: 1px solid var(--border-soft); border-radius: 4px; background: var(--input-bg); padding: 9px 12px; font-size: 16px; }
input:hover, select:hover, textarea:hover { border-color: var(--border); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
::selection { background: var(--explorer-accent); color: #ffffff; }
img { max-width: 100%; }
figure { margin: 0; }
h1, h2, h3, p { margin: 0 0 12px; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-family: var(--display); font-weight: 900; letter-spacing: .015em; text-transform: uppercase; }
.place-card h3, .place-card h2, #detail h2 { font-family: var(--font); font-weight: 700; letter-spacing: -.025em; }
.sr-only, .visually-hidden, .field > span { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* The shell reserves the workspace; only the results region scrolls. */
#app { width: 100%; max-width: 100%; min-width: 0; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.app-header { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 24px; border-bottom: 1px solid var(--border-soft); }
.brand { flex: 1 1 0; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.brand h1 { margin: 0; font-size: 36px; line-height: 1; }
.brand h1 span { color: inherit; }
.eyebrow { margin: 0 0 5px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.header-actions { display: flex; flex: 0 1 auto; min-width: 0; max-width: 100%; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.header-actions > button { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.header-actions button { font-size: 13px; font-weight: 500; color: var(--muted); }
.header-actions button:hover { color: var(--text); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-raised); color: var(--text); }
.explorer { min-width: 0; max-width: 100%; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); }
.intro { display: none; }
.filters { min-width: 0; max-width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 160px) minmax(0, 2fr); gap: 16px; padding: 20px 24px 0; align-items: end; }
.filter-controls { display: contents; }
.field { min-width: 0; max-width: 100%; display: block; }
.field input, .field select { width: 100%; height: 44px; }
.category-filter { min-width: 0; max-width: 100%; }
.category-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; min-width: 0; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.category-scroll-hint { margin-left: auto; }
.category-ribbon { width: 100%; min-width: 0; max-width: 100%; display: flex; gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; padding: 0 0 4px; scroll-padding-inline: 4px; scrollbar-width: thin; scrollbar-color: var(--border) var(--bg-2); }
.category-chip, #categories button { flex: 0 0 auto; min-height: 44px; padding: 10px 12px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; }
#categories button:hover { background: var(--surface-raised); color: var(--text); }
.category-dot, .chip-dot { display: none; }
#categories button::before, #categories button::after { display: none; }
.explorer-toolbar { min-width: 0; max-width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 24px; }
.result-count { min-width: 0; margin: 0; color: var(--muted); font-size: 13px; }
.view-tabs { min-width: 0; max-width: 100%; display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 6px; background: var(--bg-2); }
.view-tabs button { min-width: 72px; font-size: 13px; border-color: transparent; background: transparent; color: var(--muted); }
.view-tabs button:hover { background: var(--surface-raised); color: var(--text); }
button.active, #categories button.active, #categories button[aria-pressed="true"], .view-tabs button[aria-pressed="true"], .btn.primary, button.primary { background: var(--explorer-accent); color: #ffffff; border-color: transparent; }
#categories button[aria-pressed="true"], .view-tabs button[aria-pressed="true"] { font-weight: 700; }
.btn:not(.ghost) { border-color: var(--border-soft); background: var(--surface-raised); }
.btn.primary { background: var(--explorer-accent); color: #ffffff; border-color: transparent; }
.workspace { min-width: 0; max-width: 100%; min-height: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); border-top: 1px solid var(--border-soft); }
#discovery-panel { min-width: 0; max-width: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--border-soft); }
.place-list { min-width: 0; max-width: 100%; display: grid; gap: 18px; padding: 18px; align-content: start; }
#map-panel { position: relative; min-width: 0; max-width: 100%; min-height: 0; display: flex; background: var(--map-bg); }
#map { flex: 1; width: 100%; max-width: 100%; min-width: 0; min-height: 0; height: 100%; z-index: 0; }
.map-status { position: absolute; z-index: 500; bottom: 30px; left: 12px; max-width: calc(100% - 24px); margin: 0; padding: 6px 10px; border: 1px solid var(--border-soft); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 12px; pointer-events: none; }
.map-status:empty { display: none; }
.map-status button, .map-status a { pointer-events: auto; }
body[data-view="list"] .workspace, body[data-view="saved"] .workspace { grid-template-columns: minmax(0, 1fr); }
body[data-view="list"] #map-panel, body[data-view="saved"] #map-panel { display: none; }
body[data-view="list"] #discovery-panel, body[data-view="saved"] #discovery-panel { border-right: 0; }
body[data-view="list"] .place-list, body[data-view="saved"] .place-list { grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }

.place-card { position: relative; min-width: 0; border: 0; border-radius: 4px; background: var(--surface); overflow: hidden; }
.place-card.selected, .place-card.is-selected { border-color: var(--border); outline: 2px solid var(--explorer-accent); outline-offset: -2px; }
.card-open { display: block; width: 100%; min-width: 0; padding: 0; border: 0; border-radius: 0; background: transparent; text-align: left; font-weight: 400; }
.card-open:hover { background: var(--surface-raised); }
.card-photo { display: block; width: 100%; height: 180px; object-fit: cover; background: var(--photo-bg); }
.card-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-body { display: block; }
.place-list { list-style: none; margin: 0; }
.card-body > .card-meta, .card-body > .card-description { display: block; }
.place-card > .save-button { position: absolute; top: 12px; right: 12px; }
.card-copy, .card-body, .card-content { min-width: 0; padding: 14px; }
.card-open.photo-free { display: block; }
.photo-free .card-body { display: block; padding-right: 68px; }
.pin-note { display: block; margin-top: 8px; }
.place-card h3, .place-card h2 { margin-bottom: 6px; font-size: 20px; line-height: 1.25; color: var(--text); }
.card-meta, .card-area, .card-distance, .photo-caption, .photo-credit { color: var(--muted); font-size: 12px; line-height: 1.4; }
.card-description, .card-summary { margin: 8px 0 0; color: var(--muted); font-size: 14px; font-weight: 400; }
.photo-caption { padding: 7px 10px; background: var(--surface); }
.photo-caption a { color: inherit; }
.card-footer, .card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 14px 12px; }
.category-badge, .card-category, .detail-category, .place-card [style*="--category"], .place-card [style*="--cat"] { color: var(--text) !important; background: var(--bg-2) !important; border-color: var(--border-soft) !important; }
.category-badge, .card-category, .detail-category { display: inline-block; padding: 3px 6px; border: 1px solid var(--border-soft); border-radius: 2px; font-size: 12px; font-weight: 600; }
.save-button { min-width: 44px; min-height: 44px; border: 1px solid transparent; border-radius: 4px; background: var(--surface) !important; color: var(--text) !important; }
.save-button:hover { border-color: var(--border-soft); }
.save-button.saved, .save-button.is-saved, .save-button[aria-pressed="true"] { background: var(--explorer-accent) !important; color: #ffffff !important; border-color: transparent !important; }
.empty-state { grid-column: 1 / -1; padding: 36px 20px; border: 1px solid var(--border-soft); border-radius: 4px; background: var(--surface); color: var(--muted); text-align: center; }
.empty-state h2, .empty-state h3 { color: var(--text); font-size: 20px; }
.empty-state p { max-width: 48ch; margin: 0 auto 16px; }

/* Bounded sheets retain their close controls while content scrolls. */
dialog { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0; width: min(720px, calc(100% - 48px)); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow-y: auto; overscroll-behavior: contain; }
dialog::backdrop { background: rgb(0 0 0 / 70%); }
dialog:not([open]) { display: none; }
#detail > .dialog-close { position: sticky; top: 0; z-index: 3; display: flex; margin: 0 0 0 auto; border-radius: 0 0 0 4px; background: var(--surface); }
.dialog-header { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border-soft); background: var(--surface); }
.dialog-header h2 { margin: 0; font-size: 20px; }
.dialog-header .dialog-close { flex: 0 0 auto; }
.detail-body, .about-content { padding: 20px; }
.detail-photo { display: block; width: 100%; background: var(--photo-bg); border-radius: 4px; overflow: hidden; }
.detail-photo img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.detail-photo figcaption { padding: 10px 12px; color: var(--muted); font-size: 12px; }
.detail-body figure { margin-bottom: 20px; }
#detail h2 { margin: 16px 0 12px; font-size: 30px; }
.detail-meta, .detail-area, .detail-tagline { color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-grid h3, .detail-body h3 { margin-top: 20px; font-size: 16px; }
.detail-body ul, .about-content ul { padding-left: 20px; }
.about-content h3 { margin-top: 24px; font-size: 17px; }
.about-content small, .detail-source, .detail-note { color: var(--muted); }

/* Local map chrome shares the shell palette, including injected map styles. */
#map.howdy-map {
  --explorer-map-bg: var(--map-bg);
  --explorer-map-surface: var(--surface);
  --explorer-map-text: var(--text);
  --explorer-map-muted: var(--muted);
  --explorer-map-accent: var(--explorer-accent);
  --explorer-map-border: var(--border);
  background: var(--map-bg);
  font-family: var(--font);
}
#map .explorer-basemap-pane { filter: none; }
#map .explorer-basemap-pane .leaflet-tile, #map .leaflet-tile-pane .leaflet-tile { filter: grayscale(1); }
html[data-theme="dark"] #map .explorer-basemap-pane .leaflet-tile,
html[data-theme="dark"] #map .leaflet-tile-pane .leaflet-tile { filter: grayscale(1) invert(.88) brightness(.8); }
#map .pin, #map .explorer-photo-marker .pin { width: 44px; height: 44px; border: 2px solid var(--border); border-radius: 4px; background: var(--surface); box-shadow: none; }
#map .explorer-pin-image { width: 36px; height: 36px; min-width: 36px; border-radius: 2px; }
#map .pin-selected, #map .explorer-photo-marker .pin-selected { border-color: #ffffff; outline: 3px solid var(--explorer-accent); outline-offset: 1px; box-shadow: none; }
#map .pin::after, #map .explorer-photo-marker .pin::after { border-top-color: var(--border); }
#map .explorer-cluster, #map .explorer-cluster-marker button { min-width: 44px; min-height: 44px; background: var(--explorer-accent); color: #ffffff; border: 1px solid var(--border); border-radius: 4px; box-shadow: none; }
#map .leaflet-bar, #map .leaflet-control, #map .leaflet-popup-content-wrapper, #map .leaflet-popup-tip { box-shadow: none; }
#map .leaflet-bar { border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
#map .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; background: var(--surface); color: var(--text); border-color: var(--border-soft); }
#map .leaflet-bar a:hover { background: var(--surface-raised); }
#map .leaflet-bar a.leaflet-disabled { color: var(--muted); background: var(--bg-2); }
#map.howdy-map .leaflet-control-attribution { padding: 2px 6px; max-width: 100%; background: var(--surface); color: var(--muted); font: 12px/1.5 var(--font); }
#map .leaflet-control-attribution a { color: var(--text); }
#map.howdy-map .explorer-pin-initials { font-size: 12px; }
#map .leaflet-popup-content-wrapper, #map .leaflet-popup-tip { background: var(--surface); color: var(--text); border-radius: 4px; }
#map .leaflet-popup-close-button { width: 44px; height: 44px; padding-top: 10px; color: var(--text); }
#map button { border-radius: 4px; box-shadow: none; font-family: var(--font); }
#map :focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }

@media (max-width: 959px) {
  .app-header { gap: 8px; padding: 10px 12px; }
  .brand h1 { font-size: clamp(24px, 4.7vw, 32px); }
  .brand .eyebrow { display: none; }
  .header-actions { gap: 4px; }
  .header-actions button { padding: 8px; font-size: 12px; }
  #about-open { max-width: 76px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 130px); gap: 8px; padding: 10px 12px 0; }
  .search-field { grid-column: 1; }
  .area-field { grid-column: 2; }
  .category-filter { grid-column: 1 / -1; }
  .explorer-toolbar { padding: 8px 12px; gap: 8px; }
  .result-count { font-size: 12px; }
  .view-tabs { gap: 2px; padding: 3px; flex-shrink: 0; }
  .view-tabs button { min-width: 52px; padding: 9px 10px; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  body[data-view="map"] #discovery-panel { display: none; }
  #discovery-panel { border-right: 0; }
  .place-list, body[data-view="list"] .place-list, body[data-view="saved"] .place-list { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 12px; }
  .place-card { border: 0; border-bottom: 1px solid var(--border-soft); border-radius: 0; padding: 12px 52px 12px 0; min-height: 108px; overflow: visible; background: transparent; }
  .card-open { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: start; gap: 12px; }
  .card-photo { width: 100px; height: 84px; border-radius: 4px; }
  .card-copy, .card-body, .card-content { padding: 0; }
  .place-card h3, .place-card h2 { font-size: 17px; line-height: 1.3; margin-bottom: 4px; overflow-wrap: anywhere; }
  .card-description, .card-summary { display: none; }
  .place-card .photo-caption { display: none; }
  .photo-free .card-body { padding: 0; }
  .photo-free .card-summary { display: block; }
  .card-meta { margin: 0; font-size: 12px; }
  .card-footer, .card-actions { padding: 0; }
  .place-card .save-button { position: absolute; top: 12px; right: 0; width: 44px; padding: 4px; font-size: 12px; overflow-wrap: anywhere; }
  dialog { width: calc(100% - 16px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); margin: auto auto max(8px, env(safe-area-inset-bottom)); border-radius: 6px 6px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .detail-body, .about-content { padding: 16px; }
  .dialog-header { padding: 10px 16px; }
  #detail h2 { font-size: 25px; }
  .detail-photo img { max-height: 280px; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 359px) {
  .brand h1 { max-width: 130px; font-size: 24px; }
  .header-actions button { font-size: 12px; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 116px); }
  .view-tabs button { min-width: 44px; padding: 8px; }
  .card-open { grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
  .card-photo { width: 84px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  button, .place-card, dialog, #map .pin { border: 1px solid CanvasText; }
}
