﻿:root {
  --bg: #141416;
  --surface: #1d1d20;
  --surface-2: #26262a;
  --accent: #d8fb4c;
  --accent-text: #1a1d0c;
  --text: #f5f5f2;
  --muted: #9a9a9f;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Work Sans", "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 96px;
}

a { color: inherit; text-decoration: none; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.topbar {
  background: var(--bg);
  color: var(--text);
  padding: 22px 20px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar .brand .logo {
  font-size: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}
.topbar .brand .logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.topbar .brand h1 { font-size: 17px; margin: 0; letter-spacing: 0.1px; font-weight: 800; }
.topbar .brand .sub { font-size: 11.5px; color: var(--muted); margin: 2px 0 0; letter-spacing: 0.3px; }
.topbar .hub-link { font-size: 12.5px; font-weight: 700; color: var(--muted); text-decoration: none; white-space: nowrap; flex: none; }
.topbar .hub-link:hover { color: var(--accent); }

.menu-burger-wrap { position: relative; flex: 0 0 auto; z-index: 20; }
.menu-burger {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  border: none;
  color: var(--text);
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.menu-dropdown {
  display: none;
  flex-direction: column;
  position: absolute;
  top: 46px;
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
}
.menu-dropdown.open { display: flex; }
.menu-dropdown a {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.menu-dropdown a:hover { background: var(--surface-2); }
.lang-switcher {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.lang-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  border-radius: 10px;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
}
.flag-icon {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  display: block;
}
.lang-btn:hover { background: var(--surface-2); }
.lang-btn.active { background: var(--accent); color: var(--surface); border-color: var(--accent); }

.coming-soon-block { text-align: center; padding: 50px 12px; }
.coming-soon-block .emoji { font-size: 38px; margin-bottom: 14px; }
.coming-soon-block h3 { color: var(--text); font-size: 18px; text-transform: none; letter-spacing: 0; margin: 0 0 8px; }
.coming-soon-block p { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin: 0 0 20px; }

.badge-dark { background: #0c0c0e !important; }
.borneo-icon { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.hero {
  background: var(--bg);
  color: var(--text);
  padding: 18px 20px 30px;
}
.hero-cover {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 18px;
}
.hero h2 { font-family: "EB Garamond", Georgia, serif; font-size: 34px; line-height: 1.18; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.2px; }
.section h2 { font-family: "EB Garamond", Georgia, serif; font-size: 25px; line-height: 1.25; font-weight: 600; letter-spacing: -0.1px; margin: 30px 0 12px; }
.hero p { font-size: 14px; line-height: 1.6; color: var(--muted); margin: 0 0 20px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-block; padding: 13px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 700; cursor: pointer; border: none; }
.btn-gold { background: var(--accent); color: var(--accent-text); }
.btn-outline { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.section { padding: 22px 20px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 14px; font-weight: 700; }
.section p.lead { font-size: 13.5px; color: var(--muted); line-height: 1.65; margin: -6px 0 16px; }

.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0; text-align: left; overflow: hidden; display: block; }
.feature-card .cover { width: 100%; height: 84px; object-fit: cover; display: block; }
.feature-card-body { padding: 14px 16px 16px; }
.feature-card .icon {
  font-size: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.feature-card h4 { font-size: 14px; margin: 0 0 4px; font-weight: 700; }
.feature-card p { font-size: 11.5px; color: var(--muted); margin: 0; line-height: 1.45; }

.loc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0; margin-bottom: 14px; overflow: hidden; }
.loc-card .cover { width: 100%; height: 150px; object-fit: cover; display: block; }
.loc-card-body { padding: 16px; }
.loc-card .loc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.loc-card h4 { font-size: 16px; margin: 0; font-weight: 700; }
.loc-tag { font-size: 10px; background: var(--accent); color: var(--accent-text); padding: 4px 10px; border-radius: 999px; white-space: nowrap; font-weight: 700; }
.loc-card p { font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0 0 10px; }
.loc-highlights { font-size: 11.5px; color: var(--muted); }
.loc-highlights b { color: var(--text); }

.loc-website-link { font-size: 12px; font-weight: 700; color: var(--accent); margin: -4px 0 12px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.tab-btn { flex: 0 0 auto; padding: 9px 16px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 700; border: 1px solid var(--border); cursor: pointer; }
.tab-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.species-group-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); font-weight: 700; margin: 20px 0 8px; }
.species-group-heading:first-child { margin-top: 0; }

.species-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 10px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.species-card .thumb { width: 46px; height: 46px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: 0 0 auto; object-fit: cover; }
.species-card .info h5 { margin: 0 0 2px; font-size: 13.5px; font-weight: 700; }
.species-card .info .latin { font-size: 11px; font-style: italic; color: var(--muted); margin: 0 0 4px; }
.species-card .info .status { font-size: 11px; color: var(--accent); font-weight: 700; }

/* Malay / Indonesian common name, sits between the English and Latin names */
.local-name { font-size: 11.5px; color: var(--text); opacity: .85; margin: 0 0 2px; }
.local-name .ln-flag {
  width: 15px; height: 11px; border-radius: 2px;
  display: inline-block; vertical-align: -1px; margin-right: 4px;
}
/* Shared name carries both flags — pull them together so they read as one pair */
.local-name .ln-flag + .ln-flag { margin-left: -1px; }
.local-name .ln-sep { margin: 0 4px; color: var(--muted); }
.detail-local { font-size: 14px; margin: -8px 0 4px; }
.detail-local .ln-flag { width: 18px; height: 13px; vertical-align: -2px; }

.bottom-nav {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  display: flex;
  padding: 8px;
  z-index: 20;
}
.bottom-nav a { flex: 1; text-align: center; padding: 8px 4px; font-size: 10px; color: var(--muted); font-weight: 700; border-radius: 999px; }

.install-banner {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%) translateY(12px);
  width: calc(100% - 32px);
  max-width: 448px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.install-banner.visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.install-banner .install-banner-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex: 0 0 auto;
  object-fit: cover;
}
.install-banner .install-banner-body { flex: 1; min-width: 0; }
.install-banner .install-banner-title { font-size: 12.5px; font-weight: 700; margin: 0 0 1px; }
.install-banner .install-banner-sub { font-size: 11px; color: var(--muted); margin: 0; }
.install-banner-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.install-banner-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.install-banner-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.install-banner-close:hover { color: var(--text); }
@media (min-width: 720px) { .install-banner { display: none; } }

.back-to-top-wrap {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  z-index: 19;
}
.back-to-top {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  font-size: 19px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.bottom-nav a .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0 auto 3px;
  font-size: 16px;
  border-radius: 50%;
}
.bottom-nav a.active { color: var(--text); }
.bottom-nav a.active .nav-icon { background: var(--accent); }

.detail-topbar { display: flex; align-items: center; gap: 12px; }
.back-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex: 0 0 auto;
}
.detail-topbar h1 { font-size: 16px; margin: 0; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-topbar .loc-tag { flex: 0 0 auto; }

.detail-topbar-wrap { flex-wrap: wrap; }
.detail-topbar-wrap .back-btn { order: 1; }
.detail-topbar-wrap .menu-burger-wrap { order: 2; }
.detail-title-row { order: 3; flex: 1 1 100%; margin-top: 8px; }
.detail-title-row h1 { white-space: normal; overflow: visible; text-overflow: clip; margin: 0 0 6px; }
.detail-title-row .loc-tag { display: inline-block; }

.detail-cover { width: 100%; height: 190px; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 16px; }
.detail-intro { font-size: 13.5px; line-height: 1.65; color: var(--muted); margin: 0 0 10px; }

.photo-carousel { position: relative; margin-bottom: 16px; }
.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track .photo-frame,
.carousel-track > img.detail-cover {
  flex: 0 0 100%;
  scroll-snap-align: start;
  min-width: 0;
}
.carousel-track .detail-cover { margin-bottom: 0; border-radius: 0; }
.carousel-counter {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(12, 12, 14, 0.75);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 5;
  pointer-events: none;
}

.carousel-track .detail-cover { cursor: zoom-in; }

.photo-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 10, 0.96);
  z-index: 500;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.photo-lightbox.open { display: block; }
.photo-lightbox.visible { opacity: 1; }

.lightbox-viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(12, 12, 14, 0.75);
  color: var(--text);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}
.lightbox-close { top: 14px; right: 14px; }
.lightbox-nav { top: 50%; transform: translateY(-50%); }
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }

.lightbox-counter {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 12, 14, 0.75);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 2;
}

