:root {
  color-scheme: dark;
  --ink: #f5f4ec;
  --muted: #9da096;
  --dim: #6f736a;
  --surface: #11130f;
  --surface-soft: #171a15;
  --line: rgba(245, 244, 236, 0.13);
  --accent: #d9ff43;
  --accent-ink: #171b09;
  --danger: #ff8f7a;
  --sidebar: 438px;
  --topbar: 68px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
}

body {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100svh;
}

.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 15, 0.94);
  position: relative;
  z-index: 1000;
}

.brand {
  color: var(--ink);
  display: inline-flex;
  gap: 11px;
  align-items: center;
  text-decoration: none;
  font-size: 18px;
  font-weight: 730;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50% 50% 50% 4px;
  background: var(--accent);
  transform: rotate(-45deg);
  box-shadow: 0 0 24px rgba(217, 255, 67, 0.24);
}

.data-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6f736a;
}

.data-status.live .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(217, 255, 67, 0.08);
}

.data-status.demo .status-dot {
  background: #ffcc66;
}

.workspace {
  height: calc(100svh - var(--topbar));
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #3f433b transparent;
  position: relative;
  z-index: 500;
}

.search-zone {
  padding: 36px 30px 28px;
  border-bottom: 1px solid var(--line);
  animation: rise-in 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  line-height: 1;
  font-weight: 720;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 3vw, 43px);
  line-height: 0.99;
  letter-spacing: -0.055em;
  font-weight: 680;
}

.location-form {
  margin-top: 30px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  border-bottom: 1px solid rgba(245, 244, 236, 0.42);
  transition: border-color 160ms ease;
}

.search-row:focus-within {
  border-color: var(--accent);
}

.search-row input {
  width: 100%;
  padding: 13px 2px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
}

.search-row input::placeholder {
  color: var(--dim);
}

.search-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.search-button svg,
.location-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.location-button {
  margin-top: 14px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  gap: 9px;
  align-items: center;
  cursor: pointer;
  font-size: 13px;
  transition: color 160ms ease;
}

.location-button:hover {
  color: var(--ink);
}

