:root {
  color-scheme: dark;
  --bg: #071014;
  --panel: rgba(8, 17, 20, 0.9);
  --panel-solid: #0e1b20;
  --text: #f7fbf8;
  --muted: #9fb1aa;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #22c55e;
  --blue: #38bdf8;
  --red: #fb7185;
  --amber: #fbbf24;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body, .app-shell { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }

.location-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 16, 20, 0.84);
  backdrop-filter: blur(18px);
}
.location-gate[hidden] { display: none; }
.location-gate-panel {
  width: min(420px, 100%);
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 18px;
  background: #101b1f;
  color: var(--text);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
}
.location-gate-logo {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  object-fit: contain;
  background: #f8fafc;
  padding: 4px;
  margin-bottom: 14px;
}
.location-gate h1 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  line-height: 1.2;
}
.location-gate p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}
.location-gate button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #04130d;
  font-weight: 900;
}
.location-gate small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  height: 100vh;
  width: 100vw;
}

.map-surface { position: fixed; inset: 0; }
.map { width: 100%; height: 100%; background: #0f172a; }

.control-panel {
  position: relative;
  z-index: 10;
  grid-column: 1;
  align-self: stretch;
  margin: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(150%);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
}

.brand-row, .brand, .search-pill, .route-field, .mode-row, .result-card, .route-summary, .icon-button, .primary-button, .secondary-button, .send-button, .tab-row, .quick-row, .tracking-banner, .journey-actions {
  display: flex;
  align-items: center;
}

.brand-row { justify-content: space-between; gap: 12px; }
.brand { gap: 11px; color: var(--text); text-decoration: none; }
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: #f8fafc;
  padding: 3px;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; line-height: 1.1; }
.brand small { color: var(--muted); margin-top: 2px; }

.icon-button, .send-button {
  justify-content: center;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.icon-button { width: 42px; height: 42px; border-radius: 12px; }
.icon-button:hover, .send-button:hover {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.12);
  transform: translateY(-1px);
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tab-row {
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.06);
}
.tab-button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.tab-button.active { color: #05210f; background: var(--accent); }

.tool-pane { display: none; }
.tool-pane.active { display: block; }

.location-card {
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 13px;
  background: rgba(34, 197, 94, 0.1);
}
.location-card:not([hidden]) { display: flex; }
.location-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12);
  flex: 0 0 auto;
}
.location-card strong,
.location-card small {
  display: block;
}
.location-card strong {
  font-size: 0.86rem;
  line-height: 1.25;
}
.location-card small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 2px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.search-form, .directions-form { margin: 0; }
.search-pill, .route-field {
  gap: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.075);
  border-radius: 14px;
}
.search-pill { padding: 9px 9px 9px 14px; }
.search-pill:focus-within, .route-field:focus-within {
  border-color: rgba(34, 197, 94, 0.85);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
}
.search-pill input, .route-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}
.search-pill input::placeholder, .route-field input::placeholder { color: #7e918a; }
.send-button { width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto; }

.directions-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
}
.route-field { padding: 12px 13px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot-start { background: var(--accent); box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12); }
.dot-end { background: var(--red); box-shadow: 0 0 0 5px rgba(251, 113, 133, 0.12); }

.mode-row { gap: 6px; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); }
.mode-button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 8px 10px;
}
.mode-button.active { color: #05210f; background: var(--accent); font-weight: 900; }
.primary-button {
  justify-content: center;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  color: #04130d;
  font-weight: 900;
}
.journey-actions { gap: 8px; }
.primary-button { flex: 1; }
.secondary-button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 15px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 900;
}
.secondary-button[hidden] { display: none; }

.quick-row { gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.quick-row button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 800;
}

