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

:root {
  --c-primary: #c1121f;
  --c-primary-light: #e63946;
  --c-secondary: #2196a6;
  --c-accent: #f6b800;
  --c-bg: #fef9ef;
  --c-surface: #ffffff;
  --c-nav-bg: #1a1a2e;
  --c-text: #1a1a2e;
  --c-text-muted: #6b7280;
  --c-border: #e8e4d9;
  --header-h: 64px;
  --nav-h: 68px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 12px;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
}

html, body {
  height: 100%;
  background: var(--c-nav-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--c-bg);
}

/* ─── HEADER ─────────────────────────────────────── */
#app-header {
  flex-shrink: 0;
  background: var(--c-primary);
  padding-top: var(--safe-top);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  height: var(--header-h);
}

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

.app-icon { font-size: 28px; line-height: 1; }

.app-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.3px;
}

.app-subtitle {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}

.trip-badge {
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.3);
}

/* ─── MAIN CONTENT ───────────────────────────────── */
#app-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
}

.view.active { display: block; }

/* ─── BOTTOM NAV ─────────────────────────────────── */
#bottom-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--c-nav-bg);
  padding-bottom: var(--safe-bottom);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 4px;
  color: rgba(255,255,255,0.4);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.nav-btn.active { color: var(--c-accent); }

.nav-icon { width: 22px; height: 22px; }

.nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* ─── SHARED COMPONENTS ──────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  padding: 20px 16px 8px;
}

/* ─── ITINERARY VIEW ─────────────────────────────── */
.day-selector {
  display: flex;
  gap: 8px;
  padding: 16px 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.day-selector::-webkit-scrollbar { display: none; }

.day-chip {
  flex-shrink: 0;
  background: var(--c-surface);
  border: 2px solid var(--c-border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  text-align: center;
  min-width: 76px;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.day-chip.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.day-chip-num {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.6;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.day-chip-title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.day-chip-date {
  font-size: 10px;
  opacity: 0.55;
  margin-top: 2px;
}

.timeline-container { padding: 16px; }

.timeline-day-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 2px;
}

.timeline-day-subtitle {
  font-size: 13px;
  color: var(--c-text-muted);
  margin-bottom: 20px;
}

.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  background: var(--c-border);
}

.timeline-item {
  position: relative;
  margin-bottom: 14px;
}

.timeline-dot {
  position: absolute;
  left: -25px;
  top: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-primary);
  border: 2px solid var(--c-bg);
  box-shadow: 0 0 0 2px var(--c-primary);
  z-index: 1;
}

.timeline-dot.type-food        { background: var(--c-accent);    box-shadow: 0 0 0 2px var(--c-accent); }
.timeline-dot.type-transport   { background: var(--c-secondary); box-shadow: 0 0 0 2px var(--c-secondary); }
.timeline-dot.type-hotel       { background: #9b5de5;            box-shadow: 0 0 0 2px #9b5de5; }

.timeline-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.timeline-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.timeline-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-primary);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 36px;
}

.timeline-title {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
  line-height: 1.3;
}

.timeline-map-btn {
  font-size: 18px;
  text-decoration: none;
  flex-shrink: 0;
  padding-top: 1px;
}

.timeline-notes {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.timeline-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(193,18,31,0.1);
  color: var(--c-primary);
}

/* ─── LOCATIONS VIEW ─────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 8px;
  padding: 16px 16px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--c-border);
  background: var(--c-surface);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}

.filter-chip.active {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}

.locations-grid {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.location-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.location-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.location-icon-wrap.attraction { background: rgba(193,18,31,0.1); }
.location-icon-wrap.restaurant { background: rgba(246,184,0,0.15); }
.location-icon-wrap.hotel      { background: rgba(33,150,166,0.15); }
.location-icon-wrap.shopping   { background: rgba(155,93,229,0.12); }

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

.location-name {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.location-cat {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.location-cat.attraction { color: var(--c-primary); }
.location-cat.restaurant { color: #a07900; }
.location-cat.hotel      { color: var(--c-secondary); }
.location-cat.shopping   { color: #9b5de5; }

.location-address {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.location-notes {
  font-size: 12px;
  color: var(--c-text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
}

.btn-map {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  background: var(--c-primary);
  color: #fff;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

/* ─── TRANSPORT VIEW ─────────────────────────────── */
.transport-section { padding: 0 16px 4px; }

