/* Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--color-background); color: var(--color-on-background);
       font: 400 16px/24px var(--font); }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: inherit; }

/* App shell */
#app { min-height: 100%; }
.container { max-width: var(--content-max); margin-inline: auto;
             padding-inline: var(--space-container-mobile); }
@media (min-width: 768px) {
  .container { padding-inline: var(--space-container-desktop); }
}

/* Glass top app bar (64px, hairline bottom) */
.appbar { position: sticky; top: 0; z-index: 40; height: var(--appbar-h);
          display: flex; align-items: center; gap: var(--space-2);
          padding-inline: var(--space-2);
          border-bottom: 1px solid var(--color-surface-variant); }
.appbar .spacer { flex: 1; }
.icon-btn-accent { background: transparent; color: var(--color-on-surface); }
.icon-btn-accent:hover { background: var(--color-surface-container); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
       border: 0; border-radius: var(--radius-md); padding: 10px 20px; }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-text { background: transparent; color: var(--color-on-surface-variant); }
.btn-float { background: var(--color-surface-container-lowest);
             color: var(--color-on-surface); box-shadow: var(--shadow-1); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center;
            width: 40px; height: 40px; border: 0; border-radius: var(--radius-full);
            background: transparent; cursor: pointer; }
.icon-btn:hover { background: var(--color-surface-container); }

/* FAB */
.fab { position: fixed; right: var(--space-2); bottom: var(--space-3); z-index: 50;
       width: 56px; height: 56px; border: 0; border-radius: var(--radius-full);
       display: flex; align-items: center; justify-content: center; cursor: pointer;
       background: var(--color-primary); color: var(--color-on-primary);
       box-shadow: var(--shadow-3); }
.fab-secondary { background: var(--color-secondary-container);
                 color: var(--color-on-secondary-container); }
.fab-square { border-radius: var(--radius-md); }

/* Pills / chips */
.chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
        border: 1px solid var(--color-outline-variant); border-radius: var(--radius-full);
        padding: 6px 14px; background: var(--color-surface-container-low); }
.chip.selected { background: var(--color-primary); color: var(--color-on-primary);
                 border-color: var(--color-primary); }
.pill { display: inline-flex; align-items: center; border-radius: var(--radius-full);
        padding: 2px 10px; background: var(--color-surface-container-high); }

/* Cards */
.card { background: var(--color-surface-container-lowest);
        border: 1px solid var(--color-surface-variant);
        border-radius: var(--radius-md); box-shadow: var(--shadow-1); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 90;
                  background: var(--color-scrim);
                  display: flex; align-items: center; justify-content: center;
                  padding: var(--space-2); }
.modal { background: var(--color-surface-container-lowest);
         border-radius: var(--radius-md); box-shadow: var(--shadow-3);
         width: 100%; max-width: 480px; padding: var(--space-3); }
.modal h2 { margin-top: 0; }

/* Forms */
.field { display: block; margin-bottom: var(--space-2); }
.field > span { display: block; margin-bottom: 6px;
                font: 500 14px/20px var(--font); color: var(--color-on-surface-variant); }
.input { width: 100%; border: 1px solid var(--color-outline-variant);
         border-radius: var(--radius-md); padding: 10px 14px;
         background: var(--color-surface-container-lowest); }
.input:focus { outline: 2px solid var(--color-primary); outline-offset: 0; }

/* Toast (non-fatal errors, e.g. upstream failures) */
.toast { position: fixed; left: 50%; bottom: var(--space-3); transform: translateX(-50%);
         z-index: 100; background: var(--color-inverse-surface);
         color: var(--color-inverse-on-surface); border-radius: var(--radius-md);
         padding: 12px 20px; box-shadow: var(--shadow-3); }
.toast.error { background: var(--color-error); color: var(--color-on-error); }

/* Keyboard focus indicators */
.btn:focus-visible,
.fab:focus-visible,
.chip:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.hidden { display: none !important; }

/* Dashboard (mockup: meine_reisen_dashboard) */
.dashboard { padding-block: var(--space-3) 96px; }
.dashboard h1 { margin: 0 0 var(--space-3); }
.trip-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-card-gap); }
@media (min-width: 768px) { .trip-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .trip-grid { grid-template-columns: repeat(3, 1fr); } }

.trip-card { overflow: hidden; cursor: pointer; transition: box-shadow 0.15s; }
.trip-card:hover { box-shadow: var(--shadow-1-hover); }
.trip-card-cover { position: relative; height: 120px;
  background: linear-gradient(135deg, var(--color-primary-container), var(--color-surface-tint)); }
