/* ===== DESIGN TOKENS ===== */
:root {
  --bg: oklch(98.5% 0.004 80);
  --bg-card: #ffffff;
  --fg: oklch(12% 0.01 250);
  --fg-muted: oklch(45% 0.01 250);
  --fg-subtle: oklch(68% 0.008 250);
  --border: oklch(88% 0.005 250);
  --border-light: oklch(93% 0.004 250);
  --accent: oklch(52% 0.12 45);
  --accent-bg: oklch(96% 0.03 45);
  --accent-border: oklch(85% 0.06 45);
  --tag-bg: oklch(95% 0.005 250);
  --tag-fg: oklch(35% 0.01 250);
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --radius: 4px;
  --radius-lg: 6px;
}

/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

body {
  background: var(--bg) !important;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
  height: 56px;
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-brand {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 6px 0;
  font-family: var(--font);
  transition: color 0.12s;
}

.back-btn:hover { color: var(--fg); }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-subtle);
  font-size: 13px;
  font-family: var(--font);
  padding: 6px 0;
  transition: color 0.12s;
  white-space: nowrap;
}

.logout-btn:hover { color: var(--fg); }

.mobile-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--fg-muted);
  cursor: pointer;
  transition: color 0.12s;
}

.mobile-toggle-btn:hover { color: var(--fg); }

/* ===== LAYOUT UTILITIES ===== */
.page-heading {
  font-size: 34px;
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--fg);
  margin: 0;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  font-family: var(--font);
  transition: opacity 0.15s;
  white-space: nowrap;
}

.btn-primary:hover { opacity: 0.82; }
.btn-primary:active { opacity: 0.7; }

.btn-cancel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-muted);
  font-family: var(--font);
  transition: all 0.12s;
}

.btn-cancel:hover { border-color: var(--fg-subtle); color: var(--fg); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-muted);
  font-family: var(--font);
  transition: all 0.12s;
}

.btn-secondary:hover { border-color: var(--fg-subtle); color: var(--fg); }

/* Rain filter button */
.rain-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 12px;
  font-family: var(--font);
  transition: all 0.12s;
  flex-shrink: 0;
  white-space: nowrap;
}

.rain-btn:hover { border-color: var(--fg-subtle); color: var(--fg); }

.rain-btn.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ===== TRIP GRID ===== */
.trips-section { margin-bottom: 40px; }

.trips-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.trips-section-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  white-space: nowrap;
}

.trips-section-divider {
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.trips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ===== TRIP CARD ===== */
.trip-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: box-shadow 0.15s, transform 0.15s;
}

.trip-card:hover {
  box-shadow: 0 4px 24px oklch(0% 0 0 / 0.07);
  transform: translateY(-1px);
}

.trip-card:active { transform: translateY(0); }

.trip-card.trip-past { opacity: 0.55; filter: grayscale(0.3); }
.trip-card.trip-past:hover { opacity: 0.75; }

.trip-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tag-bg);
}

.trip-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.trip-card:hover .trip-cover img { transform: scale(1.03); }

.trip-card-body { padding: 14px 16px 16px; }

.trip-card-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 5px;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-card-date {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--fg-subtle);
}

.trip-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.trip-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--tag-bg);
  color: var(--tag-fg);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  border-radius: 2px;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

.trip-card-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  transition: opacity 0.15s;
  z-index: 2;
}

.trip-action-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-size: 13px;
  box-shadow: 0 1px 4px oklch(0% 0 0 / 0.1);
  transition: color 0.12s;
}

.trip-action-btn:hover { color: var(--fg); }

/* ===== DETAIL SCREEN ===== */
.detail-header { margin-bottom: 28px; }

.detail-title {
  font-size: 30px;
  font-weight: 300;
  letter-spacing: -0.03em;
  color: var(--fg);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  line-height: 1.2;
}

.detail-date {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-subtle);
}

.detail-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--fg-subtle);
  font-size: 13px;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}

.detail-edit-btn:hover { color: var(--fg); background: var(--border-light); }