.suggestions-list,
.auto-nearby-list,
.directions-suggestions {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.suggestions-list[hidden],
.auto-nearby-list[hidden],
.directions-suggestions[hidden] {
  display: none;
}
.suggestion-button,
.auto-nearby-button,
.direction-suggestion-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 11px;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.suggestion-button:hover,
.auto-nearby-button:hover,
.direction-suggestion-button:hover {
  border-color: rgba(34, 197, 94, 0.48);
  background: rgba(34, 197, 94, 0.1);
}
.suggestion-button strong,
.suggestion-button small,
.auto-nearby-button strong,
.auto-nearby-button small,
.direction-suggestion-button strong,
.direction-suggestion-button small {
  display: block;
}
.suggestion-button strong,
.auto-nearby-button strong,
.direction-suggestion-button strong {
  font-size: 0.84rem;
  line-height: 1.25;
}
.suggestion-button small,
.auto-nearby-button small,
.direction-suggestion-button small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.result-panel { min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.status-text { color: var(--muted); font-size: 0.9rem; }
.tracking-banner {
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.1);
}
.tracking-banner[hidden] { display: none; }
.tracking-pulse {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 rgba(56, 189, 248, 0.5);
  animation: trackingPulse 1.6s infinite;
  flex: 0 0 auto;
}
.tracking-banner strong,
.tracking-banner small {
  display: block;
}
.tracking-banner small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 2px;
}
@keyframes trackingPulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.5); }
  70% { box-shadow: 0 0 0 12px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}
.route-summary {
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.1);
}
.route-summary strong { display: block; font-size: 1rem; }
.route-summary span { color: var(--muted); font-size: 0.86rem; }

.journey-steps {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}
.journey-step {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  gap: 9px;
  align-items: flex-start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
}
.step-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: rgba(56, 189, 248, 0.14);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
}
.step-text { font-size: 0.84rem; line-height: 1.35; }
.step-distance { color: var(--muted); font-size: 0.75rem; font-weight: 800; white-space: nowrap; }
.journey-step { cursor: pointer; }
.journey-step.active {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(56, 189, 248, 0.13);
}
.turn-marker {
  width: 28px !important;
  height: 28px !important;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #0f1f2a;
  border: 2px solid #38bdf8;
  color: #7dd3fc;
  font-size: 0.74rem;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.36);
}

.results-list { display: grid; gap: 10px; overflow: auto; padding-right: 4px; }
.result-card {
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  padding: 13px;
}
.result-card:hover { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.1); }
.pin {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(34, 197, 94, 0.14);
  color: var(--accent);
}
.result-title { display: block; font-weight: 900; margin-bottom: 4px; }
.result-address {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}
.result-meta { display: block; color: var(--blue); font-size: 0.75rem; font-weight: 900; margin-top: 5px; }

.leaflet-control-attribution { background: rgba(255, 255, 255, 0.82) !important; }

@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { display: flex; min-height: 100vh; height: auto; }
  .map-surface { position: fixed; }
  .control-panel {
    width: calc(100% - 16px);
    max-height: min(72vh, 680px);
    margin: 8px;
    padding: 12px;
    align-self: flex-end;
    border-radius: 16px;
    gap: 10px;
  }
  .brand-logo { width: 38px; height: 38px; }
  .icon-button { width: 38px; height: 38px; }
  .tab-button { min-height: 42px; font-size: 0.96rem; }
  .directions-form { padding: 10px; gap: 8px; }
  .route-field { padding: 11px; }
  .result-panel { gap: 9px; }
  .journey-steps { max-height: 160px; }
  .result-card,
  .suggestion-button,
  .auto-nearby-button,
  .direction-suggestion-button {
    padding: 11px;
  }
}

@media (max-width: 480px) {
  .control-panel {
    width: 100%;
    margin: 0;
    border-radius: 18px 18px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    max-height: 76vh;
  }
  .brand-row { gap: 8px; }
  .brand strong { font-size: 0.95rem; }
  .brand small { font-size: 0.82rem; }
  .tab-row { gap: 3px; }
  .tab-button { font-size: 0.9rem; }
  .search-pill { padding-left: 11px; }
  .mode-button { padding: 8px 6px; }
  .route-summary { align-items: flex-start; flex-direction: column; }
  .journey-step { grid-template-columns: 24px 1fr; }
  .step-distance { grid-column: 2; }
  .location-gate-panel { padding: 20px; }
  .location-gate h1 { font-size: 1.18rem; }
}
