﻿:root {
  --ground: #f4f3f1;
  --surface: #ffffff;
  --raised: #eae7e1;
  --border: #e2ddd3;
  --rule: #eeeae3;
  --text: #0f172a;
  --muted: #6b675f;
  --accent: #e14a3e;
  --accent-ink: #b3352b;
  --accent-soft: #fbeeea;
  --panel: 336px;
  --radius: 8px;
  --radius-sm: 6px;
  --fs-title: 18px;
  --fs-body: 14px;
  --fs-small: 13px;
  --topbar: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: var(--fs-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

a {
  color: inherit;
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-columns: var(--panel) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* Sidebar */
.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 12px 0;
  background: var(--ground);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0 4px;
}

.brand__mark {
  flex: none;
  width: 28px;
  height: 28px;
  margin-top: 1px;
}

.brand__mark img,
.topbar__mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.brand__text {
  min-width: 0;
}

.brand__name {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.015em;
}

.brand__meta {
  margin: 4px 0 0;
  font-size: var(--fs-small);
  line-height: 1.45;
  color: var(--muted);
}

.panel__close {
  display: none;
  flex: none;
  width: 32px;
  height: 32px;
  margin: -4px -4px 0 auto;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}

.panel__close:hover {
  background: var(--raised);
  color: var(--text);
}

/* Search */
.search {
  position: relative;
  margin-top: 18px;
}

.search input {
  width: 100%;
  height: 38px;
  padding: 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
}

.search input::placeholder {
  color: #8b857a;
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search__icon {
  position: absolute;
  top: 50%;
  left: 11px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search__clear {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  transform: translateY(-50%);
}

.search__clear:hover {
  background: var(--raised);
  color: var(--text);
}

/* List */
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
  padding: 0 4px;
  font-size: var(--fs-small);
  color: var(--muted);
}

.places {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-height: 0;
  margin: 8px 0 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.place {
  position: relative;
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 3px;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
}

.place:hover {
  background: var(--raised);
}

.place.is-active {
  background: var(--accent-soft);
}

.place.is-active::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 2px;
  border-radius: 1px;
  background: var(--accent);
}

.place__name {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.place__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
}

.place__phone {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.place__sep {
  color: #a49e93;
}

.place__addr {
  overflow: hidden;
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-results {
  margin: 14px 4px;
  font-size: 13px;
  color: var(--muted);
}

/* Footer */
.panel__foot {
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding: 14px 4px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.legend {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: var(--fs-small);
  font-weight: 500;
}

.legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.scope-note {
  max-width: 34ch;
  margin: 0;
  font-size: var(--fs-small);
  line-height: 1.45;
  color: var(--muted);
}

.updated {
  margin: 2px 0 0;
  font-size: var(--fs-small);
  color: var(--muted);
}

/* Map */
.map-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #e8e6e2;
}

.map {
  position: absolute;
  inset: 0;
}

.maplibregl-canvas {
  outline: none;
}

.maplibregl-ctrl-attrib {
  font-family: "Geist", system-ui, sans-serif;
  font-size: 13px;
}

.maplibregl-ctrl-attrib.maplibregl-compact {
  min-height: 22px;
}

.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner {
  display: none;
}

.maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
  display: block;
}

.maplibregl-ctrl-attrib a {
  color: #4f4a42;
}

.topbar {
  display: none;
}

.map-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  display: flex;
  width: 38px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.map-controls button {
  display: grid;
  width: 100%;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
}

.map-controls button + button {
  border-top: 1px solid var(--rule);
}

.map-controls button:hover {
  background: #f4f2ee;
}

#btn3d {
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0;
}

#btn3d.is-on {
  background: var(--text);
  color: #fff;
}

#btn3d.is-on:hover {
  background: #1c2740;
}

#btnLocate.is-on {
  background: var(--text);
  color: #fff;
}

#btnLocate.is-on:hover {
  background: #1c2740;
}

#btnLocate.is-busy {
  cursor: progress;
}

#btnLocate.is-busy svg {
  animation: locate-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes locate-pulse {
  from { opacity: 0.45; transform: scale(0.86); }
  to { opacity: 1; transform: scale(1); }
}

#compassNeedle {
  transition: transform 0.15s linear;
}