/* ===== TAB BAR ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 24px;
  background: none;
  border-radius: 0;
  padding: 0;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-subtle);
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  letter-spacing: 0.01em;
  transition: color 0.12s;
  font-family: var(--font);
}

.tab-btn:hover { color: var(--fg); }

.tab-btn.active {
  font-weight: 500;
  color: var(--fg);
  border-bottom-color: var(--fg);
  background: none;
  box-shadow: none;
}

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 400;
  border: 1px solid var(--border);
  background: var(--tag-bg);
  color: var(--tag-fg);
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  font-family: var(--font);
}

.filter-btn:hover { background: var(--border-light); color: var(--fg); }

.filter-btn.active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ===== TAG CHIPS ===== */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.1s;
  user-select: none;
  border: 1px solid var(--border-light);
  font-family: var(--font);
}

.tag-chip-selected {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.tag-chip-unselected {
  background: var(--tag-bg);
  color: var(--tag-fg);
  border-color: var(--border-light);
}

.tag-chip-unselected:hover { background: var(--border-light); }

.tag-chip-location-selected {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  gap: 4px;
}

.tag-chip-location-unselected {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent-border);
  gap: 4px;
}

.tag-chip-location-unselected:hover { background: var(--accent-border); }

/* ===== LIBRARY GRID ===== */
.library-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ===== ITEM CARD ===== */
.item-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.item-card:hover { box-shadow: 0 4px 16px oklch(0% 0 0 / 0.06); }

.item-card.visited {
  opacity: 0.55;
}

.item-card.visited .item-photo-container img {
  filter: grayscale(0.4) brightness(0.92);
}

.item-photo-container {
  height: 160px;
  overflow: hidden;
  background: var(--tag-bg);
  position: relative;
}

.item-photo-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.item-card:hover .item-photo-container img { transform: scale(1.03); }

/* Visited badge */
.item-card.visited::after {
  content: "✓ Láttuk";
  position: absolute;
  top: 8px;
  left: 8px;
  background: oklch(40% 0.12 145 / 0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 2px;
  letter-spacing: 0.03em;
  z-index: 5;
}

/* Item action buttons (edit/delete) */
.item-action-btn {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  font-size: 12px;
  transition: color 0.12s, background 0.12s;
}

.item-action-btn:hover { color: var(--fg); background: var(--border-light); }
.item-action-btn.delete:hover { color: #ef4444; background: rgba(239,68,68,0.06); }

/* Item card title */
.item-card-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--border);
  transition: color 0.15s;
  touch-action: none;
}

.drag-handle:hover { color: var(--fg-subtle); }
.drag-handle:active { cursor: grabbing; }

.item-card.drag-over-top { border-top: 2px solid var(--fg); }
.item-card.drag-over-bottom { border-bottom: 2px solid var(--fg); }
.item-card.is-dragging { opacity: 0.4; transform: scale(0.97); }

/* Item description clamp */
.item-description {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre-line;
}

/* ===== VISITED TOGGLE ===== */
.visited-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--tag-bg);
  border: 1px solid var(--border-light);
  border-radius: 2px;
  cursor: pointer;
  color: var(--fg-subtle);
  font-size: 11px;
  font-weight: 400;
  transition: all 0.12s;
  font-family: var(--font);
}

.visited-toggle:hover { border-color: var(--accent); color: var(--accent); }

.visited-toggle.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ===== CALENDAR BADGE ===== */
.calendar-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 500;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.calendar-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 400;
  background: none;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}

.calendar-add-btn:hover { color: var(--fg); border-color: var(--fg-muted); }

/* ===== LINK CHIP ===== */
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 400;
  background: var(--accent-bg);
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent-border);
  transition: background 0.12s;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-chip:hover { background: oklch(93% 0.05 45); }

/* ===== MODAL STYLES ===== */
.modal-backdrop {
  background: oklch(0% 0 0 / 0.45);
}

.modal-anim-backdrop { animation: backdropIn 0.18s ease forwards; }
.modal-anim-content  { animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal inner (replaces rounded-2xl) */
.modal-panel {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px oklch(0% 0 0 / 0.18);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
  margin: 0;
}

.modal-close-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-subtle);
  font-size: 16px;
  transition: color 0.12s, background 0.12s;
}

.modal-close-btn:hover { color: var(--fg); background: var(--border-light); }

/* ===== FORM STYLES ===== */
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 5px;
  font-family: var(--font);
}

.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--bg);
  color: var(--fg);
  outline: none;
  font-family: var(--font);
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--fg-muted); }
.form-input::placeholder { color: var(--fg-subtle); }