.target-list { list-style: none; counter-reset: target; margin: 0; padding: 0; }
.target-list li {
  counter-increment: target;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
}
.target-list li::before {
  content: counter(target);
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.target-list li.linked a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}
.target-list li.linked a::after {
  content: "\203A";
  color: var(--accent);
  font-weight: 800;
  font-size: 16px;
}

.sub-location-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 10px; }
.sub-location-card h5 { margin: 0 0 4px; font-size: 13.5px; font-weight: 700; }
.sub-location-card p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--muted); }

.operator-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.operator-card h4 { margin: 0 0 6px; font-size: 14.5px; font-weight: 800; }
.operator-card p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.6; color: var(--muted); }
.operator-contact { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.operator-contact a, .operator-contact .operator-note { font-size: 12px; font-weight: 700; color: var(--accent); }
.operator-contact .operator-note { color: var(--muted); font-weight: 500; }

.detail-cover-emoji {
  width: 100%;
  height: 190px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  align-items: center;
  justify-content: center;
  font-size: 64px;
}
.detail-latin { font-size: 13px; font-style: italic; color: var(--muted); margin: -4px 0 16px; }
.detail-para { font-size: 13.5px; line-height: 1.7; color: var(--text); margin: 0 0 14px; }

.stats-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.stats-title { font-size: 15px; font-weight: 800; margin: 0 0 16px; }
.stat-row { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.stat-row:last-child { margin-bottom: 0; }
.stat-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--accent); }
.stat-icon svg { width: 20px; height: 20px; }
.stat-info { min-width: 0; }
.stat-label { font-size: 11px; font-weight: 700; color: var(--muted); margin: 0 0 2px; }
.stat-value { font-size: 14.5px; color: var(--text); margin: 0; line-height: 1.35; }

