/* Visual Builder styling for TripDeck */

/* ==========================================================================
   1. Global Editor Variables & Tokens
   ========================================================================== */
:root {
  --editor-bg-low: rgba(255, 255, 255, 0.01);
  --editor-bg-med: rgba(162, 156, 179, 0.106);
  --editor-bg-high: rgba(255, 255, 255, 0.03);
  --editor-bg-active: rgba(255, 255, 255, 0.06);
  --editor-overlay-dark: rgba(10, 11, 13, 0.6);
}

/* ==========================================================================
   2. Tabs Swapper Component
   ========================================================================== */
.editor-tabs {
  display: flex;
  background: var(--editor-bg-med);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-secondary);
  background: var(--editor-bg-high);
}

.tab-btn.active {
  color: var(--text-primary);
  background: var(--editor-bg-active);
  border-color: var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab-btn svg {
  opacity: 0.7;
}

.tab-btn.active svg {
  opacity: 1;
  color: var(--accent-flight);
}

/* Pane Management — subtle crossfade + slide on activation */
.tab-pane {
  display: none;
  flex-grow: 1;
  min-height: 0;
  will-change: opacity, transform;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
  animation: tab-pane-enter 0.18s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tab-pane-enter {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.996);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}


/* ==========================================================================
   3. Form Components
   ========================================================================== */
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.form-header h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.form-select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-col label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.form-input {
  background: var(--editor-bg-high);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  outline: none;
  transition: var(--transition-smooth);
}

.form-input:hover {
  background: rgba(255, 255, 255, 0.05);
}

.form-input.val-emoji {
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
}

.form-input.val-emoji::selection {
  background: transparent;
}

.form-input.val-emoji:hover,
.form-input.val-emoji:focus {
  background: transparent !important;
  box-shadow: none !important;
}

/* Category Focus Ring Accents */
.visual-inline-form[data-category="F"] {
  --active-category-accent: var(--accent-flight);
  --active-category-glow: var(--accent-flight-glow, rgba(0, 229, 255, 0.18));
}

.visual-inline-form[data-category="T"] {
  --active-category-accent: var(--accent-transit);
  --active-category-glow: var(--accent-transit-glow, rgba(0, 229, 163, 0.18));
}

.visual-inline-form[data-category="H"] {
  --active-category-accent: var(--accent-lodging);
  --active-category-glow: var(--accent-lodging-glow, rgba(250, 96, 255, 0.18));
}

.visual-inline-form[data-category="C"] {
  --active-category-accent: var(--accent-car);
  --active-category-glow: var(--accent-car-glow, rgba(255, 171, 0, 0.18));
}

.visual-inline-form[data-category="R"] {
  --active-category-accent: var(--accent-dining);
  --active-category-glow: var(--accent-dining-glow, rgba(250, 114, 130, 0.18));
}

.visual-inline-form[data-category="A"] {
  --active-category-accent: var(--accent-activity);
  --active-category-glow: var(--accent-activity-glow, rgba(41, 182, 246, 0.18));
}

.visual-inline-form[data-category="?"] {
  --active-category-accent: var(--accent-sandbox);
  --active-category-glow: var(--accent-sandbox-glow, rgba(0, 230, 118, 0.18));
}

.form-input:not(.val-emoji):focus,
.form-select:focus {
  border-color: var(--active-category-accent, var(--border-focus));
  background: var(--editor-bg-active);
  box-shadow: 0 0 0 2px var(--active-category-glow, rgba(255, 255, 255, 0.08));
}

.visual-inline-form .places-search-input-row:focus-within {
  border-color: var(--active-category-accent, var(--accent-flight)) !important;
  box-shadow: 0 0 0 2px var(--active-category-glow, rgba(0, 229, 255, 0.18)) !important;
}

.form-input::placeholder {
  color: var(--text-muted);
}

/* Cost + Currency — styled as one combined control (matching the
   emoji+name places-search-input-row above it) rather than two separate
   boxes, so the pairing reads as a single field instead of two mismatched
   inputs bolted together. */
.cost-currency-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--editor-bg-high);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 0 10px;
  transition: var(--transition-smooth);
}