.trip-card-cover .pill { position: absolute; top: var(--space-2); right: var(--space-2); }
.pill.status-aktiv { background: var(--color-primary); color: var(--color-on-primary); }
.pill.status-geplant { background: var(--color-surface); color: var(--color-on-surface); }
.pill.status-abgeschlossen { background: var(--color-surface-variant); color: var(--color-on-surface-variant); }
.card-menu-btn { position: absolute; top: var(--space-2); left: var(--space-2);
  color: var(--color-on-primary); }
.trip-card-body { padding: var(--space-2); display: flex; flex-direction: column; gap: 8px; }
.trip-card-body h2 { margin: 0; }
.trip-dates, .trip-details-link { margin: 0; display: flex; align-items: center; gap: 6px;
  color: var(--color-on-surface-variant); }
.trip-details-link { margin-top: auto; color: var(--color-primary); }
.card-menu { position: absolute; top: 48px; left: var(--space-2); z-index: 20;
  display: flex; flex-direction: column; padding: 4px; }
.card-menu .btn { justify-content: flex-start; }
.card-menu .danger { color: var(--color-error); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-1);
  margin-top: var(--space-2); }

/* Responsive helpers */
.mobile-only { display: flex; }
.desktop-only { display: none; }
@media (min-width: 768px) {
  .mobile-only { display: none; }
  .desktop-only { display: inline-flex; }
}

/* Trip view (mockup: travelnexus_trip_ansicht) */
.trip-view { position: fixed; inset: 0; }
.map-layer { position: absolute; inset: 0; z-index: 0; -webkit-user-select: none; user-select: none; }
.trip-appbar { position: absolute; top: 0; left: 0; right: 0; z-index: 40; }
.trip-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Trip view appbar context menu (3-dots) */
.appbar-menu-wrap { position: relative; }
.appbar-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 60;
  display: flex; flex-direction: column; padding: 4px; min-width: 200px; }
.appbar-menu[hidden] { display: none; }
.appbar-menu .btn { justify-content: flex-start; }

.view-toggle { position: absolute; top: calc(var(--appbar-h) + var(--space-2));
  left: 50%; transform: translateX(-50%); z-index: 30;
  display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-md); }
.view-toggle .seg { display: inline-flex; align-items: center; gap: 6px;
  border: 0; cursor: pointer; background: transparent; padding: 8px 16px;
  border-radius: var(--radius); color: var(--color-on-surface-variant); }
.view-toggle .seg.selected { background: var(--color-primary); color: var(--color-on-primary); }

/* List panel: bottom sheet (mobile) / right slide-over (desktop) */
.list-panel { position: absolute; z-index: 20; display: flex; flex-direction: column;
  left: 0; right: 0; bottom: 0; height: 45vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transform: translateY(105%); transition: transform 0.2s ease; }
.list-panel.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; margin: 10px auto 4px;
  border-radius: var(--radius-full); background: var(--color-outline-variant); flex: none; }
.list-content { overflow-y: auto; padding: var(--space-1) var(--space-2) var(--space-3); }
.list-empty { color: var(--color-on-surface-variant); text-align: center; }
@media (min-width: 768px) {
  .list-panel { left: auto; top: calc(var(--appbar-h) + var(--space-2));
    right: var(--space-2); bottom: var(--space-2); width: 400px; height: auto;
    border-radius: var(--radius-md); transform: translateX(calc(100% + var(--space-3))); }
  .list-panel.open { transform: translateX(0); }
  .sheet-handle { display: none; }
}

/* keep leaflet controls clear of panels */
.leaflet-bottom.leaflet-right { margin-bottom: var(--space-2); margin-right: var(--space-2); }

/* Map corner buttons (bottomright, above the zoom controls) */
.tn-locate-btn, .tn-fit-all-btn {
  width: 30px; height: 30px; margin-bottom: 5px;
  background: var(--color-surface-container);
  color: var(--color-on-surface);
  border: none; border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.65); }
.tn-locate-btn:hover, .tn-fit-all-btn:hover { background: var(--color-surface-container-high); }
.tn-locate-btn svg, .tn-fit-all-btn svg { display: block; width: 20px; height: 20px; }

