:root {
  color-scheme: light;
  --accent-color: #00cfd3;
  --on-accent-color: #041719;
  --color-main: #172033;
  --color-back: #edf3f4;
  --color-panel: rgba(255, 255, 255, 0.94);
  --color-border: rgba(23, 32, 51, 0.16);
  --color-muted: #5f6d7c;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: var(--font-ui);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --hosted-accent-duration: 3333ms;
  --host-safe-left: 0px;
  --host-safe-right: 0px;
  --host-safe-bottom: 0px;
  --cursor-info: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2720%27 height=%2720%27 viewBox=%270 0 20 20%27%3E%3Ccircle cx=%2710%27 cy=%2710%27 r=%278%27 fill=%27white%27 stroke=%27%23172033%27 stroke-width=%271.5%27/%3E%3Cpath d=%27M10 8.5v5M10 5.75h.01%27 fill=%27none%27 stroke=%27%23172033%27 stroke-width=%272%27 stroke-linecap=%27round%27/%3E%3C/svg%3E") 10 10, help;
}

:root[data-theme="dark"],
:root[data-brightness="dark"] {
  color-scheme: dark;
  --color-main: #f5f7f4;
  --color-back: #202423;
  --color-panel: rgba(30, 34, 33, 0.94);
  --color-border: rgba(255, 255, 255, 0.15);
  --color-muted: rgba(255, 255, 255, 0.62);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: var(--color-main);
  background: var(--color-back);
  font-family: var(--font-ui);
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  transition: color var(--hosted-accent-duration), background-color var(--hosted-accent-duration), border-color var(--hosted-accent-duration);
}

#app-direct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 14px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-panel);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

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

#homepage-logo {
  display: block;
  object-fit: contain;
}

#app {
  min-height: 0;
}

.map-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  min-height: 480px;
  overflow: hidden;
  background: var(--color-back);
}

#map {
  position: absolute;
  inset: 0;
  background: var(--color-back);
  transition: opacity 240ms ease;
}

#map .maplibregl-ctrl-bottom-right > .maplibregl-ctrl {
  margin: 6px;
}

#map .maplibregl-ctrl-group {
  opacity: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-panel);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transition: opacity 160ms ease;
}

#map:hover .maplibregl-ctrl-group,
#map .maplibregl-ctrl-group:hover,
#map .maplibregl-ctrl-group:focus-within {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none), (pointer: coarse) {
  #map .maplibregl-ctrl-group {
    opacity: 1;
    pointer-events: auto;
  }
}

#map .maplibregl-ctrl-group button {
  width: 28px;
  height: 28px;
  color: var(--color-main);
  background: var(--color-panel);
  font-weight: 650;
}

#map .maplibregl-ctrl-group button + button {
  border-top: 1px solid var(--color-border);
}

#map .maplibregl-ctrl-group button:hover {
  background: color-mix(in srgb, var(--accent-color) 12%, var(--color-panel));
}

#map .maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  display: grid;
  place-items: center;
  background-image: none !important;
  color: inherit;
}

#map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before,
#map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before {
  line-height: 1;
}

#map .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon::before {
  content: "+";
  font-size: 1.1rem;
}

#map .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon::before {
  content: "−";
  font-size: 1.15rem;
}

#map .maplibregl-ctrl-group button:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: -3px;
}

html[data-embed] #map {
  opacity: 0;
}

html[data-embed][data-map-paint="pending"] #map {
  opacity: 0;
}

html[data-embed][data-map-paint="ready"] #map {
  opacity: 1;
  transition-duration: 333ms;
}

html[data-map-content="pending"] #map {
  opacity: 0;
}

html[data-embed][data-map-paint="ready"][data-map-content="pending"] #map {
  opacity: 0;
}

html[data-embed][data-map-content="pending"] .route-loading {
  display: flex !important;
}

.route-loading {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: absolute;
  z-index: 6;
  top: 50%;
  left: 50%;
  width: min(240px, calc(100% - 72px));
  height: auto;
  overflow: visible;
  transform: translate(-50%, -50%);
}

.route-loading[hidden] {
  display: none;
}

.route-loading-name {
  align-self: center;
  max-width: 100%;
  overflow: hidden;
  padding: 4px 9px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-main);
  background: color-mix(in srgb, var(--color-panel) 92%, transparent);
  font-size: 0.76rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-loading-track {
  display: block;
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-color) 18%, transparent);
}

