/* Component structure, route stepper, AI chat, expense hierarchy & responsive chrome.
   Zero paper noise, zero dashed stickers, zero conflicting overrides. */

/* Collapsible nav shell & pointer pass-through */
.main-nav, .main-nav.nav-collapsed { display: block; height: auto; min-height: 0; padding: 0; }
.nav-clip { overflow: hidden; }
.nav-content {
  --nav-status-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  min-height: 56px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 24px;
  box-sizing: border-box;
  transition: opacity 160ms var(--ease);
}
.main-nav, .main-nav :where(*) { pointer-events: none; }
.main-nav :is(button, a[href], input, select, textarea, [role=button], [role=link], [data-action], [data-trip-id], .nav-links) { pointer-events: auto; }
.nav-status-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex: none;
}
.nav-save-state {
  height: var(--nav-status-height);
  min-width: 0;
  flex: 0 1 auto;
  padding: 0 8px 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.nav-save-state :is(.badge, button) { flex-shrink: 0; }
#undoBtn, #workspaceUndoBtn { max-width: 100%; white-space: nowrap; line-height: 1.4; }
#workspaceUndoBtn[hidden] { display: none; }
#tripSwitcher #workspaceUndoBtn { flex: none; align-self: center; min-height: 32px; padding: 4px 10px; font-size: 12px; }
#aiResults, #exportObject { scroll-margin-top: calc(var(--planner-nav-height, 0px) + 12px); }

.nav-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: none;
  height: var(--nav-status-height);
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
}
.nav-collapse:hover { color: var(--ink); background: var(--surface-subtle); }
.nav-collapsed .nav-content { opacity: 0; pointer-events: none; }
.nav-collapsed .nav-links { pointer-events: none; visibility: hidden; }
.nav-toggle svg { transition: transform 220ms var(--ease); }

@media screen {
  main { transition: padding-top 220ms var(--ease); }
  .main-nav.nav-collapsed ~ main { padding-top: 48px; }
}

dialog[data-closing=true] { pointer-events: none; }
dialog::backdrop { animation: dialog-backdrop-in 180ms var(--ease) both; }
dialog[data-closing=true]::backdrop { animation: dialog-backdrop-out 140ms var(--ease) both; }
@keyframes dialog-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-backdrop-out { from { opacity: 1; } to { opacity: 0; } }

/* Signature Detail: 4-step Horizontal Route Stepper */
.setup-steps { margin-bottom: 20px; }
.setup-steps ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.setup-steps li { position: relative; min-width: 0; }
.setup-steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 8px;
  top: 50%;
  width: 20px;
  height: 1px;
  background: var(--line-strong);
  pointer-events: none;
}
.setup-step-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  padding: 6px 28px 6px 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background-color 140ms var(--ease);
}
.setup-step-btn:hover { background: var(--surface-subtle); }
.setup-step-index {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
}
.setup-steps li.is-active .setup-step-index {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}
.setup-steps li.is-done:not(.is-active) .setup-step-index {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.setup-step-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.setup-step-label { font-size: 13px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.setup-steps li.is-active .setup-step-label { color: var(--green); font-weight: 600; }
.setup-step-note { font-size: 12px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Setup form refinements */
.destination-settings .section-head { gap: 12px; }
.destination-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.destination-controls .field { display: flex; flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.destination-controls .field label { font-size: 13px; white-space: nowrap; }
.destination-controls select { width: 176px; min-height: 32px; height: 32px; padding-block: 4px; font-size: 13px; }
.destination-settings [hidden] { display: none !important; }
.setup-basic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; align-items: start; }
.setup-basic-grid > .field:first-child { grid-column: 1 / -1; }
.setup-pref-notes { margin-top: 0; }
#setupForm > .actions { padding-top: 4px; }

/* AI plan comparison & adoption preview */
.ai-route {
  padding: 10px 12px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  font-size: 13px;
  line-height: 1.65;
}
.ai-route strong { font-weight: 600; font-size: 12px; color: var(--text-secondary); }
.ai-route p { margin: 4px 0 0; }
.ai-route span { padding: 0 4px; color: var(--muted); }
.ai-plan-tagline { margin: 0 0 10px; font-size: 14px; font-weight: 500; line-height: 1.5; color: var(--ink); }
.ai-plan-meta, .ai-plan-pros { margin: 8px 0; font-size: 13px; line-height: 1.65; color: var(--text-secondary); }
.ai-plan-meta strong, .ai-plan-pros strong { color: var(--ink); font-weight: 500; }
.ai-plan-cautions { margin: 6px 0 0; line-height: 1.6; }
.ai-days-disclosure {
  margin: 12px 0 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}
.ai-days-disclosure summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--green); user-select: none; }
.ai-days-disclosure .ai-days { margin: 10px 0 2px; }
.ai-plan-actions { margin-top: auto; padding-top: 16px; gap: 8px; }
.ai-plan-actions .btn { max-width: 100%; white-space: normal; }
.ai-adoption-preview details { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-md); }
.ai-adoption-preview summary { cursor: pointer; font-weight: 500; }
.ai-adoption-preview ul { padding-left: 20px; margin-bottom: 0; }
.ai-adoption-preview li { margin: 6px 0; overflow-wrap: anywhere; }

