/* =========================================================
   路迹 · Apple-style travel workspace
   System type, glass material, direct manipulation, restrained depth.
   ========================================================= */

:root {
  color-scheme: light;

  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-panel: rgba(255, 255, 255, 0.78);
  --bg-raised: rgba(255, 255, 255, 0.92);
  --label: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #86868b;
  --quaternary: #aeaeb2;
  --separator: rgba(0, 0, 0, 0.08);
  --separator-strong: rgba(0, 0, 0, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.18);
  --blue: #0071e3;
  --blue-press: #0077ed;
  --blue-soft: rgba(0, 113, 227, 0.12);
  --green: #30d158;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --teal: #00a6a6;
  --plum: #af52de;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.64);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 22px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.05), 0 18px 44px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 10px rgba(0, 0, 0, 0.08), 0 28px 70px rgba(0, 0, 0, 0.14);
  --radius-card: 8px;
  --radius-control: 10px;
  --bar-h: 58px;
  --side-w: 348px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --press: 100ms ease-out;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elevated: #1c1c1e;
  --bg-panel: rgba(28, 28, 30, 0.78);
  --bg-raised: rgba(44, 44, 46, 0.92);
  --label: #f5f5f7;
  --secondary: #a1a1a6;
  --tertiary: #8e8e93;
  --quaternary: #636366;
  --separator: rgba(255, 255, 255, 0.1);
  --separator-strong: rgba(255, 255, 255, 0.18);
  --fill: rgba(120, 120, 128, 0.24);
  --fill-strong: rgba(120, 120, 128, 0.32);
  --blue: #0a84ff;
  --blue-press: #409cff;
  --blue-soft: rgba(10, 132, 255, 0.18);
  --glass: rgba(28, 28, 30, 0.72);
  --glass-border: rgba(255, 255, 255, 0.09);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28), 0 12px 28px rgba(0, 0, 0, 0.38);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.38), 0 22px 52px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 4px 14px rgba(0, 0, 0, 0.48), 0 30px 82px rgba(0, 0, 0, 0.62);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.47;
  letter-spacing: 0;
  color: var(--label);
  background: linear-gradient(180deg, #fbfbfd 0%, var(--bg) 38%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  text-rendering: optimizeLegibility;
}

[data-theme="dark"] body {
  background: linear-gradient(180deg, #121214 0%, #000 42%, #000 100%);
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

svg {
  display: block;
}

::selection {
  background: var(--blue-soft);
}

.btn-fill:active,
.btn-quiet:active,
.btn-text:active,
.icon-btn:active,
.tpl-card:active,
.draft-card:active,
.day-chip:active,
.stop-row:active {
  transform: scale(0.97);
  transition: transform var(--press);
}

.view {
  display: none;
  height: 100%;
  min-width: 0;
  flex-direction: column;
}

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

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
}

@media (prefers-reduced-transparency: reduce) {
  .glass {
    background: var(--bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: var(--bar-h);
  min-height: var(--bar-h);
  min-width: 0;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  border-top: 0;
  border-right: 0;
  border-left: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  min-width: 0;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 20px rgba(0, 113, 227, 0.22);
}

.brand-text {
  font-size: 1.02rem;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  min-width: 0;
}

.editor-bar {
  z-index: 80;
  overflow: hidden;
}

.editor-bar .title-field {
  flex: 1;
  width: 100%;
  max-width: 430px;
  min-width: 0;
  height: 38px;
  padding: 0 0.68rem;
  font-weight: 650;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  outline: none;
}

.editor-bar .title-field:hover,
.editor-bar .title-field:focus {
  background: var(--fill);
  border-color: var(--separator);
}

.save-pill {
  display: inline-flex;
  align-items: center;
  min-width: 4.2rem;
  height: 24px;
  padding: 0 0.55rem;
  color: var(--tertiary);
  font-size: 0.76rem;
  white-space: nowrap;
  border-radius: 999px;
  background: var(--fill);
}

/* Buttons */
.btn-fill,
.btn-quiet,
.btn-text,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform var(--press), opacity 120ms ease;
}

.btn-fill {
  min-width: 72px;
  height: 36px;
  padding: 0 1rem;
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  background: var(--blue);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 10px 22px rgba(0, 113, 227, 0.18);
}

.btn-fill:hover {
  background: var(--blue-press);
}

.btn-fill.lg {
  height: 48px;
  min-width: 116px;
  padding: 0 1.25rem;
  font-size: 1rem;
}

.btn-fill.sm {
  height: 32px;
  min-width: 64px;
  padding: 0 0.84rem;
  font-size: 0.85rem;
}

.btn-quiet {
  min-width: 64px;
  height: 36px;
  padding: 0 0.95rem;
  color: var(--label);
  font-size: 0.92rem;
  font-weight: 600;
  background: var(--fill);
  border-radius: 999px;
}

.btn-quiet:hover {
  background: var(--fill-strong);
}

.btn-quiet.lg {
  height: 48px;
  min-width: 86px;
  padding: 0 1.18rem;
  font-size: 1rem;
}

.btn-quiet.sm {
  height: 30px;
  min-width: 58px;
  padding: 0 0.7rem;
  font-size: 0.82rem;
}

.btn-text {
  height: 36px;
  min-width: 44px;
  padding: 0 0.68rem;
  color: var(--blue);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-control);
}

.btn-text:hover {
  background: var(--blue-soft);
}

.import-btn {
  cursor: pointer;
}

.btn-danger {
  height: 34px;
  min-width: 58px;
  padding: 0 0.85rem;
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 600;
  background: rgba(255, 59, 48, 0.12);
  border-radius: 999px;
}

.icon-btn {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--label);
  border-radius: var(--radius-control);
  transition: background 120ms ease, color 120ms ease, transform var(--press);
}

