:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2126; --muted: #6b7280; --line: #e5e7eb;
  --accent: #0b7285; --accent-soft: #e3f4f7; --danger: #c1121f; --warn: #f59e0b;
  --tab-h: 58px; --top-h: 48px; --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
/* iOS-26-Standalone-Bug: Viewport-Höhe wird falsch berechnet → Wurzel mit 100dvh und Flex statt fixierter Leisten */
body { height: 100vh; height: 100dvh; position: relative; overflow: hidden; display: flex; flex-direction: column; }
html { background: var(--card); }
body { font: 15px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; background: var(--card); color: var(--text); overscroll-behavior: none; }
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
h3 { margin: 0 0 8px; font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.topbar { flex: 0 0 auto; height: var(--top-h); background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; z-index: 900; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.brand { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { background: rgba(255,255,255,.18); border: 0; color: #fff; border-radius: 8px; width: 34px; height: 34px; font-size: 17px; }
.sync-dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.sync-dot.ok { background: #22c55e; } .sync-dot.pending { background: #facc15; } .sync-dot.error { background: #ef4444; }

main { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; background: var(--bg); }
.view { display: none; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 12px 24px; }
.view.active { display: block; }
#view-map { padding: 0; display: none; flex-direction: column; }
#view-map.active { display: flex; }
#map { flex: 1; width: 100%; }

.tabbar { flex: 0 0 auto; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--card); border-top: 1px solid var(--line); display: flex; z-index: 900; }
.tabbar button { flex: 1; border: 0; background: none; color: var(--muted); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabbar button span { font-size: 11px; }
.tabbar button.active { color: var(--accent); font-weight: 600; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px; background: var(--card); border-bottom: 1px solid var(--line); scrollbar-width: none; flex-shrink: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 10px; font-size: 13px; white-space: nowrap; color: var(--text); }
.chip.on { background: var(--chip, var(--accent)); color: #fff; border-color: transparent; }
.chip.quiet { border-color: #4d7c0f; color: #3f6212; background: #f0fdf4; }
.chip.quiet.on { background: #4d7c0f; color: #fff; }
.badge.quiet { background: #ecfccb; color: #3f6212; }
.leaves { font-size: 11px; }
#view-list .chips, #view-list .list-head { margin: -10px -12px 8px; }
#view-list .chips { margin-top: 0; }

.card { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: #fde8e8; color: var(--danger); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row > label { flex: 1; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
input:not([type=checkbox]), select, textarea { display: block; width: 100%; margin-top: 3px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); font-size: 16px; }
input[type=search] { font-size: 16px; }

/* Liste */
.list-head { padding: 10px 12px 0; background: var(--card); display: flex; gap: 8px; }
.list-head input, .list-head select { margin: 0; }
.list-head select { width: auto; max-width: 42%; }
.poi-row { display: flex; gap: 10px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.poi-ico { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; flex-shrink: 0; }
.poi-main { flex: 1; min-width: 0; }
.poi-name { font-weight: 600; }
.poi-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-right: 4px; }
.badge.warn { background: #fef3c7; color: #92400e; }
.stars { color: #f59e0b; font-size: 12px; }

/* Plan */
.plan-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.plan-head label { margin: 0; flex: 1; }
.plan-head input { padding: 7px 8px; }
.day { background: var(--card); border-radius: var(--radius); margin-bottom: 10px; box-shadow: 0 1px 2px rgba(0,0,0,.05); overflow: hidden; }
.day-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 8px; }
.day-head .dt { font-weight: 700; } .day-head .dt small { font-weight: 400; color: var(--muted); }
.day-head .sum { font-size: 13px; color: var(--muted); }
.day-head .sum.over { color: var(--danger); font-weight: 600; }
.day-base { padding: 0 12px 8px; display: flex; gap: 6px; align-items: center; font-size: 13px; }
.day-base select { margin: 0; padding: 5px 8px; font-size: 14px; width: auto; flex: 1; }
.day-items { border-top: 1px solid var(--line); }
.day-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.day-item .poi-ico { width: 30px; height: 30px; font-size: 16px; }
.day-item .nm { flex: 1; min-width: 0; }
.day-item .nm div:first-child { font-weight: 600; }
.day-item .nm div:last-child { font-size: 12px; color: var(--muted); }
.day-item .ops { display: flex; gap: 2px; }
.day-item .ops button { border: 0; background: #f1f3f5; border-radius: 6px; width: 28px; height: 28px; font-size: 13px; }
.day-notes { width: 100%; border: 0; padding: 8px 12px; font-size: 14px; resize: vertical; background: #fafbfc; border-radius: 0; margin: 0; }
.day-add { padding: 8px 12px; }
.day-empty { padding: 8px 12px; font-size: 13px; color: var(--muted); }
.phase { font-size: 11px; color: #fff; padding: 2px 7px; border-radius: 6px; }
.phase.nord { background: #2563eb; } .phase.west { background: #d97706; } .phase.suedost { background: #16a34a; } .phase.ost { background: #7c3aed; }

/* Bottom Sheet */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 16px 16px 0 0; transform: translateY(105%); transition: transform .25s ease; z-index: 1000; max-height: 82vh; overflow-y: auto; padding: 8px 16px calc(20px + var(--safe-b)); box-shadow: 0 -4px 20px rgba(0,0,0,.15); }
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: #d1d5db; border-radius: 2px; margin: 4px auto 10px; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.3); z-index: 950; display: none; }
.backdrop.show { display: block; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; display: flex; gap: 8px; align-items: center; }
.sheet .meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.sheet p { margin: 6px 0; }
.tip { background: #f8fafc; border-left: 3px solid var(--accent); padding: 6px 10px; border-radius: 0 8px 8px 0; margin: 6px 0; font-size: 14px; }
.tip b { color: var(--accent); }
.sheet .actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sheet .actions select { flex: 1; margin: 0; width: auto; }
.links a { display: inline-block; margin-right: 10px; font-size: 14px; }

/* Modal */
.modal { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 1100; display: none; align-items: flex-end; justify-content: center; }
.modal.open { display: flex; }
.modal-card { background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 14px 16px calc(16px + var(--safe-b)); }
.modal-card label { margin: 6px 0; }

.fab { position: absolute; right: 14px; bottom: 16px; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; font-size: 28px; line-height: 1; box-shadow: 0 3px 10px rgba(0,0,0,.25); z-index: 500; }

.toast { position: absolute; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); left: 50%; transform: translateX(-50%) translateY(20px); background: #1f2937; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 14px; opacity: 0; transition: .2s; z-index: 1200; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Marker */
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 2px 5px rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; }
.pin span { transform: rotate(45deg); font-size: 15px; }
.pin.custom { border-color: #facc15; border-width: 3px; }
.pin .dot { position: absolute; top: -5px; right: -5px; width: 12px; height: 12px; background: #ef4444; border: 2px solid #fff; border-radius: 50%; }
.leaflet-popup-content { margin: 8px 10px; font-size: 14px; }

/* Info */
.info-block { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.info-block h3 { cursor: pointer; display: flex; justify-content: space-between; margin: 0; }
.info-block h3::after { content: '▸'; color: var(--muted); transition: .15s; }
.info-block.open h3::after { transform: rotate(90deg); }
.info-block .body { display: none; margin-top: 8px; font-size: 14px; }
.info-block.open .body { display: block; }
.info-block ul { padding-left: 18px; margin: 6px 0; }
.info-block li { margin: 3px 0; }
.wx { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.wx-day { flex: 0 0 74px; background: #f8fafc; border-radius: 8px; padding: 6px; text-align: center; font-size: 12px; }
.wx-day b { display: block; font-size: 14px; }
.wx-day .wind { font-size: 11px; color: var(--muted); }
.wx-day.today { outline: 2px solid var(--accent); }
.sup-hint { margin-top: 8px; font-size: 14px; background: #e3f4f7; border-radius: 8px; padding: 8px 10px; }

.check { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.check input[type=checkbox] { width: 20px; height: 20px; margin: 0; }
.check span { flex: 1; } .check span.done { text-decoration: line-through; color: var(--muted); }
.check button { border: 0; background: none; color: var(--muted); font-size: 16px; }

@media (min-width: 800px) {
  body { max-width: 800px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
}

/* Favoriten */
.fav-btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 12px; font-size: 18px; line-height: 1; }
.fav-btn.on { background: #fee2e2; border-color: #fca5a5; }
.chip.fav { border-color: #f87171; color: #b91c1c; background: #fff1f2; }
.chip.fav.on { background: #dc2626; color: #fff; }
.pin .heart { position: absolute; top: -12px; left: -14px; font-size: 16px; line-height: 1; transform: rotate(45deg); filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); pointer-events: none; }
/* Hervorhebung des zuletzt gewählten Pins */
.pin.sel { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--accent), 0 2px 8px rgba(0,0,0,.4); }
.pin.sel::after { content: ''; position: absolute; inset: -14px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; animation: pinpulse 1.6s ease-out infinite; pointer-events: none; }
@keyframes pinpulse { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
.fav-names { font-size: 12px; color: #b91c1c; }
/* Varianten */
.variants { display: flex; gap: 4px; padding: 0 12px 8px; align-items: center; flex-wrap: wrap; }
.variants button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.variants button.on { background: var(--accent); color: #fff; border-color: transparent; }
.variants button.chosen::after { content: ' ✓'; }
.variants .vadd { color: var(--muted); }
.variant-bar { display: flex; gap: 6px; padding: 6px 12px; background: #fffbeb; font-size: 13px; align-items: center; flex-wrap: wrap; border-top: 1px solid #fde68a; }
.variant-bar .btn { padding: 4px 9px; font-size: 12px; }
.day.alt-view { outline: 2px dashed #f59e0b; }
.day-item.slot .poi-ico { background: #64748b; }
.day-item .dur { font-size: 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; padding: 1px 6px; cursor: pointer; white-space: nowrap; }
.day-item .dur-edit { display: flex; gap: 4px; align-items: center; }
.day-item .dur-edit input { width: 64px; padding: 4px 6px; font-size: 14px; margin: 0; }
.day-item .dur-edit button { border: 0; background: #f1f3f5; border-radius: 6px; width: 26px; height: 26px; font-size: 13px; }
.day-add { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.wrap { flex-wrap: wrap; border: 0; padding: 0 0 8px; background: none; }

/* Wanderwege */
.trail-toggle { background: #fff; border: 2px solid rgba(0,0,0,.2); border-radius: 6px; padding: 5px 9px; font-size: 13px; font-weight: 600; color: #166534; cursor: pointer; }
.trail-toggle.on { background: #166534; color: #fff; }
.trail-chip { display: inline-block; background: #dcfce7; color: #166534; border-radius: 6px; padding: 2px 7px; margin: 2px 0; font-size: 13px; cursor: pointer; }
.tip.trails { border-left-color: #166534; }

/* Galerie */
.gallery { display: flex; gap: 6px; overflow-x: auto; margin: 8px -16px; padding: 0 16px 4px; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { height: 110px; width: auto; min-width: 90px; max-width: 200px; object-fit: cover; border-radius: 8px; background: #e5e7eb; flex: 0 0 auto; cursor: pointer; }
.gallery .g-empty { font-size: 13px; color: var(--muted); padding: 6px 0; }
.g-links { font-size: 13px; margin: 2px 0 8px; }
.lightbox { position: absolute; inset: 0; background: rgba(0,0,0,.92); z-index: 1300; display: none; flex-direction: column; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100vw; max-height: 80vh; object-fit: contain; }
.lb-cap { color: #ddd; font-size: 12px; padding: 10px 16px; text-align: center; max-width: 100%; }
.lb-cap a { color: #93c5fd; }
.lb-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 50%; width: 38px; height: 38px; font-size: 18px; }

/* Drag & Drop */
.drag-handle { color: #9ca3af; font-size: 18px; padding: 6px 4px 6px 0; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.drag-ghost { position: absolute; z-index: 1400; pointer-events: none; opacity: .92; box-shadow: 0 8px 24px rgba(0,0,0,.25); background: #fff; border-radius: 8px; transform: scale(1.02); }
.drag-placeholder { background: #e3f4f7; border: 2px dashed var(--accent); border-radius: 8px; margin: 4px 8px; }
.day-items { min-height: 24px; }

/* Tage einklappen / verschieben */
.day-head { cursor: pointer; user-select: none; -webkit-user-select: none; }
.day-head .caret { color: var(--muted); font-size: 13px; width: 12px; }
.day-head .dt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-ops { display: flex; gap: 2px; }
.day-ops button { border: 0; background: #f1f3f5; border-radius: 6px; width: 26px; height: 26px; font-size: 12px; color: var(--text); }
.day-ops button:disabled { opacity: .3; }
.day.collapsed .day-body { display: none; }
.day-summary { padding: 0 12px 10px 34px; font-size: 13px; color: var(--muted); }
.day.past { opacity: .75; }
.day.today { box-shadow: 0 0 0 2px var(--accent); }

.trail-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.trail-row .tn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trail-row .btn { text-decoration: none; }

/* Tagesfilter auf der Karte */
.daybar { display: flex; gap: 6px; padding: 6px 10px; background: var(--card); border-bottom: 1px solid var(--line); align-items: center; flex-shrink: 0; }
.daybar select { margin: 0; padding: 6px 8px; font-size: 14px; width: auto; flex: 1; min-width: 0; }
.daybar .chip.on { background: var(--accent); color: #fff; }
.day-strip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; background: #fffbeb; border-bottom: 1px solid #fde68a; font-size: 12px; scrollbar-width: none; flex-shrink: 0; }
.day-strip::-webkit-scrollbar { display: none; }
.day-strip .ds { flex: 0 0 auto; background: #fff; border: 1px solid #fde68a; border-radius: 999px; padding: 3px 9px; white-space: nowrap; cursor: pointer; }
.day-strip .ds.base { border-color: #dc2626; color: #b91c1c; font-weight: 600; }
.day-strip .ds b { display: inline-block; min-width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #fff; text-align: center; font-size: 11px; line-height: 16px; margin-right: 4px; }
.pin.base { box-shadow: 0 0 0 4px #dc2626, 0 2px 6px rgba(0,0,0,.4); }
.pin .seq { position: absolute; top: -9px; right: -9px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; transform: rotate(45deg); border: 2px solid #fff; padding: 0 3px; }
.pin.dim { opacity: .35; }
.route-arrow { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 12px solid var(--accent); filter: drop-shadow(0 0 1px #fff); }
.hike-group { margin: 10px 0 4px; }
.hike-name { font-weight: 600; font-size: 14px; padding: 4px 0; cursor: pointer; }

[hidden] { display: none !important; }

.lightbox img { transition: opacity .15s; touch-action: pan-y; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 28px; line-height: 1; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
.lb-nav:disabled { opacity: .2; }
.lb-count { background: rgba(255,255,255,.15); border-radius: 999px; padding: 1px 8px; margin-right: 6px; }
@media (hover: none) { .lb-nav { opacity: .5; } }

.trip-info { flex-basis: 100%; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.parked-head { margin: 18px 0 8px; padding: 8px 10px; background: #fef3c7; border-radius: 8px; font-size: 14px; }
.day.parked { opacity: .9; border: 1px dashed #f59e0b; }

/* Autofill */
.moods { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.moods button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 8px; text-align: left; font-size: 14px; }
.moods button { position: relative; }
.moods button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.moods button.on::after { content: '✓'; position: absolute; top: 6px; right: 8px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
.moods button small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
label.inline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
label.inline input { width: 18px; height: 18px; margin: 0; }

.ask-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ask-item input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }
.ask-item .ai-name { font-weight: 600; }
.ask-item .ai-sub { color: var(--muted); font-size: 12px; }
.ask-item .ai-desc { font-size: 13px; }

/* Mehr: Akkordeon */
.card.acc { padding: 0; overflow: hidden; }
.acc-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 13px 14px; background: none; border: 0; text-align: left; font-size: 16px; font-weight: 600; color: var(--text); cursor: pointer; }
.acc-icon { font-size: 18px; width: 24px; text-align: center; }
.acc-title { flex: 0 0 auto; }
.acc-sum { flex: 1; min-width: 0; font-size: 12px; font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.acc-head .caret { color: var(--muted); font-size: 13px; transition: transform .15s; }
.acc.open .acc-head .caret { transform: rotate(90deg); }
.acc-body { display: none; padding: 0 14px 14px; border-top: 1px solid var(--line); }
.acc.open .acc-body { display: block; }
.acc.open .acc-head { background: #f8fafc; }

.travel { display: flex; gap: 6px; margin: 4px 0 8px; }
.travel button { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 6px; font-size: 14px; }
.travel button.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.travel button small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
input[type=range] { width: 100%; margin: 6px 0 0; padding: 0; border: 0; accent-color: var(--accent); }
