:root {
  --accent: #4A90E2;
  --accent-niosha: #E24A7A;
  --accent-johannes: #4A90E2;
  --bg: #ffffff;
  --bg2: #f5f5f0;
  --text: #1a1a1a;
  --muted: #888;
  --border: #e0e0e0;
  --sidebar-w: 460px;
  --topbar-h: 52px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1e;
    --bg2: #111115;
    --text: #f0f0f0;
    --muted: #777;
    --border: #2e2e38;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg2);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

/* ─── Layout ─── */
#app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: 1fr var(--sidebar-w);
  height: 100vh;
  transition: grid-template-columns 0.25s ease;
}

/* ─── Topbar ─── */
#topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}

#topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

#vacation-selector {
  flex: 1;
  max-width: 300px;
}

#vacation-selector select {
  width: 100%;
  padding: 0.4rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

#topbar .spacer { flex: 1; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.user-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 0.8rem;
}

.btn-icon {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.8rem;
  display: flex; align-items: center; gap: 0.35rem;
  transition: background 0.12s;
}
.btn-icon:hover { background: var(--bg2); }

/* ─── Map Area ─── */
#map-area {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  overflow: hidden;
  background: var(--bg2);
}

/* Leaflet container must fill the map-area */
#map-area .leaflet-container {
  width: 100%;
  height: 100%;
  font-family: inherit;
}

/* Hint tooltip that shows on top of the map */
#map-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: white;
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
}

/* ─── Custom Map Markers ─── */
.map-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.map-marker-bubble {
  width: 34px;
  height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--mc, #4A90E2);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  font-size: 1rem;
}

.map-marker-bubble > * {
  transform: rotate(45deg);
}

.map-marker-stem {
  width: 2px;
  height: 0;
  display: none; /* stem is baked into the rotated border-radius shape */
}

/* ─── Note Popup ─── */
.note-popup .leaflet-popup-content-wrapper {
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  border-left: 4px solid var(--note-color, #4A90E2);
  overflow: hidden;
}

.note-popup .leaflet-popup-content {
  margin: 0;
}

.note-popup .leaflet-popup-tip-container {
  display: none;
}

.note-popup-inner {
  padding: 0.75rem 1rem;
  min-width: 160px;
  max-width: 240px;
}

.note-popup-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  word-break: break-word;
}

.note-popup-body {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
  line-height: 1.4;
  word-break: break-word;
}

.note-popup-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.note-popup-user {
  font-size: 0.72rem;
  font-weight: 700;
}

.note-popup-actions {
  display: flex;
  gap: 0.2rem;
}

.note-popup-actions button {
  background: none;
  border: 1px solid #ddd;
  border-radius: 5px;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  font-size: 0.8rem;
  transition: background 0.1s;
}
.note-popup-actions button:hover { background: #f0f0f0; }

/* ─── Sidebar ─── */
#sidebar {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

#sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

#sidebar-header .sidebar-tabs {
  flex: 1;
  border-bottom: none;
  padding: 0 0.5rem;
}

#sidebar-header #add-timeline-btn {
  margin: 0 0.5rem;
}

#sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
}

#timeline-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

/* ─── Timeline Entries ─── */
.timeline-day {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.75rem 0.5rem 0.35rem;
}

.timeline-entry {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  margin-bottom: 0.3rem;
  cursor: pointer;
  transition: background 0.12s;
  border-left: 3px solid transparent;
}

.timeline-entry:hover { background: var(--bg2); }

.timeline-entry .entry-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.timeline-entry .entry-body { flex: 1; min-width: 0; }
.timeline-entry .entry-title {
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-entry .entry-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.1rem;
}
.timeline-entry .entry-actions {
  display: none;
  gap: 0.25rem;
  align-items: center;
}
.timeline-entry:hover .entry-actions { display: flex; }
.timeline-entry .entry-actions button {
  background: none; border: none; cursor: pointer;
  font-size: 0.85rem; padding: 0.15rem 0.3rem;
  border-radius: 4px; color: var(--muted);
  transition: background 0.1s;
}
.timeline-entry .entry-actions button:hover { background: var(--border); }


/* ─── Modals ─── */
dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  max-width: 480px;
  width: calc(100vw - 2rem);
}

