/* Direction 1 Core Design System — Unslop by Damir Sokolovsky (@heydamir), CC BY 4.0.
   Warm cotton-paper neutral ramp, 3 text roles, single pine-green accent, 4px grid, nested radii. */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-subtle: #f1efe9;
  --surface-hover: #eae7df;
  --ink: #1c1b18;
  --text-secondary: #57554e;
  --muted: #7a776e;
  --line: rgba(28, 27, 24, 0.09);
  --line-strong: rgba(28, 27, 24, 0.15);
  --green: #1f634c;
  --green-hover: #18513e;
  --green-soft: #eaf3ee;
  --green-line: rgba(31, 99, 76, 0.24);
  --orange: #a45a18;
  --orange-soft: #fbf3e8;
  --orange-line: rgba(164, 90, 24, 0.24);
  --red: #b83227;
  --red-soft: #fdeeec;
  --red-line: rgba(184, 50, 39, 0.24);
  --shadow-sm: 0 1px 2px rgba(28, 27, 24, 0.04);
  --shadow: 0 1px 2px rgba(28, 27, 24, 0.04), 0 8px 24px -8px rgba(28, 27, 24, 0.06);
  --shadow-overlay: 0 4px 12px rgba(28, 27, 24, 0.06), 0 20px 48px -12px rgba(28, 27, 24, 0.14);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--planner-nav-height, 0px) + 12px);
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(28, 27, 24, 0.2) transparent;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:is(button, a, input, select, textarea, .ai-plan-card):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.num { font-variant-numeric: tabular-nums; }
.ui-icon {
  display: inline-block;
  flex: none;
  vertical-align: middle;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link { position: absolute; left: -999px; }
.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 40;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
}

/* Status & quiet controls */
.save-state {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--orange-line);
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.badge.ok {
  border-color: var(--green-line);
  background: var(--green-soft);
  color: var(--green);
}
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--green);
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.text-button:hover:not(:disabled) { background: var(--surface-subtle); }

/* Navigation */
.main-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: block;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  user-select: none;
}
.nav-brand-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--green);
}
.nav-brand-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.nav-brand-divider {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
  flex: none;
}

.nav-links {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-inline: auto;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-subtle);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.nav-links button {
  height: 32px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), border-color 140ms var(--ease);
}
.nav-links button:hover { color: var(--ink); }
.nav-links button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-toggle {
  position: absolute;
  right: 12px;
  top: 8px;
  z-index: 12;
  display: none;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
.main-nav.nav-collapsed { height: 0; min-height: 0; padding: 0; border: 0; overflow: visible; }
.main-nav.nav-collapsed .nav-toggle { display: grid; }
.main-nav .trip-switcher { padding: 0; margin: 0; border: 0; max-width: none; background: transparent; }
.trip-switcher { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.trip-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }
.trip-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 0 12px;
  max-width: 220px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.trip-menu {
  position: fixed;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow: var(--shadow-overlay);
  min-width: 136px;
}
.trip-menu[hidden] { display: none; }
.trip-menu button {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 8px 12px;
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  font-size: 13px;
}
.trip-menu button:hover { background: var(--red-soft); }

/* Main layout & editorial container */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
#expenses, #export {
  max-width: 960px;
  margin: 0 auto;
}
#setup > :not(#aiResults) {
  max-width: 960px;
  margin-inline: auto;
}
#setup > #aiResults {
  max-width: 1360px;
  margin-inline: auto;
}
.view { display: none; }
.view.active { display: block; }

/* Page Header */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head > div { min-width: 0; }
.page-head h1 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-head p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 64ch;
}

/* Buttons */
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease);
}
.btn:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: rgba(28, 27, 24, 0.22);
}
.btn:active:not(:disabled) { transform: scale(0.985); }
.btn:disabled {
  color: var(--muted);
  background: var(--surface-subtle);
  border-color: var(--line);
  box-shadow: none;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}