/* Decluttered dialog record form sections (no heavy card-inside-card nesting) */
.record-form-section {
  margin: 16px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  min-width: 0;
}
section.record-form-section:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
details.record-form-section {
  margin: 12px 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
}
.record-form-section h3, .record-form-section summary { margin: 0; font-size: 14px; font-weight: 600; color: var(--ink); }
.record-form-section summary { cursor: pointer; line-height: 1.5; user-select: none; }
.record-form-section > .grid { margin-top: 16px; }
.record-form-section .checkbox { align-self: center; min-height: 36px; }
.schedule-confirmation { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.record-form-section .schedule-confirmation .checkbox { flex: 1; align-self: stretch; justify-content: flex-start; }
.record-form-section .form-toggles { display: flex; gap: 12px 16px; flex-wrap: wrap; align-items: center; }
.expense-flags { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.record-form-section .expense-flags .form-toggles { flex: 1; min-height: 40px; align-content: center; }
.record-form-section .hint { margin-top: 12px; margin-bottom: 0; overflow-wrap: anywhere; }

.backup-summary { margin-top: 12px; overflow-wrap: anywhere; }
.backup-summary p { margin: 6px 0; }
.backup-trip-list { padding-left: 20px; overflow-wrap: anywhere; }
.backup-trip-list li { margin: 6px 0; }

#saveStatus { position: relative; }
#saveStatus.saved-feedback::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--green);
  vertical-align: middle;
}

.personal-share-list { display: grid; gap: 8px; margin-top: 8px; max-height: 240px; overflow: auto; }
.personal-share-list > div { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.personal-share-list span { overflow-wrap: anywhere; min-width: 0; font-size: 13px; color: var(--text-secondary); }
.personal-share-list strong { font-size: 16px; white-space: nowrap; margin: 0; }
.split-member-row { margin-block: 12px; }
[data-payer-choice][hidden], [data-custom-rows][hidden] { display: none; }
.payer-assignment { align-items: center; margin-block: 12px; overflow-wrap: anywhere; }

/* Itinerary items & popovers */
#itinerary .timeline-item p { white-space: pre-line; overflow-wrap: anywhere; }
.schedule-status-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.day-heading { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-status-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface-subtle);
}
.timeline-time.is-soft { color: var(--muted); font-weight: 400; }
.timeline-time-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  background: var(--green-soft);
}
.timeline-item .tag.tag-confirmed { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.timeline-item .tag.tag-origin { color: var(--muted); background: transparent; }

.item-more-menu, .panel-more-menu { position: relative; }
.item-more-menu > summary, .panel-more-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding-inline: 8px;
  user-select: none;
}
.item-more-menu > summary::-webkit-details-marker,
.panel-more-menu > summary::-webkit-details-marker { display: none; }
.item-more-popover, .panel-more-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 25;
  min-width: 140px;
  padding: 6px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
}
.item-more-popover button, .panel-more-popover button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.item-more-popover button:hover:not(:disabled),
.panel-more-popover button:hover:not(:disabled) { background: var(--surface-subtle); }
.item-more-popover button.danger-item,
.panel-more-popover button.danger-item { color: var(--red); }
.item-more-popover button.danger-item:hover:not(:disabled),
.panel-more-popover button.danger-item:hover:not(:disabled) { background: var(--red-soft); }
.item-more-popover button:disabled,
.panel-more-popover button:disabled { color: var(--muted); cursor: not-allowed; }