dialog::backdrop {
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
}

.dialog-inner {
  padding: 1.75rem;
}

.dialog-inner h2 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--muted);
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-field textarea { resize: vertical; min-height: 70px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.12s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg2); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger { background: #e24a4a; color: white; }

/* ─── Vacation List Page ─── */
#vacation-home {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1.5rem;
  overflow-y: auto;
  background: var(--bg2);
  z-index: 500;
}

.vacation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 900px;
}

.vacation-card {
  background: var(--bg);
  border-radius: 12px;
  padding: 1.25rem;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.vacation-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--accent);
}

.vacation-card.new-card {
  border-style: dashed;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--muted);
}

.vacation-card.new-card:hover { color: var(--text); border-color: var(--accent); }

.vacation-card h3 { font-size: 1rem; margin-bottom: 0.3rem; }
.vacation-card .vc-dest { font-size: 0.82rem; color: var(--muted); }
.vacation-card .vc-dates { font-size: 0.78rem; color: var(--muted); margin-top: 0.5rem; }


/* ─── Misc ─── */
.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.online-indicator {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4caf50;
  display: inline-block;
}

/* Brand */
.brand-nijo { font-weight: 400; }
.brand-urlaub { font-weight: 700; color: #1a3a5c; }

/* Sidebar tabs */
.sidebar-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.sidebar-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 0.5rem 0.75rem; font-size: 0.8rem; cursor: pointer; color: var(--muted); transition: color 0.15s; margin-bottom: -1px; }
.sidebar-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.sidebar-tab:hover { color: var(--text); }