.btn.primary:hover:not(:disabled) {
  background: var(--green-hover);
  border-color: var(--green-hover);
}
.btn.danger {
  color: var(--red);
  border-color: var(--red-line);
  background: var(--surface);
}
.btn.danger:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: rgba(184, 50, 39, 0.36);
}
.btn.small {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 12px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; font-weight: 600; overflow-wrap: anywhere; }
.card h2 { font-size: 16px; line-height: 1.4; margin-bottom: 16px; }
.card h3 { font-size: 15px; line-height: 1.45; margin-bottom: 12px; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-head h2, .section-head h3 { margin: 0; }

/* Grids & Crisp Writable Forms */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; align-items: start; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .label {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--text-secondary);
}
.field input, .field select, .field textarea, .inline-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  box-shadow: inset 0 1px 2px rgba(28, 27, 24, 0.03);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease), background-color 140ms var(--ease);
}
.field :is(input, textarea)::placeholder, .inline-input::placeholder { color: var(--muted); opacity: 1; }
.field :is(input, select, textarea):hover:not(:disabled), .inline-input:hover:not(:disabled) {
  border-color: rgba(28, 27, 24, 0.25);
}
.field :is(input, select, textarea):focus, .inline-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 99, 76, 0.14);
}
.field :is(input, select, textarea):disabled, input[type=file]:disabled {
  background: var(--surface-subtle);
  color: var(--muted);
  cursor: not-allowed;
}
.field input[type=number], .field input[type=date], .field input[type=time] {
  font-variant-numeric: tabular-nums;
}
.field textarea {
  min-height: 96px;
  padding: 10px 12px;
  line-height: 1.65;
  resize: vertical;
}
.form-subsection-divider {
  height: 1px;
  background: var(--line);
  margin: 24px 0 20px;
}
.form-subsection-title {
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.hint { font-size: 12px; line-height: 1.55; color: var(--muted); }
.field .hint { margin: 0; }
.help {
  padding: 12px 16px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  border-radius: var(--radius-md);
  color: #184b3a;
  font-size: 13px;
  line-height: 1.6;
}
.warning {
  padding: 12px 16px;
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  border-radius: var(--radius-md);
  color: #7c4212;
  font-size: 13px;
  line-height: 1.6;
}
.error-text { color: var(--red); font-size: 13px; }

/* Destination rows with Signature Route Node */
.destination-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 128px auto;
  gap: 12px;
  margin-bottom: 12px;
  align-items: end;
}
.destination-row:last-child { margin-bottom: 0; }
.dest-node {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.dest-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  flex-wrap: wrap;
}

/* MOMENT 1: Bespoke Editorial Travel Dossier Card (.trip-overview) */
.trip-overview {
  position: relative;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.trip-overview::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(31, 99, 76, 0.08), rgba(31, 99, 76, 0.58) 24%, rgba(31, 99, 76, 0.58) 76%, rgba(31, 99, 76, 0.08));
  z-index: 2;
  pointer-events: none;
}
.overview-topo {
  position: absolute;
  top: 0;
  right: 120px;
  width: 440px;
  height: 176px;
  color: var(--green);
  opacity: 0.075;
  pointer-events: none;
  z-index: 0;
}
.overview-top {
  position: relative;
  z-index: 1;
  padding: 24px 28px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.overview-identity { min-width: 0; flex: 1 1 320px; }
.overview-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  background: var(--green-soft);
  border: 1px solid var(--green-line);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--green);
  margin-bottom: 12px;
}
.trip-overview h2 {
  margin: 0 0 12px;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.overview-facts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.overview-fact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}