.upload-photo-btn { display: block; text-align: center; margin-top: 18px; }

.photo-frame { position: relative; display: block; }
.credit-icon {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(12, 12, 14, 0.75);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
  z-index: 5;
  padding: 0;
  line-height: 1;
}
.credit-panel {
  position: absolute;
  bottom: 36px;
  right: 8px;
  left: 8px;
  background: rgba(12, 12, 14, 0.94);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 11px;
  line-height: 1.55;
  display: none;
  z-index: 6;
}
.credit-panel.open { display: block; }
.credit-panel a { color: var(--accent); text-decoration: underline; }

/* Species swipe navigation */
.sp-swipe-wrap { position: relative; touch-action: pan-y; }
.sp-swipe-hint { text-align: center; font-size: 11px; color: var(--muted); margin: -8px 0 16px; }

/* Location swipe navigation */
.loc-swipe-wrap { position: relative; touch-action: pan-y; }
.loc-swipe-hint { text-align: center; font-size: 11px; color: var(--muted); margin: -8px 0 16px; }

/* Arrows ON the photo page the photo — the only thing a user reads them as.
   Added by JS on desktop only, and only when there is more than one photo. */
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(12, 12, 14, 0.72);
  color: var(--text);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  z-index: 6;
  transition: background 0.15s, color 0.15s;
}
.carousel-arrow-prev { left: 8px; }
.carousel-arrow-next { right: 8px; }
.carousel-arrow:hover { background: var(--accent); color: var(--accent-text); }

/* Species / region navigation: named links under the photo, never a bare
   arrow beside it. */
.detail-nav-row {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
}
.detail-nav-link {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.detail-nav-link-next { justify-content: flex-end; text-align: right; }
.detail-nav-glyph { font-size: 17px; line-height: 1; flex: 0 0 auto; }
.detail-nav-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-nav-link:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}

/* Search */
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 13px 18px;
  margin-bottom: 18px;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--accent); }

.search-empty { font-size: 13px; color: var(--muted); text-align: center; margin-top: 30px; }

.search-group-heading { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--accent); font-weight: 700; margin: 20px 0 8px; }
.search-group-heading:first-child { margin-top: 0; }

.search-result-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 12px; align-items: center; cursor: pointer; }
.search-result-card .thumb { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto; object-fit: cover; }
.search-result-card .info h5 { margin: 0 0 2px; font-size: 13px; font-weight: 700; }
.search-result-card .info p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.search-result-card .info .latin { font-style: italic; }