.route-loading-bar {
  display: block;
  width: 12%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-color);
  animation: route-loading-progress 4s cubic-bezier(0.1, 0.7, 0.25, 1) forwards;
  transition: width 160ms ease;
}

.route-loading.is-complete .route-loading-bar {
  width: 100%;
  animation: none;
}

@keyframes route-loading-progress {
  from { width: 12%; }
  to { width: 86%; }
}

.map-shell.is-empty #map {
  opacity: 0.54;
}

html[data-embed][data-map-content="pending"] .map-shell.is-empty #map {
  opacity: 0;
}

.maplibregl-canvas:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: -4px;
}

.empty-state {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 32px;
  color: var(--color-main);
  text-align: center;
  background: color-mix(in srgb, var(--color-back) 70%, transparent);
}

.empty-state[hidden] {
  display: none;
}

.empty-state p {
  max-width: 44rem;
  margin: 0 auto;
  font: 700 clamp(1.25rem, 3vw, 2rem) / 1.25 var(--font-display);
  text-wrap: balance;
}

.smart-form {
  display: flex;
  width: min(46rem, calc(100vw - 40px));
  margin: 0 auto;
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-panel);
  box-shadow: 0 18px 55px rgba(13, 24, 32, 0.18);
}

.smart-form input {
  min-width: 0;
  flex: 1;
  padding: 12px 16px;
  border: 0;
  outline: 0;
  color: var(--color-main);
  background: transparent;
}

.smart-form input::placeholder {
  color: var(--color-muted);
}

.smart-form button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: var(--on-accent-color);
  background: var(--accent-color);
  font-weight: 750;
  cursor: pointer;
}

.smart-form button:disabled {
  cursor: progress;
  opacity: 0.7;
}

.status {
  position: absolute;
  z-index: 7;
  left: 12px;
  bottom: 12px;
  width: 36px;
  height: 36px;
}

html[data-embed] .status {
  left: calc(12px + var(--host-safe-left));
  bottom: max(12px, calc(var(--host-safe-bottom) - 12px));
}

html[data-embed]:not([data-host-dev-mode="true"]) .status {
  display: none !important;
}

.status > summary {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  list-style: none;
  backdrop-filter: blur(18px);
}

.status > summary::-webkit-details-marker {
  display: none;
}

.status > summary::marker {
  content: "";
}

.status-message {
  position: absolute;
  left: calc(100% + 8px);
  bottom: 0;
  width: max-content;
  max-width: min(32rem, calc(100vw - 68px - var(--host-safe-left) - var(--host-safe-right)));
  max-height: min(24rem, calc(100vh - 24px - var(--host-safe-bottom)));
  overflow: auto;
  font-size: 0.88rem;
  line-height: 1.4;
}

.status-summary {
  margin: 0;
  font-weight: 750;
}

.status-debug {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 12px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.status-debug dt {
  color: var(--color-muted);
  font-weight: 700;
}

.status-debug dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.widget-panel {
  padding: 11px 15px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-main);
  background: var(--color-panel);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.widget-icon {
  display: block;
  width: 20px;
  height: 20px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.warning-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23172033' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2.8 20h18.4L12 3Z'/%3E%3Cpath d='M12 9v5m0 3h.01'/%3E%3C/svg%3E");
}

.settings-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23172033' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .34 1.88l.06.06-2.83 2.83-.06-.06a1.7 1.7 0 0 0-1.88-.34A1.7 1.7 0 0 0 14 20.92V21h-4v-.08a1.7 1.7 0 0 0-1.03-1.55 1.7 1.7 0 0 0-1.88.34l-.06.06-2.83-2.83.06-.06A1.7 1.7 0 0 0 4.6 15 1.7 1.7 0 0 0 3.08 14H3v-4h.08A1.7 1.7 0 0 0 4.6 9a1.7 1.7 0 0 0-.34-1.88l-.06-.06 2.83-2.83.06.06A1.7 1.7 0 0 0 9 4.63 1.7 1.7 0 0 0 10 3.08V3h4v.08A1.7 1.7 0 0 0 15 4.63a1.7 1.7 0 0 0 1.88-.34l.06-.06 2.83 2.83-.06.06A1.7 1.7 0 0 0 19.37 9 1.7 1.7 0 0 0 20.92 10H21v4h-.08A1.7 1.7 0 0 0 19.4 15Z'/%3E%3C/svg%3E");
}

.settings-toggle {
  position: absolute;
  z-index: 10;
  left: 12px;
  bottom: 56px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-main);
  background: #fff;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: transform 180ms ease, color var(--hosted-accent-duration), background-color var(--hosted-accent-duration), border-color var(--hosted-accent-duration);
}