.overview-fact .ui-icon { color: var(--green); opacity: 0.85; }
.overview-budget {
  flex: none;
  min-width: 196px;
  text-align: center;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(234, 243, 238, 0.56) 0%, rgba(241, 239, 233, 0.44) 100%);
  border: 1px solid rgba(31, 99, 76, 0.14);
}
.overview-budget-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.overview-budget-figure {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  line-height: 1.15;
}
.overview-budget-figure strong {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.overview-budget-currency {
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.02em;
}
.overview-budget-sub {
  display: block;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(31, 99, 76, 0.12);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Route track band with crisp hairline divider & numbered cartographic stops */
.overview-route-band {
  position: relative;
  z-index: 1;
  padding: 20px 28px 22px;
  background: linear-gradient(180deg, rgba(241, 239, 233, 0.78) 0%, rgba(236, 240, 236, 0.58) 100%);
  border-top: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}
.overview-order {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.overview-route {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0;
  overflow-x: auto;
  padding: 4px 0 2px;
}
.route-stop {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 84px;
  padding-inline: 8px;
  flex: 1 0 auto;
}
.overview-route:not(.is-unordered) .route-stop::before,
.overview-route:not(.is-unordered) .route-stop::after {
  content: "";
  position: absolute;
  top: 10px;
  height: 2px;
  background: rgba(31, 99, 76, 0.30);
  z-index: 0;
}
.overview-route:not(.is-unordered) .route-stop::before { left: 0; right: 50%; }
.overview-route:not(.is-unordered) .route-stop::after { left: 50%; right: 0; }
.overview-route:not(.is-unordered) .route-stop:first-child { align-items: flex-start; text-align: left; padding-left: 0; }
.overview-route:not(.is-unordered) .route-stop:first-child::before { display: none; }
.overview-route:not(.is-unordered) .route-stop:first-child::after { left: 11px; }
.overview-route:not(.is-unordered) .route-stop:last-child { align-items: flex-end; text-align: right; padding-right: 0; }
.overview-route:not(.is-unordered) .route-stop:last-child::before { right: 11px; }
.overview-route:not(.is-unordered) .route-stop:last-child::after { display: none; }
.route-stop-dot {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--green);
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 3px rgba(31, 99, 76, 0.14);
}
.route-stop.is-terminal .route-stop-dot::after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ffffff;
}
.route-stop-node {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--green);
  color: var(--green);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 3px rgba(241, 239, 233, 0.92), 0 1px 2px rgba(28, 27, 24, 0.08);
}
.route-stop-city {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
.route-stop-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(28, 27, 24, 0.08);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-secondary);
}
.route-stop-pill.is-terminal-tag {
  background: var(--green-soft);
  border-color: var(--green-line);
  color: var(--green);
}
.overview-route.is-unordered {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px 12px;
}
.overview-route.is-unordered .route-stop {
  flex: 0 1 auto;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
}
.overview-route.is-unordered .route-stop-node { margin-bottom: 0; box-shadow: none; }
.overview-route.is-unordered .route-stop-pill { margin-top: 0; }

/* AI reference panel & 3-plan comparison */
.reference-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.reference-panel h2 { font-size: 16px; }
.reference-panel h3 { font-size: 15px; }
.reference-panel .plan-price { font-size: 20px; }
.reference-days { margin: 12px 0; }
.reference-days details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.reference-days summary { cursor: pointer; font-weight: 500; font-size: 13px; }
.reference-days p { color: var(--text-secondary); white-space: pre-wrap; font-size: 13px; margin: 6px 0 0; }

.ai-results { margin-block: 32px 24px; }
.ai-results h2 { margin-bottom: 4px; font-size: 18px; font-weight: 600; }
.ai-plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 16px; align-items: stretch; }
.ai-plan-card {
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.ai-plan-card:hover { border-color: var(--line-strong); }
.ai-plan-card.selected {
  border: 1.5px solid var(--green);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(31, 99, 76, 0.08), var(--shadow);
}
.ai-choice-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  color: #ffffff;
}
.ai-plan-card.selected .ai-choice-mark { border-color: var(--green); background: var(--green); }
.ai-plan-card .plan-price { font-size: 22px; }
.ai-days { margin: 10px 0 2px; }
.ai-days > div { border-left: 1.5px solid var(--green-line); padding: 2px 0 2px 10px; margin: 8px 0; font-size: 13px; line-height: 1.55; }
.ai-days > div:last-child { margin-bottom: 0; }
.ai-days p { margin: 2px 0 0; color: var(--text-secondary); white-space: pre-wrap; font-size: 13px; line-height: 1.55; }

