/* ===== Drift — Design System ===== */
:root {
  --bg: #FBF6F3;
  --bg-card: #FFFFFF;
  --bg-elevated: #FDF9F7;
  --primary: #C9938A;
  --primary-hover: #B8827A;
  --primary-light: rgba(201, 147, 138, 0.12);
  --primary-glow: rgba(201, 147, 138, 0.25);
  --secondary: #95BDAA;
  --secondary-light: rgba(149, 189, 170, 0.12);
  --accent: #E8D0A0;
  --accent-light: rgba(232, 208, 160, 0.15);
  --text: #4A4553;
  --text-secondary: #7D7888;
  --text-muted: #B5B0BC;
  --border: #EDE6DF;
  --border-light: #F5F0EB;
  --shadow-sm: 0 1px 4px rgba(74, 69, 83, 0.05);
  --shadow-md: 0 4px 16px rgba(74, 69, 83, 0.07);
  --shadow-lg: 0 8px 32px rgba(74, 69, 83, 0.1);
  --shadow-glow: 0 4px 24px rgba(201, 147, 138, 0.2);
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-full: 100px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-height: 72px;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
  box-shadow: 0 0 80px rgba(201, 147, 138, 0.06);
}

/* ===== Views ===== */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 12px);
}

.view {
  display: none;
  animation: viewIn 0.4s var(--ease-out) both;
  min-height: 100%;
}

.view.active {
  display: block;
}

.view.view-fullheight {
  display: none;
  height: 100%;
  min-height: 0;
}

.view.view-fullheight.active {
  display: flex;
  flex-direction: column;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Header ===== */
.view-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(251, 246, 243, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: calc(var(--safe-top) + 14px) 20px 14px;
  border-bottom: 1px solid var(--border-light);
}

.view-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}

/* Shimmer title effect */
.view-header h1.shimmer {
  background: linear-gradient(
    120deg,
    var(--text) 0%,
    var(--text) 40%,
    var(--primary) 50%,
    var(--text) 60%,
    var(--text) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { background-position: 200% center; }
  50% { background-position: -200% center; }
}

.view-header .subtitle {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--primary);
  cursor: pointer;
  padding: 8px 0;
  font-weight: 500;
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

/* ===== Tab Bar ===== */
#tab-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: var(--tab-height);
  padding-bottom: var(--safe-bottom);
  background: rgba(253, 249, 247, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-light);
  position: relative;
  z-index: 200;
  flex-shrink: 0;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color 0.2s, transform 0.2s var(--ease-spring);
  position: relative;
  font-family: inherit;
}

.tab-btn svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s var(--ease-spring);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active svg {
  transform: scale(1.1);
}

.tab-btn:active {
  transform: scale(0.92);
}

/* FAB (New Entry) */
.tab-fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #b8827a 100%);
  border: none;
  color: white;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  transition: transform 0.3s var(--ease-spring), box-shadow 0.3s;
  margin-top: -20px;
  position: relative;
  animation: fabBreathe 4s ease-in-out infinite;
}

@keyframes fabBreathe {
  0%, 100% { box-shadow: 0 4px 24px rgba(201, 147, 138, 0.2); }
  50% { box-shadow: 0 6px 36px rgba(201, 147, 138, 0.4), 0 0 0 10px rgba(201, 147, 138, 0.05); }
}

.tab-fab::before {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, rgba(201,147,138,0.2), transparent);
  animation: fabRing 6s linear infinite;
  opacity: 0.4;
  z-index: -1;
}

@keyframes fabRing {
  to { transform: rotate(360deg); }
}

.tab-fab:active {
  transform: scale(0.85) rotate(-8deg);
  animation-play-state: paused;
}

.tab-fab:hover {
  box-shadow: 0 8px 32px rgba(201, 147, 138, 0.35);
  animation-play-state: paused;
}

/* ===== Journal Feed ===== */
.journal-feed {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trip-pill-bar {
  display: flex;
  gap: 8px;
  padding: 4px 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.trip-pill-bar::-webkit-scrollbar { display: none; }

.trip-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.25s var(--ease-spring);
  white-space: nowrap;
}

.trip-pill.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(201, 147, 138, 0.15);
}

/* Entry Cards */
.entry-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s;
  animation: cardIn 0.5s var(--ease-out) both;
  position: relative;
  overflow: hidden;
  display: flex;
}