.cost-currency-input-row:focus-within {
  border-color: var(--border-focus);
  background: var(--editor-bg-active);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.visual-inline-form .cost-currency-input-row:focus-within {
  border-color: var(--active-category-accent, var(--border-focus));
  box-shadow: 0 0 0 2px var(--active-category-glow, rgba(255, 255, 255, 0.08));
}

.cost-currency-amount {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  padding: 8px 0;
  outline: none;
}

.cost-currency-amount::placeholder {
  color: var(--text-muted);
}

/* Flat number field — the native up/down spinner reads as a stray control
   floating in an otherwise borderless input, not as a cost amount. */
.cost-currency-amount::-webkit-outer-spin-button,
.cost-currency-amount::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.cost-currency-amount[type="number"] {
  -moz-appearance: textfield;
}

.cost-currency-divider {
  width: 1px;
  height: 16px;
  background: var(--border-color);
  flex-shrink: 0;
}

.cost-currency-select {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 0;
  outline: none;
  cursor: pointer;
}

.emoji-search-input {
  background: var(--editor-bg-high, rgba(0, 0, 0, 0.08)) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color, rgba(0, 0, 0, 0.15)) !important;
}

.emoji-search-input::placeholder {
  color: var(--text-secondary, #666) !important;
  opacity: 0.75;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* Category Pills Row (Single-Select Category Model) */
.category-pills-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.category-pill {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--border-radius-full, 9999px);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.category-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.category-pill.selected {
  background: var(--accent-activity-glow, rgba(41, 182, 246, 0.15));
  border-color: var(--accent-activity);
  color: var(--accent-activity);
}

.category-pill[data-cat="A"].selected {
  background: var(--accent-activity-glow, rgba(41, 182, 246, 0.15));
  border-color: var(--accent-activity);
  color: var(--accent-activity);
}

.category-pill[data-cat="F"].selected {
  background: var(--accent-flight-glow, rgba(0, 229, 255, 0.15));
  border-color: var(--accent-flight);
  color: var(--accent-flight);
}

.category-pill[data-cat="T"].selected {
  background: var(--accent-transit-glow, rgba(0, 229, 163, 0.15));
  border-color: var(--accent-transit);
  color: var(--accent-transit);
}

.category-pill[data-cat="H"].selected {
  background: var(--accent-lodging-glow, rgba(250, 96, 255, 0.15));
  border-color: var(--accent-lodging);
  color: var(--accent-lodging);
}

.category-pill[data-cat="C"].selected {
  background: var(--accent-car-glow, rgba(255, 171, 0, 0.15));
  border-color: var(--accent-car);
  color: var(--accent-car);
}

.category-pill[data-cat="R"].selected {
  background: var(--accent-dining-glow, rgba(250, 114, 130, 0.15));
  border-color: var(--accent-dining);
  color: var(--accent-dining);
}

.category-pill[data-cat="?"].selected {
  background: var(--accent-sandbox-glow, rgba(0, 230, 118, 0.15));
  border-color: var(--accent-sandbox);
  color: var(--accent-sandbox);
}

/* Add-to (Day) Picker Row — shown only on forms opened without a fixed day
   context, e.g. Quick Capture (see visualBuilder.js spawnCaptureForm) */
.inline-target-picker-row .val-target-date {
  width: auto;
}

/* Add/Edit Event form — name/emoji row, flight lookup, autocomplete
   dropdowns, emoji picker. Previously built entirely from inline `style`
   attributes in visualBuilder.js; consolidated here so theming (colors,
   tokens) actually reaches these elements instead of being hardcoded. */
.form-col-anchor {
  position: relative;
}

.places-search-divider {
  width: 1px;
  height: 16px;
  background: var(--border-color);
  flex-shrink: 0;
}

.form-input.val-emoji {
  width: 32px;
  border: none;
  padding: 4px 0;
  background: transparent;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
}

.btn-flight-lookup-wand {
  display: none;
  align-items: center;
  gap: 4px;
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid var(--accent-flight);
  color: var(--accent-flight);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-url-fetch {
  display: none;
  align-items: center;
  gap: 4px;
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid var(--accent-flight, #00e5ff);
  color: var(--accent-flight, #00e5ff);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-url-fetch:hover:not(:disabled) {
  background: rgba(0, 229, 255, 0.25);
}

.btn-url-fetch:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.details-toggle-row {
  margin-top: 4px;
}

.form-error-message {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--danger, #ff5252);
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
}

/* Informational variant for failures that aren't the user's fault — an
   upstream service being unavailable is something we report, not something
   they did wrong, so it shouldn't wear the same red alarm styling as a
   validation error they need to go fix. */
.form-error-message.is-notice {
  color: var(--text-primary, #e4e9f0);
  background: rgba(120, 144, 176, 0.12);
  border-color: rgba(120, 144, 176, 0.3);
  font-weight: 400;
  align-items: flex-start;
}

.form-error-message.is-notice svg {
  color: var(--accent, #5b9dff);
  flex-shrink: 0;
  margin-top: 1px;
}

.form-label-caption {
  font-size: 10px;
  opacity: 0.8;
}

.form-input.val-notes {
  resize: vertical;
  min-height: 38px;
}

.autocomplete-suggestions-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: var(--editor-bg-high);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  list-style: none;
  padding: 0;
  margin: 0;
}

.emoji-picker-popover {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1000;
  width: 375px;
  max-width: calc(100vw - 24px);
  background: var(--editor-bg-high);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.emoji-search-row {
  margin-bottom: 8px;
}

.emoji-search-input {
  width: 100%;
  box-sizing: border-box;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

.emoji-category-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
  align-items: center;
  -webkit-overflow-scrolling: touch;
}

.emoji-tab-btn {
  background: transparent;
  border: none;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 4px 6px;
  min-width: 28px;
  min-height: 28px;
  cursor: pointer;
}

.emoji-tab-btn.active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.emoji-tab-btn[data-cat="all"] {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.emoji-option-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s ease;
}

.emoji-option-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.emoji-clear-btn {
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 6px;
  margin-left: auto;
  white-space: nowrap;
}

.emoji-grid-content {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}

.emoji-grid-btn {
  font-size: 26px;
  min-height: 40px;
  line-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.emoji-grid-empty {
  grid-column: span 7;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  padding: 12px 0;
}


/* ==========================================================================
   4. Outline & Drag/Drop Components
   ========================================================================== */
.visual-outline-wrapper {
  padding: 5px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-grow: 1;
  background: transparent;
  overflow-y: auto;
  min-height: 0;
}

.outline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 0 0 0;
  /* The header's width tracks the editor pane's grid fraction, not the
     viewport — a window-width media query can't reliably tell when the
     capsule + Manage Dates button run out of room, so size off this
     element's own box instead. */
  container-type: inline-size;
  container-name: outline-header;
}

.outline-trip-summary {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  cursor: default;
}

.trip-summary-capsule {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  background: var(--editor-bg-active, rgba(255, 255, 255, 0.07));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
  padding: 5px 14px;
  border-radius: 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: var(--transition-smooth);
}

.trip-summary-capsule .capsule-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-flight, #38bdf8);
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}

.trip-summary-capsule .capsule-divider {
  font-size: 10px;
  opacity: 0.4;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.trip-summary-capsule .capsule-range {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-shift-trip {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
  transition: var(--transition-smooth);
}

.btn-shift-trip span {
  white-space: nowrap;
}

.btn-shift-trip:hover {
  color: var(--accent-flight, #38bdf8);
  background: var(--editor-bg-high, rgba(255, 255, 255, 0.05));
  opacity: 1;
}

/* Shorten "Manage Dates" down to just "Dates" - same long-label
   pattern .editor-header-bar uses for Text/Editor, Budget, Packing. */
@container outline-header (max-width: 380px) {
  .btn-shift-trip .long-label {
    display: none;
  }
}

/* Finally, once even "Dates" can't fit, drop to icon-only - matches the
   icon-only fallback the Budget/Packing/Share buttons use. */
@container outline-header (max-width: 320px) {
  .btn-shift-trip span {
    display: none;
  }

  .btn-shift-trip {
    padding: 6px;
  }
}

.visual-outline-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Visual Builder Skeleton */
.visual-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
  width: 100%;
}

.visual-skeleton .skeleton-pill {
  height: 20px;
  width: 120px;
  border-radius: var(--border-radius-sm, 6px);
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.05));
  animation: skeleton-pulse 1.5s infinite ease-in-out;
}

.skeleton-card-small {
  height: 48px;
  width: 100%;
  border-radius: var(--border-radius-md, 8px);
  background: var(--bg-surface, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  animation: skeleton-pulse 1.5s infinite ease-in-out;
}

/* Day Group Cards */
.outline-day-group {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  background: var(--editor-bg-low);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition-smooth);
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
  animation: day-card-spawn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}

.no-entry-animations .outline-day-group,
body.no-entry-animations .outline-day-group {
  animation: none !important;
}

@keyframes day-card-spawn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.outline-day-group.deleting-day {
  animation: day-card-delete 0.2s cubic-bezier(0.4, 0, 1, 1) forwards !important;
  pointer-events: none;
}

@keyframes day-card-delete {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  100% {
    opacity: 0;
    transform: scale(0.95) translateY(-8px);
  }
}

.outline-day-group.drag-over {
  border-color: var(--color-accent-blue, #2563eb);
  background: rgba(37, 99, 235, 0.07);
  box-shadow: 0 0 16px rgba(37, 99, 235, 0.15);
  transform: scale(1.005);
}

.outline-day-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.outline-day-title-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.outline-day-date {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 140px;
}

.outline-day-title {
  font-size: 12px;
  color: var(--text-secondary);
}

.outline-day-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.btn-outline-action {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-outline-action:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.btn-outline-action.delete:hover {
  color: var(--accent-dining);
  background: rgba(255, 61, 0, 0.2);
}

.outline-day-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 30px;
}


/* ==========================================================================
   5. Tokenized Draggable Outline Items
   ========================================================================== */
.outline-item {
  /* Default fallbacks */
  --outline-accent: var(--border-color);
  --outline-glow: transparent;

  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--editor-bg-med);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--outline-accent);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  transition: var(--transition-smooth);
  min-width: 0;
  box-sizing: border-box;
  width: 100%;
}

/* Category Semantic Token Mappings */
.outline-item.type-F {
  --outline-accent: var(--accent-flight);
  --outline-glow: var(--accent-flight-glow);
}

.outline-item.type-H {
  --outline-accent: var(--accent-lodging);
  --outline-glow: var(--accent-lodging-glow);
}

.outline-item.type-C {
  --outline-accent: var(--accent-car);
  --outline-glow: var(--accent-car-glow);
}

.outline-item.type-R {
  --outline-accent: var(--accent-dining);
  --outline-glow: var(--accent-dining-glow);
}

.outline-item.type-A {
  --outline-accent: var(--text-primary);
  --outline-glow: rgba(255, 255, 255, 0.03);
}

.outline-item.type-\? {
  --outline-accent: var(--accent-sandbox);
  --outline-glow: rgba(0, 230, 118, 0.03);
}

/* Dynamic & Vivid Dragging State */
.outline-item.dragging {
  opacity: 0.35;
  transform: scale(0.98) translateY(-2px);
  border: 1px dashed var(--outline-accent, var(--accent-flight));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.15s ease;
}

/* Insertion Line & Target Highlight — a real flex-column child, so the
   siblings around it are pushed by genuine layout flow (FLIP-animated in JS)
   rather than a hack applied to whichever card the cursor happens to be
   over. Color is the theme's stable --border-focus, not a per-category
   accent, so it doesn't change hue between flights/hotels/dining. */
.outline-drop-placeholder {
  height: 4px;
  margin: 13px 4px;
  border-radius: 4px;
  background: var(--border-focus);
  box-shadow: 0 0 12px 2px var(--border-focus);
  position: relative;
  flex-shrink: 0;
}

.outline-drop-placeholder::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -5px;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-focus);
  box-shadow: 0 0 8px 1px var(--border-focus);
}

.outline-item-handle {
  color: var(--text-muted);
  font-size: 14px;
  user-select: none;
  cursor: grab;
  touch-action: none;
}

.outline-item-handle:active {
  cursor: grabbing;
}

/* Coarse pointers (touch) get a bigger invisible hit area around the
   handle glyph — the 14px "☰" alone is well under a usable touch target. */
@media (pointer: coarse) {
  .outline-item-handle {
    position: relative;
  }

  .outline-item-handle::after {
    content: '';
    position: absolute;
    inset: -14px;
  }
}

.outline-item-icon {
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.outline-item-details {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}

.outline-item-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}


/* Location confirmation chip — see the "Location Confirmation Chip" comment
   in visualBuilder.js's inline event form template for context. */
.inline-location-chip-row {
  margin-top: -4px;
}

.inline-location-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 4px 3px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.inline-location-chip-icon {
  flex-shrink: 0;
  font-size: 10px;
}

.inline-location-chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inline-location-chip-clear {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.inline-location-chip-clear:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.outline-item-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outline-item-meta {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Interactive Editing States using Local Tokens */
.outline-item.editing {
  /* border-color: var(--outline-accent);
  background: var(--outline-glow); */
  box-shadow: 0 0 8px rgba(from var(--outline-accent) r g b / 0.2);
}

.outline-day-group.editing {
  border-color: var(--text-primary);
  background: var(--editor-bg-high);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.1);
}

/* Sandbox Outline Section overrides */
.outline-sandbox-group {
  margin-top: 10px;
  border: 1px dashed var(--border-color);
}

.outline-sandbox-group.drag-over {
  border-color: var(--accent-sandbox);
  background: rgba(0, 230, 118, 0.03);
}


/* ==========================================================================
   6. Tokenized Inline Forms
   ========================================================================== */
.visual-inline-form {
  /* Default token values */
  --form-accent: var(--border-focus);

  background: var(--editor-bg-high);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-top: 2px solid var(--form-accent);
  border-radius: var(--border-radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0;
  width: 100%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  /* Generous cap so the collapse transition below has a concrete "from"
     number to animate down from — transitions can't animate to/from `auto`.
     Real content never gets near this, so it's never visibly constrained. */
  max-height: 2000px;
  /* `both` matters here: without it, a freshly-inserted element can paint its
     normal (post-animation) style on the very first frame before the
     animation timeline picks up, so the "from" keyframe never actually
     shows — the same reason day-card-spawn below carries `both` too. */
  animation: form-collapse-in 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
  /* Every property that changes on exit shares this exact duration/curve so
     the fade, the shrink, and the surrounding row closing up all read as one
     motion instead of the fade finishing and the layout snapping afterward. */
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1), transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.26s cubic-bezier(0.16, 1, 0.3, 1), margin 0.26s cubic-bezier(0.16, 1, 0.3, 1), padding 0.26s cubic-bezier(0.16, 1, 0.3, 1), border-width 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes form-collapse-in {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Context Accent Token Overrides */
.visual-inline-form.type-F {
  --form-accent: var(--accent-flight);
}

.visual-inline-form.type-T {
  --form-accent: var(--accent-transit);
}

.visual-inline-form.type-H {
  --form-accent: var(--accent-lodging);
}

.visual-inline-form.type-C {
  --form-accent: var(--accent-car);
}

.visual-inline-form.type-R {
  --form-accent: var(--accent-dining);
}

.visual-inline-form.type-A {
  --form-accent: var(--border-focus);
}

.visual-inline-form.type-\? {
  --form-accent: var(--accent-sandbox);
}

.visual-inline-form.type-day {
  --form-accent: var(--border-focus);
}

.inline-form-title {
  color: var(--form-accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inline-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 6px;
  margin-bottom: 4px;
}

.inline-fields-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inline-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

/* Progressive Disclosure: ghost row toggle + smooth grid-height expand */
.btn-toggle-details {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: var(--border-radius-sm, 6px);
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth, all 0.2s ease), border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn-toggle-details:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--active-category-accent, rgba(255, 255, 255, 0.25));
  color: var(--text-primary);
}

.btn-toggle-details.expanded {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-toggle-details.expanded .toggle-icon {
  transform: rotate(90deg);
}


.progressive-details-drawer {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.progressive-details-drawer.expanded {
  grid-template-rows: 1fr;
  opacity: 1;
}

.progressive-details-drawer-inner {
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progressive-details-drawer.expanded .progressive-details-drawer-inner {
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.row-show-route {
  padding-top: 2px;
}

.form-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: color var(--transition-smooth, 0.15s ease);
}

.form-checkbox-label:hover {
  color: var(--text-primary);
}

.form-checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
  background: var(--editor-bg-high, rgba(255, 255, 255, 0.05));
  accent-color: var(--active-category-accent, var(--accent-flight, #00e5ff));
  cursor: pointer;
  margin: 0;
}


/* ==========================================================================
   7. Add-Triggers and Interactive Borders
   ========================================================================== */
.add-event-btn,
.btn-outline-add-event {
  width: 100%;
  padding: 10px 16px;
  background: rgba(from var(--text-primary) r g b / 0.08);
  border: 1px solid rgba(from var(--text-primary) r g b / 0.25);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 6px;
  text-align: center;
}

.add-event-btn:hover,
.add-event-btn:focus,
.btn-outline-add-event:hover,
.btn-outline-add-event:focus {
  background: rgba(from var(--text-primary) r g b / 0.16);
  border-color: var(--border-focus, var(--text-primary));
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(from var(--text-primary) r g b / 0.18);
  outline: none;
}

.btn-outline-add-day {
  background: var(--editor-bg-med);
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  width: 100%;
  text-align: center;
  transition: var(--transition-smooth);
  margin-top: 10px;
}

.btn-outline-add-day:hover {
  border-color: var(--accent-flight);
  color: var(--text-primary);
  background: rgba(0, 229, 255, 0.03);
}

@media (max-width: 768px) {
  .visual-outline-wrapper {
    padding: 16px 12px;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: visible !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .emoji-picker-popover {
    left: 13px !important;
  }

}

/* Bigger touch targets for touch/coarse-pointer devices (iPad, etc.) */
@media (pointer: coarse) {
  .visual-inline-form {
    padding: 16px;
    gap: 14px;
  }

  .inline-fields-wrapper {
    gap: 12px;
  }

  .form-input,
  .places-search-input-row {
    padding: 11px 14px;
    font-size: 15px;
  }

  .places-search-input-row .val-name {
    padding: 11px 0;
  }

  .category-pills-row {
    gap: 8px;
  }

  .category-pill {
    padding: 9px 16px;
    font-size: 13px;
  }

  .btn-toggle-details {
    padding: 12px 14px !important;
    font-size: 13px;
  }

  .inline-form-actions {
    gap: 10px;
  }

  .inline-form-actions .btn {
    padding: 12px 20px;
    font-size: 14px;
  }

  .emoji-grid-btn {
    font-size: 24px;
    min-height: 44px;
    line-height: 44px;
  }

  .emoji-tab-btn {
    min-width: 36px;
    min-height: 36px;
    font-size: 16px;
    padding: 6px 8px;
  }
}

/* ==========================================================================
   Date Gap Banner & Prompt Modals
   ========================================================================== */
.outline-date-gap-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  margin: 6px 0 10px 0;
  background: var(--editor-bg-high, rgba(255, 255, 255, 0.03));
  border: 1px dashed var(--border-color, rgba(255, 255, 255, 0.12));
  border-radius: var(--border-radius-md, 8px);
  font-size: 12px;
  color: var(--text-muted);
  transition: var(--transition-smooth);
}

.outline-date-gap-banner:hover {
  background: var(--editor-bg-active, rgba(255, 255, 255, 0.06));
  border-color: var(--border-focus, rgba(255, 255, 255, 0.3));
}

.gap-banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-weight: 500;
}

.gap-banner-text svg {
  opacity: 0.65;
}

.btn-add-gap-days {
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.08));
  color: var(--accent-flight, #38bdf8);
  border: 1px solid rgba(56, 189, 248, 0.25);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-add-gap-days:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-flight, #38bdf8);
  transform: translateY(-1px);
}

/* Inline Date Prompt Callout Banner */
.inline-date-prompt-banner {
  background: var(--bg-surface-elevated, rgba(30, 35, 45, 0.95));
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.12));
  border-left: 3px solid var(--accent-flight, #38bdf8);
  border-radius: var(--border-radius-md, 8px);
  padding: 14px 16px;
  margin: 10px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  animation: inline-banner-slide 0.18s ease-out;
  transition: opacity 0.14s ease-out, transform 0.14s ease-out;
}

.inline-date-prompt-banner.exiting {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.visual-inline-form.exiting {
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
  pointer-events: none;
}

/* Only applied when Cancel discards a brand-new, never-saved "Add" row — the
   one case where this form's whole footprint is actually going away, rather
   than being replaced by a smaller but still-visible summary row (every
   Save, and Cancel on an edit, land on the latter — collapsing those all the
   way to 0 would overshoot past their real target height and spring back up
   the instant the actual row swaps in). */
.visual-inline-form.exiting.exiting-remove {
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  /* Higher specificity than editor.css's `.visual-inline-form { overflow:
     visible !important }` (needed there so the emoji picker and autocomplete
     dropdowns, both absolutely positioned inside this form, never get
     clipped) — !important vs !important is settled by specificity, and this
     compound selector wins, so the collapse only clips once any popover the
     user had open has already been dismissed. */
  overflow: hidden !important;
}

@keyframes inline-banner-slide {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inline-date-prompt-banner .prompt-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px 0;
}

.inline-date-prompt-banner .prompt-msg {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0 0 12px 0;
}

.inline-date-prompt-banner .prompt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-date-prompt-banner .btn-prompt-primary {
  background: var(--accent-flight, #0284c7);
  color: #ffffff;
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.inline-date-prompt-banner .btn-prompt-primary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.inline-date-prompt-banner .btn-prompt-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
  font-size: 12px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.inline-date-prompt-banner .btn-prompt-secondary:hover {
  background: var(--editor-bg-high, rgba(255, 255, 255, 0.08));
}

.inline-date-prompt-banner .btn-prompt-dismiss {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

.inline-date-prompt-banner .btn-prompt-dismiss:hover {
  color: var(--text-secondary);
}