:root {
  --bg: #e8e8ed;
  --sheet: rgba(255, 255, 255, 0.78);
  --sheet-solid: #ffffff;
  --hairline: rgba(60, 60, 67, 0.12);
  --text: #1c1c1e;
  --text-2: #8e8e93;
  --user-bubble: #e9e9eb;
  --fill: #f2f2f7;
  --accent: #007aff;
  --handle: #c7c7cc;
  --sheet-gap: 10px;
  --satt: constant(safe-area-inset-top);
  --satt: env(safe-area-inset-top, 0px);
  --satb: constant(safe-area-inset-bottom);
  --satb: env(safe-area-inset-bottom, 0px);
  --satl: env(safe-area-inset-left, 0px);
  --satr: env(safe-area-inset-right, 0px);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body,
#map {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
}

html,
body {
  overflow: hidden;
  overscroll-behavior: none;
  background: #e8e8ed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Noto Sans SC", sans-serif;
}

#map {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 0;
  isolation: isolate;
  background: #e8e8ed;
  touch-action: pan-x pan-y;
}

#map.amap-container {
  background: #e8e8ed !important;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  html,
  body,
  #map {
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
    background: #e8e8ed;
  }
}

.amap-controlbar,
.amap-toolbar,
.amap-touch-toolbar {
  display: none !important;
}

#map-controls {
  position: fixed;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: calc(48dvh + 22px);
  z-index: 35;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

@media (min-width: 769px) {
  #map-controls {
    right: max(20px, env(safe-area-inset-right, 0px));
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
  }
}

#map-controls button {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  margin: 0;
  padding: 0 !important;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0;
  line-height: 0;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#map-controls button svg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#btn-locate {
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.zoom-stack {
  display: flex;
  flex-direction: column;
  width: 40px;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.zoom-stack button + button {
  border-top: 1px solid var(--hairline);
}

#sheet {
  position: fixed;
  left: max(var(--sheet-gap), var(--satl));
  right: max(var(--sheet-gap), var(--satr));
  top: auto;
  bottom: max(var(--sheet-gap), var(--satb));
  width: auto;
  max-width: none;
  z-index: 40;
  isolation: isolate;
  pointer-events: auto;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  background: var(--sheet);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  border-radius: 26px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  will-change: height, top;
  height: 48vh;
  padding: 0;
}

@media (min-width: 769px) {
  #sheet {
    right: auto;
    width: min(480px, calc(100% - 2 * var(--sheet-gap)));
  }
}

#sheet-handle {
  flex: none;
  width: 100%;
  height: 44px;
  border: 0;
  background: transparent;
  cursor: grab;
  position: relative;
  z-index: 6;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#sheet-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 36px;
  height: 5px;
  margin-left: -18px;
  border-radius: 99px;
  background: var(--handle);
  pointer-events: none;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 16px 8px;
  flex: none;
  touch-action: none;
  cursor: grab;
}

html.sheet-dragging #map {
  pointer-events: none !important;
}

.sheet-head h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.sheet-head button,
.text-btn,
#key-panel button,
#plus-menu button {
  font: inherit;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 15px;
  touch-action: manipulation;
}

#sheet[data-snap="collapsed"] .sheet-head,
#sheet[data-snap="collapsed"] #sheet-messages,
#sheet[data-snap="collapsed"] #key-panel,
#sheet[data-snap="collapsed"] #plus-menu {
  display: none;
}

#sheet-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 16px 12px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.msg {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.45;
}

.msg p {
  margin: 0 0 8px;
}

.msg p:last-child {
  margin-bottom: 0;
}

.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-user .bubble {
  max-width: 82%;
  background: var(--user-bubble);
  border-radius: 18px;
  padding: 8px 14px;
}

.msg-assistant {
  color: var(--text);
}

.msg-system {
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
}

.msg ul {
  margin: 6px 0;
  padding-left: 1.2em;
}

.route-card {
  margin-top: 10px;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.55);
}

.route-card h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.route-card .meta {
  color: var(--text-2);
  font-size: 13px;
  margin-bottom: 8px;
}

.route-card ol {
  margin: 0;
  padding-left: 1.2em;
  font-size: 14px;
}

.gate-actions {
  display: flex;
  gap: 16px;
  margin-top: 10px;
}

.gate-actions button,
.key-actions button {
  font: inherit;
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 14px;
  padding: 0;
  cursor: pointer;
}

.gate-actions button[disabled] {
  color: var(--text-2);
}

.chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding: 0 4px 8px;
}

.chips button {
  appearance: none;
  -webkit-appearance: none;
  text-align: left;
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 11px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#plus-menu {
  position: absolute;
  left: 12px;
  bottom: 64px;
  background: var(--sheet-solid);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  padding: 6px;
  min-width: 180px;
  z-index: 5;
}

