:root {
  --green: #047857;
  --green-deep: #065f46;
  --green-light: #a7f3d0;
  --bg: #f3f5f3;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: rgba(31, 41, 55, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101410;
    --card: #1a201b;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: rgba(229, 231, 235, 0.12);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.bar {
  background: var(--green);
  color: #ffffff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  padding-top: calc(0.5rem + env(safe-area-inset-top));
}

.bar h1 {
  font-size: 1.05rem;
  margin: 0 0.5rem 0 0;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.bar h1 span {
  color: var(--green-light);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.field span {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--green-light);
}

select {
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #ffffff;
  color: #1f2937;
}

.segment {
  display: inline-flex;
  border-radius: 8px;
  overflow: hidden;
}

.segment button {
  border: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
  cursor: pointer;
}

.segment button[aria-pressed="true"] {
  background: #ffffff;
  color: var(--green-deep);
}

#locate {
  border: 0;
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--green-deep);
  color: #ffffff;
  cursor: pointer;
}

.status {
  margin: 0;
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  min-height: 1.2em;
}

main {
  flex: 1;
  display: flex;
  min-height: 0;
}

#map {
  width: 55%;
  min-width: 300px;
}

.results {
  width: 45%;
  margin: 0;
  padding: 0.6rem;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.station {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  cursor: pointer;
}

.station:hover {
  border-color: var(--green);
}

.station.best {
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.rank {
  width: 1.4rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.station-main {
  min-width: 0;
}

.station-name {
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-addr {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.station.best .station-price {
  color: #059669;
}

.station-dist {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
}

.price-pin {
  background: transparent;
  border: 0;
}

.price-tag {
  display: inline-block;
  background: var(--green);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1.5px solid #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transform: translate(-50%, -130%);
}

.price-tag.best {
  background: #b45309;
}

.popup-price {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0.2rem 0 0.15rem;
}

.popup-addr {
  font-size: 0.78rem;
}

.popup-meta {
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 0.35rem;
}

@media (max-width: 720px) {
  main {
    flex-direction: column;
  }

  #map {
    width: 100%;
    height: 46vh;
    min-height: 250px;
  }

  .results {
    width: 100%;
    overflow: visible;
  }
}