.icon-btn:hover {
  background: var(--fill);
}

.icon-btn.is-on {
  color: var(--blue);
  background: var(--blue-soft);
}

.only-mobile {
  display: none;
}

/* Home */
#home {
  overflow: auto;
}

.home-main {
  width: min(1120px, calc(100vw - 2.5rem));
  margin: 0 auto;
  padding: 2.2rem 0 4rem;
}

.workspace-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.88fr) minmax(0, 1.12fr);
  gap: 1.4rem;
  align-items: center;
  min-height: 470px;
  padding: 1.4rem 0 2.6rem;
  overflow: hidden;
}

.workspace-copy {
  min-width: 0;
}

.eyebrow,
.overline {
  color: var(--tertiary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin-bottom: 0.8rem;
}

.workspace-copy h1 {
  margin-bottom: 0.72rem;
  font-size: 4rem;
  line-height: 1.02;
  font-weight: 760;
}

.lede {
  max-width: 28rem;
  margin-bottom: 1.45rem;
  color: var(--secondary);
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.route-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 420px;
  max-height: 480px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.56)),
    linear-gradient(115deg, rgba(0, 113, 227, 0.14) 0 18%, transparent 18% 100%),
    linear-gradient(36deg, transparent 0 62%, rgba(48, 209, 88, 0.14) 62% 100%),
    #e7edf2;
  border: 1px solid var(--separator);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .route-preview {
  background:
    linear-gradient(135deg, rgba(44, 44, 46, 0.92), rgba(28, 28, 30, 0.68)),
    linear-gradient(115deg, rgba(10, 132, 255, 0.16) 0 18%, transparent 18% 100%),
    linear-gradient(36deg, transparent 0 62%, rgba(48, 209, 88, 0.11) 62% 100%),
    #151516;
}

.preview-top {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  display: flex;
  gap: 6px;
}

.preview-top span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--quaternary);
}

.preview-top span:nth-child(1) {
  background: #ff5f57;
}

.preview-top span:nth-child(2) {
  background: #ffbd2e;
}

.preview-top span:nth-child(3) {
  background: #28c840;
}

.preview-map {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.preview-map::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.86;
}

[data-theme="dark"] .preview-map::before {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
}

.route-line {
  position: absolute;
  z-index: 1;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  border-radius: 99px;
  transform-origin: left center;
  box-shadow: 0 0 0 6px rgba(0, 113, 227, 0.08);
}

.route-line.one {
  top: 37%;
  left: 24%;
  width: 42%;
  transform: rotate(24deg);
}

.route-line.two {
  top: 60%;
  left: 43%;
  width: 28%;
  background: linear-gradient(90deg, var(--teal), var(--orange));
  transform: rotate(-35deg);
}

.preview-pin {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--blue);
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50% 50% 50% 0;
  box-shadow: var(--shadow-md);
  transform: rotate(-45deg);
}

.preview-pin i {
  display: block;
  font-style: normal;
  line-height: 1;
  transform: rotate(45deg);
}

.preview-pin.p1 {
  top: 30%;
  left: 20%;
}

.preview-pin.p2 {
  top: 45%;
  left: 58%;
  background: var(--teal);
}

.preview-pin.p3 {
  top: 63%;
  left: 40%;
  background: var(--orange);
}

.preview-pin.p4 {
  top: 46%;
  left: 72%;
  background: var(--plum);
}

.preview-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.92rem 1rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.preview-panel b {
  display: block;
  font-size: 1rem;
}