/* Shine sweep on cards */
.entry-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 255, 255, 0.15) 45%,
    rgba(255, 255, 255, 0.35) 50%,
    rgba(255, 255, 255, 0.15) 55%,
    transparent 60%
  );
  transition: left 0.6s var(--ease-out);
  pointer-events: none;
  z-index: 1;
}

.entry-card:active::after {
  left: 120%;
}

.entry-card:active {
  transform: scale(0.975);
  box-shadow: var(--shadow-md);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
}

.entry-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.entry-card-date {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.entry-card-location {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--secondary);
  font-weight: 500;
}

.entry-card-location svg {
  width: 12px;
  height: 12px;
}

.entry-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.35;
}

.entry-card .summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-card-photos {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.entry-card-photos::-webkit-scrollbar { display: none; }

.entry-card-photo {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  transition: transform 0.3s var(--ease-spring);
}

.entry-card:active .entry-card-photo {
  transform: scale(1.05);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 40px;
  animation: fadeUp 0.7s var(--ease-out) both;
  position: relative;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
}

.empty-state-icon {
  font-size: 60px;
  margin-bottom: 20px;
  opacity: 0.85;
  animation: float 4s ease-in-out infinite;
}

.empty-state h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.empty-state p {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 260px;
}

.empty-state .btn-primary {
  margin-top: 24px;
}

/* ===== Entry Detail ===== */
.detail-view {
  padding: 0;
}

.detail-photos {
  position: relative;
  width: 100%;
  height: 240px;
  overflow: hidden;
  background: var(--border-light);
}

.detail-photos-scroll {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  height: 100%;
}

.detail-photos-scroll::-webkit-scrollbar { display: none; }

.detail-photos-scroll img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.detail-photo-count {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
}

.detail-no-photo {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  opacity: 0.3;
  background: linear-gradient(135deg, var(--border-light), var(--bg));
}

/* Photo scroll dots */
.detail-photo-dots {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 5;
}

.detail-photo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transition: all 0.3s var(--ease-spring);
}

.detail-photo-dot.active {
  background: white;
  transform: scale(1.3);
  box-shadow: 0 0 6px rgba(255,255,255,0.5);
}