.transport-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 0;
}

.transport-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--c-border);
}

.transport-row:last-child { border-bottom: none; }

.transport-row-icon { font-size: 20px; flex-shrink: 0; padding-top: 1px; }

.transport-row-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.transport-row-detail {
  font-size: 12px;
  color: var(--c-text-muted);
  line-height: 1.4;
}

/* ─── INFO VIEW ──────────────────────────────────── */
.info-section { padding: 0 16px 4px; }

.info-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.info-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.info-card-icon { font-size: 20px; }
.info-card-title { font-size: 15px; font-weight: 700; flex: 1; }

.info-card-chevron {
  font-size: 11px;
  color: var(--c-text-muted);
  transition: transform 0.2s;
}

.info-card.expanded .info-card-chevron { transform: rotate(180deg); }

.info-card-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--c-border);
}

.info-card.expanded .info-card-body { display: block; }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 13px;
  gap: 12px;
}

.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--c-text-muted); font-weight: 500; flex-shrink: 0; }
.info-row-value { font-weight: 600; text-align: right; }

/* Phrase list */
.phrase-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--c-border);
}

.phrase-item:last-child { border-bottom: none; }
.phrase-ro { font-size: 12px; color: var(--c-text-muted); margin-bottom: 2px; }
.phrase-tr { font-size: 14px; font-weight: 600; }
.phrase-pron { font-size: 11px; color: var(--c-secondary); font-style: italic; margin-top: 1px; }

/* Emergency */
.emergency-wrap {
  margin: 0 16px 4px;
  background: rgba(193,18,31,0.07);
  border: 1px solid rgba(193,18,31,0.18);
  border-radius: var(--radius);
  padding: 12px;
}

.emergency-label-top {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-primary);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin-bottom: 10px;
}

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

.emergency-item {
  text-align: center;
  background: var(--c-surface);
  border-radius: 8px;
  padding: 10px 6px;
  text-decoration: none;
  color: inherit;
  display: block;
}

.emergency-num { font-size: 22px; font-weight: 700; color: var(--c-primary); }
.emergency-lbl { font-size: 11px; color: var(--c-text-muted); margin-top: 2px; }