.route-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 6;
  display: flex;
  max-width: calc(100% - 84px);
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.route-bar__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.route-bar__text {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.route-bar__label {
  font-size: var(--fs-small);
  line-height: 1.25;
  color: var(--muted);
}

.route-bar__value {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.route-bar__close {
  display: grid;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.route-bar__close:hover {
  background: #f2f0eb;
  color: var(--text);
}

.map-status {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 5;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-small);
  color: var(--muted);
}

.map-error {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  padding: 24px;
  place-items: center;
  background: var(--ground);
}

.map-error__box {
  width: 100%;
  max-width: 340px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.map-error__box h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.map-error__box p {
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--muted);
}

/* Markers */
.marker {
  width: 30px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
}

.marker__inner {
  position: relative;
  display: block;
  width: 30px;
  height: 40px;
  transform-origin: 50% 100%;
  transition: transform 0.16s ease;
}

.marker svg {
  width: 30px;
  height: 40px;
  filter: drop-shadow(0 2px 2px rgba(20, 18, 14, 0.28));
}

.marker__pin {
  fill: var(--accent);
  transition: fill 0.16s ease;
}

.marker__dot {
  fill: #fff;
}

.marker:hover .marker__inner,
.marker:focus-visible .marker__inner {
  transform: translateY(-2px) scale(1.03);
}

.marker.is-active {
  z-index: 3;
}

.marker.is-active .marker__inner {
  transform: scale(1.12);
}

.marker.is-active .marker__pin {
  fill: var(--accent-ink);
}

.marker.is-dimmed {
  opacity: 0.22;
}

.marker:focus {
  outline: none;
}

.marker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.me-marker {
  position: relative;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
}

.me-marker__halo {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.1);
}

.me-marker__dot {
  position: relative;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
}

.me-marker__label {
  position: absolute;
  top: 50%;
  left: 24px;
  padding: 4px 7px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
  transform: translateY(-50%);
}

.marker__label {
  position: absolute;
  top: 2px;
  left: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.marker:hover .marker__label,
.marker:focus-visible .marker__label {
  opacity: 1;
}

/* Popup + company card */
.company-popup .maplibregl-popup-content {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: "Geist", system-ui, sans-serif;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.05);
}

.company-popup .maplibregl-popup-tip {
  border-width: 8px;
}

.card {
  width: 320px;
  padding: 16px 16px 14px;
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.card__name {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.01em;
}

.card__close {
  display: grid;
  flex: none;
  width: 28px;
  height: 28px;
  margin: -2px -4px 0 0;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.card__close:hover {
  background: #f2f0eb;
  color: var(--text);
}

.card__rows {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
}

.card__row {
  display: grid;
  gap: 1px;
}

.card__label {
  font-size: var(--fs-small);
  color: var(--muted);
}

.card__value {
  font-size: 14px;
  line-height: 1.4;
}

.card__phone-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card__phone {
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

.card__phone:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card__copy {
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
}

.card__copy:hover {
  background: #f6f4ef;
  color: var(--text);
}

.card__addr {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.card__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btn {
  display: inline-flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.btn--primary {
  flex: 1;
  background: var(--text);
  color: #fff;
}

.btn--primary:hover {
  background: #1c2740;
}

.btn--ghost {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.btn--ghost:hover {
  background: #f6f4ef;
}

.card__source {
  display: inline-block;
  margin-top: 10px;
  font-size: var(--fs-small);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card__source:hover {
  color: var(--text);
}

/* Mobile */
.mobile-card {
  display: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 80;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 860px) {
  .app {
    display: block;
  }

  .panel {
    position: fixed;
    inset: 0;
    z-index: 40;
    padding: calc(16px + env(safe-area-inset-top)) 12px 0;
    border-right: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.24s;
  }

  .panel.is-open {
    visibility: visible;
    transform: none;
  }

  .panel__close {
    display: grid;
  }

  .search input {
    font-size: 16px;
  }

  .map-wrap {
    position: fixed;
    inset: 0;
  }

  .topbar {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 6;
    display: flex;
    height: calc(var(--topbar) + env(safe-area-inset-top));
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: env(safe-area-inset-top) 14px 0;
    border-bottom: 1px solid var(--border);
    background: var(--ground);
  }

  .topbar__brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
  }

  .topbar__mark {
    flex: none;
    width: 22px;
    height: 22px;
    color: var(--text);
  }

  .topbar__name {
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar__list {
    display: inline-flex;
    flex: none;
    height: 34px;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
    font-weight: 500;
  }

  .topbar__list:hover {
    background: #faf9f6;
  }

  .topbar__count {
    color: var(--muted);
  }

  .map {
    position: absolute;
    inset: calc(var(--topbar) + env(safe-area-inset-top)) 0 0;
  }

  .map-controls {
    top: calc(var(--topbar) + env(safe-area-inset-top) + 12px);
    right: 12px;
  }

  .route-bar {
    top: calc(var(--topbar) + env(safe-area-inset-top) + 12px);
    left: 12px;
    max-width: calc(100% - 74px);
    gap: 8px;
    padding: 8px 8px 8px 10px;
  }

  .map-status {
    bottom: calc(12px + env(safe-area-inset-bottom));
    left: 12px;
  }

  .mobile-card {
    position: fixed;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    z-index: 35;
    display: block;
    max-height: 72dvh;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  }

  .mobile-card .card {
    width: auto;
    padding: 16px;
  }

  .card__phone {
    font-size: 17px;
  }

  .toast {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

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

  #compassNeedle {
    transition: none;
  }
}