.detail-body {
  padding: 20px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-date {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-location-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--secondary);
  font-weight: 500;
  background: var(--secondary-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.detail-location-badge svg {
  width: 14px;
  height: 14px;
}

.detail-body h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 12px;
  line-height: 1.2;
}

.detail-summary {
  font-size: 16px;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
  line-height: 1.7;
}

.detail-text {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.detail-minimap {
  margin: 24px 0;
  height: 180px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

/* ===== New/Edit Entry Form ===== */
.entry-form {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.25s, box-shadow 0.25s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.form-input::placeholder {
  color: var(--text-muted);
}

textarea.form-input {
  resize: vertical;
  min-height: 48px;
  line-height: 1.6;
}

.form-input-title {
  font-size: 22px;
  font-weight: 700;
  border: none;
  padding: 8px 0;
  background: transparent;
  letter-spacing: -0.2px;
}

.form-input-title:focus {
  box-shadow: none;
}

/* Photo upload area */
.photo-upload-area {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-preview {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview .remove-photo {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.photo-preview .remove-photo::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.photo-add-btn {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: border-color 0.2s, color 0.2s;
}

.photo-add-btn:active {
  border-color: var(--primary);
  color: var(--primary);
}

.photo-add-btn svg {
  width: 24px;
  height: 24px;
}

/* Location picker */
.location-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--secondary-light);
  border-radius: var(--radius-sm);
  color: var(--secondary);
  font-weight: 500;
  font-size: 14px;
}

.location-display svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.location-display .coords {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.location-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  flex: 1;
}

.location-btn:active {
  border-color: var(--secondary);
  color: var(--secondary);
}

.location-btn svg {
  width: 18px;
  height: 18px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 28px;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.25s var(--ease-out);
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: white;
  box-shadow: var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transform: translate(-50%, -50%);
  transition: width 0.5s, height 0.5s;
}

.btn-primary:active::after {
  width: 300px;
  height: 300px;
}

.btn-primary:hover {
  box-shadow: 0 8px 28px rgba(201, 147, 138, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-danger {
  background: rgba(224, 95, 95, 0.1);
  color: #c0392b;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.btn-block {
  width: 100%;
}

/* ===== Map View ===== */
.map-container {
  flex: 1;
  width: 100%;
  position: relative;
  min-height: 300px;
}

#map-view-map {
  height: 100%;
  width: 100%;
  position: absolute;
  inset: 0;
}

.map-controls {
  position: absolute;
  bottom: 24px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-control-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: none;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: transform 0.2s var(--ease-spring);
}

.map-control-btn:active {
  transform: scale(0.9);
}

.map-control-btn.active {
  background: var(--primary);
  color: white;
}

.map-trip-filter {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.map-trip-filter::-webkit-scrollbar { display: none; }

/* ===== Settings ===== */
.settings-list {
  padding: 8px 16px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 4px;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--border-light);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-item-label {
  font-size: 15px;
  font-weight: 500;
}

.settings-item-desc {
  font-size: 13px;
  color: var(--text-muted);
}

/* Greeting preview */
.greeting-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 12px;
}
.greeting-preview-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.greeting-preview-muted {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 50px;
  height: 30px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 30px;
  transition: 0.3s var(--ease-out);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s var(--ease-spring);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
  box-shadow: 0 0 14px rgba(201, 147, 138, 0.3);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Time input */
.time-input {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  outline: none;
}

.time-input:focus {
  border-color: var(--primary);
}

/* Trip management */
.trip-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  margin-bottom: 8px;
  transition: border-color 0.2s;
}

.trip-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.trip-card-name {
  font-weight: 600;
  font-size: 15px;
}

.trip-card-dates {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.trip-actions {
  display: flex;
  gap: 6px;
}

.add-trip-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.2s;
}

.add-trip-btn:active {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== Onboarding / Welcome ===== */
.onboarding {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 32px;
  min-height: 100%;
  animation: fadeUp 0.9s var(--ease-out) both;
}

.onboarding-icon {
  font-size: 72px;
  margin-bottom: 24px;
  animation: float 4s ease-in-out infinite;
  filter: drop-shadow(0 8px 20px rgba(201, 147, 138, 0.2));
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-6px) rotate(1.5deg); }
  75% { transform: translateY(-3px) rotate(-1deg); }
  50% { transform: translateY(-10px) rotate(-1.5deg); }
}

.onboarding h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.onboarding p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 300px;
  margin-bottom: 32px;
}

/* Floating particles for onboarding & empty states */
.particles-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(100%) scale(0);
  }
  10% {
    opacity: 0.7;
    transform: translateY(80%) scale(1);
  }
  90% {
    opacity: 0.3;
  }
  100% {
    opacity: 0;
    transform: translateY(-20%) scale(0.5);
  }
}

.onboarding .btn-primary {
  font-size: 17px;
  padding: 14px 36px;
}

/* ===== Auth / Lock Screen ===== */
.lock-screen .onboarding-icon {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

.auth-form {
  width: 100%;
  max-width: 280px;
  margin-bottom: 24px;
}

.auth-form .form-group {
  margin-bottom: 14px;
  text-align: left;
}

.auth-form .form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.auth-form .form-input {
  text-align: center;
  font-size: 16px;
  letter-spacing: 1px;
}

.auth-hint {
  font-size: 12px;
  margin-top: 4px;
  min-height: 18px;
  transition: color 0.2s;
}

.auth-hint-ok {
  color: var(--secondary);
}

.auth-hint-err {
  color: #c0392b;
}

/* ===== Modal / Dialog ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 69, 83, 0.35);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease both;
  backdrop-filter: blur(6px);
}

@keyframes fadeIn {
  from { opacity: 0; }
}

.modal-sheet {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideUp 0.35s var(--ease-out) both;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 20px;
}

.modal-sheet h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions .btn {
  flex: 1;
}

/* ===== Ripple Effect ===== */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: rippleAnim 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes rippleAnim {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* ===== Confetti ===== */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  z-index: 3000;
  pointer-events: none;
  border-radius: 2px;
}

/* ===== Greeting badge ===== */
.greeting-text {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.greeting-emoji {
  display: inline-block;
  animation: wave 2s ease-in-out infinite;
  transform-origin: 70% 70%;
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
  60%, 100% { transform: rotate(0deg); }
}

/* ===== Stats bar ===== */
.stats-bar {
  display: flex;
  gap: 16px;
  padding: 12px 0 4px;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== Tab active indicator blob ===== */
.tab-indicator {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 6px);
  width: 32px;
  height: 3px;
  border-radius: 3px;
  background: var(--primary);
  transition: left 0.35s var(--ease-spring), width 0.35s var(--ease-spring);
  pointer-events: none;
}

/* ===== Image tilt on detail ===== */
.detail-photos-scroll img {
  transition: transform 0.4s var(--ease-out);
}

/* ===== Animated location display ===== */
.location-display {
  animation: slideInLeft 0.35s var(--ease-out) both;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
}

/* ===== Photo preview pop-in ===== */
.photo-preview {
  animation: popIn 0.3s var(--ease-spring) both;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.5) rotate(-8deg);
  }
}

/* ===== Toast Notification ===== */
.toast {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.4s var(--ease-spring);
  pointer-events: none;
  max-width: 90%;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(74, 69, 83, 0.9);
  font-family: inherit;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Tracking indicator ===== */
.tracking-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--secondary-light);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
}

.tracking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--secondary);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ===== Leaflet overrides ===== */
.leaflet-container {
  font-family: inherit;
  background: var(--bg);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border-light) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  font-size: 14px;
  line-height: 1.5;
}

