:root {
  color-scheme: light;
  --ink: #18201b;
  --muted: #68736c;
  --panel: rgba(255, 255, 255, 0.92);
  --card: #ffffff;
  --field: #ffffff;
  --ghost: #edf1ee;
  --line: rgba(24, 32, 27, 0.12);
  --green: #18a058;
  --red: #d94841;
  --blue: #2374ab;
  --unknown: #8b9490;
  --map-fallback: #d9e3d8;
  --grid-line: rgba(255, 255, 255, 0.36);
  --page-bg: #e8ece8;
  --count-bg: #18201b;
  --count-ink: #ffffff;
  --shadow: 0 18px 60px rgba(21, 31, 25, 0.18);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef5ee;
  --muted: #a7b2ac;
  --panel: rgba(20, 25, 22, 0.9);
  --card: #1a211d;
  --field: #111713;
  --ghost: #26302a;
  --line: rgba(238, 245, 238, 0.14);
  --green: #35c979;
  --red: #ff6b63;
  --blue: #5eb1ff;
  --unknown: #9aa5a0;
  --map-fallback: #131a17;
  --grid-line: rgba(255, 255, 255, 0.08);
  --page-bg: #0f1512;
  --count-bg: #eef5ee;
  --count-ink: #101511;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--page-bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.map-surface {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    var(--map-fallback);
  background-size: 44px 44px;
}

.brand-panel,
.search-panel,
.map-tools,
.result-drawer {
  position: absolute;
  z-index: 2;
}

.brand-panel,
.search-panel,
.result-drawer,
.config-form {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand-panel {
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 210px;
  padding: 14px 16px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.status-pill {
  margin-left: auto;
  padding: 7px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  background: var(--blue);
}

.status-pill.error {
  background: var(--red);
}

.status-pill.ready {
  background: var(--green);
}

.search-panel {
  top: 18px;
  left: max(360px, calc(20vw + 48px));
  right: 92px;
  display: grid;
  grid-template-columns: minmax(96px, 0.7fr) 92px minmax(220px, 1.7fr) 118px 92px 96px;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
}

.search-field,
.config-form label {
  display: grid;
  gap: 6px;
}

.search-field span,
.config-form label span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.search-field input,
.search-field select,
.config-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  color: var(--ink);
  background: var(--field);
  outline: none;
}

.search-field input:focus,
.search-field select:focus,
.config-form input:focus {
  border-color: rgba(24, 160, 88, 0.55);
  box-shadow: 0 0 0 3px rgba(24, 160, 88, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.tool-button {
  border: 0;
  border-radius: 6px;
}

.primary-button {
  align-self: end;
  min-height: 40px;
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary-button {
  align-self: end;
  min-height: 40px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--ghost);
  font-weight: 700;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.map-tools {
  top: 18px;
  right: 18px;
  display: grid;
  gap: 10px;
}

.tool-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(21, 31, 25, 0.14);
  backdrop-filter: blur(16px);
}

.tool-button span {
  font-size: 24px;
  line-height: 1;
}

.result-drawer {
  top: 104px;
  left: 18px;
  bottom: 18px;
  width: clamp(300px, 20vw, 390px);
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#resultCount {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 30px;
  border-radius: 999px;
  color: var(--count-ink);
  background: var(--count-bg);
  font-weight: 700;
}

.result-list {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-color: rgba(104, 115, 108, 0.62) transparent;
  scrollbar-width: thin;
}

.result-list::-webkit-scrollbar {
  width: 8px;
}

.result-list::-webkit-scrollbar-track {
  background: transparent;
}

.result-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(104, 115, 108, 0.55);
}

.result-list.detail-mode {
  grid-template-columns: 1fr;
}

.result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 8px;
  align-items: stretch;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--card);
}

.result-main {
  display: grid;
  gap: 7px;
  min-width: 0;
  border: 0;
  padding: 3px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.result-main strong,
.route-summary strong {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-main span,
.route-summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.route-button {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
}

.route-button.large {
  min-height: 44px;
  padding: 0 18px;
}

.poi-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--card);
}

.poi-detail-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.poi-detail-main strong {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poi-detail-main span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.route-summary {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--card);
}

.metro-detail {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--card);
}

.metro-line-chip {
  display: flex;
  gap: 8px;
  align-items: center;
}

.metro-line-chip span {
  width: 34px;
  height: 6px;
  border-radius: 999px;
  background: var(--line-color);
}

.metro-line-chip strong,
.metro-status strong {
  font-size: 15px;
  line-height: 1.25;
}

.metro-status {
  display: grid;
  gap: 6px;
  border-left: 4px solid var(--unknown);
  padding-left: 10px;
}

.metro-status.status-1 {
  border-left-color: var(--green);
}

.metro-status.status-0 {
  border-left-color: var(--red);
}

.metro-status span {
  color: var(--muted);
  font-size: 13px;
}

.dialog-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.dialog-copy code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.empty-state {
  color: var(--muted);
  padding: 16px 4px;
}

.config-dialog {
  width: min(520px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.config-dialog::backdrop {
  background: rgba(18, 23, 20, 0.38);
}

.config-form {
  display: grid;
  gap: 15px;
  padding: 18px;
  border-radius: 8px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--ghost);
}

.toilet-marker,
.place-marker,
.base-marker {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(21, 31, 25, 0.2);
  font-size: 16px;
  font-weight: 800;
}

.toilet-marker {
  border: 3px solid var(--green);
  color: var(--green);
}

.toilet-marker.selected {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
  transform: scale(1.18);
}

.place-marker {
  border: 3px solid var(--blue);
  color: var(--blue);
}

.place-marker.selected {
  color: #fff;
  background: var(--blue);
  transform: scale(1.18);
}

.base-marker {
  width: 30px;
  height: 30px;
  border: 3px solid #fff;
  border-radius: 8px 8px 8px 2px;
  color: #fff;
  background: var(--blue);
  transform: rotate(-45deg);
}

.base-marker::after {
  content: "我";
  transform: rotate(45deg);
  font-size: 14px;
}

.base-marker {
  font-size: 0;
}

.metro-station {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--unknown);
  box-shadow:
    0 0 0 2px rgba(24, 32, 27, 0.2),
    0 5px 16px rgba(0, 0, 0, 0.36);
}

.metro-station::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
}

.metro-station.status-1 {
  background: var(--green);
}

.metro-station.status-0 {
  background: var(--red);
}

.metro-station.status-2 {
  background: var(--unknown);
}

.user-marker {
  width: 18px;
  height: 18px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(35, 116, 171, 0.22);
}

@media (max-width: 760px) {
  .brand-panel {
    top: 12px;
    left: 12px;
    right: 74px;
    min-width: 0;
  }

  .search-panel {
    top: 88px;
    left: 12px;
    right: 12px;
    grid-template-columns: 1fr 96px;
  }

  .place-field,
  .search-panel .primary-button {
    grid-column: 1 / -1;
  }

  .search-panel .secondary-button {
    min-width: 0;
    padding: 0 10px;
  }

  .map-tools {
    top: 12px;
    right: 12px;
  }

  .tool-button {
    width: 46px;
    height: 46px;
  }

  .result-drawer {
    top: auto;
    left: 12px;
    right: 12px;
    width: auto;
    bottom: 12px;
    max-height: 36vh;
  }

  .result-list {
    grid-template-columns: 1fr;
  }

  .result-card {
    grid-template-columns: minmax(0, 1fr) 64px;
  }

  .poi-detail {
    grid-template-columns: 1fr;
  }

  .detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 761px) and (max-width: 1040px) {
  .search-panel {
    left: 18px;
    top: 88px;
    right: 84px;
  }

  .result-drawer {
    top: 160px;
  }
}
