.page-research {
  margin: 0;
  min-height: 100vh;
  background: #e8eee9;
  font-family: var(--font-body, "Sora", sans-serif);
  color: #1a1f1c;
}

.research-shell {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) 1fr;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  height: 100vh;
  height: var(--app-height, 100dvh);
}

.research-bar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  background: #f7f5f0;
  border-bottom: 1px solid rgba(20, 53, 40, 0.12);
}

.research-bar__title {
  margin: 0;
  font-family: var(--font-display, Fraunces, Georgia, serif);
  font-size: 1.15rem;
  color: #143528;
  flex: 1;
}

.research-bar__links {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 0.85rem;
  font-size: 0.8rem;
}

.research-bar__links .auth-chipbar {
  margin-left: 0.25rem;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(20, 53, 40, 0.14);
}

.research-bar__links a {
  color: #143528;
  font-weight: 600;
  text-decoration: none;
}

.research-bar__links a:hover {
  text-decoration: underline;
}

.research-search {
  padding: 1rem;
  background: #f7f5f0;
  min-width: 0;
}

.research-views { display: none; }

.research-panel {
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 1rem 1.5rem;
  background: #f7f5f0;
  border-right: 1px solid rgba(20, 53, 40, 0.1);
}

.research-form {
  display: grid;
  gap: 0.65rem;
}

.research-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4a554e;
}

.research-typeahead {
  position: relative;
  z-index: 5;
}

.research-typeahead input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-weight: 400;
  font-size: 1rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid rgba(20, 53, 40, 0.2);
  border-radius: 4px;
  background: #fff;
  color: #1a1f1c;
}

.research-typeahead input:focus {
  outline: 2px solid rgba(20, 53, 40, 0.35);
  outline-offset: 1px;
}

.research-suggest {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: 16rem;
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(20, 53, 40, 0.18);
  border-radius: 4px;
  box-shadow: 0 8px 20px rgba(20, 53, 40, 0.12);
}

.research-suggest[hidden] {
  display: none;
}

.research-suggest__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.7rem;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.35;
  color: #1a1f1c;
  cursor: pointer;
}

.research-suggest__item--status {
  cursor: default;
  color: #5a655e;
  font-size: 0.82rem;
}

.research-suggest__item--status:hover {
  background: transparent;
}

.research-suggest__item strong {
  font-weight: 600;
}

.research-suggest__meta {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.75rem;
  color: #5a655e;
}

.research-overlays {
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(20, 53, 40, 0.18);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
}

.research-overlays legend {
  padding: 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #143528;
}

.research-overlays label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.86rem;
  cursor: pointer;
  user-select: none;
}

