/* ==========================================================================
   Travel Diary Globe - Modern Glassmorphism & Cosmic Styling
   ========================================================================== */

:root {
  --bg-deep: #070913;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-card: rgba(18, 24, 38, 0.92);
  --bg-card-hover: rgba(28, 38, 58, 0.96);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-bright: rgba(255, 255, 255, 0.25);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.45);
  --accent: #ec4899;
  --accent-glow: rgba(236, 72, 153, 0.4);
  --success: #10b981;
  --gold: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.8), 0 0 25px rgba(99, 102, 241, 0.18);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Outfit', var(--font-sans);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  position: fixed;
  inset: 0;
  user-select: none;
  -webkit-user-select: none;
}

/* Background nebula glow overlay */
.cosmic-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 15% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(236, 72, 153, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 1;
}

/* 3D Globe Visualization Canvas */
#globeViz {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2;
  cursor: grab;
}

#globeViz:active {
  cursor: grabbing;
}

/* ==========================================================================
   HTML Elements Layer - Precision Ground Anchoring
   ========================================================================== */

/* The Zero-dimension coordinate anchor on Globe */
.travel-marker {
  position: relative;
  width: 0;
  height: 0;
  pointer-events: auto;
  z-index: 25;
  transition: opacity 300ms ease;
}

.travel-marker.is-hovered,
.travel-marker:hover,
.travel-marker.is-active {
  z-index: 99999 !important;
}

/* Precision Ground Anchor container at (0, 0) */
.pin-ground-anchor {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
}

/* Solid ground dot centered precisely at (0, 0) on Earth's crust */
.pin-ground-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--marker-color, var(--primary));
  box-shadow: 0 0 10px var(--marker-color, var(--primary)), 0 0 3px #ffffff;
  z-index: 8;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Concentric radar surface pulse ring */
.pin-ground-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid var(--marker-color, var(--primary));
  animation: surface-pulse-wave 2.2s infinite ease-out;
  pointer-events: none;
  z-index: 6;
}

@keyframes surface-pulse-wave {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.95;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.4);
    opacity: 0;
  }
}

/* Compact Badge rooted right above the ground dot */
.pin-badge-anchor {
  position: absolute;
  bottom: 4px; /* Sits directly above the 8px ground dot! */
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10;
}

/* Invisible hover bridge to prevent mouse leaves between badge and card */
.pin-badge-anchor::before {
  content: '';
  position: absolute;
  top: -18px;
  left: -20px;
  right: -20px;
  bottom: -10px;
  background: transparent;
  z-index: 1;
}

/* The Sleek City Pill Badge */
.pin-pill-badge {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(13, 19, 36, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--marker-color, var(--primary));
  padding: 3px 9px 3px 6px;
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), 0 0 10px var(--marker-glow);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.badge-icon {
  font-size: 13px;
  line-height: 1;
}

.badge-text {
  font-family: var(--font-sans);
}

.badge-flag {
  font-size: 11px;
  opacity: 0.9;
}

/* Downward Pointer Tip touching the ground dot */
.pin-pointer-tip {
  position: relative;
  z-index: 2;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--marker-color, var(--primary));
  margin-top: -1px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
  transition: border-top-color 0.2s;
}

/* Hover effects on the pin */
.travel-marker:hover .pin-badge-anchor,
.travel-marker.is-hovered .pin-badge-anchor {
  transform: translateX(-50%) scale(1.12);
}

.travel-marker:hover .pin-pill-badge,
.travel-marker.is-hovered .pin-pill-badge {
  background: rgba(22, 33, 62, 0.98);
  border-color: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8), 0 0 20px var(--marker-color, var(--primary));
}

.travel-marker:hover .pin-ground-dot,
.travel-marker.is-hovered .pin-ground-dot {
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 14px #ffffff, 0 0 20px var(--marker-color, var(--primary));
}

/* ==========================================================================
   The Floating Small Page (Float-up Preview Card)
   ========================================================================== */

.diary-preview-card {
  position: absolute;
  bottom: 100%;
  left: 50%;
  /* Default unhovered position: lowered and slightly scaled down */
  transform: translate(-50%, 12px) scale(0.92);
  width: 300px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border-bright);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  margin-bottom: 10px;
  z-index: 1000;
  /* Smooth float up physics */
  transition: 
    opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.36s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.28s,
    box-shadow 0.3s;
}