#plus-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
}

#plus-menu button:hover {
  background: var(--fill);
}

#key-panel {
  flex: none;
  padding: 0 16px 12px;
  border-top: 1px solid var(--hairline);
}

#key-panel[hidden],
#plus-menu[hidden] {
  display: none !important;
}

.key-lead {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
}

#key-panel label {
  display: block;
  font-size: 13px;
  margin: 8px 0;
}

#key-panel input {
  width: 100%;
  margin-top: 4px;
  border: 0;
  background: var(--fill);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}

.key-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

#composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 12px 12px;
  padding: 6px 6px 6px 8px;
  background: var(--fill);
  border-radius: 24px;
}

#sheet.kb-open #composer {
  margin-bottom: 8px;
}

#btn-plus,
#send {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

#btn-plus {
  background: transparent;
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

#prompt {
  flex: 1;
  border: 0;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.35;
  max-height: 120px;
  outline: none;
  padding: 7px 0;
  touch-action: manipulation;
}

#send {
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
}

#send:disabled {
  background: #d1d1d6;
  color: #fff;
}

.wander-bubble {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 44px;
  pointer-events: auto;
  filter: drop-shadow(0 2px 7px rgba(40, 90, 170, 0.28));
}

.wander-bubble__disc {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3.5px solid #4a90ff;
  background: #34c759;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.wander-bubble--start .wander-bubble__disc {
  width: 44px;
  height: 44px;
  border-width: 4px;
  background: linear-gradient(180deg, #d7b8ff 0%, #b48aef 100%);
}

.wander-bubble--leisure .wander-bubble__disc {
  background: #5aa8ff;
}

.wander-bubble__disc img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.wander-bubble__tip {
  width: 0;
  height: 0;
  margin-top: -1px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid #4a90ff;
}

.amap-marker-content {
  background: transparent !important;
}

.wander-me {
  background: none !important;
  border: 0 !important;
}

.wander-me i {
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: #007aff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(0, 122, 255, 0.22);
}

.amap-info,
.amap-info-contentContainer,
.amap-info-outer {
  max-width: none !important;
}

.amap-info-content {
  box-sizing: border-box !important;
  width: 240px !important;
  min-width: 240px !important;
  max-width: none !important;
  overflow: visible !important;
}

.wander-pop {
  color: var(--text);
  width: 100%;
  max-width: none;
}

.wander-pop h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.wander-pop p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.wander-pop .tips {
  color: var(--text-2);
  margin-top: 6px;
}

body.is-onboarding #map,
body.is-onboarding #map-controls,
body.is-onboarding #sheet {
  visibility: hidden;
  pointer-events: none;
}

#onboard {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) 18px max(24px, env(safe-area-inset-bottom, 0px));
  background: rgba(60, 60, 67, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#onboard[hidden] {
  display: none;
}

.onboard-card {
  width: min(400px, 100%);
  min-height: min(78dvh, 620px);
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.18);
  padding: 52px 32px 36px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 769px) {
  .onboard-card {
    width: min(680px, 86vw);
    min-height: 0;
    padding: 56px 72px 48px;
  }
}

.onboard-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  background: #eef3fb;
  box-shadow: 0 10px 28px rgba(0, 122, 255, 0.2);
  object-fit: contain;
  margin: 8px 0 32px;
}

.onboard-card h2 {
  margin: 0 0 14px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  color: var(--text);
  text-wrap: balance;
}

@media (min-width: 769px) {
  .onboard-card h2 {
    font-size: 28px;
  }
}

.onboard-lead {
  margin: 0 0 12px;
  color: #6e6e73;
  font-size: 15px;
  line-height: 1.55;
  max-width: 36em;
}

.onboard-legal {
  margin: 28px 0 36px;
  font-size: 11px;
  line-height: 1.55;
  color: #8e8e93;
  max-width: 34em;
}

.onboard-legal a {
  color: var(--accent);
  text-decoration: none;
}

.onboard-legal a:hover {
  text-decoration: underline;
}

.onboard-cta {
  appearance: none;
  border: 0;
  min-width: 200px;
  height: 44px;
  padding: 0 32px;
  border-radius: 22px;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  margin-top: auto;
}

.onboard-cta:hover {
  background: #0066d6;
}

.onboard-cta:active {
  transform: scale(0.98);
}

.onboard-cta--quiet {
  background: #f2f2f7;
  color: var(--text);
  margin-top: 28px;
}

.onboard-cta--quiet:hover {
  background: #e5e5ea;
}

#onboard-welcome,
#onboard-policy {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
}

#onboard-welcome[hidden],
#onboard-policy[hidden] {
  display: none;
}
