:root {
  --yellow: #ffd21f;
  --yellow-strong: #ffca05;
  --ink: #0b0b0b;
  --paper: #f5f5f2;
  --surface: #ffffff;
  --muted: #6b6b67;
  --line: #deded8;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --unknown: #6b7280;
  --unknown-soft: #e5e7eb;
  --shadow: 0 16px 44px rgba(0, 0, 0, 0.14);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 36px);
  background: rgba(255, 210, 31, 0.96);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0,0,0,.12);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; line-height: 1; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; background: var(--ink); border-radius: 12px; font-size: 24px; }
.brand strong { display: block; font-size: 1.15rem; letter-spacing: .02em; }
.brand small { display: block; margin-top: 5px; color: rgba(0,0,0,.68); font-weight: 650; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.public-good-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--ink);
  color: #fff;
  font-size: .78rem;
  letter-spacing: .035em;
}
.public-good-bar strong { color: var(--yellow); }

main { max-width: 1500px; margin: 0 auto; padding: 16px clamp(12px, 2.5vw, 32px) 40px; }
.control-panel { display: grid; gap: 12px; margin-bottom: 10px; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(0,0,0,.04);
}
.search-box:focus-within { outline: 3px solid rgba(255,210,31,.42); border-color: var(--ink); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: inherit; }
.search-box input::placeholder { color: #888884; }

.button, .icon-button {
  border: 0;
  border-radius: 13px;
  font-weight: 800;
  transition: transform .14s ease, filter .14s ease, background .14s ease;
}
.button:hover, .icon-button:hover { filter: brightness(.98); }
.button:active, .icon-button:active { transform: translateY(1px) scale(.99); }
.button:focus-visible, .icon-button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(255,210,31,.75); outline-offset: 2px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; padding: 0 16px; text-decoration: none; }
.button-small { min-height: 40px; padding-inline: 13px; font-size: .9rem; }
.button-dark { background: var(--ink); color: white; }
.button-light { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.button-yellow { background: var(--yellow); color: var(--ink); }
.button-full { width: 100%; }
.button[disabled], .icon-button[disabled] { opacity: .55; cursor: not-allowed; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-size: 1.25rem; }

.filters-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow-x: auto; scrollbar-width: none; }
.filters-row::-webkit-scrollbar { display: none; }
.fuel-tabs { display: flex; gap: 6px; padding: 4px; background: #e7e7e1; border-radius: 13px; }
.fuel-tab { min-height: 38px; padding: 0 15px; border: 0; border-radius: 10px; background: transparent; color: #5c5c57; font-weight: 850; white-space: nowrap; }
.fuel-tab.active { background: var(--ink); color: white; box-shadow: 0 3px 10px rgba(0,0,0,.14); }
.toggle-filter { display: flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 750; font-size: .9rem; }
.toggle-filter input { width: 18px; height: 18px; accent-color: var(--green); }

.status-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-summary > div { padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.status-summary strong { display: block; font-size: 1.05rem; }
.status-summary span { display: block; margin-top: 2px; color: var(--muted); font-size: .76rem; }
.system-message { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 8px 11px; border-radius: 12px; background: #efefe9; color: #51514d; font-size: .84rem; }
.system-message.error { background: var(--red-soft); color: var(--red); }
.system-message.success { background: var(--green-soft); color: var(--green); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 999px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.view-switcher { display: none; grid-template-columns: 1fr 1fr; gap: 4px; margin: 10px 0; padding: 4px; background: #e4e4de; border-radius: 12px; }
.view-button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 800; color: #60605c; }
.view-button.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.52fr) minmax(330px, .7fr); gap: 14px; min-height: 620px; }
.map-panel, .list-panel { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px rgba(0,0,0,.06); }
#map { width: 100%; height: 100%; min-height: 620px; background: #e8e6df; }
.map-legend { position: absolute; z-index: 500; left: 12px; bottom: 30px; display: flex; flex-wrap: wrap; gap: 8px 12px; max-width: calc(100% - 24px); padding: 8px 10px; border-radius: 11px; background: rgba(255,255,255,.94); box-shadow: 0 4px 16px rgba(0,0,0,.14); font-size: .75rem; font-weight: 750; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-attribution-note { position: absolute; z-index: 500; right: 8px; bottom: 3px; margin: 0; padding: 2px 5px; border-radius: 5px; background: rgba(255,255,255,.8); font-size: .62rem; color: #555; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 999px; }
.dot-available { background: var(--green); }
.dot-limited { background: var(--amber); }
.dot-sold-out { background: var(--red); }
.dot-unknown { background: var(--unknown); }

.station-marker-wrap { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; background: transparent; border: 0; cursor: pointer; }
.station-marker { display: grid; place-items: center; width: 34px; height: 34px; border: 3px solid #fff; border-radius: 50% 50% 50% 12%; transform: rotate(-45deg); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.station-marker span { transform: rotate(45deg); font-size: 14px; }
.station-marker.status-available { background: var(--green); }
.station-marker.status-limited { background: var(--amber); }
.station-marker.status-sold_out { background: var(--red); }
.station-marker.status-unknown { background: var(--unknown); }
.user-location-marker { width: 16px; height: 16px; border: 4px solid white; border-radius: 50%; background: #2563eb; box-shadow: 0 0 0 4px rgba(37,99,235,.25); }

.list-panel { display: flex; flex-direction: column; max-height: 720px; }
.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.list-heading strong, .list-heading small { display: block; }
.list-heading small { margin-top: 3px; color: var(--muted); }
.station-list { overflow-y: auto; padding: 8px; }
.station-card { display: grid; grid-template-columns: 1fr auto; gap: 10px; width: 100%; padding: 13px; border: 1px solid transparent; border-bottom-color: var(--line); background: transparent; text-align: left; color: inherit; }
.station-card:hover { background: #f7f7f3; border-color: #ecece5; border-radius: 13px; }
.station-card-main { min-width: 0; }
.station-card-top { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.station-card h3 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .98rem; }
.station-card p { margin: 0; color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.station-card-meta { display: flex; flex-wrap: wrap; gap: 7px 10px; margin-top: 9px; color: #555550; font-size: .76rem; }
.station-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.station-distance { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.brand-mini, .status-badge, .brand-pill { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; font-weight: 850; }
.brand-mini { padding: 3px 7px; background: #ededE7; color: #4c4c48; font-size: .66rem; }
.status-badge { gap: 5px; padding: 5px 8px; font-size: .7rem; white-space: nowrap; }
.status-badge.available { background: var(--green-soft); color: var(--green); }
.status-badge.limited { background: var(--amber-soft); color: var(--amber); }
.status-badge.sold_out { background: var(--red-soft); color: var(--red); }
.status-badge.unknown { background: var(--unknown-soft); color: var(--unknown); }
.freshness { font-weight: 750; }
.freshness.stale { color: var(--red); }
.empty-state { display: grid; place-items: center; align-content: center; min-height: 260px; padding: 30px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 2rem; }
.empty-state strong { margin-top: 10px; color: var(--ink); }
.empty-state p { margin: 6px 0 0; }

.viral-card, .trust-card { margin-top: 14px; border-radius: var(--radius); }
.viral-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 18px; background: var(--ink); color: white; }
.viral-card p { margin: 5px 0 0; color: #c9c9c5; }
.viral-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--yellow); color: var(--ink); font-size: 1.35rem; }
.trust-card { padding: 16px 18px; background: #ebeae4; color: #4c4c48; font-size: .85rem; }
.trust-card p { margin: 5px 0 0; line-height: 1.55; }
footer { display: flex; justify-content: space-between; gap: 20px; max-width: 1500px; margin: 0 auto; padding: 10px clamp(16px, 3vw, 36px) calc(28px + var(--safe-bottom)); color: #5f5f5a; font-size: .8rem; }
footer nav { display: flex; gap: 14px; }

.station-sheet { position: fixed; z-index: 2000; right: 18px; bottom: 18px; width: min(430px, calc(100vw - 36px)); padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); transform: translateY(calc(100% + 40px)); opacity: 0; pointer-events: none; transition: transform .22s ease, opacity .22s ease; }
.station-sheet.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.sheet-backdrop { position: fixed; z-index: 1900; inset: 0; background: rgba(0,0,0,.34); }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #eeeeea; font-size: 1.4rem; }
.sheet-handle { display: none; width: 46px; height: 5px; margin: -8px auto 12px; border-radius: 999px; background: #d2d2cd; }
.brand-pill { padding: 5px 9px; background: var(--yellow); font-size: .72rem; }
.sheet-header h2 { margin: 9px 44px 4px 0; font-size: 1.4rem; }
.sheet-header p { margin: 0; color: var(--muted); }
.sheet-status { margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: 15px; }
.sheet-status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-status-details { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.sheet-status-details div { padding: 9px; border-radius: 10px; background: #f2f2ed; }
.sheet-status-details span, .sheet-status-details strong { display: block; }
.sheet-status-details span { color: var(--muted); font-size: .72rem; }
.sheet-status-details strong { margin-top: 3px; font-size: .84rem; }
.sheet-note { margin: 10px 0 0; color: #555550; font-size: .82rem; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.sheet-disclaimer { margin: 10px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.4; }

.toast { position: fixed; z-index: 4000; left: 50%; bottom: calc(20px + var(--safe-bottom)); max-width: calc(100vw - 24px); padding: 11px 15px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: .84rem; font-weight: 750; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.fatal-banner { padding: 20px; background: var(--red); color: white; text-align: center; }

@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; min-height: 0; }
  .view-switcher { display: grid; }
  .map-panel, .list-panel { min-height: 58vh; max-height: none; }
  #map { min-height: 58vh; }
  .list-panel { display: none; }
  .content-grid[data-view="list"] .map-panel { display: none; }
  .content-grid[data-view="list"] .list-panel { display: flex; }
  .viral-card { grid-template-columns: auto 1fr; }
  .viral-card .button { grid-column: 1 / -1; }
  footer { flex-direction: column; }
}

@media (max-width: 600px) {
  .topbar { min-height: 64px; padding: 10px 12px; }
  .brand-mark { width: 40px; height: 40px; }
  .brand strong { font-size: 1rem; }
  .brand small { font-size: .7rem; }
  .button-small { width: 42px; padding: 0; font-size: 0; }
  .button-small span { font-size: 1rem; }
  main { padding: 12px 10px 28px; }
  .search-row { grid-template-columns: 1fr auto; }
  .location-button { width: 48px; padding: 0; }
  .location-button-label { display: none; }
  .filters-row { align-items: flex-start; flex-direction: column; }
  .fuel-tabs { width: 100%; }
  .fuel-tab { flex: 1; padding-inline: 8px; }
  .status-summary > div { padding: 9px; }
  .status-summary strong { font-size: .95rem; }
  .content-grid { gap: 0; }
  .map-panel, .list-panel { border-radius: 15px; min-height: 60vh; }
  #map { min-height: 60vh; }
  .station-sheet { right: 0; bottom: 0; width: 100%; padding: 18px 16px calc(18px + var(--safe-bottom)); border-radius: 22px 22px 0 0; border-inline: 0; border-bottom: 0; }
  .sheet-handle { display: block; }
  .sheet-backdrop { display: block; }
  .viral-card { padding: 15px; }
}

@media (prefers-color-scheme: dark) {
  :root { --paper: #151513; --surface: #20201e; --ink: #f7f7f3; --muted: #aaa9a2; --line: #3b3b37; --unknown-soft: #34343a; }
  .topbar { color: #0b0b0b; }
  .brand small { color: rgba(0,0,0,.68); }
  .button-dark { background: #0b0b0b; }
  .fuel-tabs, .view-switcher { background: #30302c; }
  .fuel-tab.active { background: #f7f7f3; color: #111; }
  .system-message, .trust-card, .sheet-status-details div { background: #292925; color: #c7c7c0; }
  .station-card:hover { background: #272724; border-color: #383834; }
  .brand-mini { background: #343430; color: #cccac2; }
  .map-legend { color: #111; }
  .search-box input { color: var(--ink); }
  .leaflet-control-zoom a { color: #111; }
}

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

.user-location-wrap { display: grid; place-items: center; width: 24px; height: 24px; }