.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.summary-grid.summary-asymmetric { grid-template-columns: 1.2fr 0.8fr; }
.summary-grid > .card { margin-bottom: 0; min-width: 0; }
.summary-list { margin: 0; }
.summary-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.summary-list > div:first-child { padding-top: 0; }
.summary-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.summary-list dt { font-size: 13px; color: var(--text-secondary); flex: none; }
.summary-list dd { margin: 0; text-align: right; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.summary-multiline { white-space: pre-wrap; }
.plan-price { font-size: 24px; font-weight: 600; color: var(--green); font-variant-numeric: tabular-nums; }

/* Stats & Expenses */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.expense-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.stat small, .stat strong { display: block; }
.stat small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.stat strong {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.budget-edit {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}
.budget-edit input {
  width: 100%;
  border: 0;
  border-bottom: 1.5px solid var(--line-strong);
  border-radius: 0;
  padding: 2px 0 4px;
  background: transparent;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  box-shadow: none;
  min-height: 0;
}
.budget-edit input:focus {
  outline: none;
  border-bottom-color: var(--green);
  box-shadow: none;
}
.budget-edit span { font-size: 12px; font-weight: 500; color: var(--muted); }
.expense-basis { margin: 0 0 20px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.expense-entry { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.expense-entry .tabs { flex: 1; min-width: 240px; margin-bottom: 0; }
.add-expense-bottom { display: inline-flex; margin: 20px auto 0; min-width: 180px; }
.tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-subtle);
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 140ms var(--ease), color 140ms var(--ease);
}
.tabs button:hover { color: var(--ink); }
.tabs button.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tab-count { font-size: 12px; color: var(--muted); font-weight: 400; }

.record-list { display: grid; gap: 12px; }
.record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(136px, auto) auto;
  align-items: start;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.record h3 { font-size: 15px; font-weight: 500; margin: 0; overflow-wrap: anywhere; }
.record p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.record-amount { text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.record-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.filters { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.filters .field { min-width: 140px; }

/* Itinerary Day & Timetable Rail */
.day-card {
  position: relative;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--line);
}
.day-card:first-child { padding-top: 4px; }
.day-card:last-child { border-bottom: 0; padding-bottom: 8px; }
.day-title { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.day-title h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; color: var(--ink); font-variant-numeric: tabular-nums; }
.day-note {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 13px;
}
.day-note strong { font-weight: 500; color: var(--text-secondary); font-size: 12px; }
.day-note p { margin: 4px 0 0; white-space: pre-wrap; color: var(--ink); }
.day-note-field { margin-top: 16px; }
.day-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.day-add { display: flex; justify-content: flex-end; }
.day-expenses {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.day-expenses h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.day-expense-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.day-expense-row:first-of-type { border-top: 0; padding-top: 0; }
.day-expense-row strong { font-weight: 500; margin: 0 4px; }
.day-expense-amt { font-weight: 500; white-space: nowrap; color: var(--ink); }

.timeline { position: relative; margin-top: 16px; }
.timeline-item {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 0 0 12px 76px;
  transition: border-color 140ms var(--ease);
}
.timeline-item:last-child { margin-bottom: 0; }
.timeline-item:hover { border-color: var(--line-strong); }
/* Signature Route Hairline + Node along timeline rail */
.timeline-item::before {
  content: "";
  position: absolute;
  left: -18px;
  top: 20px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--green);
  z-index: 2;
}
.timeline-item.is-confirmed::before { background: var(--green); }
.timeline-item::after {
  content: "";
  position: absolute;
  left: -14.5px;
  top: 28px;
  bottom: -24px;
  width: 1px;
  background: var(--line-strong);
  z-index: 1;
}
.timeline-item:last-child::after { display: none; }
.timeline-time {
  position: absolute;
  left: -76px;
  top: 16px;
  width: 50px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-secondary);
  white-space: nowrap;
}
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.item-head h3 { font-size: 15px; font-weight: 500; line-height: 1.45; margin: 0; }
.item-meta { color: var(--text-secondary); font-size: 13px; margin: 6px 0 0; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-subtle);
  color: var(--text-secondary);
}
.check-list { display: grid; gap: 8px; }
.check-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.schedule-time-actions .actions { align-items: center; }

/* Export asymmetric layout */
.export-primary-grid,
.export-secondary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.export-primary-grid > .card,
.export-secondary-grid > .card { margin-bottom: 0; min-width: 0; }
.export-card-desc { font-size: 13px; color: var(--text-secondary); margin: 0 0 16px; line-height: 1.65; }
.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border-color: var(--red-line);
}
.danger-zone h2 { margin: 0 0 4px; color: var(--red); }
.danger-zone .export-card-desc { margin: 0; max-width: 60ch; }

/* Dialogs, toast & misc */
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  padding: 0;
  max-width: min(720px, calc(100% - 32px));
  width: 700px;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
  overflow: hidden;
}
dialog::backdrop { background: rgba(28, 27, 24, 0.36); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#dialogContent { padding: 24px; overflow: auto; max-height: calc(90vh - 2px); max-height: calc(90dvh - 2px); }
#dialogContent > h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
  z-index: 40;
  max-width: 90%;
  box-shadow: var(--shadow-overlay);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 24px;
  border-top: 1px solid var(--line);
}
.empty { text-align: center; padding: 32px 16px; color: var(--muted); font-size: 13px; }
.empty p { margin: 0 0 12px; }
.print-note { font-size: 12px; color: var(--muted); }
.version {
  border-left: 2px solid var(--green);
  padding: 12px 16px;
  margin: 8px 0;
  background: var(--surface-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--green); }