.controls {
  margin-top: 26px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.controls label {
  min-width: 0;
}

.controls label > span {
  display: block;
  margin-bottom: 7px;
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.controls select {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 8px 20px 8px 0;
  background: transparent;
  color: var(--ink);
  outline: 0;
  cursor: pointer;
}

.search-results {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.search-result {
  display: block;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
}

.search-result:last-child {
  border-bottom: 0;
}

.recommendation-zone {
  padding: 28px 30px 20px;
  min-height: 340px;
}

.loading-state {
  color: var(--muted);
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.loading-line {
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 200% 100%;
  animation: loading 1s linear infinite;
}

.result-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.result-heading h2 {
  max-width: 225px;
  margin: 0;
  font-size: 24px;
  line-height: 1.06;
  letter-spacing: -0.04em;
}

.headline-price {
  text-align: right;
  color: var(--accent);
  line-height: 1;
}

.headline-price strong {
  display: block;
  font-size: 35px;
  letter-spacing: -0.055em;
}

.headline-price span {
  color: var(--muted);
  font-size: 11px;
}

.recommendation-copy {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.price-context {
  margin-top: 20px;
  padding: 17px 0 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  animation: context-in 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.price-context-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.price-context-heading div {
  min-width: 0;
}

.price-context-heading strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
  letter-spacing: -0.02em;
}

.price-context[data-tone="cheap"] .price-context-heading strong {
  color: var(--accent);
}

.price-context[data-tone="expensive"] .price-context-heading strong {
  color: var(--danger);
}

.price-context-heading div span,
.price-context-heading > span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.price-context-heading div span {
  display: block;
  margin-top: 4px;
}

.price-context-heading > span {
  flex: 0 0 auto;
  padding-top: 2px;
  color: var(--ink);
  font-weight: 700;
}

.history-scale {
  margin-top: 15px;
}

.history-scale-track {
  position: relative;
  height: 2px;
  background: linear-gradient(90deg, rgba(217, 255, 67, 0.5), rgba(245, 244, 236, 0.22) 50%, rgba(255, 143, 122, 0.52));
}

.history-scale-track i {
  position: absolute;
  top: 50%;
  left: var(--scale-position, 50%);
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px currentColor;
  transform: translate(-50%, -50%);
  transition: left 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.history-scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--dim);
  font-size: 8px;
}

.price-context-range {
  margin: 9px 0 0;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.recommendation-actions {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-top: 20px;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 2px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 760;
  transition: transform 160ms ease, filter 160ms ease;
}

.primary-action:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.text-action {
  border: 0;
  padding: 8px 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.calculation {
  margin-top: 17px;
  padding: 13px 0 3px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
}

.calculation strong {
  color: var(--ink);
  font-weight: 650;
}

.station-list-header {
  display: flex;
  justify-content: space-between;
  margin-top: 34px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.station-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.station-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: opacity 160ms ease, transform 160ms ease;
  animation: list-in 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.station-item:hover {
  transform: translateX(3px);
}

.station-rank {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
}

.station-item:first-child .station-rank {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.station-name {
  margin: 1px 0 5px;
  font-size: 13px;
  font-weight: 680;
  line-height: 1.25;
}

.station-meta,
.station-history {
  margin: 0;
  color: var(--dim);
  font-size: 10px;
  line-height: 1.45;
}

.station-history {
  margin-top: 3px;
  color: var(--muted);
}

.station-price {
  text-align: right;
  color: var(--ink);
  font-size: 14px;
  font-weight: 720;
}

.station-price small {
  display: block;
  margin-top: 3px;
  color: var(--dim);
  font-size: 9px;
  font-weight: 500;
}

.empty-state {
  padding: 20px 0;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.privacy-note {
  padding: 18px 30px 26px;
  color: #656960;
  font-size: 10px;
  line-height: 1.55;
}

.map-stage {
  position: relative;
  min-width: 0;
  background: #1b1d19;
}

#map {
  position: absolute;
  inset: 0;
  background: #171916;
  animation: map-reveal 700ms ease-out both;
}

.leaflet-tile-pane {
  filter: grayscale(1) invert(0.9) contrast(1.18) brightness(0.72);
}

.leaflet-control-zoom a {
  background: rgba(17, 19, 15, 0.9) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}

.leaflet-control-attribution {
  background: rgba(17, 19, 15, 0.76) !important;
  color: var(--muted) !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a {
  color: var(--ink) !important;
}

.price-marker {
  min-width: 58px;
  padding: 8px 9px 7px;
  border: 1px solid rgba(245, 244, 236, 0.5);
  border-radius: 2px;
  background: rgba(17, 19, 15, 0.94);
  color: var(--ink);
  text-align: center;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.26);
  transform-origin: 50% 100%;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.price-marker.best {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.price-marker:hover,
.price-marker.active {
  transform: scale(1.12) translateY(-2px);
}

.user-marker {
  width: 16px;
  height: 16px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: #79a9ff;
  box-shadow: 0 0 0 6px rgba(121, 169, 255, 0.2);
}

.map-location-label,
.map-legend {
  position: absolute;
  z-index: 450;
  background: rgba(17, 19, 15, 0.88);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.map-location-label {
  top: 20px;
  left: 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  font-size: 11px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #79a9ff;
  box-shadow: 0 0 0 0 rgba(121, 169, 255, 0.5);
  animation: pulse 2s ease-out infinite;
}

.map-legend {
  right: 20px;
  bottom: 26px;
  display: flex;
  gap: 14px;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 9px;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-best {
  background: var(--accent);
}

.legend-other {
  border: 1px solid rgba(245, 244, 236, 0.7);
}

.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;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes list-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes map-reveal {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes context-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes loading {
  to { background-position: -200% 0; }
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(121, 169, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(121, 169, 255, 0); }
}

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

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .topbar {
    height: 60px;
    padding: 0 17px;
  }

  .data-status {
    max-width: 185px;
    text-align: right;
    line-height: 1.3;
  }

  .workspace {
    height: auto;
    min-height: calc(100svh - 60px);
    display: flex;
    flex-direction: column;
  }

  .map-stage {
    order: -1;
    height: 42svh;
    min-height: 330px;
    border-bottom: 1px solid var(--line);
  }

  .sidebar {
    overflow: visible;
    border-right: 0;
  }

  .search-zone,
  .recommendation-zone {
    padding-left: 20px;
    padding-right: 20px;
  }

  h1 {
    font-size: 36px;
  }

  .map-location-label {
    top: 14px;
    left: 14px;
  }

  .map-legend {
    right: 14px;
    bottom: 20px;
  }

  .privacy-note {
    padding-left: 20px;
    padding-right: 20px;
  }
}

.mode-switch { display: flex; gap: 4px; margin-top: 24px; padding: 4px; background: var(--surface-soft); border: 1px solid var(--line); }
.mode-switch button { flex: 1; border: 0; padding: 11px 6px; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.mode-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.field-label { color: var(--muted); font-size: 12px; }
#destinationForm { margin-top: 20px; }
.route-summary { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 20px 0 0; }
.station-navigation { display: inline-block; margin-top: 7px; color: var(--accent); font-size: 12px; }