.notice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.notice-overlay.open { display: flex; }
.notice-overlay.visible { opacity: 1; }
.notice-modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  max-width: 360px;
  width: 100%;
}
.notice-modal h3 { margin: 0 0 10px; font-size: 18px; font-weight: 800; }
.notice-modal p { margin: 0; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.notice-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notice-close:hover { background: var(--accent); color: var(--accent-text); }
.credit-panel .credit-license { color: var(--muted); display: block; }

#trip-map {
  width: 100%;
  height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 16px;
}
#locations-map {
  width: 100%;
  height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 20px;
}
.locations-map-popup { width: 160px; }
.locations-map-popup img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
}
.locations-map-popup h5 { margin: 0 0 4px; font-size: 13.5px; font-weight: 700; }
.locations-map-popup p { margin: 0 0 8px; font-size: 11.5px; color: var(--muted); }
.locations-map-popup a { color: var(--accent); font-weight: 700; font-size: 12px; }
.popup-trip-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.popup-trip-btn.in-trip {
  background: var(--accent);
  color: var(--accent-text, #141416);
  border-color: var(--accent);
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface);
  color: var(--text);
}
.leaflet-popup-content { margin: 12px 14px; font-family: inherit; }
.trip-map-popup h5 { margin: 0 0 4px; font-size: 13.5px; font-weight: 700; }
.trip-map-popup p { margin: 0 0 8px; font-size: 11.5px; color: var(--muted); }
.trip-map-popup a { color: var(--accent); font-weight: 700; font-size: 12px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-control-attribution {
  background: rgba(29, 29, 32, 0.8) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--text) !important; }
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }

.trip-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px 8px 8px;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 4px;
  -webkit-tap-highlight-color: transparent;
}
.trip-toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.2s ease;
}
.trip-toggle[aria-pressed="true"] .trip-toggle-track { background: var(--accent); }
.trip-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s ease, background 0.2s ease;
}
.trip-toggle[aria-pressed="true"] .trip-toggle-thumb {
  transform: translateX(22px);
  background: var(--accent-text);
}
.trip-toggle-label { font-size: 13px; font-weight: 700; color: var(--text); text-align: left; }
.trip-toggle[aria-pressed="true"] .trip-toggle-label { color: var(--accent); }

.card-toggles {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding-left: 8px;
}
.card-toggle {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card-toggle-track {
  position: relative;
  display: block;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.2s ease;
}
.card-toggle[aria-pressed="true"] .card-toggle-track { background: var(--accent); }
.card-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s ease, background 0.2s ease;
}
.card-toggle[aria-pressed="true"] .card-toggle-thumb {
  transform: translateX(14px);
  background: var(--accent-text);
}