.preview-panel span {
  display: block;
  margin-top: 0.18rem;
  color: var(--secondary);
  font-size: 0.84rem;
}

.preview-stat {
  text-align: right;
}

.home-block {
  margin-bottom: 2.45rem;
}

.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.82rem;
}

.section-label h2 {
  font-size: 1.35rem;
  font-weight: 720;
}

.muted {
  color: var(--tertiary);
  font-size: 0.85rem;
}

.card-list {
  display: grid;
  gap: 0.7rem;
}

.draft-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  padding: 1rem;
  color: inherit;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--separator);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms var(--ease-out), box-shadow 180ms ease, border-color 180ms ease;
}

.draft-card:hover {
  border-color: var(--separator-strong);
  box-shadow: var(--shadow-md);
}

.draft-main {
  display: flex;
  align-items: center;
  gap: 0.82rem;
  min-width: 0;
}

.draft-main > div:last-child {
  min-width: 0;
}

.draft-cover {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  font-size: 1.25rem;
  background: var(--fill);
  border-radius: 8px;
}

.draft-card strong {
  display: block;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-card span {
  display: block;
  overflow: hidden;
  margin-top: 0.2rem;
  color: var(--tertiary);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(224px, 1fr));
  gap: 0.85rem;
}

.tpl-card {
  position: relative;
  width: 100%;
  min-height: 178px;
  overflow: hidden;
  padding: 1rem;
  color: inherit;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--separator);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms var(--ease-out), box-shadow 200ms ease, border-color 180ms ease;
}

.tpl-card:hover {
  transform: translateY(-2px);
  border-color: var(--separator-strong);
  box-shadow: var(--shadow-md);
}

.tpl-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, var(--blue), var(--teal), var(--orange));
}

.tpl-card .emoji {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 0.75rem;
  place-items: center;
  font-size: 1.55rem;
  background: var(--fill);
  border-radius: 8px;
}

.tpl-card h3 {
  margin-bottom: 0.35rem;
  font-size: 1rem;
  font-weight: 720;
}

.tpl-card p {
  min-height: 2.8em;
  margin-bottom: 0.78rem;
  color: var(--secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.tpl-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  color: var(--tertiary);
  font-size: 0.78rem;
}

.tpl-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 0.52rem;
  color: var(--secondary);
  font-size: 0.73rem;
  font-weight: 650;
  background: var(--fill);
  border-radius: 999px;
}

.empty {
  padding: 1.25rem;
  color: var(--tertiary);
  text-align: center;
  background: color-mix(in srgb, var(--bg-elevated) 70%, transparent);
  border: 1px dashed var(--separator-strong);
  border-radius: 8px;
}

/* Editor */
.editor-layout {
  display: grid;
  flex: 1;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: calc(100dvh - var(--bar-h));
  min-height: 0;
  overflow: hidden;
}

.side-panel {
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 1rem 0.55rem;
}

.side-head > div {
  min-width: 0;
}

.side-head h2 {
  margin-top: 0.08rem;
  font-size: 1.18rem;
  font-weight: 740;
}

.day-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem 1rem 0.78rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.day-tabs::-webkit-scrollbar {
  display: none;
}

.day-chip {
  flex: 0 0 auto;
  height: 34px;
  min-width: 54px;
  padding: 0 0.82rem;
  color: var(--secondary);
  font-size: 0.86rem;
  font-weight: 700;
  background: var(--fill);
  border-radius: 999px;
  transition: background 140ms ease, color 140ms ease, transform var(--press);
}

.day-chip.is-active {
  color: #fff;
  background: var(--label);
}

[data-theme="dark"] .day-chip.is-active {
  color: #000;
  background: #f5f5f7;
}

.side-scroll {
  flex: 1;
  min-height: 0;
  padding: 0 0.85rem 1.2rem;
  overflow: auto;
}

.day-meta-card {
  padding: 0.92rem;
  margin-bottom: 0.82rem;
  background: var(--bg-raised);
  border: 1px solid var(--separator);
  border-radius: 8px;
}

.day-meta-card h3 {
  margin-bottom: 0.24rem;
  font-size: 1rem;
  font-weight: 720;
}

.day-meta-card p {
  margin-bottom: 0.72rem;
  color: var(--secondary);
  font-size: 0.86rem;
}

.stops-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 0.15rem;
  margin-bottom: 0.48rem;
}

.stops-head h3 {
  color: var(--tertiary);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stop-list {
  display: grid;
  gap: 0.42rem;
}

.stop-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 0.58rem;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 0.68rem;
  color: inherit;
  text-align: left;
  background: var(--bg-raised);
  border: 1px solid var(--separator);
  border-radius: 8px;
  transition: background 140ms ease, border-color 140ms ease, transform var(--press);
}

