:root {
  --ink: #17221f;
  --ink-soft: #52605b;
  --paper: #f7f5ef;
  --panel: #fffdf8;
  --line: #dcd8cc;
  --accent: #d7a928;
  --accent-dark: #8f6710;
  --focus: #246b8e;
  --tier-1: #701f35;
  --tier-2: #b94d43;
  --tier-3: #e49a45;
  --tier-4: #e6dcc8;
  --not-scored: #aab0ad;
  --shadow: 0 18px 50px rgb(18 31 27 / 14%);
  color-scheme: light;
  font-family: Inter, Aptos, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); overflow: hidden; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }

.skip-link {
  position: fixed; z-index: 1000; left: 1rem; top: -5rem; padding: .65rem 1rem;
  background: white; border: 2px solid var(--focus); border-radius: .35rem;
}
.skip-link:focus { top: 1rem; }

.app-shell { display: grid; grid-template-columns: 370px minmax(0, 1fr); height: 100%; min-height: 640px; }
.sidebar {
  position: relative; z-index: 6; height: 100%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel); border-right: 1px solid var(--line); box-shadow: 8px 0 30px rgb(16 29 25 / 6%);
}
.brand-block { padding: 1.35rem 1.5rem 1.2rem; background: var(--ink); color: white; }
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; font-weight: 760; letter-spacing: .01em; }
.brand-mark {
  display: grid; place-items: center; width: 1.85rem; height: 1.85rem; border: 1px solid rgb(255 255 255 / 48%);
  color: var(--ink); background: var(--accent); border-radius: 50%; font-family: Georgia, serif; font-size: 1.05rem;
}
.eyebrow { margin: 1.2rem 0 .3rem; color: var(--accent-dark); font-size: .69rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.brand-block .eyebrow { color: #efd36e; }
h1 { margin: 0; max-width: 310px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.75rem, 3vw, 2.2rem); line-height: 1.03; font-weight: 500; }
h1 span { color: var(--accent); white-space: nowrap; }
.lede { margin: .8rem 0 0; color: #dce5e1; font-size: .86rem; line-height: 1.52; }

.control-section, .summary-section, .details-section, .method-section, .sidebar-footer { padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); }
.control-section h2, .summary-section h2, .details-section h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.22rem; font-weight: 600; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.text-button { border: 0; padding: .2rem; background: none; color: var(--accent-dark); font-size: .78rem; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.field-label { display: block; margin: .8rem 0 .32rem; color: #394640; font-size: .72rem; font-weight: 760; }
.field-help { margin: .35rem 0 0; color: var(--ink-soft); font-size: .68rem; line-height: 1.38; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
select, input[type="search"] {
  width: 100%; min-height: 2.55rem; border: 1px solid #c9c5ba; border-radius: .4rem; background: white;
  color: var(--ink); padding: .52rem .7rem; font-size: .77rem; outline: none;
}
select { padding-right: 1.8rem; }
select:focus, input:focus, button:focus-visible, a:focus-visible { box-shadow: 0 0 0 3px rgb(36 107 142 / 23%); border-color: var(--focus); outline: none; }
select:disabled { background: #efede7; color: #858b88; cursor: not-allowed; }
.search-row { display: grid; grid-template-columns: 1fr 2.55rem; gap: .4rem; }
.icon-button {
  display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border: 1px solid var(--ink); border-radius: .4rem;
  background: var(--ink); color: white;
}
.icon-button svg { width: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-button.subtle { width: 2rem; height: 2rem; border-color: var(--line); background: white; color: var(--ink); font-size: 1.35rem; }
.search-results {
  position: absolute; z-index: 20; left: 1.5rem; right: 1.5rem; max-height: 15rem; overflow-y: auto;
  margin-top: .25rem; border: 1px solid #c9c5ba; border-radius: .4rem; background: white; box-shadow: var(--shadow);
}
.search-result { width: 100%; border: 0; border-bottom: 1px solid #ebe7dc; background: white; padding: .62rem .75rem; text-align: left; }
.search-result:hover, .search-result[aria-selected="true"] { background: #f3efe2; }
.search-result strong { display: block; color: var(--ink); font-size: .78rem; }
.search-result span { display: block; margin-top: .14rem; color: var(--ink-soft); font-size: .68rem; }
.search-empty { padding: .75rem; color: var(--ink-soft); font-size: .72rem; }

.summary-section .eyebrow, .details-section .eyebrow { margin-top: 0; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-top: .75rem; }
.stat-grid article { min-height: 4.3rem; padding: .62rem; border: 1px solid var(--line); border-radius: .45rem; background: #faf8f1; }
.stat-grid span { display: block; min-height: 1.8rem; color: var(--ink-soft); font-size: .64rem; line-height: 1.25; }
.stat-grid strong { display: block; font-family: Georgia, serif; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.summary-note { margin: .6rem 0 0; color: var(--ink-soft); font-size: .66rem; line-height: 1.4; }

.details-section { background: #fff9e9; }
.tract-location { margin: .3rem 0 .65rem; color: var(--ink-soft); font-size: .75rem; }
.priority-badge { display: inline-flex; align-items: center; gap: .35rem; margin-bottom: .55rem; padding: .28rem .5rem; border-radius: 999px; color: white; font-size: .67rem; font-weight: 800; }
.priority-badge::before { content: ""; width: .43rem; height: .43rem; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 2px rgb(255 255 255 / 45%); }
.metric-list { display: grid; grid-template-columns: 1fr auto; gap: .3rem .7rem; margin: 0; font-size: .71rem; }
.metric-list dt { color: var(--ink-soft); }
.metric-list dd { margin: 0; font-weight: 760; font-variant-numeric: tabular-nums; }
.reliability-note { margin: .65rem 0 0; padding-top: .55rem; border-top: 1px solid #e9d9a8; color: #655c42; font-size: .66rem; line-height: 1.4; }

.method-section { padding-top: .85rem; padding-bottom: .85rem; }
.method-section summary { cursor: pointer; color: #394640; font-size: .75rem; font-weight: 800; }
.method-copy { margin-top: .7rem; color: var(--ink-soft); font-size: .69rem; line-height: 1.52; }
.method-copy p { margin: 0 0 .6rem; }
.sidebar-footer { border-bottom: 0; }
.footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.45rem; border-radius: .38rem; padding: .5rem .65rem; font-size: .72rem; font-weight: 800; text-decoration: none; }
.button.primary { border: 1px solid var(--ink); background: var(--ink); color: white; }
.button.secondary { border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.sidebar-footer > p { margin: .7rem 0 0; color: var(--ink-soft); font-size: .65rem; text-align: center; }

.map-panel { position: relative; min-width: 0; height: 100%; background: #e9e8e2; }
#map { position: absolute; inset: 0; }
.map-status, .error-panel {
  position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center;
  gap: .6rem; max-width: min(90%, 480px); padding: .75rem 1rem; border: 1px solid rgb(23 34 31 / 18%); border-radius: .5rem;
  background: rgb(255 253 248 / 94%); box-shadow: var(--shadow); color: var(--ink); font-size: .76rem;
}
.spinner { width: 1rem; height: 1rem; border: 2px solid #d6d1c3; border-top-color: var(--accent-dark); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-mode { position: absolute; z-index: 4; left: .75rem; top: .75rem; padding: .42rem .58rem; border: 1px solid rgb(23 34 31 / 15%); border-radius: .35rem; background: rgb(255 253 248 / 92%); box-shadow: 0 3px 14px rgb(18 31 27 / 10%); color: #394640; font-size: .68rem; font-weight: 780; }
.legend { position: absolute; z-index: 4; right: .75rem; bottom: 2rem; width: 190px; padding: .68rem .75rem; border: 1px solid rgb(23 34 31 / 15%); border-radius: .42rem; background: rgb(255 253 248 / 94%); box-shadow: 0 8px 25px rgb(18 31 27 / 12%); }
.legend h3 { margin: 0 0 .48rem; font-size: .68rem; line-height: 1.3; }
.legend-row { display: grid; grid-template-columns: .72rem 1fr; align-items: center; gap: .4rem; margin-top: .3rem; color: #46534e; font-size: .64rem; }
.legend-swatch { width: .72rem; height: .72rem; border: 1px solid rgb(23 34 31 / 14%); border-radius: .12rem; }
.legend-note { margin: .5rem 0 0; padding-top: .45rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .59rem; line-height: 1.35; }
.hover-card { position: absolute; z-index: 7; pointer-events: none; min-width: 190px; max-width: 260px; padding: .55rem .65rem; border-radius: .35rem; background: rgb(23 34 31 / 94%); color: white; box-shadow: 0 7px 24px rgb(0 0 0 / 22%); font-size: .67rem; line-height: 1.35; }
.hover-card strong { display: block; margin-bottom: .15rem; font-size: .72rem; }
.error-panel { display: none; flex-direction: column; align-items: flex-start; line-height: 1.5; }
.error-panel.visible { display: flex; }
.error-panel code { font-size: .68rem; }
.mobile-controls { display: none; }

.maplibregl-ctrl-group { border-radius: .4rem !important; box-shadow: 0 4px 16px rgb(18 31 27 / 15%) !important; }
.maplibregl-ctrl-attrib { font-size: 10px !important; }
.maplibregl-popup-content { min-width: 230px; padding: .8rem .9rem !important; border-radius: .45rem !important; box-shadow: var(--shadow) !important; font-family: inherit; }
.maplibregl-popup-close-button { width: 2rem; height: 2rem; font-size: 1.2rem; }
.popup-title { padding-right: 1rem; font-family: Georgia, serif; font-size: 1rem; font-weight: 700; }
.popup-location { margin: .16rem 0 .55rem; color: var(--ink-soft); font-size: .68rem; }
.popup-grid { display: grid; grid-template-columns: 1fr auto; gap: .26rem .7rem; font-size: .67rem; }
.popup-grid span:nth-child(odd) { color: var(--ink-soft); }
.popup-grid span:nth-child(even) { font-weight: 760; text-align: right; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .app-shell { display: block; min-height: 100%; height: auto; }
  .sidebar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: min(78vh, 720px); transform: translateY(calc(100% - 3.1rem)); transition: transform .24s ease; border: 0; border-radius: .8rem .8rem 0 0; box-shadow: 0 -10px 35px rgb(18 31 27 / 20%); }
  .sidebar.open { transform: translateY(0); }
  .brand-block { padding-top: 3.7rem; }
  .map-panel { height: 100vh; min-height: 650px; }
  .mobile-controls { position: fixed; z-index: 22; left: 50%; bottom: .42rem; transform: translateX(-50%); display: inline-flex; align-items: center; gap: .45rem; height: 2.35rem; padding: 0 1rem; border: 0; border-radius: 999px; background: var(--ink); color: white; box-shadow: 0 7px 24px rgb(0 0 0 / 24%); font-size: .76rem; font-weight: 800; }
  .mobile-controls svg { width: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .legend { right: .5rem; bottom: 3.4rem; width: 168px; }
  .map-mode { max-width: calc(100% - 6rem); }
}

@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .brand-block, .control-section, .summary-section, .details-section, .method-section, .sidebar-footer { padding-left: 1rem; padding-right: 1rem; }
  .search-results { left: 1rem; right: 1rem; }
  .legend { width: 154px; padding: .55rem; }
  .legend-row { font-size: .59rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  body { overflow: visible; }
  .app-shell { grid-template-columns: 285px 1fr; height: 7.5in; }
  .sidebar { position: relative; transform: none; height: 7.5in; box-shadow: none; }
  .control-section, .method-section, .sidebar-footer, .mobile-controls, .maplibregl-control-container { display: none !important; }
  .map-panel { height: 7.5in; }
}