/* Current-position pin (locate button) — small blue dot with white ring */
.tn-user-pin-wrap { background: none; border: none; }
.tn-user-pin { width: 16px; height: 16px; border-radius: var(--radius-full);
  background: #1a73e8; border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(26,115,232,.35); }

/* Layer switch (bottom-left) — kept clear of the attribution credit (bottom-right) */
.map-layer-switch { position: absolute; left: var(--space-2); bottom: var(--space-2);
  z-index: 1100; display: flex; flex-direction: column; align-items: center; padding: 4px; }
.map-layer-switch .map-layer-toggle { width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--color-surface-container); color: var(--color-on-surface); }
.map-layer-switch .map-layer-toggle svg { display: block; width: 20px; height: 20px; }
.map-layer-switch .map-layer-options { display: none; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.map-layer-switch.open .map-layer-options { display: flex; }
.map-layer-switch .map-layer-btn { width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--color-surface-container); color: var(--color-on-surface); }
.map-layer-switch .map-layer-btn svg { display: block; width: 20px; height: 20px; }
.map-layer-switch .map-layer-btn.active { background: var(--color-primary); color: var(--color-on-primary); }
.map-layer-switch .map-text-toggle { width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--color-surface-container); color: var(--color-on-surface); margin-bottom: 4px; }
.map-layer-switch .map-text-toggle svg { display: block; width: 20px; height: 20px; }
.map-layer-switch .map-text-toggle.active { background: var(--color-primary); color: var(--color-on-primary); }
.map-layer-switch .map-pin-toggle { width: 40px; height: 40px; border-radius: var(--radius-full);
  background: var(--color-surface-container); color: var(--color-on-surface); margin-bottom: 4px; }
.map-layer-switch .map-pin-toggle svg { display: block; width: 20px; height: 20px; }
.map-layer-switch .map-pin-toggle.active { background: var(--color-primary); color: var(--color-on-primary); }
.map-layer.tn-pin-drop { cursor: crosshair; }

/* Place form (mockup: ort_bearbeiten_erstellen) */
.form-page { max-width: 768px; padding-block: var(--space-3) var(--space-4); }
.form-subtitle { color: var(--color-on-surface-variant); margin-top: 0; }
.place-form { padding: var(--space-3); }
.coord-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.coord-picker-map { height: 260px; margin-top: var(--space-1); border-radius: var(--radius-md);
  overflow: hidden; border: 1px solid var(--color-outline-variant); z-index: 1; }
.coord-picker-map .leaflet-container { height: 100%; border-radius: var(--radius-md); }
.coord-map-hint { display: block; margin-top: 4px; color: var(--color-on-surface-variant); }
/* Keep the "Übernehmen" popup above the form's stacking context */
.coord-picker-map .leaflet-popup-pane { z-index: 1200; }
.chips-field { border: 0; padding: 0; margin: 0 0 var(--space-2); }
.chips-field legend { margin-bottom: 8px; color: var(--color-on-surface-variant); }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio { display: inline-block; margin: 0 8px 8px 0; }
.chip-radio input:checked + .chip { background: var(--color-secondary-container);
  color: var(--color-on-secondary-container); border-color: var(--color-secondary-container); }
.chip-radio input:focus-visible + .chip { outline: 2px solid var(--color-primary); }

/* Map pins (mockup: travelnexus_trip_ansicht :108-118; colors per CONTEXT marker model) */
.tn-pin-wrap { background: none; border: none; }
.tn-pin { width: 40px; height: 40px; border-radius: var(--radius-full);
  border: 2px solid var(--color-surface-container-lowest);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-3); position: relative; }