/* Library */
.lib-subtabs { display: flex; gap: 0.5rem; padding: 0.75rem; border-bottom: 1px solid var(--border); }
.lib-subtab { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.6rem; font-size: 0.8rem; cursor: pointer; color: var(--muted); }
.lib-subtab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.lib-filters { padding: 0.5rem 0.75rem; display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; border-bottom: 1px solid var(--border); font-size: 0.75rem; }
.filter-label { color: var(--muted); font-size: 0.7rem; margin-right: 0.15rem; }
.filter-chip { background: none; border: 1px solid var(--border); border-radius: 12px; padding: 0.15rem 0.5rem; font-size: 0.72rem; cursor: pointer; color: var(--text); }
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.lib-list { flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lib-add-btn { margin: 0.5rem; align-self: flex-start; }
.lib-empty { color: var(--muted); font-size: 0.85rem; text-align: center; padding: 2rem; }
.lib-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.65rem 0.75rem; display: flex; flex-direction: column; gap: 0.3rem; }
.lib-card-header { display: flex; align-items: center; gap: 0.5rem; }
.lib-card-name { font-weight: 600; font-size: 0.9rem; flex: 1; }
.lib-card-status { font-size: 0.7rem; padding: 0.15rem 0.4rem; border-radius: 10px; white-space: nowrap; }
.status-idea { background: #f0f0f0; color: #666; }
.status-shortlisted { background: #fff3cd; color: #856404; }
.status-booked, .status-planned { background: #d1fae5; color: #065f46; }
.lib-card-meta { display: flex; gap: 0.5rem; font-size: 0.75rem; color: var(--muted); flex-wrap: wrap; }
.lib-card-link { color: var(--accent); text-decoration: none; }
.lib-card-link:hover { text-decoration: underline; }
.lib-card-desc { font-size: 0.8rem; color: var(--muted); white-space: pre-wrap; }
.lib-card-actions { display: flex; gap: 0.35rem; margin-top: 0.2rem; }

/* Map filter overlay */
#map-filters { position: absolute; top: 10px; left: 10px; z-index: 1000; display: flex; flex-direction: column; gap: 0.35rem; }
.map-filter-btn { background: white; border: 2px solid #ccc; border-radius: 6px; width: 36px; height: 36px; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.2); transition: opacity 0.2s; }
.map-filter-btn.active { border-color: var(--accent); opacity: 1; }
.map-filter-btn:not(.active) { opacity: 0.4; }

/* Plans */
.plan-card { border: 1px solid var(--border); border-radius: 8px; margin: 0.5rem; overflow: hidden; }
.plan-card-header { display: flex; align-items: center; gap: 0.5rem; padding: 0.65rem 0.75rem; cursor: pointer; background: var(--bg); }
.plan-card-name { font-weight: 600; font-size: 0.9rem; flex: 1; }
.plan-card-dates { font-size: 0.75rem; color: var(--muted); }
.plan-detail { border-top: 1px solid var(--border); padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.plan-transport { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.75rem; }
.transport-fields { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.4rem; }
.transport-fields select, .transport-fields input { flex: 1; min-width: 80px; font-size: 0.8rem; }
.plan-days { display: flex; flex-direction: column; gap: 0.4rem; }
.plan-day { display: flex; gap: 0.5rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }
.plan-day-date { font-size: 0.75rem; color: var(--muted); min-width: 60px; padding-top: 0.2rem; font-weight: 600; }
.plan-day-body { flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.plan-day-acc, .plan-day-acts { display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.plan-day-label { font-size: 0.9rem; }
.plan-day-item { background: #e8f4ff; border-radius: 12px; padding: 0.1rem 0.4rem; font-size: 0.75rem; display: flex; align-items: center; gap: 0.2rem; }
.plan-day-item .btn-icon { font-size: 0.7rem; padding: 0; line-height: 1; }
.plan-day-act-list { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.plan-day-acc-picker, .plan-day-act-picker { margin-top: 0.2rem; }
.plan-day-acc-picker select, .plan-day-act-picker select { font-size: 0.8rem; max-width: 200px; }
.plan-day-notes textarea { width: 100%; font-size: 0.8rem; border: 1px solid var(--border); border-radius: 4px; padding: 0.3rem; resize: vertical; min-height: 40px; background: var(--bg); color: var(--text); }

/* Chat */
.plan-chat-panel { border: 1px solid var(--border); border-radius: 8px; margin-top: 0.5rem; overflow: hidden; }
.chat-messages { max-height: 200px; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.chat-bubble { background: var(--bg); border-radius: 8px; padding: 0.4rem 0.6rem; font-size: 0.82rem; }
.chat-author { font-weight: 600; margin-right: 0.35rem; }
.chat-time { font-size: 0.7rem; color: var(--muted); margin-left: 0.35rem; }
.chat-input-row { display: flex; gap: 0.35rem; padding: 0.4rem; border-top: 1px solid var(--border); }
.chat-input { flex: 1; font-size: 0.85rem; }

/* Panel layout */
#timeline-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#library-panel, #plans-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Item Comments ── */
.item-comments { border-top: 1px solid var(--border); padding-top: 0.5rem; margin-top: 0.4rem; display: flex; flex-direction: column; gap: 0.3rem; }
.comment-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 120px; overflow-y: auto; }
.comment-item { font-size: 0.78rem; display: flex; align-items: baseline; gap: 0.3rem; line-height: 1.3; }
.comment-author { font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.comment-body { flex: 1; word-break: break-word; }
.comment-del-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 0 0.1rem; line-height: 1; flex-shrink: 0; }
.comment-del-btn:hover { color: #e24a4a; }
.comment-input-row { display: flex; gap: 0.3rem; margin-top: 0.2rem; }
.comment-input { flex: 1; font-size: 0.8rem; padding: 0.3rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); }
.comment-send-btn { background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 0.2rem 0.5rem; font-size: 0.85rem; }
.comment-send-btn:hover { background: var(--border); }

/* ── Transport library cards ── */
.lib-card-cat { font-size: 0.78rem; color: var(--muted); background: var(--bg2); border-radius: 10px; padding: 0.1rem 0.5rem; }

/* ── Pinboard ── */
.pinboard-card { border-left: 3px solid var(--accent); }
.pinboard-thought { border-left-color: #7c83fd; }
.pinboard-question { border-left-color: #f59e0b; }
.pinboard-idea { border-left-color: #10b981; }
.pinboard-todo { border-left-color: #3b82f6; }
.pinboard-type-badge { font-size: 0.75rem; font-weight: 600; }
.pinboard-author { font-size: 0.75rem; font-weight: 700; flex: 1; }
.pinboard-body { font-size: 0.88rem; white-space: pre-wrap; line-height: 1.5; margin-top: 0.3rem; }

/* ── Plan description ── */
.plan-description-wrap { padding: 0.3rem 0; }
.plan-description-input { width: 100%; font-size: 0.85rem; border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.6rem; resize: vertical; min-height: 50px; background: var(--bg); color: var(--text); font-family: inherit; }
.plan-description-input:focus { outline: none; border-color: var(--accent); }

/* ── Sidebar Toggle ── */
#sidebar-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1001;
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  width: 22px;
  height: 48px;
  font-size: 0.7rem;
  cursor: pointer;
  color: var(--muted);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: -2px 0 6px rgba(0,0,0,0.08);
  transition: background 0.12s;
}
#sidebar-toggle:hover { background: var(--bg2); color: var(--text); }
#app.sidebar-open #sidebar-toggle { display: flex; }

/* When sidebar is collapsed, map takes full width */
#app.sidebar-collapsed {
  grid-template-columns: 1fr 0;
}
#app.sidebar-collapsed #sidebar {
  width: 0;
  overflow: hidden;
  border-left: none;
}
#app.sidebar-collapsed #sidebar-toggle {
  content: '▶';
}

/* ── Plan card: allow scrolling inside detail ── */
.plan-card { overflow: visible; }

/* ── Plans panel scroll ── */
#plans-panel { overflow-y: auto; }

/* ── Leaflet controls: clean overlay look ── */
.leaflet-bar {
  border: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
  border-radius: 8px !important;
  overflow: hidden;
}
.leaflet-bar a {
  border-bottom: 1px solid var(--border) !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  font-size: 1.1rem !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
}
.leaflet-bar a:hover {
  background: var(--bg2) !important;
}
.leaflet-bar a:last-child {
  border-bottom: none !important;
}
.leaflet-control-attribution {
  background: rgba(255,255,255,0.7) !important;
  border-radius: 4px !important;
  font-size: 10px !important;
}

/* Map filter buttons: clean overlay */
.map-filter-btn {
  background: var(--bg) !important;
  border: none !important;
  border-radius: 8px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
}
.map-filter-btn.active { opacity: 1; box-shadow: 0 2px 8px rgba(74,144,226,0.3) !important; }
.map-filter-btn:not(.active) { opacity: 0.45; }

/* ── Active plan styling ── */
.plan-card-active {
  background: #f0f9ff;
  border-bottom: 2px solid #10b981;
}
.plan-active-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: #065f46;
  background: #d1fae5;
  border-radius: 10px;
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}
.plan-activate-btn {
  opacity: 0.5;
  transition: opacity 0.15s;
}
.plan-activate-btn:hover { opacity: 1; }

/* ── Map Search ── */
#map-search {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: stretch;
  width: 300px;
}
#app.sidebar-open #map-search { display: flex; }

#map-search-input-row {
  display: flex;
  gap: 0;
}

#map-search {
  background: var(--bg);
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
  overflow: visible;
}

#map-search input {
  flex: 1;
  border: none;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text);
  outline: none;
  border-radius: 10px 0 0 10px;
  width: calc(100% - 38px);
  display: inline-block;
}

#map-search-btn {
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  padding: 0 0.65rem;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  transition: background 0.12s;
}
#map-search-btn:hover { background: var(--bg2); }

#map-search-results {
  background: var(--bg);
  border-radius: 0 0 10px 10px;
  border-top: 1px solid var(--border);
  max-height: 240px;
  overflow-y: auto;
  display: none;
}
#map-search-results.open { display: block; }

.search-result-item {
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg2); }
.search-result-name { font-weight: 600; }
.search-result-type { font-size: 0.72rem; color: var(--muted); }

