:root {
  --orange: #FF9500;
  --orange-light: #FFF3E0;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #000000;
  --text-secondary: #6C6C70;
  --border: #E5E5EA;
  --green: #34C759;
  --red: #FF3B30;
  --radius: 12px;
  --header-h: 100px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --text: #FFFFFF;
    --text-secondary: #8E8E93;
    --border: #38383A;
    --orange-light: #2C1A00;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

/* ── Header ─────────────────────────────────────── */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-title {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  padding: 12px 16px 4px;
}

.tabs {
  display: flex;
  padding: 4px 16px 8px;
  gap: 8px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.tab svg { width: 16px; height: 16px; }

.tab.active {
  background: var(--orange);
  color: white;
}

/* ── Main ────────────────────────────────────────── */
main {
  margin-top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}

.view { display: none; height: 100%; }
.view.active { display: block; }

/* ── Liste ───────────────────────────────────────── */
#list-view { overflow-y: auto; -webkit-overflow-scrolling: touch; }

#bar-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }

.bar-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-user-select: none;
}

.bar-card:active { opacity: 0.7; }
.bar-card.closed { opacity: 0.55; }

.bar-emoji {
  font-size: 32px;
  width: 44px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
  padding-top: 2px;
}

.bar-emoji.grayscale { filter: grayscale(1); }

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

.bar-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bar-name .fav-star { color: #FFD700; font-size: 13px; }

.fav-btn-list {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--text-secondary);
  flex-shrink: 0;
  line-height: 1;
}

.fav-btn-list.active { color: #FFD700; }

.bar-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-sun {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.bar-sun.sunny { color: var(--orange); }

.bar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.badge-open { background: rgba(52,199,89,0.15); color: var(--green); }
.badge-closed { background: rgba(255,59,48,0.15); color: var(--red); }

.bar-distance {
  font-size: 12px;
  color: #007AFF;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Carte ───────────────────────────────────────── */
#map { width: 100%; height: 100%; }

.beer-marker {
  font-size: 28px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.beer-marker.grayscale { filter: grayscale(1) drop-shadow(0 1px 2px rgba(0,0,0,0.2)); }
.beer-marker.selected { transform: scale(1.4); z-index: 1000 !important; }

/* ── Carte panneau résumé ────────────────────────── */
.map-card {
  position: absolute;
  bottom: 20px;
  left: 12px;
  right: 12px;
  z-index: 500;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.25s cubic-bezier(0.32,0.72,0,1), opacity 0.25s;
}

.map-card.hidden {
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
}

.map-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-card-emoji { font-size: 30px; flex-shrink: 0; }
.map-card-emoji.grayscale { filter: grayscale(1); }

.map-card-name { font-size: 16px; font-weight: 700; flex: 1; }

.map-card-close {
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 26px; height: 26px;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.map-card-sun { font-size: 13px; }
.map-card-sun.sunny { color: var(--orange); }

.map-card-meta { display: flex; align-items: center; gap: 8px; }

.map-card-detail {
  width: 100%;
  padding: 10px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 2px;
}

/* ── Bottom sheet ────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}

.overlay.active { display: block; }

.sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 300;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: calc(20px + var(--safe-bottom));
}

.sheet.open { transform: translateY(0); }

.sheet-handle-bar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 10px 0 6px;
  display: flex;
  justify-content: center;
  z-index: 1;
}

.sheet-handle {
  width: 36px; height: 5px;
  background: var(--border);
  border-radius: 3px;
}

/* ── Détail ──────────────────────────────────────── */
#detail-content { padding: 0 16px 16px; }

.detail-header { margin-bottom: 12px; }

.detail-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-fav-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
  flex-shrink: 0;
}

.detail-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Chips jours */
.day-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0 8px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.day-chips::-webkit-scrollbar { display: none; }

.day-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--border);
  border: none;
  cursor: pointer;
  text-align: center;
}

.day-chip.active { background: var(--orange); color: white; }

.day-chip-label { font-size: 12px; font-weight: 500; display: block; }
.day-chip-date { font-size: 11px; color: var(--text-secondary); display: block; }
.day-chip.active .day-chip-date { color: rgba(255,255,255,0.8); }

/* Timeline soleil */
.sun-section { margin: 12px 0; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.timeline-wrap { position: relative; }

.timeline-bar {
  height: 28px;
  background: var(--border);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  margin-bottom: 4px;
}

.timeline-segment {
  position: absolute;
  top: 0; bottom: 0;
  background: linear-gradient(90deg, #FFD60A, #FF9500);
  border-radius: 4px;
}

.timeline-now {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 2px;
  background: white;
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-secondary);
  padding: 0 1px;
}

/* Plages soleil */
.sun-periods { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.sun-period {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
}

.sun-period-icon { font-size: 26px; }

.sun-period-time { font-size: 16px; font-weight: 600; }
.sun-period-dur { font-size: 13px; color: var(--orange); margin-top: 1px; }

.no-sun {
  text-align: center;
  padding: 32px 0;
  color: var(--text-secondary);
}

.no-sun-emoji { font-size: 48px; display: block; margin-bottom: 8px; }

.sun-total {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  background: var(--orange-light);
  border-radius: 10px;
  margin-top: 8px;
  color: var(--orange);
}

/* Horaires */
.hours-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 16px;
}

.hours-row {
  display: flex;
  align-items: flex-start;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.hours-row:last-child { border-bottom: none; }
.hours-row.today .hours-day { color: var(--orange); font-weight: 600; }
.hours-row.today .hours-time { color: var(--orange); font-weight: 600; }

.hours-day { width: 110px; font-size: 14px; flex-shrink: 0; }
.hours-time { font-size: 14px; color: var(--text-secondary); }
.hours-row.today .hours-time { color: var(--orange); }
.hours-closed { color: var(--text-secondary); font-size: 14px; }

/* Loading */
.loading-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }
