:root {
  color-scheme: light;
  --bg: #edf7f5;
  --panel: #ffffff;
  --panel-soft: #f3fbf8;
  --ink: #17252d;
  --muted: #637676;
  --line: #d5e6e2;
  --line-strong: #b9d3cd;
  --green: #07856f;
  --green-strong: #056555;
  --green-soft: #e4f8f1;
  --mint: #42c9a6;
  --aqua: #4fb7d8;
  --aqua-soft: #e7f7fb;
  --coral: #d56a4a;
  --coral-soft: #fff0ea;
  --amber: #e4a72e;
  --amber-soft: #fff7df;
  --blue: #2e74a4;
  --blue-soft: #eaf5fc;
  --lavender: #7f7bd8;
  --shadow: 0 20px 50px rgba(31, 72, 78, 0.16);
  --shadow-soft: 0 10px 28px rgba(31, 72, 78, 0.1);
}

* {
  box-sizing: border-box;
}

/* Layout */
body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, #effaf6 0%, #eef8fd 48%, #fff7e6 100%);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #becbc7 transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #becbc7;
  background-clip: content-box;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(460px, 1fr) minmax(320px, 370px);
  height: 100vh;
  min-height: 620px;
}

.sidebar,
.rightbar {
  gap: 16px;
  min-width: 0;
  padding: 16px;
  border-color: rgba(181, 213, 207, 0.8);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(243, 251, 248, 0.94));
  backdrop-filter: blur(14px);
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border-right: 1px solid var(--line);
}

.rightbar {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  overflow: hidden;
}

.right-dock,
.places-dock {
  display: grid;
  min-height: 0;
}

.right-dock {
  flex: 1;
}

.rightbar .itinerary-panel,
.rightbar .route-context-panel {
  flex: 1;
  min-height: 0;
}

.topbar,
.section-title,
.modal-head,
.inline-actions {
  display: flex;
  align-items: center;
}

.topbar,
.section-title,
.modal-head {
  justify-content: space-between;
  gap: 14px;
}

.topbar h1,
.modal h2,
.section-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 25px;
  line-height: 1.1;
}

.section-title h2,
.modal h2 {
  font-size: 16px;
  line-height: 1.25;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Panels */
.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(185, 211, 205, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 255, 253, 0.96));
  box-shadow: var(--shadow-soft);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--mint), var(--aqua), var(--amber));
}

.panel > * {
  position: relative;
}

.sidebar .panel,
.rightbar .panel {
  padding: 15px;
}

.topbar {
  padding: 2px 2px 0;
}

.topbar h1 {
  color: #12343b;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.78);
}

.section-title {
  min-height: 34px;
}

.section-title h2 {
  color: #132226;
}

.places-panel::before {
  background: linear-gradient(90deg, var(--aqua), var(--mint));
}

.itinerary-panel::before {
  background: linear-gradient(90deg, var(--amber), var(--mint), var(--aqua));
}

.places-panel,
.itinerary-panel {
  min-height: 0;
}

.left-workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.left-workspace > .panel,
.left-workspace > .places-dock {
  min-height: 0;
}

.side-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 22px rgba(31, 72, 78, 0.08);
}