/* ─── HERO COUNTDOWN CARD ────────────────────────── */
.hero-card {
  margin: 14px 16px 4px;
  border-radius: 20px;
  padding: 26px 20px 22px;
  color: #fff;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-pre    { background: linear-gradient(140deg, #c1121f 0%, #8a0c15 45%, #1a1a2e 100%); }
.hero-during { background: linear-gradient(140deg, #2196a6 0%, #0d6b78 45%, #1a1a2e 100%); }
.hero-done   { background: linear-gradient(140deg, #f6b800 0%, #e05a00 50%, #c1121f 100%); }

.hero-bg-emoji {
  position: absolute;
  font-size: 140px;
  line-height: 1;
  opacity: 0.07;
  top: -12px;
  right: -8px;
  pointer-events: none;
  user-select: none;
}

.hero-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  opacity: 0.75;
  margin-bottom: 10px;
}

.hero-big-num {
  font-size: 84px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -4px;
}

.hero-big-unit {
  font-size: 20px;
  font-weight: 600;
  opacity: 0.85;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.hero-separator {
  width: 36px;
  height: 2px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  margin: 16px auto 14px;
}

.hero-info-row {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.hero-sub-row {
  font-size: 11px;
  opacity: 0.65;
}

.hero-pills {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.hero-pill {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
}

.hero-footer {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 14px;
}

/* during-trip specific */
.hero-day-line {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
}

.hero-of-total {
  font-size: 20px;
  font-weight: 500;
  opacity: 0.7;
  margin-left: 2px;
}

.hero-dest {
  font-size: 26px;
  font-weight: 700;
  margin-top: 8px;
  line-height: 1.15;
}

.hero-dest-sub {
  font-size: 12px;
  opacity: 0.75;
  margin-top: 4px;
  line-height: 1.4;
}

.hero-progress-wrap { margin-top: 18px; }

.hero-progress-track {
  background: rgba(255,255,255,0.18);
  border-radius: 10px;
  height: 5px;
  overflow: hidden;
}

.hero-progress-fill {
  height: 100%;
  background: rgba(255,255,255,0.85);
  border-radius: 10px;
}

.hero-progress-lbl {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 6px;
}

/* ─── HOME STATS ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px 16px 4px;
}

.stat-card {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 8px;
  text-align: center;
}

.stat-num {
  font-size: 26px;
  font-weight: 800;
  color: var(--c-primary);
  line-height: 1;
}

.stat-lbl {
  font-size: 11px;
  color: var(--c-text-muted);
  margin-top: 3px;
  font-weight: 500;
}

.nights-bars {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-bar-label {
  font-size: 12px;
  font-weight: 600;
  min-width: 82px;
  white-space: nowrap;
}

.stat-bar-track {
  flex: 1;
  height: 6px;
  background: var(--c-border);
  border-radius: 4px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 4px;
}

.stat-bar-nights {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-muted);
  min-width: 22px;
  text-align: right;
}

/* ─── TIMELINE TAPPABLE ──────────────────────────────── */
.timeline-item--tappable .timeline-card {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.timeline-item--tappable .timeline-card:active {
  background: #f0f0f0;
}

.timeline-arrow {
  font-size: 20px;
  color: var(--c-text-muted);
  flex-shrink: 0;
  line-height: 1;
  padding-top: 1px;
}

/* ─── MODAL OVERLAY ──────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  background: var(--c-surface);
  border-radius: 20px 20px 0 0;
  max-height: 90vh;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  will-change: transform;
}

#modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-drag-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--c-border);
  margin: 12px auto 8px;
}

/* ─── MODAL CAROUSEL ─────────────────────────────────── */
.modal-carousel-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: #111;
  touch-action: pan-y;
  flex-shrink: 0;
}

.carousel-track {
  display: flex;
  height: 100%;
  transition: transform 0.3s ease;
}

.carousel-slide {
  flex-shrink: 0;
  width: 100%;
  height: 100%;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  color: #fff;
  border: none;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.carousel-prev { left: 8px; }
.carousel-next { right: 8px; }

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  gap: 6px;
  justify-content: center;
}

.carousel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  cursor: pointer;
  transition: background 0.15s;
}

.carousel-dot.active { background: #fff; }

/* ─── MODAL BODY ─────────────────────────────────────── */
.modal-body {
  padding: 16px 20px 12px;
  position: relative;
}

/* X close button */
.modal-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.07);
  color: var(--c-text-muted);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  flex-shrink: 0;
}

.modal-close-btn:active { background: rgba(0,0,0,0.14); }

/* Info bar chips */
.modal-infobar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.infobar-chip {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  line-height: 1.4;
}

.modal-meta {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--c-secondary);
  margin-bottom: 4px;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
  color: var(--c-text);
}

.modal-desc {
  font-size: 14px;
  line-height: 1.65;
  color: var(--c-text);
}

.modal-desc p { margin-bottom: 10px; }
.modal-desc p:last-child { margin-bottom: 0; }

.modal-map-btn {
  display: block;
  margin: 16px 0 8px;
  padding: 13px 0;
  background: var(--c-primary);
  color: #fff;
  text-align: center;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
