:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #66716b;
  --line: #d9dfdb;
  --paper: #f5f7f5;
  --surface: #ffffff;
  --green: #1c6b4a;
  --green-dark: #122f24;
  --green-pale: #e8f2ed;
  --orange: #d75a2c;
  --danger: #a43e34;
  --shadow: 0 12px 30px rgba(25, 44, 35, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 22px;
  color: #fff;
  background: var(--green-dark);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--orange);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.service-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d6a83d;
}

.service-state.is-online .state-dot {
  background: #54c28a;
}

.service-state.is-offline .state-dot {
  background: #e67668;
}

.workspace {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(300px, 360px) minmax(360px, 1fr) minmax(320px, 390px);
  overflow: hidden;
}

.view {
  min-width: 0;
  min-height: 0;
}

.plan-view,
.places-view {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: var(--surface);
}

.plan-view {
  padding: 28px 26px 48px;
  border-right: 1px solid var(--line);
}

.places-view {
  padding: 28px 22px 40px;
  border-left: 1px solid var(--line);
}

.panel-head {
  margin-bottom: 24px;
}

.panel-head h1,
.panel-head h2 {
  margin: 4px 0 8px;
  color: var(--green-dark);
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.panel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.panel-head .eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.trip-form {
  display: grid;
  gap: 20px;
}

.field,
.field-group {
  display: grid;
  gap: 7px;
}

.field > span,
.field-heading > span {
  color: #3d4842;
  font-size: 12px;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd3ce;
  border-radius: 7px;
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(28, 107, 74, 0.12);
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-button {
  padding: 5px 0;
  color: var(--green);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.waypoint-list {
  display: grid;
  gap: 8px;
}

.waypoint-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 7px;
}

.waypoint-number {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-pale);
  font-size: 11px;
  font-weight: 800;
}

.remove-waypoint {
  width: 34px;
  height: 40px;
  padding: 0;
  color: #76817b;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 21px;
  cursor: pointer;
}

.remove-waypoint:hover,
.remove-waypoint:focus-visible {
  color: var(--danger);
  background: #f8ecea;
}

.vehicle-settings {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.vehicle-settings summary {
  padding: 14px 0;
  color: #3d4842;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 0 16px;
}

.primary-button {
  min-height: 48px;
  padding: 12px 18px;
  color: #fff;
  background: var(--green);
  border: 0;
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover {
  background: #15573c;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.notice {
  margin-top: 18px;
  padding: 12px 14px;
  color: #714027;
  background: #fff4eb;
  border: 1px solid #f0c8ad;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1.45;
}

.notice.is-error {
  color: #762f29;
  background: #fff0ee;
  border-color: #e9b5af;
}

.route-result {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.route-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.route-stat {
  padding: 12px;
  background: var(--paper);
  border-radius: 7px;
}

.route-stat strong,
.route-stat span {
  display: block;
}

.route-stat strong {
  color: var(--green-dark);
  font-size: 20px;
}

.route-stat span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.route-heading {
  margin: 0 0 10px;
  color: var(--green-dark);
  font-size: 14px;
}

.route-points {
  display: grid;
  gap: 9px;
}

.route-point {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding-bottom: 9px;
  border-bottom: 1px solid #edf0ee;
}

.route-point:last-child {
  border-bottom: 0;
}

.route-point-index {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 10px;
  font-weight: 800;
}

.route-point strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.route-actions,
.place-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.action-link,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 9px;
  color: #405049;
  background: #fff;
  border: 1px solid #cfd6d2;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.action-link:hover,
.small-button:hover {
  color: var(--green);
  border-color: var(--green);
}

.route-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.map-view {
  position: relative;
  overflow: hidden;
  background: #dce7e0;
}

.map,
.map-fallback {
  position: absolute;
  inset: 0;
}

.map-fallback iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.map-fallback-note {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  max-width: 440px;
  padding: 11px 13px;
  color: #fff;
  background: rgba(18, 47, 36, 0.92);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.map-fallback-note strong,
.map-fallback-note span {
  display: block;
}

.map-fallback-note span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.map-toolbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 7px;
}

.map-toolbar button {
  min-height: 38px;
  padding: 8px 11px;
  color: var(--green-dark);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(18, 47, 36, 0.18);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(21, 48, 36, 0.12);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.map-empty {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: min(280px, calc(100% - 40px));
  padding: 18px;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(18, 47, 36, 0.15);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.map-empty strong,
.map-empty span {
  display: block;
}

.map-empty span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.place-drawer {
  position: absolute;
  z-index: 6;
  right: 14px;
  bottom: 14px;
  width: min(360px, calc(100% - 28px));
  padding: 16px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(18, 47, 36, 0.16);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.place-drawer h3 {
  margin: 0 26px 4px 0;
  color: var(--green-dark);
  font-size: 16px;
}

.place-drawer p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.drawer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 20px;
  cursor: pointer;
}

.place-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 18px;
}

.place-search button {
  padding: 0 13px;
  color: #fff;
  background: var(--green);
  border: 0;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.filter-row {
  display: flex;
  gap: 6px;
  margin: -5px 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 10px;
  color: #5b6761;
  background: var(--paper);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.filter.is-active {
  color: var(--green);
  background: var(--green-pale);
  border-color: #c5ddcf;
}

.search-status {
  min-height: 18px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.place-list {
  display: grid;
  gap: 22px;
}

.place-stage {
  display: grid;
  gap: 9px;
}

.place-stage-head {
  display: grid;
  gap: 3px;
  padding: 0 2px 2px;
}

.place-stage-head span {
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.place-stage-head strong {
  overflow: hidden;
  color: var(--green-dark);
  font-size: 14px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.place-card.is-waypoint {
  background: var(--green-pale);
  border-color: #bfd8c9;
  border-left: 4px solid var(--green);
}

.place-card h3 {
  margin: 0;
  color: var(--green-dark);
  font-size: 14px;
  line-height: 1.35;
}

.place-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  color: #59645f;
  background: var(--paper);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 750;
}

.tag.is-verified {
  color: var(--green);
  background: var(--green-pale);
}

.place-note {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-list {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}

.mobile-nav {
  display: none;
}

.maplibregl-popup-content {
  padding: 10px 12px;
  border-radius: 7px;
  font: 12px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}

.maplibregl-ctrl-group {
  border-radius: 6px;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #fff;
  background: var(--green-dark);
  text-align: center;
}

@media (max-width: 1100px) and (min-width: 761px) {
  .workspace {
    grid-template-columns: 330px minmax(340px, 1fr);
  }

  .places-view {
    display: none;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-rows: 58px minmax(0, 1fr) calc(62px + env(safe-area-inset-bottom));
  }

  .topbar {
    padding: 0 14px;
  }

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

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

  .brand small {
    display: none;
  }

  .service-state {
    max-width: 45%;
    font-size: 11px;
  }

  #service-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .workspace {
    display: block;
    height: 100%;
    overflow: hidden;
  }

  .view {
    display: none;
    width: 100%;
    height: 100%;
  }

  .view.is-active {
    display: block;
  }

  .plan-view,
  .places-view {
    padding: 22px 17px calc(34px + env(safe-area-inset-bottom));
    border: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .map-view.is-active {
    display: block;
    overflow: hidden;
  }

  .panel-head {
    margin-bottom: 20px;
  }

  .panel-head h1,
  .panel-head h2 {
    font-size: 24px;
  }

  .mobile-nav {
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 6px 9px calc(6px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--line);
  }

  .nav-button {
    display: grid;
    min-width: 0;
    place-items: center;
    gap: 2px;
    padding: 4px;
    color: #728079;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
  }

  .nav-button.is-active {
    color: var(--green);
    background: var(--green-pale);
  }

  .nav-symbol {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 10px;
  }

  .map-toolbar {
    top: 10px;
    left: 10px;
  }

  .map-toolbar button {
    min-height: 40px;
  }

  .place-drawer {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: 44%;
    overflow-y: auto;
  }
}

@media (max-width: 390px) {
  .vehicle-grid {
    grid-template-columns: 1fr;
  }

  .route-summary {
    grid-template-columns: 1fr;
  }

  .place-search {
    grid-template-columns: 1fr;
  }

  .place-search button {
    min-height: 42px;
  }
}

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