.research-overlay-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.research-overlay-swatch--costco { background: #e31837; }
.research-overlay-swatch--aldi { background: #1a472a; }
.research-overlay-swatch--ymca { background: #0060ad; }
.research-overlay-swatch--demo {
  background: linear-gradient(90deg, #f3efe6, #a67c52, #4a3224);
}

.research-hint {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #4a554e;
}

.research-hint.is-error {
  color: #8a2f2f;
}

.research-result {
  margin-top: 1rem;
}

.research-result h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display, Fraunces, Georgia, serif);
  font-size: 1.05rem;
  line-height: 1.3;
  color: #143528;
}

.research-regs {
  margin: 0;
  padding: 0.9rem 0.95rem;
  border: 1px solid rgba(20, 53, 40, 0.14);
  background: #fff;
}

.research-regs--miss {
  background: rgba(160, 80, 40, 0.08);
  border-color: rgba(160, 80, 40, 0.25);
}

.research-regs--miss p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: #4a554e;
}

.research-regs__place {
  margin: 0 0 0.55rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: #143528;
}

.research-regs__score-row .badge {
  margin-top: 0;
}

.research-regs__score {
  font-family: var(--font-display, Fraunces, Georgia, serif);
  font-size: 2.35rem;
  font-weight: 700;
  line-height: 1;
}

.research-regs__score span {
  font-size: 0.95rem;
  font-weight: 500;
  margin-left: 0.12rem;
  color: #5a655e;
}

.research-lookup-btn {
  justify-self: start;
  background: #143528;
  color: #f7f5f0;
  border-color: #143528;
  padding: 0.55rem 1.1rem;
}

.research-lookup-btn:hover {
  background: #1c4634;
  border-color: #1c4634;
  color: #f7f5f0;
}

.research-regs__link {
  display: inline;
  font-size: 0.88rem;
  font-weight: 600;
  color: #143528;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.research-regs__link:hover {
  color: #1c4634;
}

.research-demo {
  margin-top: 0.85rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid rgba(20, 53, 40, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
}

.research-demo--miss {
  font-size: 0.8rem;
  color: #5a655e;
}

.research-demo h3 {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #143528;
}

.research-demo__geo {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  color: #5a655e;
  line-height: 1.35;
}

.research-demo__stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.research-demo__stats > div {
  display: grid;
  gap: 0.1rem;
}

.research-demo__k {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #6a756e;
}

.research-demo__stats strong {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1a1f1c;
}

.research-demo__race {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.2rem;
}

.research-demo__race li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.5rem;
  font-size: 0.78rem;
  align-items: baseline;
}

.research-demo__label {
  color: #3a443e;
}

.research-demo__pct {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.research-demo__n {
  min-width: 2.5rem;
  text-align: right;
  color: #6a756e;
  font-variant-numeric: tabular-nums;
}

.research-demo__src {
  margin: 0.55rem 0 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #6a756e;
}

.research-share-row {
  margin: 0.65rem 0 0;
}

.research-share-btn {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: #143528;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  cursor: pointer;
}

.research-share-btn:hover {
  color: #1c4634;
}

.research-poi-more {
  margin: 1rem 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #4a554e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.research-poi-list {
  margin-top: 1rem;
}

.research-poi-list h3 {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4a554e;
}

.research-poi-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(20, 53, 40, 0.12);
  background: #fff;
}

.research-poi-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
  align-items: baseline;
  padding: 0.55rem 0.7rem;
  border-top: 1px solid rgba(20, 53, 40, 0.08);
  font-size: 0.82rem;
}

.research-poi-list li:first-child {
  border-top: 0;
}

.research-poi-list .kind {
  grid-column: 1 / -1;
  font-weight: 600;
  text-transform: capitalize;
}

.research-poi-list .miles {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #143528;
  white-space: nowrap;
}

.research-map {
  grid-column: 2;
  grid-row: 2 / 4;
  min-width: 0;
  min-height: 0;
}

