:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.84);
  --surface-muted: #f4f6f8;
  --text: #202124;
  --muted: #6b7280;
  --line: rgba(32, 33, 36, 0.12);
  --line-strong: rgba(32, 33, 36, 0.18);
  --accent: #256bd5;
  --accent-strong: #1758bb;
  --accent-soft: #e8f0fe;
  --success: #1a9a69;
  --shadow: 0 3px 12px rgba(36, 40, 46, 0.14), 0 14px 28px rgba(36, 40, 46, 0.09);
  --soft-shadow: 0 2px 8px rgba(36, 40, 46, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 107, 213, 0.32);
  outline-offset: 2px;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

.app-shell[data-theme="dark"] {
  --surface: rgba(34, 38, 43, 0.97);
  --surface-soft: rgba(34, 38, 43, 0.88);
  --surface-muted: #2b3037;
  --text: #f4f6f8;
  --muted: #abb4c1;
  --line: rgba(244, 246, 248, 0.14);
  --line-strong: rgba(244, 246, 248, 0.2);
  --accent: #74a9ff;
  --accent-strong: #4b8cf3;
  --accent-soft: #243a60;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.34), 0 16px 30px rgba(0, 0, 0, 0.24);
  --soft-shadow: 0 2px 8px rgba(0, 0, 0, 0.34);
}

.map-header {
  position: fixed;
  z-index: 6;
  top: 12px;
  left: 12px;
  display: grid;
  grid-template-columns: auto minmax(360px, 520px) auto;
  align-items: start;
  gap: 10px;
  max-width: calc(100vw - 24px);
}

.brand-button,
.route-launcher,
.search-box,
.results-list,
.map-tools,
.route-panel,
.drawer,
.place-sheet,
.toast {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--surface);
}

.brand-button {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 48px;
  padding: 0 12px 0 7px;
  border-radius: 8px;
  font-weight: 750;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.brand-button:hover,
.route-launcher:hover,
.map-tools button:hover,
.panel-head button:hover,
#favoritePlace:hover {
  background: var(--surface-muted);
}

.brand-mark {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  color: white;
  background: var(--accent);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand-name {
  font-size: 15px;
}

.brand-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.search-panel {
  position: relative;
  width: 100%;
}

.search-box {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 5px 0 15px;
  border-radius: 8px;
}

.search-box > svg {
  color: var(--muted);
}

.search-box input {
  min-width: 0;
  height: 46px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 15px;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box button,
.map-tools button,
.panel-head button,
#favoritePlace {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  background: transparent;
}

.quick-search {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  padding: 1px 1px 3px;
  scrollbar-width: none;
}

.quick-search::-webkit-scrollbar {
  display: none;
}

.quick-search button {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--soft-shadow);
  color: var(--text);
  font-size: 13px;
  background: var(--surface);
  transition: background-color 140ms ease, transform 140ms ease;
}

.quick-search button:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.quick-search svg {
  width: 15px;
  height: 15px;
  color: var(--accent);
}

.route-launcher {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.route-launcher svg {
  color: var(--accent);
}

.results-list {
  position: absolute;
  top: 96px;
  right: 0;
  left: 0;
  overflow: hidden auto;
  max-height: min(510px, calc(100vh - 125px));
  border-radius: 8px;
}

.result-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 13px 15px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: transparent;
  transition: background-color 140ms ease;
}

.result-item:hover {
  background: var(--surface-muted);
}

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

.result-item svg {
  width: 19px;
  height: 19px;
  margin-top: 1px;
  color: var(--accent);
}

.result-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  font-weight: 650;
}

.result-item span,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.map-tools {
  position: fixed;
  z-index: 4;
  right: 14px;
  bottom: 86px;
  display: grid;
  gap: 1px;
  padding: 4px;
  border-radius: 8px;
}

.map-tools button {
  position: relative;
  transition: background-color 140ms ease, color 140ms ease;
}

.map-tools button + button::before {
  position: absolute;
  top: -1px;
  right: 5px;
  left: 5px;
  height: 1px;
  content: "";
  background: var(--line);
}

.map-tools .active,
.segmented .active,
.actions button:first-child {
  color: white;
  background: var(--accent);
}