.leaflet-popup-content .popup-title {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.leaflet-popup-content .popup-date {
  font-size: 12px;
  color: var(--text-muted);
}

.leaflet-popup-content .popup-photo {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  margin-top: 8px;
}

.map-entry-marker {
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: var(--shadow-md);
}

/* ===== Scrollbar ===== */
#main-content::-webkit-scrollbar {
  width: 0;
}

/* ===== Loading spinner ===== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== SVG sizing in buttons ===== */
.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.tab-fab svg {
  width: 26px;
  height: 26px;
}

.add-trip-btn svg {
  width: 16px;
  height: 16px;
}

.map-control-btn svg {
  width: 20px;
  height: 20px;
}

/* ===== Responsive — desktop preview ===== */
@media (min-width: 481px) {
  body {
    background: linear-gradient(135deg, #EDE4DC 0%, #F5ECE4 50%, #E8DDD6 100%);
  }

  #app {
    height: 100vh;
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
  }
}

/* ===== Timeline & Year Filter ===== */
.year-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.year-filter-bar::-webkit-scrollbar { display: none; }
.year-filter-bar svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.year-pill {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.year-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.timeline-group {
  margin-bottom: 8px;
}
.timeline-month-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px 4px;
}

/* ===== Trip Color Dots ===== */
.trip-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.trip-pill .trip-color-dot {
  margin-right: 2px;
}

/* ===== Entry Card v2 ===== */
.entry-card-color-bar {
  width: 4px;
  flex-shrink: 0;
  border-radius: 4px 0 0 4px;
}

.entry-card-content {
  flex: 1;
  padding: 14px 16px;
  min-width: 0;
}

.entry-card-trip-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ===== Trip Card v2 extensions ===== */
.trip-card-color {
  width: 6px;
  align-self: stretch;
  border-radius: 3px;
  flex-shrink: 0;
}

.trip-card-body {
  flex: 1;
  min-width: 0;
}

.trip-card.archived {
  opacity: 0.6;
}

.archived-badge {
  font-size: 10px;
  background: var(--text-muted);
  color: white;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
}

.trip-color-btn {
  width: 24px !important;
  height: 24px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  min-width: 0 !important;
  border: 2px solid white !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.toggle-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: auto;
}
.toggle-inline input {
  accent-color: var(--primary);
}

/* ===== Color Picker ===== */
.color-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  padding: 16px 0;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  margin: 0 auto;
}
.color-swatch:hover,
.color-swatch.active {
  border-color: var(--text-primary);
  transform: scale(1.15);
}