/* Float Up Effect When Hovered! */
.travel-marker:hover .diary-preview-card,
.travel-marker.is-hovered .diary-preview-card {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  /* Floats up smoothly! */
  transform: translate(-50%, -6px) scale(1);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85), 0 0 30px var(--marker-glow, var(--primary-glow));
}

/* Card Thumbnail Banner */
.card-thumb {
  position: relative;
  width: 100%;
  height: 135px;
  background-size: cover;
  background-position: center;
  background-color: #1e293b;
}

.card-thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(18, 24, 38, 0.98) 0%, rgba(18, 24, 38, 0.4) 50%, rgba(0, 0, 0, 0.2) 100%);
}

.card-badge-country {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(10, 15, 29, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
  color: #fff;
}

.card-date {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(10, 15, 29, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 500;
  color: #cbd5e1;
}

/* Card Body Content */
.card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.25;
}

.card-rating {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.card-summary {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-style: italic;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.card-tag {
  font-size: 10px;
  font-weight: 500;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-card-read {
  flex: 1;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-card-read:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
  filter: brightness(1.08);
}

.btn-card-focus {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-card-focus:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Little pointer triangle beneath the card */
.diary-preview-card::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--bg-card);
  border-right: 1px solid var(--glass-border-bright);
  border-bottom: 1px solid var(--glass-border-bright);
}

/* ==========================================================================
   Country Map Polygons Layer Tooltip & Highlights
   ========================================================================== */

.country-tooltip {
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border-bright);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(99, 102, 241, 0.2);
  color: #fff;
  font-family: var(--font-sans);
  pointer-events: none;
  min-width: 170px;
}

.tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 5px;
}

.tooltip-flag {
  font-size: 18px;
}

.tooltip-body {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tooltip-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tooltip-visited-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #34d399;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  margin-top: 4px;
}

.tooltip-unvisited-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  margin-top: 3px;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: linear-gradient(to bottom, rgba(7, 9, 19, 0.85) 0%, rgba(7, 9, 19, 0) 100%);
  pointer-events: none;
}

.header-brand,
.header-nav,
.header-actions {
  pointer-events: auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4f46e5, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ==========================================================================
   Collapsible Bottom Controls HUD (Default collapsed '>')
   ========================================================================== */

.hud-container {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  right: calc(18px + env(safe-area-inset-right, 0px));
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row-reverse;
  pointer-events: auto;
}

/* Expand / Collapse Toggle Button */
.hud-toggle-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(18, 26, 46, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), 0 0 16px rgba(99, 102, 241, 0.35);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  flex-shrink: 0;
}

.hud-toggle-btn:hover {
  background: rgba(30, 41, 59, 0.98);
  border-color: #ffffff;
  transform: scale(1.08);
}

.hud-toggle-btn:active {
  transform: scale(0.92);
}

/* Controls Bar Container */
.hud-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              max-width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
              padding 0.3s ease;
  max-width: 650px;
  opacity: 1;
  transform: translateX(0);
  overflow: hidden;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-label-text {
  display: none;
}

/* Collapsed state: smoothly hides the bar and only shows '>' */
.hud-container.collapsed .hud-bar {
  opacity: 0;
  pointer-events: none;
  max-width: 0;
  padding: 0;
  margin: 0;
  border: none;
  transform: translateX(20px) scale(0.95);
}