/* Scope & versions */
.record-delete-message { overflow-wrap: anywhere; }
.scope-check-item { align-items: center; gap: 12px; }
.scope-check-item > div { min-width: 0; overflow-wrap: anywhere; }
.scope-check-item > .btn { flex: none; }
.scope-banner { margin-bottom: 16px; overflow-wrap: anywhere; }
.scope-banner p { margin: 0 0 10px; }
.scope-issue { color: var(--orange); background: var(--orange-soft); border-color: var(--orange-line); white-space: normal; }
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; }
.version-row > div, .version-row > .actions { min-width: 0; overflow-wrap: anywhere; }
.version-preview { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; font: 13px/1.6 var(--font-mono); }
.version-diff { padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.version-diff summary { cursor: pointer; font-weight: 500; }
.version-comparison dd { overflow-wrap: anywhere; min-width: 0; }
#exportObjectLabel { overflow-wrap: anywhere; }
.restore-trip, .restore-conflict { padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.restore-trip h3, .restore-conflict h3 { margin: 0 0 8px; font-size: 15px; }
.restore-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 4px 12px; }
.restore-counts p { margin: 4px 0; }
.restore-differences dd { min-width: 0; overflow-wrap: anywhere; }
.restore-conflict details { margin-block: 10px; }
.restore-conflict label { display: grid; gap: 6px; }

/* AI Conversation Stream & Composer */
#itinerary .ai-chat-panel .reference-panel-head { padding-bottom: 10px; }
.chat-speaker { display: block; font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.chat-initial { padding-bottom: 12px; }
.chat-initial-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.chat-initial-head .chat-speaker { margin-bottom: 0; }
.ai-chat-panel .chat-initial-toggle { width: auto; flex: none; padding: 2px 8px; font-size: 12px; }
.chat-initial.is-collapsed {
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
}
.chat-initial-summary { margin: 0; font-size: 12px; line-height: 1.5; }
.chat-message {
  padding: 12px 14px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow-wrap: anywhere;
  min-width: 0;
  font-size: 13px;
}
.chat-user { margin-left: 20px; background: var(--surface-subtle); border-color: transparent; }
.chat-assistant { margin-right: 4px; }
.chat-message-text { white-space: pre-wrap; line-height: 1.65; }
.chat-assistant .chat-message-text { white-space: normal; }
.chat-message-text code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-subtle); padding: 1px 5px; border-radius: 4px; }
.chat-md-p { margin: 0 0 8px; }
.chat-md-p:last-child { margin-bottom: 0; }
.chat-md-heading { margin: 12px 0 6px; font-weight: 600; line-height: 1.4; color: var(--ink); }
.chat-md-heading:first-child { margin-top: 0; }
.chat-md-h1, .chat-md-h2 { font-size: 14px; }
.chat-md-h3, .chat-md-h4 { font-size: 13px; }
.chat-md-list { margin: 4px 0 8px; padding-left: 20px; }
.chat-md-list:last-child { margin-bottom: 0; }
.chat-md-list li { margin: 3px 0; }
.chat-md-hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.chat-message-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.chat-message-meta { margin: 0; }
.chat-message-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.ai-chat-panel .chat-message-actions .btn { width: auto; flex: none; min-height: 28px; padding: 4px 8px; font-size: 12px; }
.chat-sources { padding-left: 18px; margin: 8px 0 0; font-size: 12px; }
.chat-sources a { color: var(--green); overflow-wrap: anywhere; }
.chat-pending { font-size: 13px; color: var(--muted); padding: 8px 0; }