.trip-toggle-seen[aria-pressed="true"] .trip-toggle-track { background: #5fd0e0; }
.trip-toggle-seen[aria-pressed="true"] .trip-toggle-thumb { background: #0c2e33; }
.trip-toggle-seen[aria-pressed="true"] .trip-toggle-label { color: #5fd0e0; }

.card-toggle-seen[aria-pressed="true"] .card-toggle-track { background: #5fd0e0; }
.card-toggle-seen[aria-pressed="true"] .card-toggle-thumb { background: #0c2e33; }

.cap-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 500;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
}
.cap-toast.visible { opacity: 1; transform: translate(-50%, 0); }

.species-group-heading .group-trip-count { font-weight: 500; color: var(--muted); }

#my-trip-list { margin-bottom: 20px; }
.my-trip-empty { font-size: 13px; color: var(--muted); line-height: 1.6; }
.my-trip-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.my-trip-item a { flex: 1; font-size: 13.5px; font-weight: 700; }
.my-trip-item .my-trip-tag { font-size: 11px; color: var(--muted); font-weight: 500; display: block; margin-top: 2px; }
.my-trip-remove {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.my-trip-remove:hover { background: var(--accent); color: var(--accent-text); }

/* Wildlife checklist page */
.checklist-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 18px;
}
.checklist-progress-track {
  flex: 1;
  height: 8px;
  border-radius: 5px;
  background: var(--surface-2);
  overflow: hidden;
}
.checklist-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.3s ease;
}
.checklist-progress-count { font-size: 12.5px; font-weight: 700; color: var(--text); white-space: nowrap; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.checklist-item.hidden { display: none; }
.checklist-check {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.checklist-check svg { width: 14px; height: 14px; opacity: 0; transition: opacity 0.15s ease; }
.checklist-item.seen .checklist-check { background: var(--accent); border-color: var(--accent); }
.checklist-item.seen .checklist-check svg { opacity: 1; }
.checklist-names { min-width: 0; }
.checklist-common { margin: 0 0 2px; font-size: 13.5px; font-weight: 700; }
.checklist-latin { margin: 0; font-size: 11px; font-style: italic; color: var(--muted); }
.checklist-item.seen .checklist-common { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border); }

.species-group-heading.hidden { display: none; }

.checklist-actions { display: flex; gap: 10px; margin: 0 0 8px; flex-wrap: wrap; }
.checklist-actions .btn { flex: 1 1 auto; text-align: center; }
.checklist-actions-note { font-size: 11px; color: var(--muted); line-height: 1.5; margin: 0 0 18px; }

.enquiry-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.enquiry-row { display: flex; gap: 10px; }
.enquiry-row .search-input { margin-bottom: 0; flex: 1 1 0; min-width: 0; }
.enquiry-row .field-group { flex: 1 1 0; min-width: 0; }
.enquiry-form .search-input { margin-bottom: 0; }
.enquiry-form select.search-input { appearance: none; -webkit-appearance: none; }
.enquiry-form textarea.search-input { resize: vertical; font-family: inherit; padding-top: 12px; }
@media (max-width: 420px) {
  .enquiry-row { flex-direction: column; }
}

.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 11px; font-weight: 700; color: var(--muted); padding-left: 4px; }

input[type="date"].search-input,
input[type="month"].search-input {
  color-scheme: dark;
}
input[type="date"].search-input::-webkit-datetime-edit,
input[type="month"].search-input::-webkit-datetime-edit {
  color: var(--text);
}
input[type="date"].search-input::-webkit-datetime-edit-text,
input[type="date"].search-input::-webkit-datetime-edit-month-field,
input[type="date"].search-input::-webkit-datetime-edit-day-field,
input[type="date"].search-input::-webkit-datetime-edit-year-field,
input[type="month"].search-input::-webkit-datetime-edit-text,
input[type="month"].search-input::-webkit-datetime-edit-month-field,
input[type="month"].search-input::-webkit-datetime-edit-year-field {
  color: var(--text);
}
input[type="date"].search-input::-webkit-calendar-picker-indicator,
input[type="month"].search-input::-webkit-calendar-picker-indicator {
  filter: invert(0.8);
}

.single-day-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  margin: -2px 0 4px;
  cursor: pointer;
  user-select: none;
}
.single-day-toggle input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

.danger-btn { color: #ff8a8a; border-color: rgba(255, 138, 138, 0.35); }
.danger-btn:hover { background: rgba(255, 138, 138, 0.12); }

.notice-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.notice-modal-actions .btn { flex: 1 1 0; text-align: center; padding: 11px 16px; font-size: 13px; }

/* ===================================================================
   Desktop view (ported from Wildlife of Borneo)
   -------------------------------------------------------------------
   Everything below is gated behind min-width: 900px, so it cannot fire
   on a phone, the installed app, or a narrow window. Mobile rules above
   are untouched. Layout rule of thumb: paragraphs written for a phone
   get a max-width (~760px), and short stacked blocks go side by side, so
   widening the page never just leaves a wide empty gap.
   =================================================================== */
@media (min-width: 900px) {
  .app { max-width: 1100px; }
  .section { padding-left: 32px; padding-right: 32px; }
  .topbar { padding-left: 32px; padding-right: 32px; }

  .bottom-nav { max-width: 560px; }
  .back-to-top-wrap { max-width: 1068px; }

  /* Home */
  .hero { padding: 24px 32px 36px; }
  .hero-cover { height: 340px; }
  .hero h2 { font-size: 44px; max-width: 760px; }
  .hero p { max-width: 720px; font-size: 15px; }
  .section > .card-grid:has(> .feature-card) { grid-template-columns: repeat(4, 1fr); gap: 20px; }
  .feature-card .cover { height: 160px; }

  /* Prose never runs the full 1100px */
  .section p.lead, .detail-para, .section > p[data-i18n], .section > .search-input { max-width: 760px; }

  /* Species detail: photo, names, toggles and body text in the left
     column; the stats cards run down a right sidebar. */
  .section:has(> #sp-swipe-wrap):has(> #sp-stats:not(:empty)) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    column-gap: 40px;
    align-content: start;
    grid-template-areas:
      "gallery sidebar"
      "hint    sidebar"
      "nav     sidebar"
      "local   sidebar"
      "latin   sidebar"
      "trip    sidebar"
      "seen    sidebar"
      "body    sidebar"
      "upload  sidebar"
      ".       sidebar";
    grid-template-rows: auto auto auto auto auto auto auto auto auto 1fr;
  }
  #sp-swipe-wrap { grid-area: gallery; }
  #sp-swipe-hint { grid-area: hint; }
  .section:has(> #sp-swipe-wrap) > .detail-nav-row { grid-area: nav; }
  #sp-local { grid-area: local; }
  #sp-latin { grid-area: latin; }
  #sp-trip-toggle { grid-area: trip; max-width: 520px; }
  #sp-seen-toggle { grid-area: seen; max-width: 520px; }
  #sp-stats { grid-area: sidebar; }
  #sp-body { grid-area: body; max-width: 760px; }
  #sp-upload-btn { grid-area: upload; margin-top: 20px; justify-self: start; }
  #sp-swipe-wrap .detail-cover,
  #sp-swipe-wrap .detail-cover-emoji { height: 480px; }
  #sp-stats .stats-card:last-child { margin-bottom: 0; }
  /* No stats yet: keep a single column at reading width. */
  .section:has(> #sp-swipe-wrap):has(> #sp-stats:empty) > * { max-width: 760px; }

  /* Regions list: taller map, region cards in a grid. */
  #locations-map { height: 480px; }
  .loc-card .cover { height: 190px; }
  .tab-panel.active:has(> a.loc-card) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
  .tab-panel.active:has(> a.loc-card) > * { grid-column: 1 / -1; }
  .tab-panel.active:has(> a.loc-card) > a.loc-card { grid-column: auto; margin-bottom: 0; height: 100%; display: flex; flex-direction: column; }
  .tab-panel.active > a.loc-card .loc-card-body { display: flex; flex-direction: column; flex: 1; }
  /* Long intros are trimmed on the grid card; the full text is on the
     location's own page. */
  .tab-panel.active > a.loc-card p { display: -webkit-box; -webkit-line-clamp: 5; line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }

  /* Species list: cards in two columns; headings/notes span the row. */
  .tab-panel.active:has(> .species-card) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; align-items: stretch; }
  .tab-panel.active:has(> .species-card) > * { grid-column: 1 / -1; }
  .tab-panel.active:has(> .species-card) > .species-card { grid-column: auto; margin-bottom: 0; }

  /* Directories: guides and tour operators */
  #guides-grid, #operators-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

  /* Trip planner and sightings: maps sized for desktop, forms and
     button rows kept to a readable width, saved lists in two columns. */
  .section > .hero-cover { height: 300px; }
  #trip-map { height: 480px; }
  #my-trip-list:has(> :not(.my-trip-empty)),
  #my-species-trip-list:has(> :not(.my-trip-empty)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
  .enquiry-form, .checklist-actions { max-width: 820px; }
  .section:has(> .checklist-progress) > :not(.tab-panel):not(.tabs) { max-width: 820px; }
  .section > .photo-frame { max-width: 760px; }

  /* Location detail: gallery + intro in the main column, highlights in a
     sidebar card, then targets / sub-locations / map full width. */
  .section:has(> #loc-gallery-wrap) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    column-gap: 40px;
    align-content: start;
  }
  .section:has(> #loc-gallery-wrap) > * { grid-column: 1 / -1; }
  .section:has(> #loc-highlights-wrap:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto auto auto auto auto 1fr;
  }
  .section:has(> #loc-highlights-wrap:not([hidden])) > #loc-gallery-wrap { grid-column: 1; grid-row: 1; }
  .section:has(> #loc-highlights-wrap:not([hidden])) > #loc-swipe-hint { grid-column: 1; grid-row: 2; }
  .section:has(> #loc-highlights-wrap:not([hidden])) > .detail-nav-row { grid-column: 1; grid-row: 3; }
  .section:has(> #loc-highlights-wrap:not([hidden])) > #loc-trip-toggle { grid-column: 1; grid-row: 4; }
  .section:has(> #loc-highlights-wrap:not([hidden])) > #loc-intro { grid-column: 1; grid-row: 5; }
  .section:has(> #loc-highlights-wrap:not([hidden])) > #loc-highlights-wrap {
    grid-column: 2;
    grid-row: 1 / 7;
    align-self: start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
  }
  #loc-gallery-wrap .detail-cover { height: 420px; }
  #loc-trip-toggle { max-width: 520px; }
  #loc-intro { max-width: 760px; }
  #loc-targets, #loc-sub { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #loc-enquiry-wrap { max-width: 760px; }
}