/* Desktop fixed split itinerary */
@media (min-width: 1024px) {
  body.fixed-itinerary { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
  body.fixed-itinerary .main-nav { flex: none; }
  body.fixed-itinerary main {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 12px;
    padding-bottom: 16px;
  }
  body.fixed-itinerary #itinerary.active { display: flex; flex-direction: column; min-height: 0; }
  body.fixed-itinerary #itinerary .page-head { flex: none; align-items: center; margin-bottom: 12px; gap: 12px; }
  body.fixed-itinerary .itinerary-main { height: 100%; overflow-y: auto; }
  body.fixed-itinerary .reference-panel { height: 100%; display: flex; flex-direction: column; overflow: hidden; padding: 0; }
  body.fixed-itinerary .reference-panel-head { position: relative; flex: none; padding: 10px 16px; border-bottom: 1px solid var(--line); }
  body.fixed-itinerary .reference-panel-head .section-head { margin: 0; }
  body.fixed-itinerary .reference-panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 16px; scrollbar-width: thin; }
  body.fixed-itinerary footer { display: none; }
}

/* Hide secondary save timestamp below 1120px so 1024px 4:3 tablets stay on one nav row */
@media (max-width: 1120px) {
  .save-state #saveStatus { display: none; }
}

/* Tablet landscape AI 3-plan grid breathing room */
@media (min-width: 851px) and (max-width: 1180px) {
  .ai-plan-grid { gap: 12px; }
  .ai-plan-card { padding: 16px; }
}

/* Tablet & narrow viewports */
@media (max-width: 850px) {
  .grid, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-plan-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.expense-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .expense-stats .stat { padding: 16px; }
  .expense-stats .stat strong, .expense-stats .budget-edit input { font-size: 22px; }
  .record { grid-template-columns: 1fr auto; }
  .record-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .page-head { align-items: flex-start; }
  .grid.two, .summary-grid, .summary-grid.summary-asymmetric, .export-primary-grid, .export-secondary-grid { grid-template-columns: 1fr; }
  .overview-budget { width: 100%; }
  .overview-topo { right: -40px; opacity: 0.055; }
}

@media (max-width: 560px) {
  main { padding: 16px 16px 28px; }
  footer { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .page-head h1 { font-size: 22px; }
  .card { padding: 20px; margin-bottom: 16px; }
  .overview-top { padding: 20px 20px 16px; }
  .overview-route-band { padding: 16px 20px 20px; }
  .trip-overview h2 { font-size: 24px; }
  .grid, .grid.four, .ai-plan-grid { grid-template-columns: 1fr; }
  .field :is(input, select, textarea) { font-size: 16px; }
  .destination-row { grid-template-columns: 24px minmax(0, 1fr) 96px; gap: 8px; }
  .destination-row .dest-actions { grid-column: 1 / -1; justify-content: flex-end; min-height: 0; }
  .timeline-item { margin-left: 56px; padding: 12px; }
  .timeline-item::before { left: -14px; }
  .timeline-item::after { left: -10.5px; }
  .timeline-time { left: -56px; width: 38px; font-size: 11px; }
  .stats { gap: 12px; }
  .stats.expense-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .expense-stats .budget-stat { grid-column: 1 / -1; order: -1; }
  .stat { padding: 16px; }
  .stat strong, .budget-edit input { font-size: 22px; }
  .expense-entry .tabs { min-width: 0; flex-basis: 100%; }
  .record { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .record-amount { text-align: left; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters .field { min-width: 0; }
  .day-title { flex-direction: column; }
  .check-item { flex-direction: column; align-items: flex-start; }
  .actions .btn { flex: 1 1 auto; }
  #setupForm > .actions .btn { flex: 1 1 140px; }
  .day-footer-bar .actions .btn { flex: 0 0 auto; }
  .route-stop { min-width: 68px; }
}

@media print {
  .main-nav, .actions, .filters, footer, .record-actions, .setup-steps, .external-update-banner, .trip-dropdown, .panel-more-menu, .item-more-menu { display: none !important; }
  body { background: #ffffff !important; color: #111111; }
  main { padding: 0; max-width: none; }
  #setup > :not(#aiResults), #setup > #aiResults, #expenses, #export { max-width: none; }
  .view { display: none; }
  .view.active { display: block; }
  .card, .trip-overview, .stat, .record, .timeline-item { box-shadow: none !important; background: #ffffff !important; break-inside: avoid; }
  .overview-topo, .trip-overview::before { display: none; }
}