.stop-row:hover {
  border-color: var(--separator-strong);
}

.stop-row.is-active {
  background: var(--blue-soft);
  border-color: color-mix(in srgb, var(--blue) 45%, transparent);
}

.stop-idx {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
}

.stop-row strong {
  display: block;
  overflow: hidden;
  font-size: 0.94rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stop-row small {
  display: block;
  margin-top: 0.12rem;
  color: var(--tertiary);
  font-size: 0.79rem;
}

.hint {
  margin-top: 0.86rem;
  padding: 0.65rem;
  color: var(--tertiary);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: center;
}

/* Map */
.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #dfe5eb;
}

#map {
  z-index: 1;
  width: 100%;
  height: 100%;
}

.map-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 2rem;
  color: var(--secondary);
  text-align: center;
  background: var(--bg);
}

.map-chrome {
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  pointer-events: none;
}

.map-chrome > * {
  pointer-events: auto;
}

.search {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  max-width: 460px;
  min-width: 0;
  min-height: 48px;
  padding: 0 0.88rem 0 2.45rem;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.search-ico {
  position: absolute;
  left: 0.92rem;
  color: var(--tertiary);
}

.search input {
  width: 100%;
  height: 46px;
  font-size: 0.96rem;
  background: transparent;
  border: 0;
  outline: none;
}

.search input::placeholder {
  color: var(--tertiary);
}

.search-drop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 20;
  max-height: 308px;
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.search-drop button {
  width: 100%;
  padding: 0.78rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--separator);
  transition: background 100ms ease;
}

.search-drop button:last-child {
  border-bottom: 0;
}

.search-drop button:hover,
.search-drop button:active {
  background: var(--fill);
}

.search-drop .n {
  display: block;
  font-size: 0.94rem;
  font-weight: 700;
}

.search-drop .a {
  display: block;
  margin-top: 0.14rem;
  color: var(--tertiary);
  font-size: 0.78rem;
}

.map-fab {
  display: flex;
  flex: 0 0 auto;
  gap: 0.22rem;
  padding: 0.28rem;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

.map-status {
  position: absolute;
  bottom: 18px;
  left: 50%;
  z-index: 500;
  display: flex;
  align-items: center;
  max-width: calc(100% - 1.5rem);
  gap: 0.56rem;
  padding: 0.6rem 0.95rem;
  overflow: auto;
  color: var(--secondary);
  font-size: 0.83rem;
  white-space: nowrap;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%);
}

.map-status b {
  color: var(--label);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.map-status .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--tertiary);
  opacity: 0.65;
}

/* Leaflet */
.leaflet-container {
  font: inherit;
  background: #dfe5eb;
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: var(--shadow-md);
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  color: var(--label) !important;
  line-height: 34px !important;
  background: var(--bg-elevated) !important;
  border-color: var(--separator) !important;
}

.leaflet-control-attribution {
  color: var(--tertiary) !important;
  font-size: 10px !important;
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent) !important;
}

.pin {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.26);
  transform: rotate(-45deg);
}

.pin span {
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  transform: rotate(45deg);
}

.pin.is-on {
  box-shadow: 0 0 0 3px var(--blue), 0 4px 12px rgba(0, 0, 0, 0.26);
}

/* Sheet */
.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  z-index: 800;
  display: flex;
  flex-direction: column;
  width: min(500px, 100%);
  max-height: min(74vh, 660px);
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 110%);
  transition: transform 380ms var(--ease-out);
  will-change: transform;
}

.sheet.is-open {
  transform: translate(-50%, 0);
}

.sheet.is-dragging {
  transition: none;
}

.sheet-handle {
  flex: 0 0 auto;
  width: 38px;
  height: 5px;
  margin: 0.58rem auto 0;
  background: var(--fill-strong);
  border-radius: 999px;
  cursor: grab;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.56rem 0.86rem 0.36rem 1.1rem;
  cursor: grab;
}

.sheet-head h3 {
  font-size: 1.08rem;
  font-weight: 740;
}

.sheet-body {
  padding: 0.35rem 1.1rem 1.35rem;
  overflow: auto;
}

/* Forms */
.field {
  margin-bottom: 0.86rem;
}

.field label {
  display: block;
  margin-bottom: 0.34rem;
  color: var(--tertiary);
  font-size: 0.75rem;
  font-weight: 720;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.72rem 0.78rem;
  color: var(--label);
  background: var(--bg);
  border: 1px solid var(--separator-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.row-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.68rem;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.52rem;
  margin-top: 0.35rem;
}

/* Modal */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal-root[hidden] {
  display: none !important;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 450px);
  max-height: min(86vh, 690px);
  overflow: hidden;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 260ms var(--ease-out);
}