/* ===== Collection Card ===== */
.collection-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: 12px;
  margin-bottom: 8px;
}
.collection-card svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
  flex-shrink: 0;
}
.collection-card-body {
  flex: 1;
  min-width: 0;
}
.collection-card-name {
  font-weight: 600;
  font-size: 14px;
}
.collection-card-count {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Map Playback ===== */
.playback-bar {
  position: absolute;
  bottom: 80px;
  left: 12px;
  right: 12px;
  background: var(--bg-elevated);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 1001;
  backdrop-filter: blur(12px);
}

.playback-progress {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.playback-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0;
  transition: width 0.15s linear;
}

.playback-info {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playback-stop-btn {
  background: var(--danger, #E74C3C);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== Waypoint Cards ===== */
.waypoints-feed {
  padding: 0 16px 100px;
}

.waypoint-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 6px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.waypoint-card:active {
  transform: scale(0.98);
}
.waypoint-card.has-entry {
  border-left: 3px solid var(--secondary);
}

.waypoint-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.8);
}

.waypoint-card-body {
  flex: 1;
  min-width: 0;
}
.waypoint-card-time {
  font-weight: 600;
  font-size: 14px;
}
.waypoint-card-coords {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
}
.waypoint-card-place {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.waypoint-card-action {
  flex-shrink: 0;
}
.waypoint-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
}
.waypoint-add-btn svg {
  width: 16px;
  height: 16px;
}
.waypoint-journaled {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  font-size: 13px;
  font-weight: 700;
}

/* ===== Waypoint Entry Context ===== */
.waypoint-context {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin: 0 16px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
}
.waypoint-context-icon {
  color: var(--primary);
}
.waypoint-context-icon svg {
  width: 22px;
  height: 22px;
}
.waypoint-context-time {
  font-weight: 600;
  font-size: 14px;
}
.waypoint-context-place {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== Map Legend ===== */
.map-legend {
  position: absolute;
  bottom: 80px;
  left: 12px;
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
  font-size: 12px;
  backdrop-filter: blur(12px);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== Share Modal ===== */
.share-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}
.share-option input {
  accent-color: var(--primary);
}

.modal-sheet h3 svg {
  width: 18px;
  height: 18px;
  display: inline;
  vertical-align: middle;
  margin-right: 6px;
}

/* ===== Circle Sharing ===== */
.circle-intro {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(201,147,138,0.08) 0%, rgba(149,189,170,0.08) 100%);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  border: 1px solid var(--border-light);
}

.circle-intro-icon {
  font-size: 32px;
  flex-shrink: 0;
  line-height: 1;
}

.circle-intro-text strong {
  font-size: 14px;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.circle-intro-text p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0;
}

.circle-contacts {
  margin-bottom: 16px;
}

.circle-contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
}

.circle-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.circle-contact-info {
  flex: 1;
  min-width: 0;
}

.circle-contact-name {
  font-weight: 700;
  font-size: 15px;
  display: block;
}

.circle-contact-detail {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.circle-contact-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 50%;
  transition: all 0.2s;
  line-height: 1;
}

.circle-contact-remove:active {
  background: rgba(192, 57, 43, 0.1);
  color: #c0392b;
}

.circle-prefs {
  margin-bottom: 16px;
}

.circle-share-btn {
  margin-top: 4px;
}

.circle-share-hint {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  padding: 10px 16px 0;
  margin: 0;
}

/* ===== Location Options ===== */
.location-options {
  display: flex;
  gap: 8px;
}
.location-btn-secondary {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border) !important;
}
.location-btn-secondary svg {
  color: var(--text-muted);
}
.location-clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  margin-left: auto;
}

/* ===== Manual Coordinates Hint ===== */
.manual-coord-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.6;
  margin-top: 8px;
}

/* ===== Import Stats ===== */
.import-stats {
  display: flex;
  gap: 16px;
  padding: 12px 0;
}
.import-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.import-stat .stat-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}
.import-stat .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ===== Offline Indicator ===== */
#offline-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 6px 18px;
  border-radius: 0 0 14px 14px;
  font-size: 12px;
  font-weight: 700;
  z-index: 10000;
  box-shadow: 0 2px 16px rgba(0,0,0,0.15);
  animation: slideDown 0.35s ease-out;
  max-width: 300px;
  text-align: center;
  font-family: inherit;
}

/* ===== Update Banner ===== */
#update-banner {
  position: fixed;
  bottom: calc(var(--tab-height, 72px) + env(safe-area-inset-bottom, 0px) + 60px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 14px 10px 18px;
  border-radius: var(--radius-full, 100px);
  font-size: 14px;
  font-weight: 600;
  z-index: 2500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUpBanner 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  font-family: inherit;
  white-space: nowrap;
}

#update-banner button {
  background: white;
  color: var(--text, #4A4553);
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius-full, 100px);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