.map-tools .active:hover,
.segmented .active:hover,
.actions button:first-child:hover {
  background: var(--accent-strong);
}

.route-panel,
.drawer,
.place-sheet {
  position: fixed;
  z-index: 5;
  left: 70px;
  top: 80px;
  width: min(402px, calc(100vw - 94px));
  max-height: calc(100vh - 98px);
  overflow: auto;
  border-radius: 8px;
}

.route-panel,
.drawer {
  padding: 14px;
}

.drawer {
  top: 80px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  margin-bottom: 12px;
}

.panel-head strong {
  font-size: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 12px;
}

.route-form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.route-start-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.route-start-mode button,
.segmented button,
.actions button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.route-start-mode button:hover,
.segmented button:hover,
.actions button:hover {
  background: var(--surface-muted);
}

.route-start-mode .active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: var(--accent-soft);
}

.route-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.route-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface-muted);
}

.route-form input:focus {
  border-color: var(--accent);
}

.route-form > button[type="submit"] {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  color: white;
  background: var(--accent);
  font-weight: 650;
}

.route-form > button[type="submit"]:hover {
  background: var(--accent-strong);
}

.route-summary {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 12px;
  background: var(--surface-muted);
  line-height: 1.35;
}

.route-summary strong {
  font-size: 18px;
}

.route-steps {
  padding-left: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.route-steps li {
  margin: 9px 0;
}

.place-sheet {
  padding: 11px 14px 14px;
}

.sheet-handle {
  display: none;
}

.place-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 10px;
  align-items: start;
}

.place-main h1 {
  margin: 2px 0 4px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.place-main p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.place-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 13px 0;
}

.metric {
  min-height: 54px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.metric span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.list-button {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.list-button:hover {
  background: var(--surface-muted);
}

.list-button:last-child {
  border-bottom: 0;
}

.toast {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: 22px;
  max-width: min(440px, calc(100vw - 36px));
  padding: 11px 14px;
  border-radius: 8px;
  transform: translateX(-50%);
  font-size: 14px;
}

.maplibregl-ctrl-top-right {
  top: auto;
  right: 14px;
  bottom: 15px;
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid var(--line) !important;
  border-radius: 8px !important;
  box-shadow: var(--soft-shadow) !important;
}

.maplibregl-ctrl-group button {
  width: 38px;
  height: 38px;
  background-color: var(--surface);
}

.maplibregl-popup-content {
  border-radius: 6px;
  padding: 10px 12px;
  color: #202124;
  box-shadow: var(--soft-shadow);
}

svg {
  width: 19px;
  height: 19px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .map-header {
    top: 8px;
    right: 8px;
    left: 8px;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 8px;
    max-width: none;
  }

  .brand-button {
    width: 48px;
    padding: 7px;
  }

  .brand-name,
  .brand-label {
    display: none;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .route-launcher {
    position: fixed;
    top: 64px;
    left: 8px;
    min-height: 40px;
    padding: 0 11px;
    box-shadow: var(--soft-shadow);
  }

  .route-launcher span {
    font-size: 13px;
  }

  .quick-search {
    margin-top: 7px;
    padding-left: 60px;
  }

  .results-list {
    top: 95px;
    max-height: min(460px, calc(100vh - 164px));
  }

  .map-tools {
    right: 8px;
    bottom: 76px;
  }

  .route-panel,
  .drawer {
    top: 112px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100vh - 132px);
  }

  .place-sheet {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    max-height: min(53vh, 440px);
    padding-top: 9px;
  }

  .sheet-handle {
    display: block;
    width: 36px;
    height: 4px;
    margin: 0 auto 9px;
    border-radius: 2px;
    background: var(--line-strong);
  }

  .place-main h1 {
    font-size: 19px;
  }

  .metric {
    min-height: 49px;
  }

  .toast {
    bottom: 12px;
  }
}

@media (max-width: 430px) {
  .quick-search button {
    padding: 0 9px;
  }

  .route-start-mode,
  .segmented {
    grid-template-columns: 1fr;
  }

  .route-panel {
    max-height: calc(100vh - 120px);
  }

  .actions {
    grid-template-columns: 1fr;
  }
}

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