.hud-btn {
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.hud-btn.active {
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.hud-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
}

/* Dropdown styling */
.hud-select {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--glass-border);
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.hud-select:hover {
  border-color: var(--glass-border-bright);
}

.hud-select option {
  background: #0f172a;
  color: #fff;
}

/* ==========================================================================
   Destinations Slide-out Drawer (Sidebar)
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 80;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.destinations-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 390px;
  max-width: 90vw;
  background: rgba(12, 17, 30, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-border-bright);
  z-index: 85;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.7);
}

.destinations-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 22px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-drawer-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-drawer-close:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.drawer-search-box {
  padding: 16px 24px;
  border-bottom: 1px solid var(--glass-border);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: var(--text-subtle);
}

.drawer-search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 10px 14px 10px 36px;
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.drawer-search-input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.1);
}

.drawer-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-list::-webkit-scrollbar {
  width: 5px;
}

.drawer-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.drawer-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.22s ease;
}

.drawer-card:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--glass-border-bright);
  transform: translateX(4px);
}

.drawer-card-img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.drawer-card-info {
  flex: 1;
  min-width: 0;
}

.drawer-card-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.drawer-card-date {
  color: var(--text-subtle);
}

/* ==========================================================================
   Full Travel Diary Reader Modal
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 16, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.diary-modal {
  position: relative;
  width: 820px;
  max-width: 95vw;
  max-height: 88vh;
  background: #0f1629;
  border: 1px solid var(--glass-border-bright);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9), 0 0 40px rgba(99, 102, 241, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .diary-modal {
  transform: translateY(0) scale(1);
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 20;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: rgba(239, 68, 68, 0.8);
  border-color: rgba(239, 68, 68, 0.9);
  transform: rotate(90deg);
}

/* Hero Banner */
.modal-hero {
  position: relative;
  width: 100%;
  height: 280px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.modal-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #0f1629 0%, rgba(15, 22, 41, 0.4) 60%, rgba(0,0,0,0.5) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 28px 32px;
}

.modal-hero-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.badge-country-large {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.badge-category {
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.modal-tagline {
  font-size: 14px;
  color: #cbd5e1;
  margin-top: 4px;
}

/* Modal Content Scroll Area */
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

/* Fast Facts Grid */
.facts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.fact-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.fact-label {
  font-size: 11px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fact-val {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

/* Section styling */
.modal-section-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Journal Story Text */
.journal-story-text {
  font-size: 15px;
  line-height: 1.8;
  color: #e2e8f0;
  white-space: pre-line;
}

/* Highlights List */
.highlights-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.highlight-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}

/* Photo Gallery Strip */
.gallery-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.gallery-item {
  height: 140px;
  border-radius: var(--radius-md);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s;
}

.gallery-item:hover {
  transform: scale(1.03);
  filter: brightness(1.1);
}

/* Travel Tips Box */
.tips-box {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

.tips-box strong {
  color: #fff;
}

/* Modal Footer Navigation */
.modal-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--glass-border);
  background: rgba(11, 16, 30, 0.95);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-nav-dest {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
  color: #f1f5f9;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-nav-dest:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--glass-border-bright);
}

/* ==========================================================================
   Add Journey Modal (Interactive Form)
   ========================================================================== */

.add-modal-body {
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  max-height: 70vh;
}

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

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.form-input,
.form-textarea,
.form-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.1);
}

.form-select option {
  background: #0f1629;
}

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

.add-modal-footer {
  padding: 16px 32px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid var(--primary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px var(--primary-glow);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(15px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Timeline Component (環球足跡時間軸元件)
   ========================================================================== */

.timeline-dock {
  position: absolute;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94vw, 1140px);
  z-index: 46;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-dock * {
  pointer-events: auto;
}

.timeline-dock.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 40px);
}

.timeline-card {
  width: 100%;
  background: rgba(11, 17, 33, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(99, 102, 241, 0.15);
  padding: 12px 18px 14px 18px;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.timeline-dock.is-collapsed .timeline-card {
  max-height: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  border-color: transparent;
  transform: translateY(15px);
}

.timeline-collapsed-tab {
  display: none;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-full);
  padding: 8px 18px;
  color: #e0e7ff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px rgba(99, 102, 241, 0.25);
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.timeline-dock.is-collapsed .timeline-collapsed-tab {
  display: inline-flex;
}

.timeline-collapsed-tab:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(99, 102, 241, 0.7);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5), 0 0 20px rgba(99, 102, 241, 0.4);
}

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

.timeline-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-badge {
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.5px;
}

.timeline-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6366f1;
  box-shadow: 0 0 8px #6366f1;
  animation: pulse-dot 1.8s infinite;
}

.timeline-heading-text {
  display: flex;
  flex-direction: column;
}

.timeline-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.timeline-title-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  opacity: 0.85;
}

.timeline-caption {
  font-size: 11px;
  color: var(--text-muted);
}

.timeline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.timeline-action-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.timeline-action-btn.primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border: none;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.4);
}

.timeline-action-btn.primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.6);
}