.research-shell { position: relative; overflow: hidden; }
.research-panel, .research-search { overflow-wrap: anywhere; }
.research-suggest__item.is-active { background: #e8eee9; }
.research-lookup-btn:disabled { opacity: .65; cursor: wait; }
.research-poi-list .miles { align-self: start; }

/* Google Maps–style basemap switcher (bottom-left) */
.research-basemap-control.leaflet-bar {
  border: 0;
  box-shadow: none;
  background: transparent;
}

.research-basemap-toggle {
  display: block;
  width: 76px;
  padding: 0;
  margin: 0;
  border: 2px solid #fff;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  font: inherit;
  color: #1a1a1a;
  text-align: center;
  transition: box-shadow 0.15s ease;
}

.research-basemap-toggle:hover,
.research-basemap-toggle:focus-visible {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  outline: none;
}

.research-basemap-toggle__preview {
  display: block;
  height: 54px;
  background-size: cover;
  background-position: center;
}

/* Preview shows the mode you will switch TO */
.research-basemap-toggle[data-mode="streets"] .research-basemap-toggle__preview {
  background-image: url("https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/6/22/18");
}

.research-basemap-toggle[data-mode="satellite"] .research-basemap-toggle__preview {
  background-image: url("https://tile.openstreetmap.org/6/18/22.png");
}

.research-basemap-toggle__label {
  display: block;
  padding: 0.28rem 0.2rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.1;
  background: #fff;
}

.leaflet-bottom .research-basemap-control {
  margin-bottom: 22px;
}

.poi-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.poi-dot--airport { background: #1d4e89; }
.poi-dot--university { background: #8b5a2b; }
.poi-dot--hospital { background: #a33b3b; }
.poi-dot--stadium { background: #2f6b4f; }
.poi-dot--attraction { background: #9a4d1c; }
.poi-dot--costco { background: #e31837; }
.poi-dot--aldi { background: #1a472a; }
.poi-dot--ymca { background: #0060ad; }
.poi-dot--subject {
  width: 16px;
  height: 16px;
  background: #143528;
  border-width: 3px;
}

.research-subject-popup .leaflet-popup-content-wrapper {
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(20, 53, 40, 0.18);
}

.research-subject-popup .leaflet-popup-content {
  margin: 0.7rem 0.85rem;
  line-height: 1.35;
}

.research-map-popup__kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a655e;
  margin-bottom: 0.25rem;
}

.research-map-popup__addr {
  display: block;
  font-size: 0.92rem;
  color: #143528;
}

.research-map-popup__juri {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: #4a554e;
}

@media (max-width: 860px) {
  .page-research { min-height: 0; overflow: hidden; }
  .research-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }
  .research-bar {
    gap: .35rem .65rem;
    padding: max(.45rem, env(safe-area-inset-top)) max(.75rem, env(safe-area-inset-right)) .45rem max(.75rem, env(safe-area-inset-left));
  }
  .research-bar .nav__brand { font-size: 1rem; }
  .research-bar__title { font-size: 1rem; }
  .research-bar__links { gap: .5rem; }
  .research-bar__links > a { display: none; }
  .research-bar__links .auth-chipbar { padding: 0; margin: 0; border: 0; }
  .research-search { padding: .55rem .75rem; z-index: 500; }
  .research-form { grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; align-items: end; }
  .research-label { grid-column: 1 / -1; margin: 0; }
  .research-typeahead input { height: 44px; }
  .research-lookup-btn { min-height: 44px; margin: 0; padding: .5rem .7rem; font-size: .85rem; }
  .research-hint { font-size: .75rem; margin-top: .45rem; }
  .research-suggest { max-height: min(16rem, 40dvh); }
  .research-views {
    display: flex;
    gap: .25rem;
    padding: 0 .75rem .5rem;
    background: #f7f5f0;
    border-bottom: 1px solid var(--line);
  }
  .research-views button {
    flex: 1;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
    color: var(--pine);
    font: inherit;
    font-size: .85rem;
    font-weight: 600;
  }
  .research-views button[aria-pressed="true"] { background: var(--pine); color: var(--paper); }
  .research-panel, .research-map { grid-column: 1; grid-row: 4; min-height: 0; }
  .research-panel {
    visibility: hidden;
    border: 0;
    padding: .75rem .75rem max(1rem, env(safe-area-inset-bottom));
    overscroll-behavior-y: contain;
  }
  .research-shell[data-view="details"] .research-panel { visibility: visible; }
  .research-shell[data-view="details"] .research-map { visibility: hidden; }
  .research-overlays { margin-top: 0; gap: .25rem .75rem; }
  .research-overlays label { min-height: 44px; }
  .research-overlays input { width: 18px; height: 18px; }
  .research-share-btn, .research-regs__link { display: inline-flex; align-items: center; min-height: 44px; }
  .research-basemap-toggle { width: 60px; }
  .research-basemap-toggle__preview { height: 34px; }
  .research-basemap-toggle__label { font-size: .65rem; }
}
@media (max-width: 360px) {
  .research-bar__title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (max-width: 860px) and (max-height: 500px) {
  .research-label, .research-bar__title { display: none; }
  .research-bar { padding-top: .15rem; padding-bottom: .15rem; }
  .research-search { padding-top: .25rem; padding-bottom: .25rem; }
  .research-views { padding-bottom: .25rem; }
}
@media (max-width: 860px) {
  .research-panel { display: flex; flex-direction: column; gap: .75rem; }
  .research-panel > * { flex: none; }
  .research-result { order: 1; margin-top: 0; }
  .research-poi-list { order: 2; margin-top: 0; }
  .research-overlays { order: 3; }
}

.research-regs__boundary { font-size: .75rem; line-height: 1.5; color: #4a554e; margin: 0 0 .75rem; }