.date-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.duration-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Extra link row in item modal */
.link-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.link-row input { flex: 1; }

.link-remove-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: none;
  background: rgba(239,68,68,0.06);
  color: #ef4444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.link-remove-btn:hover { background: rgba(239,68,68,0.15); }

/* Photo preview */
.photo-preview {
  width: 100%;
  height: 120px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border);
  margin-top: 6px;
  display: block;
}

/* ===== DELETE CONFIRM ===== */
.confirm-delete-btn {
  background: #dc2626;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: var(--font);
}

.confirm-delete-btn:hover { opacity: 0.88; }

/* ===== EMPTY STATES ===== */
.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  grid-column: 1 / -1;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.view-animate {
  animation: fadeSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ===== CALENDAR ===== */

/* Snap indicator */
.snap-indicator {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--fg);
  z-index: 15;
  pointer-events: none;
  box-shadow: 0 0 6px oklch(12% 0.01 250 / 0.25);
}

.snap-indicator::before {
  content: "";
  position: absolute;
  left: -3px; top: -3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fg);
}

/* Drag time tooltip */
.drag-time-tooltip {
  position: fixed;
  z-index: 200;
  background: var(--fg);
  color: var(--bg);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 8px oklch(12% 0.01 250 / 0.2);
  letter-spacing: 0.03em;
}

/* Staging zone */
.staging-zone {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  min-height: 72px;
  transition: border-color 0.2s, background 0.2s;
}

.staging-zone.drag-over {
  border-color: var(--fg);
  background: var(--tag-bg);
}

.staging-zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.staging-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Calendar lock toggle */
.cal-lock-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  font-family: var(--font);
}

.cal-lock-toggle--locked {
  background: var(--tag-bg);
  color: var(--fg-muted);
  border-color: var(--border);
}

.cal-lock-toggle--locked:hover {
  background: var(--border-light);
  color: var(--fg);
}

.cal-lock-toggle--unlocked {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.cal-lock-toggle--unlocked:hover { opacity: 0.85; }

/* Staging card */
.staging-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 180px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  font-size: 11px;
}

.staging-card:hover {
  box-shadow: 0 4px 12px oklch(0% 0 0 / 0.07);
  transform: translateY(-1px);
}

.staging-card:active { cursor: grabbing; }
.staging-card.is-dragging { opacity: 0.4; transform: scale(0.95); }
.staging-card.visited { opacity: 0.5; background: var(--tag-bg); }
.staging-card.cal-locked { cursor: default; }

.staging-card .staging-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 18px; height: 18px;
  border-radius: 3px;
  border: none;
  background: rgba(239,68,68,0.06);
  color: #ef4444;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s;
}

.staging-card:hover .staging-remove { opacity: 1; }
.staging-card .staging-remove:hover { background: rgba(239,68,68,0.2); }

/* Calendar grid */
.calendar-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.calendar-scroll { overflow-x: auto; overflow-y: visible; }

.calendar-grid {
  display: grid;
  min-width: 600px;
  position: relative;
}

.time-gutter {
  width: 54px;
  flex-shrink: 0;
  background: var(--tag-bg);
  border-right: 1px solid var(--border-light);
}

.time-label {
  height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 3px;
  font-size: 10px;
  font-weight: 400;
  color: var(--fg-subtle);
}

.day-column {
  flex: 1;
  min-width: 120px;
  position: relative;
  border-left: 1px solid var(--border-light);
}

.day-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 8px 4px;
  text-align: center;
}

.day-header-name {
  font-size: 10px;
  font-weight: 400;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.day-header-date {
  font-size: 16px;
  font-weight: 300;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.day-header.today { background: var(--accent-bg); }
.day-header.today .day-header-date { color: var(--accent); }

.time-slot {
  height: 60px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  transition: background 0.12s;
}

.time-slot::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px;
  top: 50%;
  border-top: 1px dashed oklch(88% 0.005 250 / 0.6);
  pointer-events: none;
}

.time-slot.drag-over { background: var(--tag-bg); }

/* Calendar event card */
.calendar-event {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 11px;
  cursor: grab;
  overflow: hidden;
  z-index: 5;
  transition: box-shadow 0.15s, opacity 0.2s;
  border-width: 1px;
  border-style: solid;
}

.calendar-event:hover {
  box-shadow: 0 4px 12px oklch(0% 0 0 / 0.12);
  z-index: 8;
}

.calendar-event:active { cursor: grabbing; }
.calendar-event.visited { opacity: 0.5; filter: grayscale(0.3); }
.calendar-event.cal-locked { cursor: default; }

.calendar-event .event-name {
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-event .event-time { font-size: 10px; opacity: 0.7; margin-top: 1px; }

.calendar-event .event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 2px;
}

.calendar-event .event-tag-mini {
  font-size: 9px;
  padding: 0 4px;
  border-radius: 2px;
  background: oklch(100% 0 0 / 0.4);
  white-space: nowrap;
}

.calendar-event .event-actions {
  position: absolute;
  top: 3px; right: 3px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}

.calendar-event:hover .event-actions { opacity: 1; }

.event-action-btn {
  width: 17px; height: 17px;
  border-radius: 3px;
  border: none;
  background: oklch(100% 0 0 / 0.65);
  color: var(--fg-muted);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.event-action-btn:hover { background: oklch(100% 0 0 / 0.9); }
.event-action-btn.remove:hover { color: #ef4444; }
.event-action-btn.visited-btn:hover { color: oklch(40% 0.12 145); }

.event-action-btn.visited-btn.active {
  background: oklch(40% 0.12 145);
  color: #fff;
}

.resize-handle {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 8px;
  cursor: ns-resize;
  background: transparent;
  transition: background 0.12s;
  border-radius: 0 0 3px 3px;
}

.resize-handle:hover, .resize-handle.resizing { background: oklch(100% 0 0 / 0.35); }

/* Category colors (flat, no gradient) */
.event-cat-sight {
  background: oklch(90% 0.04 240);
  border-color: oklch(75% 0.08 240);
  color: oklch(28% 0.12 240);
}

.event-cat-food {
  background: oklch(92% 0.06 60);
  border-color: oklch(76% 0.10 60);
  color: oklch(32% 0.12 60);
}

.event-cat-stay {
  background: oklch(92% 0.05 145);
  border-color: oklch(76% 0.09 145);
  color: oklch(30% 0.12 145);
}

.event-cat-transport {
  background: oklch(90% 0.005 250);
  border-color: oklch(78% 0.01 250);
  color: oklch(30% 0.01 250);
}

/* Calendar empty/staging empty */
.calendar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--fg-subtle);
  font-size: 13px;
}

.staging-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  color: var(--fg-subtle);
  font-size: 12px;
  font-style: italic;
}

/* Now indicator */
.now-indicator {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #ef4444;
  z-index: 9;
  pointer-events: none;
}

.now-indicator::before {
  content: "";
  position: absolute;
  left: -3px; top: -3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ef4444;
}

/* ===== MAP ===== */
.map-outer {
  position: relative;
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

#map-container { width: 100%; height: 100%; }

.map-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
  text-align: center;
  min-height: 400px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.map-filter-panel {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100% - 60px);
}

.map-layer-toggle {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 10;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: 0 1px 4px oklch(0% 0 0 / 0.08);
  transition: color 0.15s, background 0.15s;
}

.map-layer-toggle:hover { color: var(--fg); background: var(--tag-bg); }

/* Map pin */
.map-pin {
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2.5px solid #fff;
  box-shadow: 0 3px 10px oklch(0% 0 0 / 0.22);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s cubic-bezier(0.16,1,0.3,1), box-shadow 0.15s;
}

.map-pin:hover {
  transform: rotate(-45deg) scale(1.18);
  box-shadow: 0 5px 16px oklch(0% 0 0 / 0.28);
}

.map-pin-icon { transform: rotate(45deg); font-size: 14px; line-height: 1; }

.map-you-are-here {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.4);
  animation: map-pulse 2s ease-out infinite;
}

@keyframes map-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(59,130,246,0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(59,130,246,0); }
  100% { box-shadow: 0 0 0 0   rgba(59,130,246,0); }
}

/* Map popup */
.maplibregl-popup-content {
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 8px 28px oklch(0% 0 0 / 0.13) !important;
  padding: 14px !important;
  border: 1px solid var(--border) !important;
}