.tn-pin::after { content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent; }
.pin-must { background: var(--color-secondary-container); color: var(--color-on-secondary-container); }
.pin-must::after { border-top-color: var(--color-secondary-container); }
.pin-optional { background: var(--color-primary); color: var(--color-on-primary); }
.pin-optional::after { border-top-color: var(--color-primary); }
.pin-new { background: var(--color-tertiary, #2e7d32); color: var(--color-on-tertiary, #fff);
  border-color: var(--color-surface-container-lowest);
  outline: 3px solid color-mix(in srgb, var(--color-tertiary, #2e7d32) 35%, transparent); }
.pin-new::after { border-top-color: var(--color-tertiary, #2e7d32); }
.pin-research { background: var(--color-surface-container-highest, #b71c1c); color: var(--color-on-surface, #fff);
  outline: 3px solid color-mix(in srgb, var(--color-error, #b71c1c) 30%, transparent); }
.pin-research::after { border-top-color: var(--color-surface-container-highest, #b71c1c); }
.pin-research-on { background: var(--color-tertiary, #2e7d32); color: var(--color-on-tertiary, #fff);
  outline: 3px solid color-mix(in srgb, var(--color-tertiary, #2e7d32) 40%, transparent); }
.pin-research-on::after { border-top-color: var(--color-tertiary, #2e7d32); }
.pin-popup-actions { display: flex; gap: 4px; margin-top: 6px; }
.pin-popup-actions .icon-btn { width: 32px; height: 32px; border-radius: var(--radius-full); }
.pin-popup-actions .danger { color: var(--color-error); }
/* Create-popup with two stacked actions ("Ort anlegen" + "Text-Box anlegen") */
.pin-popup-stack { flex-direction: column; align-items: stretch; }
.pin-popup-stack .btn { justify-content: flex-start; }
.pin-popup-stack .btn-text { color: var(--color-on-surface-variant); }
/* POI popup: raw OSM tags as wrap pills */
.pin-popup-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pin-popup-tags .pill { font-size: 11px; padding: 1px 8px; }
/* POI popup: LLM explanation (lazily loaded, cached server-side) */
.pin-popup-explain { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--color-surface-variant);
  font: 400 13px/18px var(--font); white-space: pre-wrap; overflow-wrap: break-word;
  color: var(--color-on-surface-variant); max-height: 200px; overflow-y: auto; }

/* Persistent map text-box overlays (white bordered label + edit icon) */
.tn-textbox-wrap { background: none; border: none; transform: translate(-50%, -100%); }
.tn-textbox { position: relative; display: flex; align-items: center; gap: 6px;
  background: var(--color-surface-container-lowest, #fff); color: var(--color-on-surface);
  border: 2px solid var(--color-outline); border-radius: var(--radius-md);
  box-shadow: var(--shadow-2); padding: 6px 8px;
  max-width: min(320px, calc(100vw - 32px)); }
.tn-textbox::after { content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--color-surface-container-lowest, #fff); }
.tn-textbox-text { font: 500 13px/18px var(--font); white-space: pre-wrap;
  overflow-wrap: break-word; }
.tn-textbox .icon-btn { width: 24px; height: 24px; border-radius: var(--radius-full);
  flex: none; padding: 0; }

/* Text-box editor modal: click-through backdrop keeps the map interactive so a
   click on the map moves the box. The card itself stays clickable. */
.modal-backdrop.textbox-edit { background: transparent; pointer-events: none;
  align-items: flex-start; padding-top: calc(var(--appbar-h) + 16px); }
.textbox-edit .modal { pointer-events: auto; }
.textbox-edit .modal-actions .danger { color: var(--color-error); }
.textbox-spacer { flex: 1; }
.textbox-coords { display: block; color: var(--color-on-surface-variant);
  font-family: var(--font-mono, monospace); }
.textbox-move-hint { display: flex; align-items: center; gap: 6px; margin: 8px 0 0;
  color: var(--color-on-surface-variant); }

/* Map context menu (right-click / long-tap) */
.map-context-menu { position: absolute; z-index: 60; padding: 4px; min-width: 170px;
  display: flex; flex-direction: column; transform: translate(-50%, -100%);
  margin-top: -8px; pointer-events: auto; }
.map-context-menu::after { content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--color-surface-container-lowest); }
.map-context-coords { display: block; padding: 6px 12px; font-size: 12px;
  font-family: var(--font-mono, monospace); color: var(--color-on-surface-variant);
  border-bottom: 1px solid var(--color-surface-variant); margin-bottom: 2px; }
.map-context-menu .btn { justify-content: flex-start; width: 100%; }

/* Nominatim search (mockup: floating glass bar with orange icon) */
.search-bar { position: relative; display: flex; align-items: center; gap: 4px;
  border-radius: var(--radius-md); padding: 4px 8px;
  background: var(--color-surface-container-lowest); }
.search-bar[hidden] { display: none; }
.search-floating { position: absolute; z-index: 30; left: 50%; transform: translateX(-50%);
  top: calc(var(--appbar-h) + 60px); width: min(480px, calc(100vw - 32px)); }
.search-icon { color: var(--color-secondary-container); display: flex; }
.search-input { flex: 1; border: 0; background: transparent; padding: 8px 4px; }
.search-input:focus { outline: none; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  margin: 0; padding: 4px; list-style: none; max-height: 320px; overflow-y: auto; z-index: 35; }
.search-results button { display: block; width: 100%; text-align: left; border: 0;
  background: transparent; cursor: pointer; padding: 10px 12px;
  border-radius: var(--radius); }
.search-results button:hover { background: var(--color-surface-container); }
.search-results button span { display: block; color: var(--color-on-surface-variant); }
.search-hint { padding: 10px 12px; color: var(--color-on-surface-variant); }

/* Places timeline (mockup: trip_orte_liste) */
.sort-chips { display: flex; gap: 8px; padding: 4px var(--space-2) var(--space-1);
  overflow-x: auto; }
.sort-chips .chip[disabled] { opacity: 0.45; cursor: not-allowed; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 8px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 28px; top: 8px; bottom: 8px;
  width: 2px; background: var(--color-surface-container-highest); }
.tl-item { position: relative; display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-1); cursor: pointer;
  border-bottom: 1px solid var(--color-surface-container-high); }
.tl-item:last-child { border-bottom: 0; }
.tl-node { position: relative; z-index: 1; flex: none; width: 40px; height: 40px;
  border-radius: var(--radius-full); border: 4px solid var(--color-surface-container-lowest);
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary); color: var(--color-on-primary); }
.tl-optional .tl-node { background: var(--color-surface-container-highest);
  color: var(--color-on-surface-variant); }
.tl-optional .tl-body { opacity: 0.8; }
.tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tl-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.option-tag { color: var(--color-on-surface-variant);
  border: 1px solid var(--color-outline-variant); border-radius: var(--radius-sm);
  padding: 0 6px; }
.tl-sub { color: var(--color-on-surface-variant); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tl-meta { flex: none; }

/* Route connector rows (designed from DESIGN.md dot-and-line, 1.5pt stroke) */
.tl-connector { position: relative; display: flex; align-items: center; gap: var(--space-1);
  padding: 4px var(--space-1) 4px 48px; border-bottom: 1px solid var(--color-surface-container-high); }
.tl-connector-line { position: absolute; left: 27px; top: 0; bottom: 0; width: 0;
  border-left: 1.5px dashed var(--color-outline); }
.tl-connector-body { display: flex; align-items: center; gap: 6px;
  color: var(--color-on-surface-variant); flex: 1; }
.tl-connector-del { width: 28px; height: 28px; color: var(--color-on-surface-variant); }
.tl-connector-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* Place detail modal + comments */
.detail-modal { max-width: 560px; max-height: 85vh; overflow-y: auto; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; }
.detail-head h2 { margin: 0; }
.detail-meta { color: var(--color-on-surface-variant); display: flex; align-items: center;
  gap: 6px; flex-wrap: wrap; }
.detail-actions { display: flex; gap: var(--space-1); margin-block: var(--space-2); }
.share-popover { display: flex; flex-direction: column; padding: 4px; margin-bottom: var(--space-2); }
.share-popover .btn { justify-content: flex-start; }
.comments { display: flex; flex-direction: column; gap: var(--space-1); }
.comment { padding: var(--space-2); }
.comment p { margin: 0 0 8px; }
.comment-images { display: flex; gap: 8px; flex-wrap: wrap; }
.comment-images img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius); }
.comment-date { color: var(--color-on-surface-variant); }
.comment-form { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-2); }
/* Dropzone (mockup: ort_bearbeiten_erstellen :217-226) */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 2px dashed var(--color-outline-variant); border-radius: var(--radius-md);
  padding: var(--space-2); cursor: pointer; color: var(--color-on-surface-variant);
  text-align: center; }
.dropzone:hover { border-color: var(--color-primary); }

/* Offline / PWA */
.trip-card-cover .pill.offline-badge {
  top: auto; right: auto; bottom: var(--space-2); left: var(--space-2);
  background: var(--color-tertiary-container); color: var(--color-on-tertiary-container); gap: 4px; }
.offline-progress { display: flex; flex-direction: column; gap: var(--space-2); min-width: 280px; }
.offline-progress h2 { display: flex; align-items: center; gap: 8px; margin: 0; }
.offline-phase { margin: 0; color: var(--color-on-surface-variant); }
.progress-track { height: 8px; border-radius: var(--radius-full);
  background: var(--color-surface-container-high); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: var(--radius-full);
  background: var(--color-primary); transition: width 0.2s ease; }
.offline-banner { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); z-index: 1200;
  display: flex; align-items: center; gap: 8px;
  background: var(--color-inverse-surface); color: var(--color-inverse-on-surface);
  padding: 8px 16px; border-radius: var(--radius-full); box-shadow: var(--shadow-2); }

/* Login (auth gate shown before the app loads) */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--space-2); background:
    linear-gradient(160deg, var(--color-primary-container), var(--color-surface-tint)); }
.login-card { width: 100%; max-width: 400px; padding: var(--space-4); display: flex;
  flex-direction: column; border-radius: var(--radius-lg); }
.login-brand { display: flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-1); }
.login-logo { display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--color-primary); color: var(--color-on-primary); }
.login-brand h1 { margin: 0; }
.login-sub { color: var(--color-on-surface-variant); margin: 0 0 var(--space-3); }
.login-hint { color: var(--color-error); margin: 0 0 var(--space-2); }
.login-btn { justify-content: center; width: 100%; margin-top: var(--space-1); }
.appbar-email { padding: 6px 12px 4px; color: var(--color-on-surface-variant);
  border-bottom: 1px solid var(--color-surface-variant); margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Research view: full-screen overlay reusing the trip map + list-panel layout */
.research-view { position: absolute; inset: 0; }
.research-view .map-layer { position: absolute; inset: 0; }
.research-hint { color: var(--color-on-surface-variant); text-align: center; padding: var(--space-2); }
.research-item { display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-2); border-radius: var(--radius-md); cursor: pointer; }
.research-item:hover { background: var(--color-surface-container-high); }
.research-item input { margin-top: 3px; flex: none; }
.research-item-body { display: flex; flex-direction: column; gap: 2px; }
.research-actions { flex: none; padding: var(--space-2);
  border-top: 1px solid var(--color-outline-variant); }
.research-actions .btn { width: 100%; }

/* Info view: full-screen Markdown editor + preview */
.info-view { position: fixed; inset: 0; display: flex; flex-direction: column;
  background: var(--color-surface); }
.info-status { color: var(--color-on-surface-variant); white-space: nowrap;
  padding-right: var(--space-1); }
.info-tabs { display: flex; justify-content: center; gap: 4px; padding: 4px;
  width: fit-content; max-width: calc(100% - 2 * var(--space-2));
  margin: calc(var(--appbar-h) + var(--space-2)) auto 0; border-radius: var(--radius-md); }
.info-tabs .seg { display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer;
  background: transparent; padding: 8px 16px; border-radius: var(--radius);
  color: var(--color-on-surface-variant); }
.info-tabs .seg.selected { background: var(--color-primary); color: var(--color-on-primary); }
.info-body { flex: 1; min-height: 0; margin-top: var(--space-2); }
.info-editor { width: 100%; height: 100%; padding: var(--space-2) var(--space-3);
  border: 0; outline: none; resize: none; background: var(--color-surface-container-lowest);
  color: var(--color-on-surface); font: 400 16px/24px ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace; }
.info-preview { height: 100%; overflow-y: auto; padding: var(--space-2) var(--space-3) var(--space-4);
  color: var(--color-on-surface); }
.info-empty { color: var(--color-on-surface-variant); }

/* Rendered Markdown typography */
.markdown-body h1, .markdown-body h2, .markdown-body h3 { font: 600 22px/30px var(--font);
  margin: var(--space-3) 0 var(--space-1); }
.markdown-body h1 { font-size: 26px; line-height: 34px; }
.markdown-body h2 { font-size: 22px; line-height: 30px; }
.markdown-body h3 { font-size: 18px; line-height: 26px; }
.markdown-body h1:first-child, .markdown-body h2:first-child, .markdown-body h3:first-child { margin-top: 0; }
.markdown-body p { margin: var(--space-1) 0; }
.markdown-body ul, .markdown-body ol { margin: var(--space-1) 0; padding-left: 24px; }
.markdown-body li { margin: 2px 0; }
.markdown-body a { color: var(--color-primary); text-decoration: underline; }
.markdown-body code { font: 400 14px/20px ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
  background: var(--color-surface-container-high); border-radius: 4px; padding: 2px 4px; }
.markdown-body pre { background: var(--color-inverse-surface); color: var(--color-inverse-on-surface);
  padding: var(--space-2); border-radius: var(--radius); overflow-x: auto; }
.markdown-body pre code { background: transparent; padding: 0; color: inherit; }
.markdown-body blockquote { margin: var(--space-1) 0; padding: 0 var(--space-2);
  border-left: 3px solid var(--color-primary); color: var(--color-on-surface-variant); }
.markdown-body img { max-width: 100%; border-radius: var(--radius); }
.markdown-body hr { border: 0; border-top: 1px solid var(--color-outline-variant); margin: var(--space-2) 0; }