.side-tab {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.side-tab.active {
  background: linear-gradient(135deg, var(--green), var(--mint));
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(7, 133, 111, 0.22);
}

.search-panel,
.places-panel {
  display: grid;
  overflow: hidden;
}

.search-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.places-panel {
  grid-template-rows: auto minmax(0, 1fr);
}

.search-panel.hidden,
.places-panel.hidden {
  display: none;
}

.itinerary-panel {
  flex: 1;
}

.city-form,
.search-grid {
  display: grid;
  gap: 10px;
}

.city-form {
  position: relative;
  margin-top: 0;
}

.search-grid {
  margin-top: 14px;
}

.search-grid {
  grid-template-columns: minmax(0, 1fr) 86px;
  align-items: end;
}

.search-grid .wide {
  grid-column: auto;
}

.city-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.city-search-row input {
  min-width: 110px;
}

.selected-city {
  padding: 8px 11px;
  border: 1px solid rgba(66, 201, 166, 0.28);
  border-radius: 6px;
  background: linear-gradient(90deg, var(--green-soft), var(--aqua-soft));
  color: var(--green-strong);
  font-size: 12px;
  line-height: 1.4;
}

.city-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  display: grid;
  max-height: 230px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.city-results.hidden {
  display: none;
}

.city-option {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.city-option:hover,
.city-option:focus-visible {
  background: #f1faf6;
  outline: none;
}

/* Forms And Buttons */
.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  min-height: 138px;
  resize: vertical;
  padding: 11px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(66, 201, 166, 0.88);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(66, 201, 166, 0.16);
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  white-space: nowrap;
  transition:
    transform 0.14s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.primary-button {
  padding: 0 13px;
  background: linear-gradient(135deg, var(--green), #0aa98d);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(8, 123, 103, 0.24);
}

.primary-button:hover {
  background: linear-gradient(135deg, var(--green-strong), var(--green));
  box-shadow: 0 12px 26px rgba(8, 123, 103, 0.3);
  transform: translateY(-1px);
}

.ghost-button,
.icon-button {
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  border-color: rgba(185, 211, 205, 0.86);
}

.ghost-button {
  padding: 0 10px;
}

.ghost-button:hover,
.icon-button:hover {
  border-color: rgba(66, 201, 166, 0.58);
  color: var(--green-strong);
  background: linear-gradient(180deg, #ffffff, var(--green-soft));
  transform: translateY(-1px);
}

.ghost-button.danger:hover {
  border-color: rgba(185, 81, 60, 0.48);
  color: var(--coral);
}

.icon-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.search-grid .primary-button {
  height: 38px;
  min-height: 38px;
  padding: 0 12px;
  box-shadow: 0 8px 18px rgba(8, 123, 103, 0.2);
}

svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.1;
}

.inline-actions {
  gap: 8px;
}

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

.plan-actions .ghost-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 5px 16px rgba(31, 72, 78, 0.06);
}

/* Places */
.result-list,
.place-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.result-list {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.place-list {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.result-item,
.place-item {
  display: grid;
  gap: 8px;
  padding: 11px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfffd);
  box-shadow: 0 5px 16px rgba(31, 72, 78, 0.055);
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.place-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.place-item.active {
  border-color: rgba(66, 201, 166, 0.74);
  background:
    linear-gradient(90deg, rgba(228, 248, 241, 0.88), rgba(255, 255, 255, 0.96));
  box-shadow:
    inset 4px 0 0 var(--mint),
    0 10px 22px rgba(66, 201, 166, 0.14);
}

.result-item:hover,
.place-item:hover {
  border-color: rgba(66, 201, 166, 0.5);
  box-shadow: 0 10px 24px rgba(31, 72, 78, 0.1);
  transform: translateY(-1px);
}

.reset-button {
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.place-text {
  min-width: 0;
  padding: 0;
}

.place-text:focus-visible {
  outline: 2px solid rgba(11, 122, 98, 0.42);
  outline-offset: 3px;
  border-radius: 4px;
}

.place-actions {
  display: flex;
  gap: 6px;
}

.item-title {
  margin: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.item-actions {
  display: flex;
  gap: 8px;
}

.empty-state,
.selected-empty {
  display: grid;
  min-height: 82px;
  place-items: center;
  padding: 12px;
  border: 1px dashed rgba(79, 183, 216, 0.46);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--aqua-soft), #ffffff);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.itinerary-list > .empty-state {
  min-height: 64px;
  align-self: start;
  padding: 14px;
  background: rgba(255, 255, 255, 0.62);
  border-style: dashed;
}

/* Map */
.map-wrap {
  position: relative;
  min-width: 0;
  background: linear-gradient(135deg, #dff1ed, #eef8fd);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 38, 0.05);
}

#map {
  width: 100%;
  height: 100%;
}

.map-status {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  max-width: min(420px, calc(100% - 36px));
  padding: 9px 12px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  color: var(--muted);
  font-size: 13px;
  backdrop-filter: blur(12px);
}

.map-tools {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
}

.map-tools .ghost-button {
  box-shadow: var(--shadow-soft);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

.ghost-button.active {
  border-color: rgba(66, 201, 166, 0.72);
  background: linear-gradient(135deg, var(--green-soft), var(--aqua-soft));
  color: var(--green-strong);
}

.map-status.ready {
  color: var(--green-strong);
}

.map-status.error {
  color: var(--coral);
}

.map-pin {
  display: flex;
  align-items: center;
  gap: 7px;
  transform: translateY(-8px);
  filter: drop-shadow(0 10px 14px rgba(18, 52, 59, 0.24));
}

.map-pin:not(.active) {
  opacity: 0.86;
}

.map-pin.active {
  gap: 9px;
  transform: translateY(-12px) scale(1.08);
  filter: drop-shadow(0 16px 22px rgba(5, 101, 85, 0.34));
}

.pin-dot {
  display: grid;
  position: relative;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--category-color, var(--coral));
  box-shadow:
    0 0 0 2px rgba(23, 33, 38, 0.1),
    0 10px 22px rgba(31, 72, 78, 0.34);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.map-pin:not(.active) .pin-dot {
  transform: scale(0.92);
}

.pin-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 10px;
  height: 10px;
  border-right: 3px solid #ffffff;
  border-bottom: 3px solid #ffffff;
  background: var(--category-color, var(--coral));
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 2px 2px 4px rgba(18, 52, 59, 0.16);
}

.pin-label {
  max-width: 190px;
  overflow: hidden;
  padding: 7px 10px;
  border: 1px solid rgba(23, 33, 38, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(31, 72, 78, 0.22);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-pin.active .pin-dot {
  width: 38px;
  height: 38px;
  outline: 5px solid rgba(66, 201, 166, 0.28);
  background: var(--green);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.95),
    0 0 0 8px rgba(66, 201, 166, 0.16),
    0 14px 28px rgba(31, 72, 78, 0.36);
}

.map-pin.active .pin-dot::after {
  background: var(--green);
}

.map-pin.active .pin-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-color: rgba(255, 255, 255, 0.92);
  background: linear-gradient(135deg, var(--green), #0aa98d);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 12px 28px rgba(8, 123, 103, 0.28);
  color: #ffffff;
}

.map-pin.active .pin-label::before {
  content: "当前";
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.rail-segment-pin {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 5px;
  border: 1px solid rgba(29, 78, 216, 0.28);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.rail-segment-pin span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 11px;
}

.rail-segment-pin strong {
  color: var(--ink);
}

.category-chip {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 2px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 2px 8px rgba(31, 72, 78, 0.05);
  color: var(--category-color);
  font-size: 11px;
  font-weight: 800;
}

.context-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  overflow: auto;
}

.place-detail-drawer {
  position: absolute;
  top: 64px;
  right: 14px;
  z-index: 20;
  display: grid;
  gap: 12px;
  width: min(372px, calc(100% - 28px));
  max-height: calc(100% - 92px);
  overflow: auto;
  padding: 13px;
  border-color: rgba(185, 211, 205, 0.86);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 252, 249, 0.96));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.place-detail-drawer::before {
  background: linear-gradient(90deg, var(--aqua), var(--mint), var(--amber));
}

.detail-form {
  display: grid;
  gap: 11px;
  margin-top: 12px;
}

.detail-meta {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--panel-soft), var(--aqua-soft));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-actions .primary-button,
.detail-actions .ghost-button {
  flex: 1;
}

/* Itinerary */
.itinerary-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  align-content: stretch;
}

.itinerary-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(66, 201, 166, 0.24);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green-soft), var(--amber-soft));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.itinerary-chain span {
  color: var(--ink);
  font-weight: 800;
}

.itinerary-chain b {
  color: var(--amber);
}

.itinerary-list {
  display: grid;
  gap: 8px;
  align-content: start;
  grid-auto-rows: max-content;
  max-height: none;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.itinerary-stop {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  padding: 9px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfffd);
  box-shadow: 0 6px 18px rgba(31, 72, 78, 0.06);
}

.itinerary-stop-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--category-color), rgba(255, 255, 255, 0.22));
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.itinerary-stop-main {
  min-width: 0;
  display: block;
  padding: 0;
  cursor: pointer;
}