.map-popup { min-width: 150px; }
.map-popup-cat { font-size: 11px; font-weight: 500; letter-spacing: 0.02em; margin-bottom: 3px; }
.map-popup-name { font-size: 14px; font-weight: 500; color: var(--fg); line-height: 1.3; margin-bottom: 5px; }
.map-popup-location { font-size: 11px; color: var(--fg-subtle); display: flex; align-items: center; gap: 3px; margin-bottom: 10px; }

.map-popup-detail-btn {
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  font-size: 12px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--font);
  transition: opacity 0.15s;
}

.map-popup-detail-btn:hover { opacity: 0.82; }
.map-popup-wrapper .maplibregl-popup-tip { border-top-color: #fff; }

/* ===== MOBILE MENU ===== */
.mobile-menu-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 260px;
  max-width: 80vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 60;
  padding: 16px;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 30px oklch(0% 0 0 / 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-menu-panel.open { transform: translateX(0); }

.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / 0.3);
  z-index: 55;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.mobile-menu-backdrop.open { opacity: 1; pointer-events: auto; }

.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 400;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.mobile-menu-item:hover, .mobile-menu-item.active {
  background: var(--tag-bg);
  color: var(--fg);
}

.mobile-menu-item i { font-size: 16px; width: 20px; text-align: center; }

.mobile-trip-info {
  padding: 10px 12px;
  background: var(--tag-bg);
  border-radius: var(--radius);
  margin-bottom: 4px;
}

.mobile-trip-info h3 { font-size: 13px; font-weight: 500; color: var(--fg); margin-bottom: 2px; }
.mobile-trip-info p { font-size: 11px; color: var(--fg-subtle); }

/* ===== DETAIL MODAL ===== */
.detail-modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 -4px 40px oklch(0% 0 0 / 0.13);
}

@media (min-width: 640px) {
  .detail-modal-sheet {
    border-radius: var(--radius-lg);
    max-height: 82vh;
  }
}

.detail-photo {
  width: 100%;
  max-height: 220px;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--tag-bg);
}

.detail-photo img { width: 100%; height: 220px; object-fit: cover; display: block; }

.detail-modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 4px;
}

.detail-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 2px;
  letter-spacing: 0.01em;
}

.detail-visited-badge {
  font-size: 11px;
  font-weight: 500;
  color: oklch(35% 0.12 145);
  background: oklch(92% 0.05 145);
  padding: 2px 8px;
  border-radius: 2px;
}

.detail-modal-title {
  font-size: 20px;
  font-weight: 400;
  color: var(--fg);
  padding: 4px 14px 6px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.detail-modal-body {
  padding: 4px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.45;
}

.detail-icon { font-size: 14px; color: var(--fg-subtle); flex-shrink: 0; margin-top: 1px; }

.detail-desc {
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.6;
  background: var(--tag-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  border-left: 2px solid var(--border);
  white-space: pre-line;
}

.detail-link { color: var(--accent); font-weight: 500; text-decoration: none; font-size: 13px; }
.detail-link:hover { text-decoration: underline; }

.detail-links-row { display: flex; align-items: flex-start; gap: 8px; }

.detail-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 2px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 400;
  text-decoration: none;
  border: 1px solid var(--accent-border);
  transition: background 0.12s;
}

.detail-link-chip:hover { background: oklch(93% 0.05 45); }
.detail-tags { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 4px; }

/* ===== LOADING ===== */
.global-loading {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--fg);
  background-size: 200% 100%;
  animation: loadingBar 1.2s ease infinite;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
}

.global-loading.active { opacity: 1; }