.settings-toggle:hover {
  background: var(--accent-color);
  transform: rotate(12deg) scale(1.04);
}

.status[hidden] + .settings-toggle {
  bottom: 12px;
}

.settings-panel {
  position: absolute;
  z-index: 9;
  left: 56px;
  bottom: 56px;
  width: min(23rem, calc(100% - 68px));
  max-height: calc(100% - 68px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  color: var(--color-main);
  background: var(--color-panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(22px);
}

.settings-panel[hidden] {
  display: none;
}

.settings-group {
  padding: 16px 0;
  border-top: 1px solid var(--color-border);
}

.settings-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.settings-group h2 {
  margin: 0 0 13px;
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.settings-group label:not(.switch) {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 13px 0 6px;
  font-size: 0.82rem;
}

.settings-group output {
  color: var(--accent-color);
  font: 700 0.74rem var(--font-mono);
}

.settings-group input[type="range"],
.settings-group select {
  width: 100%;
}

.settings-group input[type="range"] {
  accent-color: var(--accent-color);
}

.settings-group select {
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-main);
  background: var(--color-panel);
}

.settings-group option:disabled {
  color: var(--color-muted);
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.82rem;
}

.switch input {
  width: 38px;
  height: 22px;
  accent-color: var(--accent-color);
}

.route-mode-field + .route-mode-field {
  margin-top: 12px;
}

.location-dot {
  appearance: none;
  z-index: 2 !important;
  width: 14px;
  height: 14px;
  border: 2px solid var(--on-accent-color);
  border-radius: 50%;
  padding: 0;
  background: var(--accent-color);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.34);
  transition: background-color var(--hosted-accent-duration), border-color var(--hosted-accent-duration);
  cursor: pointer;
}

.map-shell.is-route-hover .maplibregl-canvas {
  cursor: pointer !important;
}

.location-dot:focus-visible,
.travel-mode-symbol:focus-visible {
  outline: 3px solid var(--color-main);
  outline-offset: 3px;
}

.maps-hover-popup {
  z-index: 20;
  pointer-events: none;
}

.maps-hover-popup .maplibregl-popup-content {
  max-width: min(320px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-main);
  background: var(--color-panel);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
  font-size: 0.78rem;
  line-height: 1.35;
}

.maps-hover-popup.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maps-hover-popup.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maps-hover-popup.maplibregl-popup-anchor-top-right .maplibregl-popup-tip {
  border-bottom-color: var(--color-panel);
}

.maps-hover-popup.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maps-hover-popup.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maps-hover-popup.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip {
  border-top-color: var(--color-panel);
}

.maps-hover-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: var(--color-panel);
}

.maps-hover-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: var(--color-panel);
}

.travel-mode-symbol {
  appearance: none;
  z-index: 1 !important;
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent-color) 72%, var(--color-border));
  border-radius: 50%;
  padding: 0;
  color: var(--accent-color);
  background: color-mix(in srgb, var(--color-panel) 90%, transparent);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: color var(--hosted-accent-duration), background-color var(--hosted-accent-duration), border-color var(--hosted-accent-duration);
}

.travel-mode-symbol svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#app-direct-footer {
  padding: 11px clamp(18px, 4vw, 48px);
  color: var(--color-muted);
  background: var(--color-panel);
  font-size: 0.82rem;
}

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

html[data-embed] body {
  display: block;
  height: 100vh;
  min-height: 0;
}

html[data-embed] #app-direct-header,
html[data-embed] #app-direct-footer,
html[data-embed] .settings-toggle,
html[data-embed] .settings-panel,
html[data-embed] .empty-state {
  display: none !important;
}

html[data-embed] #app,
html[data-embed] .map-shell {
  width: 100%;
  height: 100vh;
  min-height: 0;
}

@media (prefers-reduced-motion: reduce) {
  html[data-embed][data-map-paint="ready"] #map {
    transition-duration: 0ms;
  }

  .route-loading-bar {
    width: 72%;
    animation: none;
    transition-duration: 0ms;
  }
}

html[data-embed="full"] .map-shell {
  height: 100%;
}

@media (max-width: 600px) {
  .map-shell {
    min-height: 420px;
  }

  .empty-state {
    padding: 22px;
  }

  .smart-form {
    align-items: stretch;
    flex-direction: column;
    border-radius: 18px;
  }

  .smart-form button {
    border-radius: 13px;
  }
}

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