.ai-chat-composer {
  flex: none;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  min-width: 0;
}
.chat-input-shell {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  min-width: 0;
  transition: border-color 140ms var(--ease), box-shadow 140ms var(--ease);
}
.chat-input-shell:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 99, 76, 0.14);
}
.ai-chat-composer textarea {
  display: block;
  width: 100%;
  min-height: 64px;
  max-height: 132px;
  resize: vertical;
  border: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 12px 12px 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
}
.ai-chat-composer textarea:focus-visible { outline: none; }
.chat-compose-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 0 10px 10px; }
.ai-chat-panel .chat-compose-actions .btn { min-height: 32px; padding: 4px 14px; border-radius: var(--radius-md); min-width: 68px; width: auto; flex: none; }
.chat-notice { margin: 8px 0 0; line-height: 1.5; font-size: 12px; color: var(--orange); }

/* MOMENT 2: Expenses Budget Meter & 3-tier record hierarchy */
.budget-stat .budget-amount-over { color: var(--red); }
.budget-balance-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.budget-balance-row small { margin: 0; }
.budget-balance.is-over { color: var(--red); font-weight: 500; }
.budget-pct { font-size: 12px; font-weight: 600; white-space: nowrap; }
.budget-pct.is-ok { color: var(--green); }
.budget-pct.is-warn { color: var(--orange); }
.budget-pct.is-over { color: var(--red); }
.budget-pct.is-idle { color: var(--muted); font-weight: 400; }
.budget-bar {
  height: 6px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}
.budget-bar-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  transform-origin: left center;
  transition: transform 240ms var(--ease);
}
.budget-bar-fill.is-ok { background: var(--green); }
.budget-bar-fill.is-warn { background: var(--orange); }
.budget-bar-fill.is-over { background: var(--red); }
.budget-note { margin-top: 6px; color: var(--orange); }