@keyframes slideUpBanner {
  from { opacity: 0; transform: translateX(-50%) translateY(30px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-100%); }
  to { transform: translateX(-50%) translateY(0); }
}

/* ===== Travel Stats =====*/
.travel-stats-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 0 16px 16px;
  box-shadow: var(--shadow-sm);
}
.travel-stats-row {
  display: flex;
  justify-content: space-around;
  gap: 8px;
}
.travel-stat-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.travel-stat-big .stat-number {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}
.travel-stat-big .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Mode breakdown pills */
.mode-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  justify-content: center;
}
.mode-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: color-mix(in srgb, var(--mode-color) 12%, transparent);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.mode-icon { font-size: 13px; }
.mode-label { font-weight: 700; }
.mode-dist { color: var(--text-secondary); }

/* Waypoint card mode extras */
.waypoint-card-dot {
  position: relative;
}
.waypoint-mode-icon {
  font-size: 10px;
  position: absolute;
  top: -2px;
  right: -6px;
  line-height: 1;
}
.waypoint-speed {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 6px;
  font-weight: 600;
}
.waypoint-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: color-mix(in srgb, var(--mode-color) 12%, transparent);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.dist-badge {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Trip stats picker */
.trip-stats-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.trip-stats-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: none;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.trip-stats-item:hover { background: var(--bg-elevated); }

/* Trip Stats View */
.trip-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px 12px;
}
.trip-stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.trip-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.trip-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 2px;
}
.trip-stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.stats-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  padding: 16px 16px 8px;
}

/* Mode detail cards */
.mode-detail-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mode-detail-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.mode-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mode-detail-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.mode-detail-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}
.mode-detail-pct {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-secondary);
}
.mode-detail-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}
.mode-detail-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s var(--ease-out);
}
.mode-detail-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Segment timeline */
.segments-timeline {
  padding: 0 16px 24px;
}
.segment-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-left: 3px solid var(--seg-color, var(--border));
  padding-left: 14px;
  margin-left: 8px;
}
.segment-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: -1px;
}
.segment-body { flex: 1; }
.segment-mode {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.segment-details {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Photo Editor ===== */
#photo-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: #000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#photo-editor-overlay.open { opacity: 1; }

.pe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: #111;
}
.pe-header-btn {
  background: none;
  border: none;
  color: white;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 8px;
}
.pe-header-btn:hover { background: rgba(255,255,255,0.1); }
.pe-apply-btn { color: var(--primary, #C9938A); }
.pe-title {
  color: white;
  font-size: 16px;
  font-weight: 700;
}

.pe-preview-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 0;
}
#pe-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: filter 0.15s ease;
  user-select: none;
  -webkit-user-drag: none;
}
.pe-vignette-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}
.pe-grain-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: overlay;
  opacity: 0.8;
  display: none;
  image-rendering: pixelated;
}

.pe-tabs {
  display: flex;
  background: #111;
  border-top: 1px solid #222;
}
.pe-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  color: #888;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.pe-tab.active {
  color: white;
  border-bottom-color: var(--primary, #C9938A);
}