.itinerary-stop-main:hover .item-title {
  color: var(--green-strong);
}

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

.itinerary-stop-actions,
.itinerary-actions,
.route-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.itinerary-stop-actions {
  gap: 4px;
}

.itinerary-stop-actions .icon-button {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
}

.itinerary-connector {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  margin: -1px 0 -1px 46px;
  padding: 0 12px;
  border: 1px solid rgba(79, 183, 216, 0.36);
  border-left: 3px solid rgba(66, 201, 166, 0.74);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.itinerary-connector.has-plan {
  border-color: rgba(66, 201, 166, 0.48);
  border-left-color: var(--green);
  background: linear-gradient(90deg, var(--green-soft), #ffffff);
  color: var(--green-strong);
}

.itinerary-connector:hover {
  border-color: rgba(66, 201, 166, 0.7);
  background: linear-gradient(90deg, var(--green-soft), var(--aqua-soft));
  transform: translateY(-1px);
}

.itinerary-connector strong {
  color: var(--ink);
}

.itinerary-plan-summary {
  padding: 8px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.itinerary-plan-summary strong {
  color: var(--ink);
}

.itinerary-actions {
  flex-wrap: wrap;
}

.itinerary-actions .ghost-button {
  flex: 1;
  min-width: 92px;
}

/* Route Editor */
.segment-modal {
  width: min(880px, 100%);
}

.route-context-panel {
  grid-template-rows: auto auto minmax(0, 1fr);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 255, 252, 0.97));
}

.route-context-panel::before {
  background: linear-gradient(90deg, var(--amber), var(--aqua), var(--mint));
}

.route-context-panel .modal-head {
  min-height: 34px;
}

.route-context-panel .segment-modal-body {
  overflow: auto;
}

.segment-modal-body,
.segment-plan-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.segment-plan-item {
  display: grid;
  gap: 9px;
  padding: 11px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfffd);
  box-shadow: 0 6px 18px rgba(31, 72, 78, 0.06);
}

