:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-alt: #f0ece3;
  --ink: #18253b;
  --ink-muted: #5b6577;
  --border: #e2dcd0;
  --accent: #c84b31;
  --accent-dark: #a63a24;
  --indigo: #1e3a5f;
  --green: #1d7a52;
  --green-bg: #e7f6ee;
  --amber: #b4690e;
  --amber-bg: #fef4e4;
  --red: #b42318;
  --red-bg: #feeceb;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(24, 37, 59, 0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--ink-muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.88rem; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
}
.brand-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; }
.brand-title { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.74rem; color: #b7c4d9; }

.desktop-nav { display: flex; gap: 6px; }
.nav-btn {
  background: transparent;
  color: #d6dfec;
  border: 1px solid transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,0.18); color: #fff; }
.nav-btn.nav-cta { background: var(--accent); color: #fff; }
.nav-btn.nav-cta:hover { background: var(--accent-dark); }

.topbar-status { display: flex; align-items: center; gap: 8px; }

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  border: none;
}
.pill-license { background: rgba(255,255,255,0.14); color: #f4e8d4; }
.pill-muted { background: #4a5568; color: #fff; }
.pill-warn { background: #f59e0b; color: #18253b; cursor: pointer; }
.pill-info { background: #e8eff8; color: var(--indigo); }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); }
.pill-red { background: var(--red-bg); color: var(--red); }

.digipin-pill {
  display: inline-block;
  background: #edf2f9;
  color: var(--indigo);
  border: 1px solid #cdd9eb;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

/* Main Views */
.app-main { max-width: 1380px; margin: 0 auto; padding: 16px 20px 84px; }
.view { display: none; }
.view.active { display: block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #263b5e; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-subtle { background: var(--surface-alt); color: var(--ink); }
.btn-sm { padding: 5px 11px; font-size: 0.82rem; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 1rem; width: 100%; }
.icon-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 1.05rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title-row h2, .card-title-row h3 { margin: 0; font-size: 1.08rem; }

/* Explore Toolbar & Split */
.explore-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  box-shadow: var(--shadow);
}
.search-box input {
  flex: 1;
  border: none;
  outline: none;
  padding: 9px 6px;
  font-size: 0.98rem;
  background: transparent;
  color: var(--ink);
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.stats-strip { font-size: 0.84rem; color: var(--ink-muted); display: flex; gap: 16px; flex-wrap: wrap; }

.explore-split {
  display: grid;
  grid-template-columns: minmax(340px, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: start;
}
.places-list { display: flex; flex-direction: column; gap: 10px; }

.place-card {
  display: grid;
  grid-template-columns: 106px 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  box-shadow: var(--shadow);
}
.place-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.place-thumb {
  width: 106px;
  height: 92px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
  font-size: 0.75rem;
  text-align: center;
  padding: 6px;
  border: 1px dashed var(--border);
}
.place-thumb.has-img { border: none; padding: 0; }
.place-card-body { min-width: 0; }
.place-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.place-card-title { font-weight: 700; font-size: 1rem; margin: 0 0 2px; }
.place-card-ml { font-size: 0.84rem; color: var(--ink-muted); margin-bottom: 4px; }
.place-card-desc {
  font-size: 0.86rem;
  color: #3a4454;
  margin: 4px 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.place-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.77rem; color: var(--ink-muted); }

/* Interactive Slippy Map */
.map-column { position: sticky; top: 70px; }
.map-shell {
  position: relative;
  height: calc(100vh - 190px);
  min-height: 440px;
  background: #e6ebe6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.map-canvas-wrap { position: relative; width: 100%; height: 100%; user-select: none; touch-action: none; cursor: grab; }
.map-canvas-wrap:active { cursor: grabbing; }
.map-tile { position: absolute; width: 256px; height: 256px; pointer-events: none; }
.map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  cursor: pointer;
  z-index: 5;
  transition: transform 0.12s;
}
.map-pin:hover { transform: translate(-50%, -108%) scale(1.12); z-index: 10; }
.pin-dot {
  width: 24px;
  height: 24px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--indigo);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pin-dot.verified { background: var(--accent); }
.pin-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
}
.map-pin-label {
  position: absolute;
  left: 50%;
  top: -6px;
  transform: translate(-50%, -100%);
  background: var(--ink);
  color: #fff;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.73rem;
  white-space: nowrap;
  display: none;
  pointer-events: none;
}
.map-pin:hover .map-pin-label { display: block; }
.map-controls { position: absolute; top: 12px; right: 12px; z-index: 15; display: flex; flex-direction: column; gap: 6px; }
.map-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.map-attribution {
  position: absolute;
  bottom: 6px;
  right: 8px;
  z-index: 15;
  background: rgba(255,255,255,0.86);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

/* Capture View */
.section-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-header h1 { margin: 0 0 4px; font-size: 1.45rem; }
.capture-grid { display: grid; grid-template-columns: minmax(300px, 0.92fr) minmax(320px, 1.08fr); gap: 18px; align-items: start; }

.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #101827;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.camera-stage.compact { aspect-ratio: 16 / 10; }
.camera-video, .camera-preview { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { color: #d6dfec; text-align: center; padding: 20px; }
.camera-icon { font-size: 2.2rem; margin-bottom: 6px; }
.reticle-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.reticle-frame {
  width: 82%;
  height: 70%;
  border: 2px dashed rgba(255,255,255,0.72);
  border-radius: 10px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 8px;
}
.reticle-frame span { background: rgba(0,0,0,0.55); color: #fff; font-size: 0.76rem; padding: 3px 10px; border-radius: 999px; }

.camera-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.gps-card { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.gps-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.label { display: block; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); font-weight: 700; }
.manual-gps-inputs { display: flex; gap: 6px; }
.manual-gps-inputs input { width: 112px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.82rem; }

/* Forms */
.field { margin-bottom: 12px; position: relative; flex: 1; }
.field label { display: block; font-size: 0.84rem; font-weight: 600; margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(200, 75, 49, 0.25); border-color: var(--accent); }
.field-row { display: flex; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 10px; }
.selected-cat { margin-top: 6px; font-size: 0.83rem; background: var(--surface-alt); padding: 6px 10px; border-radius: 7px; }
.selected-cat code { font-size: 0.78rem; color: var(--indigo); margin-left: 6px; }
.dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 64px;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.14);
  max-height: 240px;
  overflow-y: auto;
}
.dropdown-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f2eee6; }
.dropdown-item:hover { background: #f8f4ec; }
.dropdown-item .cat-sub { font-size: 0.76rem; color: var(--ink-muted); }

.consent-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fdf6ee;
  border: 1px solid #efd8bc;
  border-radius: 9px;
  padding: 11px;
  font-size: 0.85rem;
  margin: 14px 0;
  cursor: pointer;
}
.consent-box input { margin-top: 3px; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 12px; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #f7c7c4; }

/* Place Wiki Detail */
.detail-container { max-width: 1040px; margin: 0 auto; }
.wiki-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.wiki-breadcrumb { font-size: 0.82rem; color: var(--indigo); font-weight: 600; margin-bottom: 6px; }
.wiki-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.wiki-title-row h1 { margin: 0; font-size: 1.55rem; }
.wiki-ml-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.wiki-meta-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

.conf-meter { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; }
.conf-bar { width: 72px; height: 7px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.conf-fill { height: 100%; background: var(--green); }

.wiki-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.wtab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
}
.wtab.active { color: var(--accent); border-bottom-color: var(--accent); }

.wiki-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 16px; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 12px; }
.photo-tile { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-alt); }
.photo-tile img { width: 100%; height: 160px; object-fit: cover; display: block; }
.photo-meta { padding: 8px 10px; font-size: 0.76rem; color: var(--ink-muted); }

.fact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fact-item { background: var(--bg); padding: 9px 11px; border-radius: 8px; }
.fact-item strong { display: block; font-size: 0.9rem; margin-top: 2px; word-break: break-word; }

.context-card, .talk-card, .rev-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface);
  margin-bottom: 10px;
}
.talk-card.resolved { border-left: 4px solid var(--green); background: #f8fcf9; }
.talk-reply { margin-left: 22px; margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--border); }
.diff-row { font-size: 0.83rem; margin-top: 4px; background: var(--bg); padding: 5px 8px; border-radius: 6px; }
.diff-old { color: var(--red); text-decoration: line-through; margin-right: 6px; }
.diff-new { color: var(--green); font-weight: 600; }

/* Releases */
.releases-container { max-width: 1060px; margin: 0 auto; }
.release-build-bar { display: flex; gap: 8px; align-items: center; }
.release-build-bar input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.info-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #edf2f9;
  border: 1px solid #cdd9eb;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.release-card { margin-bottom: 14px; }
.release-files { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin-top: 12px; }
.file-box { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 11px; display: flex; flex-direction: column; gap: 6px; }
.code-block {
  background: #141e30;
  color: #e6edf7;
  padding: 14px;
  border-radius: 9px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
}

/* Modal & Toast */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 24, 39, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card { width: 100%; max-width: 500px; background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 18px 48px rgba(0,0,0,0.28); }
.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.24);
}

/* Mobile Nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.mnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 14px;
  border-radius: 10px;
}
.mnav-btn.active { color: var(--accent); }
.mnav-btn.mnav-primary { background: var(--accent); color: #fff; }

@media (max-width: 900px) {
  .desktop-nav { display: none; }
  .mobile-nav { display: flex; }
  .explore-split, .capture-grid, .wiki-grid { grid-template-columns: 1fr; }
  .map-column { position: static; order: -1; }
  .map-shell { height: 280px; min-height: 260px; }
  .field-row, .field-row-3 { flex-direction: column; grid-template-columns: 1fr; }
  .fact-grid { grid-template-columns: 1fr; }
}