.timeline-action-btn.is-touring {
  background: linear-gradient(135deg, #f43f5e, #ec4899) !important;
  box-shadow: 0 0 16px rgba(244, 63, 94, 0.6) !important;
  animation: pulse-tour-btn 1.6s infinite;
}

@keyframes pulse-tour-btn {
  0%, 100% {
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
  }
  50% {
    box-shadow: 0 0 24px rgba(244, 63, 94, 0.9);
  }
}

.timeline-divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.15);
}

/* Timeline Horizontal Track */
.timeline-track-container {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 6px 4px 6px 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.timeline-track-container::-webkit-scrollbar {
  height: 4px;
}

.timeline-track-container::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.35);
  border-radius: 9999px;
}

.timeline-track-line {
  position: absolute;
  top: 19px;
  left: 30px;
  right: 30px;
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(99, 102, 241, 0.4) 0, rgba(99, 102, 241, 0.4) 8px, transparent 8px, transparent 16px);
  z-index: 1;
  pointer-events: none;
}

.timeline-track-nodes {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 14px;
  min-width: max-content;
  padding-top: 4px;
  padding-bottom: 2px;
}

/* Individual Milestone Node */
.timeline-node {
  flex-shrink: 0;
  width: 155px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-node:hover {
  transform: translateY(-3px);
}

.node-milestone-marker {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  width: 32px;
  height: 32px;
}

.milestone-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid var(--node-color, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.25);
  transition: all 0.25s ease;
  z-index: 2;
}

.timeline-node:hover .milestone-dot {
  transform: scale(1.1);
  box-shadow: 0 0 14px var(--node-color, #6366f1);
}

.timeline-node.active .milestone-dot {
  background: var(--node-color, #6366f1);
  transform: scale(1.2);
  box-shadow: 0 0 18px var(--node-color, #6366f1);
  border-color: #ffffff;
}

.milestone-radar {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(99, 102, 241, 0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}

.timeline-node.active .milestone-radar {
  animation: radar-ping 1.8s infinite;
  opacity: 1;
}

@keyframes radar-ping {
  0% {
    transform: scale(0.85);
    opacity: 0.9;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.node-content-card {
  width: 100%;
  background: rgba(18, 26, 44, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 10px;
  transition: all 0.25s ease;
}

.timeline-node:hover .node-content-card {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(24, 34, 58, 0.9);
}

.timeline-node.active .node-content-card {
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.22), rgba(15, 23, 42, 0.95));
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.node-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.node-leg-tag {
  font-size: 9px;
  font-weight: 700;
  color: #818cf8;
  letter-spacing: 0.5px;
}

.timeline-node.active .node-leg-tag {
  color: #c7d2fe;
}

.node-date-tag {
  font-size: 10px;
  color: var(--text-muted);
}

.node-main-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 2px;
}

.node-city-title {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.node-country-sub {
  font-size: 10px;
  color: var(--text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 900px) {
  .facts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .gallery-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 12px 14px;
  }

  .brand-text h1 {
    font-size: 17px;
  }

  .brand-icon-box {
    width: 36px;
    height: 36px;
    font-size: 18px;
  }

  .btn-header {
    padding: 7px 11px;
    font-size: 11px;
    gap: 4px;
  }

  /* Mobile Collapsible HUD: floats vertically upwards above the toggle button */
  .hud-container {
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 8px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
  }

  .hud-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 250px;
    max-width: calc(100vw - 32px);
    padding: 14px;
    border-radius: 20px;
    background: rgba(13, 19, 36, 0.96);
    border: 1px solid var(--glass-border-bright);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 25px rgba(99, 102, 241, 0.25);
    transform: translateY(0);
    overflow: visible;
  }

  .hud-container.collapsed .hud-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.92);
    max-width: 0;
    max-height: 0;
    padding: 0;
    margin: 0;
    border: none;
  }

  .hud-group {
    width: 100%;
    justify-content: space-between;
  }

  .hud-group .hud-btn {
    padding: 7px 10px;
    font-size: 12px;
  }

  .hud-group .hud-select {
    flex: 1;
    font-size: 11px;
    padding: 6px 8px;
    max-width: 135px;
  }

  .hud-label-text {
    display: inline;
    font-size: 11px;
  }

  .btn-reset-taiwan {
    width: 100%;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    padding: 8px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
  }

  .hud-divider {
    display: none;
  }
}