.segment-plan-item.active {
  border-color: rgba(66, 201, 166, 0.68);
  background: linear-gradient(90deg, var(--green-soft), #ffffff);
  box-shadow: inset 4px 0 0 var(--mint), 0 10px 22px rgba(66, 201, 166, 0.12);
}

.segment-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment-plan-actions .ghost-button {
  flex: 1;
}

.segment-route-editor {
  display: grid;
  gap: 0;
  min-height: 0;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(79, 183, 216, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--aqua-soft) 0%, #ffffff 100%);
  overflow: auto;
}

.route-context-panel .route-result {
  max-height: min(32vh, 300px);
}

.compact-field {
  gap: 5px;
}

.route-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
  gap: 9px;
  margin-top: 14px;
  align-items: end;
}

.route-controls .field:nth-of-type(3),
.route-controls .field:nth-of-type(4),
.rail-fields,
.route-button {
  grid-column: 1 / -1;
}

.rail-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}

.rail-fields.hidden {
  display: none;
}

.rail-fields .rail-hint,
.rail-fields .custom-rail-fields {
  grid-column: 1 / -1;
}

.rail-hint {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 9px;
  border: 1px dashed rgba(79, 183, 216, 0.48);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--muted);
  font-size: 12px;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 6px 9px 6px 11px;
  border: 1px solid rgba(185, 211, 205, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.switch-field span {
  order: 1;
  white-space: nowrap;
}

.switch-field input {
  position: relative;
  order: 2;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  appearance: none;
  background: #c8d8d3;
  cursor: pointer;
  transition: background 0.18s ease;
}

.switch-field input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(31, 72, 78, 0.2);
  transition: transform 0.18s ease;
}

.switch-field input:checked {
  background: var(--green);
}

.switch-field input:checked::after {
  transform: translateX(14px);
}

.custom-rail-fields {
  display: grid;
  gap: 9px;
}

.custom-rail-fields.hidden {
  display: none;
}

.custom-leg-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 12px;
}

.custom-leg-toolbar .ghost-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.custom-leg-list {
  display: grid;
  gap: 9px;
}

.custom-leg {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: #ffffff;
}

.custom-leg input,
.custom-leg select {
  height: 34px;
  padding: 0 10px;
}

.custom-leg-head {
  display: flex;
  gap: 8px;
  align-items: start;
  justify-content: space-between;
}

.custom-leg-head-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
}

.custom-leg textarea {
  min-height: 60px;
}

.custom-leg-planner {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px dashed rgba(79, 183, 216, 0.38);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--blue-soft), #ffffff);
}

.custom-leg-planner .ghost-button {
  justify-content: center;
}

.custom-leg-plan-button {
  width: 100%;
  min-height: 34px;
}

.custom-leg-result {
  display: grid;
  gap: 8px;
}

.legacy-custom-rail-fields {
  display: none;
}

/* Rail And Route Results */
.rail-plan {
  display: grid;
  gap: 10px;
}

.connector-section {
  display: grid;
  gap: 8px;
}

.connector-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.connector-panel {
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
}

