:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #666d75;
  --paper: #fffdf9;
  --panel: rgba(255, 253, 249, 0.96);
  --line: rgba(32, 33, 36, 0.14);
  --teal: #00897b;
  --teal-dark: #00695c;
  --red: #d8403a;
  --gold: #f4b942;
  --green-soft: #d9f2ea;
  --shadow: 0 18px 55px rgba(20, 26, 31, 0.22);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
.shell,
.map-stage,
#map {
  min-height: 100%;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--paper);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: 100%;
}

.map-stage {
  position: relative;
  height: 100vh;
  min-height: 640px;
  overflow: hidden;
}

#map {
  z-index: 1;
  height: 100%;
  width: 100%;
  background: #dbe6df;
}

.topbar {
  position: absolute;
  z-index: 500;
  top: 20px;
  left: 20px;
  right: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.eyebrow,
h1 {
  margin: 0;
}

.eyebrow {
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.05;
}

.ghost-button,
.drawer-toggle,
.action-link {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.ghost-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--teal);
  border-color: transparent;
  font-weight: 750;
  white-space: nowrap;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: var(--teal-dark);
}

.finder {
  position: absolute;
  z-index: 510;
  top: 20px;
  right: 20px;
  bottom: 20px;
  width: min(410px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.finder-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 4px 2px 6px;
}

.finder-head div {
  display: grid;
  gap: 4px;
}

.finder-head span {
  color: var(--muted);
  font-size: 0.84rem;
}

.finder-head strong {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.15;
}

#resultCount {
  padding: 6px 9px;
  color: var(--teal-dark);
  background: rgba(0, 137, 123, 0.1);
  border: 1px solid rgba(0, 137, 123, 0.2);
  border-radius: 8px;
  font-weight: 850;
  white-space: nowrap;
}

.finder-controls {
  display: grid;
  grid-template-columns: 0.92fr 1.18fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field select,
.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.field select:focus,
.field input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.16);
}

.notice {
  padding: 11px 12px;
  color: #30453f;
  background: linear-gradient(135deg, var(--green-soft), #ffffff);
  border: 1px solid rgba(0, 137, 123, 0.18);
  border-radius: 8px;
  font-size: 0.86rem;
  line-height: 1.35;
}

.pharmacy-list {
  display: grid;
  gap: 9px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.35;
}

.pharmacy-card {
  min-height: 132px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(20, 26, 31, 0.06);
}

.pharmacy-card.is-selected {
  border-color: rgba(0, 137, 123, 0.52);
  box-shadow: 0 0 0 3px rgba(0, 137, 123, 0.13);
}

.card-main {
  width: 100%;
  display: grid;
  gap: 9px;
  padding: 13px 13px 12px;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.pharmacy-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  line-height: 1.2;
}

.district-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  color: #ffffff;
  background: var(--red);
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 800;
}

.address,
.meta-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 0.88rem;
}

.meta-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 2px;
}

.hours {
  color: var(--teal-dark);
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  border: 0;
  border-radius: 0;
  font-size: 0.9rem;
  font-weight: 850;
  background: #fbfcfc;
}

.action-link + .action-link {
  border-left: 1px solid var(--line);
}

.call-link {
  color: var(--teal-dark);
}

.route-link {
  color: var(--red);
}

.drawer-toggle {
  display: none;
  position: absolute;
  z-index: 530;
  left: 16px;
  bottom: 16px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--red);
  border-color: transparent;
  font-weight: 850;
  box-shadow: var(--shadow);
}

.map-marker {
  position: relative;
  display: block;
  width: 34px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  appearance: none;
}

.marker-pin {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #ffffff;
  background: var(--red);
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(32, 33, 36, 0.28);
  font-weight: 900;
}

.marker-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid var(--red);
  transform: translateX(-50%);
}

.map-marker.is-selected .marker-pin {
  background: var(--teal);
}

.map-marker.is-selected .marker-pin::after {
  border-top-color: var(--teal);
}

.popup-title {
  margin: 0 0 5px;
  font-weight: 850;
}

.popup-text {
  margin: 0;
  color: var(--muted);
}

.maplibregl-popup-content {
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(20, 26, 31, 0.22);
}

.maplibregl-ctrl-bottom-left {
  left: 20px;
  bottom: 20px;
}

.user-marker {
  width: 18px;
  height: 18px;
  background: var(--teal);
  border: 3px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(0, 137, 123, 0.18);
}

@media (max-width: 860px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .map-stage {
    min-height: 100vh;
    height: auto;
    overflow: visible;
    padding-bottom: 0;
    background: var(--paper);
  }

  #map {
    height: 64vh;
    min-height: 430px;
  }

  .topbar {
    top: 12px;
    left: 12px;
    right: 12px;
    align-items: flex-start;
    padding: 12px;
  }

  .ghost-button {
    min-width: 112px;
    padding: 0 10px;
  }

  .finder {
    position: relative;
    z-index: 520;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: auto;
    max-height: none;
    margin: -18px 12px 16px;
    min-height: 360px;
    transform: translateY(0);
    transition: none;
  }

  .drawer-toggle {
    display: none;
  }

  .finder-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .topbar {
    display: grid;
  }

  h1 {
    font-size: 1.45rem;
  }

  .ghost-button {
    width: 100%;
  }
}