.record-list .record.record-cancelled { opacity: 0.72; }
.record-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.record-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.record .status-tag {
  margin: 0;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
}
.record .status-tag.status-booked { background: var(--green-soft); color: var(--green); }
.record .status-tag.status-pending { background: var(--orange-soft); color: var(--orange); }
.record .status-tag.status-cancelled { background: var(--red-soft); color: var(--red); }
.record .status-tag.status-unbooked { background: var(--surface-subtle); color: var(--text-secondary); }
.record-summary { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-secondary); }
.record-highlights { display: flex; flex-wrap: wrap; gap: 6px; }
.record-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--text-secondary);
}
.record-chip.chip-info { background: var(--green-soft); border-color: var(--green-line); color: var(--green); }
.record-chip.chip-warn { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange); }
.record-chip.chip-muted { color: var(--muted); }
.record-details { margin-top: 2px; font-size: 12px; color: var(--muted); }
.record-details summary { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); user-select: none; }
.record-details summary:hover { color: var(--green); }
.record-detail-list {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  display: grid;
  gap: 6px;
}
.record-detail-list > div { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.record-detail-list dt { flex: none; color: var(--muted); font-weight: 500; }
.record-detail-list dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.record-detail-list a { display: inline-flex; align-items: center; gap: 3px; color: var(--green); text-underline-offset: 2px; }
.record .record-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.record-amount-main { font-size: 18px; font-weight: 600; line-height: 1.3; color: var(--ink); }
.record-amount-fx { color: var(--muted); font-weight: 400; font-size: 12px; }
.record-payment { font-size: 12px; font-weight: 500; }
.record-payment.payment-ok { color: var(--green); }
.record-payment.payment-warn { color: var(--orange); }
.record-payment.payment-muted, .record-payment.payment-neutral { color: var(--muted); }

/* Cross-tab alert banner */
.external-update-banner {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 1400px;
  width: calc(100% - 32px);
  margin: 8px auto 0;
  padding: 10px 16px;
  border: 1px solid var(--orange-line);
  border-radius: var(--radius-lg);
  background: var(--orange-soft);
  color: #7c4212;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}
.external-update-banner[hidden] { display: none; }
.external-update-banner > .actions { flex: none; gap: 8px; }

/* Trip dropdown popover */
.trip-dropdown-trigger { display: inline-flex; align-items: center; gap: 8px; max-width: 220px; min-width: 0; }
.trip-dropdown-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.trip-dropdown-count { flex: none; font-size: 12px; color: var(--muted); font-weight: 400; }
.trip-dropdown-caret { flex: none; display: inline-flex; color: var(--muted); }
.trip-dropdown {
  position: fixed;
  z-index: 35;
  max-width: calc(100vw - 24px);
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
}
.trip-dropdown[hidden] { display: none; }
.trip-dropdown-list { display: grid; gap: 4px; }
.trip-dropdown-row { display: flex; align-items: center; gap: 6px; }
.trip-dropdown-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background-color 120ms var(--ease);
}
.trip-dropdown-item:hover { background: var(--surface-subtle); }
.trip-dropdown-item.active { background: var(--green-soft); color: var(--green); }
.trip-dropdown-check { width: 16px; flex: none; display: grid; place-items: center; color: var(--green); }
.trip-dropdown-item-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.trip-dropdown-item-body strong { font-size: 13px; font-weight: 500; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-dropdown-item-body small { font-size: 12px; color: var(--muted); line-height: 1.3; }
.trip-dropdown-delete {
  flex: none;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--red);
  font-size: 12px;
  white-space: nowrap;
}
.trip-dropdown-delete:hover { background: var(--red-soft); }
.trip-dropdown-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

/* Responsive adjustments */
@media (max-width: 1280px) {
  .nav-links button { padding-inline: 12px; }
}
/* 4:3 (1024px) & 3:2 (1080px/1180px) landscape tablets: keep top nav comfortably on 1 row */
@media (max-width: 1180px) {
  .nav-content { padding: 8px 16px; gap: 8px; }
  .nav-brand-group { gap: 8px; }
  .trip-dropdown-trigger { max-width: 172px; padding: 0 10px; }
  #draftBadge[data-compact-label] { font-size: 0; padding: 0 7px; }
  #draftBadge[data-compact-label]::after { content: attr(data-compact-label); font-size: 11px; line-height: 1; }
  .nav-collapse { min-width: 36px; width: 36px; height: 36px; padding: 0; }
  .nav-collapse span { display: none; }
}
/* 4:3 (768px) & 3:2 (800px) portrait tablets: keep single-row with wrap safety net, zero horizontal overflow */
@media (max-width: 1023px) {
  .nav-content { flex-wrap: wrap; row-gap: 8px; padding-inline: 16px; gap: 8px; }
  .nav-brand-name { display: none; }
  .trip-dropdown-trigger { max-width: 152px; }
  .nav-links { margin-inline: 0; }
  .nav-links button { padding-inline: 10px; }
  .nav-status-tools { margin-left: auto; }
}
@media (max-width: 850px) {
  .expense-flags > .label, .schedule-confirmation > .label { display: none; }
  .record-form-section .schedule-confirmation .checkbox { min-height: 40px; }
  .item-more-popover { left: 0; right: auto; }
}
@media (max-width: 720px) {
  .setup-steps ol { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; }
  .setup-steps li::after { display: none; }
  .setup-step-btn { padding: 8px; }
  .destination-controls { width: 100%; justify-content: space-between; }
  .destination-controls select { width: 168px; }
}

/* Single-row mobile top bar + thumb-zone floating bottom tab dock */
@media (max-width: 560px) {
  .nav-brand, .nav-brand-divider { display: none; }
  .nav-brand-group { flex: 1 1 0; min-width: 0; gap: 6px; }
  .nav-content { --nav-status-height: 36px; flex-wrap: nowrap; gap: 6px; min-height: 50px; padding: 6px 12px; }
  .main-nav .trip-switcher { flex: 1 1 0; min-width: 0; }
  .trip-dropdown-trigger { max-width: 100%; height: 36px; padding: 0 10px; font-size: 13px; gap: 6px; }
  #tripSwitcher #workspaceUndoBtn { padding: 4px 8px; font-size: 12px; }
  .nav-status-tools { gap: 6px; margin-left: 0; }
  .nav-save-state { height: 36px; padding: 0 6px; gap: 4px; }
  #draftBadge[data-compact-label] { font-size: 0; padding: 0 6px; }
  #draftBadge[data-compact-label]::after { content: attr(data-compact-label); font-size: 11px; line-height: 1; }
  #undoBtn { padding: 4px 6px; font-size: 12px; }
  .nav-collapse { min-width: 36px; width: 36px; height: 36px; padding: 0; }
  .nav-collapse span { display: none; }
  .nav-links {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    width: auto;
    margin: 0;
    padding: 4px;
    gap: 4px;
    border-radius: 16px;
    overflow: hidden;
  }
  .nav-links button { flex: 1 1 0; min-width: 0; height: 38px; padding: 0 4px; font-size: 13px; text-align: center; border-radius: 12px; }
  .setup-basic-grid { grid-template-columns: minmax(0, 1fr); }
  .ai-chat-composer { padding: 8px 12px 12px; }
  .ai-chat-composer textarea { min-height: 48px; max-height: 108px; padding: 8px 10px; }
  .chat-compose-actions { padding: 0 8px 8px; }
  .chat-user { margin-left: 12px; }
  .chat-assistant { margin-right: 0; }
  .record .record-amount { align-items: flex-start; }
  .external-update-banner { width: calc(100% - 24px); padding: 10px 12px; font-size: 12px; }
  .external-update-banner > .actions { width: 100%; justify-content: flex-end; }
  #dialogContent { padding: 20px; }
}

/* Short phone landscape (e.g. 844x390) */
@media (max-width: 960px) and (max-height: 500px) {
  .nav-brand, .nav-brand-divider { display: none; }
  .nav-content { --nav-status-height: 36px; flex-wrap: nowrap; gap: 8px; min-height: 52px; padding: 6px 16px; }
  .trip-dropdown-trigger { max-width: 172px; height: 36px; padding: 0 10px; }
  .nav-links button { padding: 0 10px; font-size: 12px; }
  .nav-save-state { height: 36px; padding: 0 6px; gap: 4px; }
  #draftBadge[data-compact-label] { font-size: 0; padding: 0 6px; }
  #draftBadge[data-compact-label]::after { content: attr(data-compact-label); font-size: 11px; line-height: 1; }
  .nav-collapse { min-width: 36px; width: 36px; height: 36px; padding: 0; }
  .nav-collapse span { display: none; }
  .ai-chat-composer { padding: 6px 10px 8px; }
  .ai-chat-composer textarea { min-height: 44px; max-height: 84px; padding: 6px 10px; }
  .chat-compose-actions { padding: 0 6px 6px; }
}

/* Coarse-pointer touch target reinforcement */
@media (pointer: coarse) {
  .nav-toggle { width: 38px; height: 38px; }
  #undoBtn { display: inline-flex; align-items: center; justify-content: center; min-width: 38px; min-height: 32px; padding: 4px 6px; }
  .item-more-menu > summary, .panel-more-menu > summary { min-width: 38px; min-height: 36px; }
  .record-actions .btn, .day-query .btn, .dest-actions .btn { min-height: 36px; }
}
@media (pointer: coarse) and (max-width: 560px),
       (pointer: coarse) and (max-width: 960px) and (max-height: 500px) {
  #undoBtn { min-width: 36px; min-height: 28px; padding: 2px 6px; }
}

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