.modal.wide {
  width: min(100%, 580px);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1rem 0.36rem 1.16rem;
}

.modal-head h3 {
  font-size: 1.14rem;
  font-weight: 740;
}

.modal-body {
  padding: 0.5rem 1.16rem;
  overflow: auto;
}

.modal-body > p {
  margin-bottom: 1rem;
  color: var(--secondary);
  font-size: 0.92rem;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.52rem;
  padding: 0.76rem 1.16rem 1.08rem;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.56rem;
  margin-bottom: 1rem;
}

.stat {
  padding: 0.86rem 0.62rem;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: 8px;
}

.stat b {
  display: block;
  font-size: 1.08rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--tertiary);
  font-size: 0.72rem;
}

.budget-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  margin-bottom: 0.42rem;
  padding: 0.66rem 0.75rem;
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--separator);
  border-radius: 8px;
}

.budget-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.budget-line b {
  color: var(--blue);
  font-variant-numeric: tabular-nums;
}

.export-stack {
  display: grid;
  gap: 0.55rem;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.3);
}

.scrim[hidden] {
  display: none !important;
}

/* Toasts */
#toasts {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  width: min(92vw, 360px);
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  padding: 0.72rem 1rem;
  color: var(--bg);
  font-size: 0.88rem;
  font-weight: 650;
  text-align: center;
  background: var(--label);
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 240ms var(--ease-out);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

  .sheet {
    transition: opacity 180ms ease;
  }

  .sheet:not(.is-open) {
    opacity: 0;
    pointer-events: none;
  }

  .sheet.is-open {
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 980px) {
  .workspace-hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 0.8rem;
    overflow: visible;
  }

  .route-preview {
    aspect-ratio: 16 / 9;
    min-height: 320px;
    max-height: none;
  }

  .workspace-copy h1 {
    font-size: 3.2rem;
  }
}

@media (max-width: 900px) {
  .only-mobile {
    display: grid;
  }

  .editor-layout {
    height: calc(100dvh - var(--bar-h));
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: fixed;
    top: var(--bar-h);
    bottom: 0;
    left: 0;
    z-index: 30;
    width: min(100%, 354px);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 340ms var(--ease-out);
  }

  .side-panel.is-open {
    transform: none;
  }

  .editor-bar .btn-text {
    display: none;
  }

  .save-pill {
    display: none;
  }

  .home-main {
    width: min(calc(100vw - 1.5rem), 1120px);
    padding-top: 1.4rem;
  }

  .stat-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 0.42rem;
    padding-right: max(0.72rem, env(safe-area-inset-right));
    padding-left: max(0.72rem, env(safe-area-inset-left));
  }

  .brand-text {
    display: none;
  }

  .topbar-actions {
    gap: 0.22rem;
  }

  .topbar-actions .btn-text {
    min-width: 0;
    padding: 0 0.48rem;
  }

  #home .topbar-actions .btn-text {
    display: none;
  }

  #home .topbar-actions .btn-fill {
    min-width: 64px;
  }

  .editor-bar .title-field {
    height: 34px;
    padding: 0 0.5rem;
    font-size: 0.94rem;
  }

  .workspace-copy h1 {
    font-size: 2.72rem;
  }

  .lede {
    font-size: 1rem;
  }

  .route-preview {
    aspect-ratio: 1 / 0.82;
    min-height: 270px;
  }

  .preview-panel {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.55rem;
  }

  .preview-stat {
    text-align: left;
  }

  .draft-card {
    grid-template-columns: 1fr;
  }

  .draft-actions {
    justify-content: flex-start;
  }

  .map-chrome {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  .search {
    min-height: 46px;
  }

  .map-status {
    bottom: 12px;
    gap: 0.42rem;
    padding: 0.52rem 0.72rem;
    font-size: 0.75rem;
  }

  .row-2 {
    grid-template-columns: 1fr;
  }

  .modal-foot {
    flex-wrap: wrap;
  }
}

@media print {
  .topbar,
  .map-chrome,
  .map-fab,
  .map-status,
  .sheet,
  .modal-root,
  #toasts,
  .scrim {
    display: none !important;
  }

  body {
    overflow: auto;
    background: #fff;
  }

  #editor {
    display: block !important;
  }

  .editor-layout {
    display: block;
  }

  .side-panel {
    position: static;
    width: 100%;
    border: 0;
    background: #fff;
    box-shadow: none;
    transform: none;
  }

  .map-stage {
    height: 320px;
  }
}
