:root {
  /* iOS system colors */
  --bg: #F2F2F7;
  --bg-card: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --accent: #007AFF;
  --accent-light: rgba(0, 122, 255, 0.10);
  --accent-orange: #FF9500;
  --accent-green: #34C759;
  --text: #000000;
  --text2: #6E6E73;
  --text3: #AEAEB2;
  --separator: rgba(60, 60, 67, 0.18);
  --red: #FF3B30;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 12px rgba(0,0,0,0.10), 0 0 1px rgba(0,0,0,0.06);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  safe-area-inset-top: env(safe-area-inset-top);
}

/* ── Status bar ─────────────────────────────────────── */
#statusbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bg-card);
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  border-bottom: 1px solid var(--separator);
  flex-shrink: 0;
  letter-spacing: -0.1px;
}
#status-gps { flex: 1; }
#status-bearing, #status-speed { color: var(--accent); font-weight: 600; }

/* ── Highlight panel ─────────────────────────────────── */
#highlight-panel {
  flex-shrink: 0;
  height: 210px;
  background: var(--bg);
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
}

.highlight-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text2);
  font-size: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: 0;
  box-shadow: var(--shadow);
}

#highlight-content {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  height: 100%;
}

#highlight-image-wrap {
  width: 200px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

#highlight-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* When no image: hide the wrap */
#highlight-image-wrap:empty, #highlight-image-wrap[style*="none"] {
  display: none;
}

#highlight-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

#highlight-text {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
  min-width: 0;
}

#highlight-name {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#highlight-eta {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

#highlight-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.5;
  flex: 1;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  margin-top: 2px;
}

.wiki-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  margin-top: auto;
  padding-top: 4px;
}

/* ── Category nav ────────────────────────────────────── */
#category-nav {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: var(--bg);
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#category-nav::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 7px 15px;
  border-radius: 20px;
  border: 1.5px solid var(--separator);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: var(--shadow);
  letter-spacing: -0.1px;
}
.cat-btn:active { opacity: 0.75; }
.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,122,255,0.28);
}

/* ── POI list ────────────────────────────────────────── */
#poi-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 20px;
}

.list-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px;
  color: var(--text3);
  font-size: 15px;
}

/* Grouped list: first/last card rounding */
#poi-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.poi-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: opacity 0.12s;
  border: none;
  outline: none;
}
.poi-card:active { opacity: 0.6; }
.poi-card.passed { opacity: 0.45; }
.poi-card.passed .poi-name::after {
  content: ' ✓';
  color: var(--accent-green);
  font-size: 12px;
}

.poi-icon {
  font-size: 26px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: 10px;
  flex-shrink: 0;
}

.poi-main {
  flex: 1;
  min-width: 0;
}

.poi-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.poi-sub {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poi-rating {
  color: var(--accent-orange);
  font-weight: 700;
}

.poi-distance {
  flex-shrink: 0;
  text-align: right;
}

.poi-dist-km {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.poi-dist-eta {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.poi-chevron {
  color: var(--text3);
  font-size: 13px;
  margin-left: 4px;
}

/* ── Detail panel (iOS bottom sheet) ──────────────────── */
#detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

#detail-panel {
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Drag handle */
#detail-panel::before {
  content: '';
  display: block;
  width: 36px;
  height: 5px;
  background: var(--separator);
  border-radius: 3px;
  margin: 10px auto 4px;
}

#detail-close {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 16px 12px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--separator);
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

#detail-images {
  width: 100%;
  height: 220px;
  overflow: hidden;
  background: var(--bg);
}
#detail-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#detail-body {
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#detail-name {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

#detail-meta {
  font-size: 14px;
  color: var(--text2);
  font-weight: 500;
}

#detail-description {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text2);
}

#detail-amenities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.amenity-tag {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 11px;
  background: var(--bg);
  border-radius: 20px;
  color: var(--text2);
  border: 1px solid var(--separator);
}

#detail-warnings {
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.25);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 500;
  color: var(--red);
}

#detail-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.maps-btn {
  display: block;
  margin-top: 8px;
  padding: 15px;
  background: var(--accent);
  color: #FFFFFF;
  text-align: center;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.2px;
  box-shadow: 0 2px 10px rgba(0,122,255,0.30);
}
.maps-btn:active { opacity: 0.85; }

/* ── Spinner ─────────────────────────────────────────── */
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--separator);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ───────────────────────────────────────── */
.hidden { display: none !important; }

/* ── iPad landscape ──────────────────────────────────── */
@media (min-width: 768px) {
  #highlight-panel { height: 220px; }
  #highlight-image-wrap { width: 260px; }
  #highlight-name { font-size: 21px; }
  #highlight-desc { -webkit-line-clamp: 6; font-size: 13.5px; }
  .poi-card { padding: 13px 16px; }
  .poi-name { font-size: 16px; }
  .poi-icon { font-size: 28px; width: 44px; height: 44px; }
}

@media (min-width: 1024px) {
  #highlight-panel { height: 230px; padding: 14px 20px 0; }
  #highlight-image-wrap { width: 300px; }
  #category-nav { padding: 10px 20px; }
  #poi-list { padding: 4px 20px 24px; }
  .poi-card { padding: 14px 18px; }
}