.rail-options {
  display: grid;
  gap: 8px;
}

.rail-option {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfffd);
  box-shadow: 0 6px 18px rgba(31, 72, 78, 0.06);
}

.rail-option-main,
.rail-option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rail-option-main strong {
  color: var(--ink);
}

.rail-option-main span,
.rail-option-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.train-card {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfffd);
  box-shadow: 0 6px 18px rgba(31, 72, 78, 0.06);
}

.train-line,
.train-seats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.train-no {
  color: var(--green-strong);
  font-weight: 900;
}

.seat-pill {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.custom-segment {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: #ffffff;
}

.custom-segment-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.custom-segment-line strong {
  color: var(--ink);
}

.custom-segment-line span {
  color: var(--muted);
}

.rail-note-field textarea {
  min-height: 64px;
}

.swap-button {
  align-self: end;
}

.route-summary {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(66, 201, 166, 0.24);
  border-radius: 8px;
  background: linear-gradient(90deg, var(--green-soft), #ffffff);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.route-summary strong {
  color: var(--ink);
}

.route-actions {
  margin-top: 10px;
}

.route-actions .ghost-button,
.route-actions .primary-button {
  flex: 1;
}

.hidden {
  display: none !important;
}

.route-result {
  margin-top: 10px;
  max-height: calc(100vh - 460px);
  overflow: auto;
  font-size: 12px;
}

.route-result:empty {
  display: none;
}

.route-choice-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.route-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  text-align: left;
  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease;
}

.route-choice-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.route-choice-main span,
.route-choice-main em {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-choice-main em {
  color: var(--ink);
  font-weight: 700;
}

.route-choice-metric {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.route-choice:hover {
  border-color: rgba(79, 183, 216, 0.58);
  background: var(--aqua-soft);
}

.route-choice.active {
  border-color: rgba(66, 201, 166, 0.68);
  color: var(--green-strong);
  background: var(--green-soft);
  box-shadow: inset 4px 0 0 var(--mint);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 33, 38, 0.38);
  backdrop-filter: blur(3px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  border: 1px solid rgba(185, 211, 205, 0.72);
  background:
    linear-gradient(180deg, #ffffff, #f8fffc);
  box-shadow: var(--shadow);
}

.settings-modal {
  width: min(560px, 100%);
}

.rail-query-modal {
  width: min(760px, 100%);
}

.settings-form {
  display: grid;
  gap: 13px;
  margin-top: 16px;
}

.rail-query-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
}

.rail-query-result {
  display: grid;
  gap: 10px;
  max-height: min(58vh, 520px);
  margin-top: 14px;
  overflow: auto;
}

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

.modal-actions .primary-button,
.modal-actions .ghost-button {
  width: 100%;
}

.amap-guide {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(79, 183, 216, 0.28);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-soft), #ffffff);
}

.amap-guide-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.amap-guide ol {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
}

.amap-guide-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.amap-guide-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(8, 123, 103, 0.24);
  border-radius: 6px;
  color: var(--green);
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.amap-guide-links a:hover {
  border-color: rgba(8, 123, 103, 0.44);
  background: #eff8f4;
}

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

.toast {
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* Responsive */
@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 340px minmax(360px, 1fr);
    grid-template-rows: minmax(560px, 62vh) auto;
    height: auto;
    min-height: 100vh;
  }

  .rightbar {
    grid-column: 1 / -1;
    display: flex;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .sidebar {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .place-list,
  .itinerary-list {
    max-height: none;
  }

  .route-context-panel .route-result {
    max-height: 420px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  .sidebar,
  .rightbar {
    display: flex;
    flex-direction: column;
    overflow: visible;
    border: 0;
    padding: 12px;
  }

  .result-list,
  .place-list {
    max-height: none;
  }

  .map-wrap {
    order: -1;
    height: 54vh;
    min-height: 380px;
  }

  .place-detail-drawer {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: min(72vh, 560px);
  }

  .rightbar .itinerary-panel,
  .rightbar .route-context-panel {
    min-height: 360px;
  }

  .search-grid,
  .city-search-row,
  .route-controls,
  .rail-fields,
  .rail-query-form {
    grid-template-columns: 1fr;
  }

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

  .itinerary-stop {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .itinerary-stop-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .swap-button {
    width: 100%;
  }

  .modal-actions .primary-button,
  .modal-actions .ghost-button {
    width: 100%;
  }
}