.search-result-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.search-result-actions button {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}
.search-result-actions button:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Plan Detail Tabs ── */
.plan-detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.plan-detail-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
  margin-bottom: -1px;
  transition: color 0.12s;
}
.plan-detail-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.plan-detail-tab:hover { color: var(--text); }

.plan-detail-content { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; }
.plan-loading { padding: 1rem; color: var(--muted); font-size: 0.85rem; text-align: center; }

/* ── View Mode ── */
.plan-view-desc {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 0.4rem 0;
}
.plan-view-transport {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  background: var(--bg2);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  flex-wrap: wrap;
}
.plan-view-transport-icon { font-size: 0.9rem; }
.plan-view-transport-label { font-weight: 600; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; }
.plan-view-days { display: flex; flex-direction: column; gap: 0; }
.plan-view-day {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  align-items: start;
}
.plan-view-day:last-child { border-bottom: none; }
.plan-view-day-empty { opacity: 0.45; }
.plan-view-day-date { font-size: 0.78rem; font-weight: 700; color: var(--muted); padding-top: 0.1rem; }
.plan-view-day-body { display: flex; flex-direction: column; gap: 0.3rem; }
.plan-view-item { display: flex; align-items: center; gap: 0.4rem; font-size: 0.84rem; }
.plan-view-item-icon { flex-shrink: 0; }
.plan-view-item-name { font-weight: 500; }
.plan-view-item-meta { font-size: 0.72rem; color: var(--muted); }
.plan-view-acc .plan-view-item-name { color: #1e7a5f; }
.plan-view-act .plan-view-item-name { color: #4A90E2; }
.plan-view-notes { font-size: 0.78rem; color: var(--muted); white-space: pre-wrap; }
.plan-view-day-free { font-size: 0.75rem; color: var(--muted); font-style: italic; }

/* ── Edit Mode Drag & Drop ── */
.plan-edit-days { display: flex; flex-direction: column; gap: 0.4rem; }
.plan-edit-day { display: flex; gap: 0.5rem; align-items: start; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.plan-day-dropzone {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.35rem 0.5rem;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  min-height: 34px;
  transition: border-color 0.15s, background 0.15s;
  flex: 1;
}
.plan-day-dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(74,144,226,0.07);
}
.drop-label { font-size: 0.9rem; flex-shrink: 0; }
.drop-hint { font-size: 0.7rem; color: var(--muted); font-style: italic; align-self: center; }
.drop-items { display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }

/* ── Library drag source ── */
.plan-lib-source {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.plan-lib-source-header {
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.plan-lib-source-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.45rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.12s;
}
.plan-lib-source-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.plan-lib-items { padding: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.35rem; max-height: 120px; overflow-y: auto; }
.lib-source-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.25rem 0.65rem;
  font-size: 0.78rem;
  cursor: grab;
  user-select: none;
  transition: background 0.1s, box-shadow 0.1s;
}
.lib-source-item:hover { background: var(--bg2); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.lib-source-item.dragging { opacity: 0.5; cursor: grabbing; }
.lib-source-name { font-weight: 500; }
.lib-source-meta { font-size: 0.7rem; color: var(--muted); }
.lib-source-empty { font-size: 0.78rem; color: var(--muted); padding: 0.5rem; }

/* ── Plan Day Rows (new chip+picker design) ── */
.plan-day-row {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  flex-wrap: wrap;
  min-height: 28px;
}
.plan-day-row-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.plan-day-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #e8f4ff;
  border-radius: 12px;
  padding: 0.18rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
}
.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
}
.chip-remove:hover { color: #e24a4a; }

/* ── Add button + inline picker ── */
.plan-day-add-wrap {
  position: relative;
}
.plan-day-add-btn {
  font-size: 0.75rem;
  padding: 0.18rem 0.55rem;
  border-radius: 12px;
  background: var(--bg2);
  color: var(--muted);
  border-color: var(--border);
  white-space: nowrap;
}
.plan-day-add-btn:hover { color: var(--text); background: var(--border); }
.plan-day-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 2000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 200px;
  max-width: 260px;
  overflow: hidden;
}
.picker-search {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.picker-list {
  max-height: 180px;
  overflow-y: auto;
}
.picker-option {
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.picker-option:last-child { border-bottom: none; }
.picker-option:hover { background: var(--bg2); }
.picker-name { flex: 1; font-weight: 500; }
.picker-meta { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.picker-empty { padding: 0.6rem 0.65rem; font-size: 0.78rem; color: var(--muted); }

/* ── Map Context Menu ── */
.map-context-menu {
  position: absolute;
  z-index: 2000;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  overflow: hidden;
  min-width: 160px;
  animation: ctx-pop 0.1s ease;
}
@keyframes ctx-pop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
.map-context-item {
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.map-context-item:last-child { border-bottom: none; }
.map-context-item:hover { background: var(--bg2); }

/* ── Plan rename button ── */
.plan-rename-btn {
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  align-self: flex-start;
}