.pe-panel {
  background: #111;
  max-height: 260px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Filters panel */
.pe-filters-scroll {
  padding: 8px 0 16px;
}
.pe-filter-cat-label {
  color: #666;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 4px;
}
.pe-filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 12px 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pe-filter-row::-webkit-scrollbar { display: none; }
.pe-filter-thumb {
  flex-shrink: 0;
  background: none;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 70px;
  border-radius: 10px;
  transition: border-color 0.2s;
}
.pe-filter-thumb.active {
  border-color: var(--primary, #C9938A);
}
.pe-filter-img-wrap {
  width: 62px;
  height: 62px;
  border-radius: 8px;
  overflow: hidden;
}
.pe-filter-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pe-filter-thumb span {
  color: #aaa;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}
.pe-filter-thumb.active span {
  color: var(--primary, #C9938A);
}

/* Adjust panel */
.pe-adjust-scroll {
  padding: 8px 16px 20px;
}
.pe-adjust-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.pe-adjust-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.pe-adjust-label {
  color: #ccc;
  font-size: 13px;
  font-weight: 600;
  width: 72px;
  flex-shrink: 0;
}
.pe-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: #333;
  border-radius: 4px;
  outline: none;
}
.pe-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}
.pe-adjust-val {
  color: #888;
  font-size: 12px;
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pe-reset-btn {
  background: none;
  border: none;
  color: #666;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.pe-reset-btn:hover { color: white; }

/* Photo preview edit hint */
.photo-preview img.edit-photo-btn {
  cursor: pointer;
}
.photo-preview:hover::after {
  content: '✏️';
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  pointer-events: none;
}
.photo-preview { position: relative; }

/* ===== Map Style Picker ===== */
.map-style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 8px 0 16px;
}
.map-style-option {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}
.map-style-option:active { transform: scale(0.96); }
.map-style-option.active {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}
.map-style-preview {
  width: 100%;
  height: 60px;
  background-size: cover;
  background-position: center;
}
.map-style-preview-voyager { background: linear-gradient(135deg, #e8e0d8 0%, #d4ccc4 50%, #c8c0b8 100%); }
.map-style-preview-positron { background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 50%, #d0d0d0 100%); }
.map-style-preview-dark { background: linear-gradient(135deg, #2a2a2e 0%, #1e1e22 50%, #141418 100%); }
.map-style-preview-osm { background: linear-gradient(135deg, #f2e8d4 0%, #d0e8c8 50%, #c4d8f0 100%); }
.map-style-preview-topo { background: linear-gradient(135deg, #e8dcc8 0%, #c8d4a8 50%, #a8c0a0 100%); }
.map-style-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  padding: 8px 4px 2px;
}
.map-style-desc {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 4px 8px;
}

/* ===== Focus Writing Mode ===== */
#focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#focus-overlay.open { opacity: 1; }

.focus-header {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}
.focus-done-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 24px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.focus-textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  padding: 0 32px;
  font-family: 'Nunito', Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.8;
  color: var(--text);
  background: transparent;
  -webkit-overflow-scrolling: touch;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.focus-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.focus-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 32px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.focus-word-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.focus-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Form label row with focus button */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.form-label-row label {
  margin-bottom: 0;
}
.focus-mode-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}
.focus-mode-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.focus-mode-btn svg { stroke: currentColor; }

.form-word-count {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
  padding-top: 4px;
  min-height: 20px;
  font-variant-numeric: tabular-nums;
}

/* ===== Synonym Popup ===== */
.synonym-popup {
  position: fixed;
  z-index: 9500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  max-width: 240px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.synonym-popup.open {
  opacity: 1;
  transform: translateY(0);
}
.synonym-header {
  padding: 10px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  text-transform: lowercase;
  font-style: italic;
}
.synonym-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 14px;
}
.synonym-word {
  background: var(--primary-light);
  color: var(--text);
  border: none;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.synonym-word:hover {
  background: var(--primary);
  color: white;
}
.synonym-word:active { transform: scale(0.95); }
.synonym-word.related {
  background: var(--secondary-light);
}
.synonym-word.related:hover {
  background: var(--secondary);
  color: white;
}
.synonym-loading, .synonym-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* ===== Dark mode support ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1917;
    --bg-card: #262220;
    --bg-elevated: #2E2A27;
    --primary: #D4A59E;
    --primary-light: rgba(212, 165, 158, 0.14);
    --secondary: #95BDAA;
    --secondary-light: rgba(149, 189, 170, 0.14);
    --accent: #E8D0A0;
    --text: #EDE8E4;
    --text-secondary: #AEA69E;
    --text-muted: #756E68;
    --border: #3A3533;
    --border-light: #2E2A27;
  }

  .view-header {
    background: rgba(28, 25, 23, 0.88);
  }

  #tab-bar {
    background: rgba(38, 34, 32, 0.92);
  }

  body {
    background: #151210;
  }

  .tab-fab {
    box-shadow: 0 4px 24px rgba(212, 165, 158, 0.25);
  }

  .entry-card::after {
    background: linear-gradient(
      105deg,
      transparent 40%,
      rgba(255, 255, 255, 0.03) 45%,
      rgba(255, 255, 255, 0.08) 50%,
      rgba(255, 255, 255, 0.03) 55%,
      transparent 60%
    );
  }

  .onboarding h2 {
    background: linear-gradient(135deg, var(--text) 0%, #D4A59E 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }

  .btn-danger {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
  }

  .modal-overlay {
    background: rgba(10, 8, 7, 0.6);
  }

  .toast {
    background: rgba(46, 42, 39, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
}