@keyframes loadingBar {
  0%   { transform: translateX(-100%) scaleX(0.3); }
  50%  { transform: translateX(0%) scaleX(0.7); }
  100% { transform: translateX(100%) scaleX(0.3); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .trips-grid    { grid-template-columns: repeat(2, 1fr); }
  .library-grid  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .mobile-toggle-btn { display: flex !important; }
  .header-inner { padding: 0 16px; }

  .trips-grid    { grid-template-columns: 1fr; gap: 12px; }
  .library-grid  { grid-template-columns: 1fr; gap: 12px; }

  .page-heading  { font-size: 26px; }
  .detail-title  { font-size: 22px; }

  .map-outer     { height: calc(100vh - 190px); }

  .filter-bar    { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .filter-bar::-webkit-scrollbar { display: none; }

  .tab-btn { padding: 8px 14px; font-size: 12px; }

  .date-pair     { grid-template-columns: 1fr; }
  .duration-pair { grid-template-columns: 1fr 1fr; }

  .time-slot    { height: 48px; }
  .time-label   { height: 48px; font-size: 9px; }
  .time-gutter  { width: 42px; }
  .calendar-event { font-size: 10px; padding: 3px 5px; }
  .calendar-event .event-time  { font-size: 9px; }
  .calendar-event .event-tags  { display: none; }
  .staging-card  { width: 150px; padding: 6px 8px; font-size: 10px; }
  .calendar-grid { min-width: unset; }
  .day-column    { min-width: 100px; }

  .map-filter-panel .filter-btn { font-size: 11px; padding: 4px 8px; }
}

@media (max-width: 380px) {
  .trips-grid { gap: 10px; }
}

/* ===== ACCESSIBILITY ===== */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== PRINT ===== */
@media print {
  header, .tab-bar, .staging-zone, .filter-bar,
  #toast-container, .mobile-menu-panel, .mobile-menu-backdrop,
  .event-actions, .staging-remove, .drag-handle, .resize-handle {
    display: none !important;
  }
  body { background: #fff !important; }
  .item-card, .calendar-event { break-inside: avoid; }
}

/* ===== TRAVEL MODE TOGGLE ===== */
.travel-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 2px 8px;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s;
}

.travel-mode-toggle:hover { background: oklch(93% 0.05 45); }

/* ===== TRAVEL MODE ===== */

body.travel-mode main > div {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

.tm-wrapper {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px);
}

.tm-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}

.tm-trip-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.tm-today-label {
  font-size: 12px;
  color: var(--fg-subtle);
  margin-top: 2px;
  text-transform: capitalize;
}

.tm-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
  padding-bottom: 80px;
}

.tm-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px oklch(0% 0 0 / 0.06);
}

.tm-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  color: var(--fg-subtle);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
  padding: 8px;
  letter-spacing: 0.02em;
  font-family: var(--font);
}

.tm-nav-btn i { font-size: 20px; line-height: 1; }
.tm-nav-btn.active { color: var(--accent); }

/* --- Today tab --- */

.tm-today-wrapper { display: flex; flex-direction: column; gap: 10px; }

.tm-fallback-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-subtle);
  padding: 10px 12px;
  background: var(--tag-bg);
  border-radius: var(--radius);
  margin-bottom: 4px;
}

.tm-event-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  gap: 12px;
  padding: 12px;
  transition: border-color 0.15s, opacity 0.15s;
}

.tm-event-card.visited { opacity: 0.65; background: var(--tag-bg); }

.tm-event-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 44px;
  flex-shrink: 0;
  padding-top: 2px;
}

.tm-time-val  { font-size: 15px; font-weight: 600; color: var(--fg); line-height: 1; }
.tm-time-end  { font-size: 10px; color: var(--fg-subtle); margin-top: 2px; }
.tm-time-none { font-size: 18px; color: var(--fg-subtle); opacity: 0.4; }

.tm-event-body { flex: 1; min-width: 0; }

.tm-event-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.tm-event-cat-icon { font-size: 1.1rem; flex-shrink: 0; }

.tm-event-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-event-name.visited { text-decoration: line-through; color: var(--fg-subtle); }

.tm-maps-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--accent-bg);
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.12s;
}

.tm-maps-btn:hover { background: oklch(93% 0.05 45); }

.tm-event-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-subtle);
  margin-bottom: 2px;
}

.tm-event-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.tm-visited-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}

.tm-visited-btn.active {
  background: oklch(92% 0.05 145);
  color: oklch(35% 0.12 145);
  border-color: oklch(80% 0.08 145);
}

.tm-detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 400;
  background: transparent;
  color: var(--fg-subtle);
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.12s;
}

.tm-detail-btn:hover { background: var(--tag-bg); }

/* --- Library tab --- */

.tm-library-wrapper { display: flex; flex-direction: column; }

.tm-library-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }

.tm-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, opacity 0.15s;
}

.tm-item-card.visited { opacity: 0.65; background: var(--tag-bg); }

/* ===== TOAST ===== */
@media (max-width: 640px) {
  #toast-container {
    bottom: 1rem !important;
    right: 0.75rem !important;
    left: 0.75rem !important;
    align-items: stretch !important;
  }
}
