:root {
  --lime: #DBFFB0;
  --lime-soft: #EAFFCE;
  --lime-deep: #C8F598;
  --dark: #1A2E00;
  --dark-2: #2A4500;
  --dark-3: #0F1F00;

  --bg: var(--lime);
  --surface: #FFFFFF;
  --surface-2: var(--lime-soft);
  --surface-3: var(--lime-deep);
  --border: rgba(26, 46, 0, 0.14);
  --border-strong: rgba(26, 46, 0, 0.25);
  --text: var(--dark);
  --muted: #5C7A3D;
  --error: #B33A2C;
  --error-bg: #FCDCDC;

  --primary: var(--dark);
  --on-primary: var(--lime);
  --primary-hover: var(--dark-3);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --shadow-sm: 0 1px 2px rgba(26,46,0,0.06), 0 2px 4px rgba(26,46,0,0.04);
  --shadow: 0 4px 16px rgba(26,46,0,0.08), 0 2px 6px rgba(26,46,0,0.05);
  --shadow-lg: 0 8px 32px rgba(26,46,0,0.14), 0 4px 12px rgba(26,46,0,0.08);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden; /* contain the full-bleed map's overhang on wide screens */
}

a {
  color: var(--dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(26,46,0,0.4);
}
a:hover { text-decoration-color: var(--dark); }

button { font-family: inherit; cursor: pointer; }

h1, h2, h3 { font-weight: 600; letter-spacing: -0.015em; margin: 0; color: var(--text); }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p  { margin: 0; }

::selection { background: var(--dark); color: var(--lime); }

/* ----- Layout ----- */
.page {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-3);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.page--wide { max-width: 720px; }

/* ----- Slideshow background ----- */
html:has(body.landing),
body.landing {
  background: transparent;
}
body.landing .page { position: relative; z-index: 1; }

.bg-slideshow {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg);
  overflow: hidden;
  pointer-events: none;
}
.bg-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  /* hard cuts — no transition */
}
.bg-slide.is-active { opacity: 1; }

.bg-slideshow::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(219,255,176,0.25) 0%, rgba(219,255,176,0.05) 35%, rgba(26,46,0,0.35) 100%);
  pointer-events: none;
}

/* Login landing header: lime backdrop fading softly into the slideshow */
.login-header {
  background: var(--bg);
  width: calc(100% + 2 * var(--space-4));
  margin-inline: calc(-1 * var(--space-4));
  margin-top: calc(-1 * var(--space-5));
  padding: var(--space-5) var(--space-4) var(--space-4);
  margin-bottom: 0 !important;
  position: relative;
  z-index: 2;
}
.login-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 100px;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 100%);
  pointer-events: none;
}

/* Landing explainer card — uses the "pressed" lime-deep tint */
.landing-card {
  background: var(--surface-3);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6) var(--space-5);
  margin: var(--space-5) auto 0;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
}
.landing-card .landing-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--dark);
  line-height: 1.15;
  margin: 0 0 var(--space-1);
}
.landing-card p {
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  margin: 0;
}
.landing-card strong {
  font-weight: 700;
  color: var(--dark);
}
.landing-card .landing-intro {
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
}
.landing-card .btn,
.landing-card .open-btn {
  margin-top: var(--space-2);
  align-self: center; /* content-width, centered as the primary CTA */
}

/* Numbered steps — used inside landing-card or any explainer */
.landing-steps {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.landing-steps .step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.landing-steps .step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--dark);
  color: var(--lime);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.landing-steps .step-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.landing-steps .step-sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 2px;
}

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--space-5); }

.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.grow { flex: 1; }

/* ----- Logo ----- */
.logo {
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.03em;
  color: var(--dark);
  display: inline-block;
  user-select: none;
}
.logo--lg { font-size: 40px; }
.logo .dim { opacity: 0.4; }

/* ----- Header ----- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.header-actions { display: flex; gap: var(--space-2); }

/* ----- Card / Surface ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card-lg { padding: var(--space-5); }

.muted { color: var(--muted); }
.error { color: var(--error); }
.success { color: var(--dark); font-weight: 600; }
.small  { font-size: 13px; }
.tiny   { font-size: 12px; }
.center { text-align: center; }

/* ----- Inputs ----- */
.field { display: flex; flex-direction: column; gap: var(--space-2); }

.label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.input, .textarea {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .textarea:focus {
  border-color: var(--dark);
  box-shadow: 0 0 0 4px rgba(26,46,0,0.08);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }

.textarea { resize: vertical; min-height: 96px; }

.input--otp {
  font-family: var(--font-mono);
  font-size: 28px;
  letter-spacing: 12px;
  text-align: center;
  padding: 18px 16px;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  text-decoration: none;
  min-height: 48px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: var(--dark);
  color: var(--lime);
  border-color: var(--dark);
}
.btn--primary:hover:not(:disabled) {
  background: var(--dark-3);
  border-color: var(--dark-3);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--dark);
}
.btn--ghost:hover:not(:disabled) {
  background: rgba(26,46,0,0.05);
}

.btn--link {
  background: transparent;
  color: var(--dark);
  padding: 8px 12px;
  min-height: auto;
  font-weight: 600;
  text-decoration: none;
}
.btn--link:hover:not(:disabled) {
  text-decoration: underline;
}

.btn--icon {
  width: 40px; height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
}

.btn--block { width: 100%; }

/* Apple Pay button — matches Apple's own dark style */
.btn.btn--apple-pay,
.btn.btn--apple-pay:hover {
  background: #000;
  border-color: #000;
  color: #fff;
  font-weight: 500;
  letter-spacing: 0;
}
.btn.btn--apple-pay:hover { background: #222; border-color: #222; }
.btn.btn--apple-pay span[aria-hidden="true"] { font-size: 18px; line-height: 1; }

/* ----- Tag list (dashboard) ----- */
.tag-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.05s ease;
  box-shadow: var(--shadow-sm);
}
.tag-item:hover { border-color: var(--dark); text-decoration: none; }
.tag-item:active { transform: scale(0.99); }
.tag-item .title { font-weight: 700; font-size: 16px; }
.tag-item .sub { color: var(--muted); font-size: 13px; }
.tag-item .stats {
  display: flex;
  gap: var(--space-4);
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.tag-item .stat { display: inline-flex; align-items: center; gap: 4px; }
.tag-item .stat .v { color: var(--text); font-weight: 600; }

.tag-item .status {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--dark);
  width: fit-content;
  border: 1px solid var(--border);
}
.tag-item .status--ready { background: var(--dark); color: var(--lime); border-color: var(--dark); }
.tag-item .status--scanned { background: var(--surface-3); color: var(--dark); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  justify-items: center;
  position: relative;
  z-index: 1; /* sits in front of the map's top fade */
  margin-top: var(--space-4);
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
  min-width: 0;
}
.stat-card .big {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--dark);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-card .lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.25;
}

/* Animated counter — slot-machine style digit reels */
.counter-digit {
  display: inline-block;
  overflow: hidden;
  height: 1em;
  line-height: 1;
  vertical-align: top;
}
.counter-reel {
  display: block;
  will-change: transform;
}
.counter-reel > span {
  display: block;
  height: 1em;
  line-height: 1;
  text-align: center;
}
@media (max-width: 380px) {
  .stat-card .big { font-size: 30px; }
}

/* ----- Tag list (integrated surface card) ----- */
.tag-list {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0 var(--space-4);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  overflow-y: auto;
  height: 290px;                /* room for exactly 5 tag rows */
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 46, 0, 0.25) transparent;
}
.tag-list::-webkit-scrollbar { width: 6px; }
.tag-list::-webkit-scrollbar-track { background: transparent; }
.tag-list::-webkit-scrollbar-thumb {
  background: rgba(26, 46, 0, 0.22);
  border-radius: 3px;
}
.tag-list::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 46, 0, 0.4);
}
.tag-list .list-empty {
  margin: auto 0;               /* center vertically when empty */
}
.tag-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  margin-inline: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}
.tag-row:last-child { border-bottom: none; }
.tag-row:hover {
  background: rgba(26, 46, 0, 0.04);
  margin-inline: calc(-1 * var(--space-4));
  padding-inline: var(--space-4);
  border-bottom-color: transparent;
}
.tag-row.is-selected {
  background: var(--surface-3); /* matches the active toggle pill */
  margin-inline: calc(-1 * var(--space-4));
  padding-inline: var(--space-4);
  border-bottom-color: transparent;
}
.tag-row .title-line {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  overflow: hidden;
}
.tag-row .title {
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-row .dot {
  color: var(--muted);
  flex-shrink: 0;
}
.tag-row .meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tag-row .title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.tag-row .title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.tag-row .sub { color: var(--muted); font-size: 13px; }
.tag-row .stats {
  display: flex;
  gap: var(--space-4);
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}
.tag-row .stat { display: inline-flex; align-items: center; gap: 4px; }
.tag-row .stat .v { color: var(--text); font-weight: 600; }

/* ----- Open button on a tag row ----- */
.open-btn {
  background: var(--dark);
  color: var(--lime);
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.open-btn:hover {
  background: var(--dark-3);
  text-decoration: none;
  color: var(--lime);
}

/* ----- Set toggle (Wippschalter) above the list ----- */
.set-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg); /* UI brand lime */
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}
.set-toggle button {
  background: transparent;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
  transition: background 0.15s ease, color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.set-toggle button:hover:not(.is-active) { color: var(--dark); }
.set-toggle button.is-active {
  background: var(--surface-3); /* lime-deep — darker than the toggle bg */
  color: var(--dark);
}
.set-toggle .count {
  opacity: 0.7;
  font-weight: 500;
}
.set-toggle .swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--dark);
  flex-shrink: 0;
}
.set-toggle .swatch--own {
  background: var(--lime);
  border-color: var(--dark);
}
.set-toggle .swatch--scanned {
  background: var(--dark);
  border-color: var(--lime);
}

/* Compact size variant (matches the in-map toggle dimensions) */
.set-toggle--compact {
  padding: 3px;
  width: auto;             /* override the 100% from .set-toggle */
  display: grid;           /* block-level so margin auto can center */
  margin-inline: auto;     /* horizontally center on the page */
}
.set-toggle--compact button { padding: 6px 14px; font-size: 12px; }

/* Compact variant overlaid at the bottom of the map */
.set-toggle--in-map {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  width: auto;
  padding: 3px;
  box-shadow: 0 6px 16px rgba(26, 46, 0, 0.22);
}
.set-toggle--in-map button {
  padding: 6px 14px;
  font-size: 12px;
  gap: 6px;
  width: 120px;
}
.set-toggle--in-map .swatch {
  width: 11px;
  height: 11px;
  border-width: 1.5px;
}
.set-toggle--in-map .count {
  font-size: 11px;
}

.list-empty {
  color: var(--muted);
  text-align: center;
  padding: var(--space-6) 0;
  font-size: 14px;
}
.list-empty .small { font-size: 13px; opacity: 0.8; }

/* ----- Stacked header actions ----- */
.header-actions--col {
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

/* ----- Inline + button ----- */
.btn--icon-plus {
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 50%;
  background: var(--dark);
  color: var(--lime);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
  padding: 0;
  border-color: var(--dark);
}
.btn--icon-plus:hover:not(:disabled) {
  background: var(--dark-3);
  border-color: var(--dark-3);
  color: var(--lime);
  text-decoration: none;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ----- Footer ----- */
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: var(--space-5) 0 0;
  margin-top: auto;
  letter-spacing: 0.02em;
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover { color: var(--dark); text-decoration: underline; }
.site-footer .sep {
  margin: 0 6px;
  opacity: 0.6;
}
.section-label .meta {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  opacity: 0.8;
  margin-left: 4px;
  font-size: 11px;
}

.empty {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-6);
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
}

/* ----- NFC scan visual ----- */
.scan-graphic {
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(26,46,0,0.10), rgba(26,46,0,0) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}
.scan-graphic .inner {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--dark);
  color: var(--lime);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  letter-spacing: 0.04em;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(26,46,0,0.4); }
  100%      { transform: scale(1); box-shadow: 0 0 0 22px rgba(26,46,0,0); }
}

/* ----- Map (Leaflet) ----- */
.map {
  width: 100%;
  height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
  position: relative;
}

/* Full-bleed map: extends to viewport edges; stats overlay the soft top */
.map--bleed {
  width: calc(100% + 2 * var(--space-4));
  margin-inline: calc(-1 * var(--space-4));
  border: none;
  border-radius: 0;
  box-shadow: none;
  height: 340px;
  margin-top: -42px; /* pull up so map top sits at ~50% of the stat grid */
  position: relative;
  z-index: 0;
}
.map--bleed::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 100%);
  z-index: 800; /* above tiles & markers, below Leaflet controls (1000) */
  pointer-events: none;
}
/* (no bottom fade — hard edge at the map's lower border) */

/* Map-floor: map acts as a backdrop, tag list floats on top */
.map-floor {
  position: relative;
  width: calc(100% + 2 * var(--space-4));
  margin-inline: calc(-1 * var(--space-4));
  margin-top: -42px;            /* takes over the pull-up from the map */
  padding-bottom: var(--space-4); /* same 16px as side margins / toggle gap */
}
.map-floor .map--bleed {
  position: absolute;
  top: 0;
  bottom: 0;
  /* span the full viewport width, even when the page itself is capped at 720px.
     left offset compensates for the page being horizontally centered. */
  left: calc((100vw - 100%) / -2);
  width: 100vw;
  height: auto;
  margin: 0;
  z-index: 0;
}
/* Light blur overlay — only over the list area, with a soft top fade-in */
.map-floor .map-overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 280px;        /* start ~60px above the list */
  bottom: 0;
  z-index: 1;
  backdrop-filter: blur(3px) saturate(0.9);
  -webkit-backdrop-filter: blur(3px) saturate(0.9);
  background: rgba(219, 255, 176, 0.10);
  pointer-events: none;
  /* Soft fade-in from transparent at the top edge to full overlay 60px down */
  mask-image: linear-gradient(180deg, transparent 0, black 60px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, black 60px);
}
.map-floor .set-toggle--in-map {
  /* anchor the toggle just above the list (16px gap), above the overlay */
  bottom: auto;
  top: 288px;
  z-index: 5;
}
.map-floor .tag-list {
  position: relative;
  z-index: 10;
  margin: 340px var(--space-4) 0;
  background: var(--bg); /* UI brand lime — blends into the page palette */
}

/* ----- Logo image + sidebar icon (shared scaling factor) ----- */
:root {
  /* Both icons keep their intrinsic SVG proportions.
     Change --icon-scale to scale both up/down by the same factor. */
  --icon-scale: 1;
}

.logo-img {
  display: block;
  /* baseline 112px tall (logo SVG is 1283×1284) */
  height: calc(112px * var(--icon-scale));
  width: auto;
  /* drop shadow: offset 0, blur ~10px, 40% opacity */
  filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.4));
}
.sidebar-icon {
  display: block;
  /* baseline 22.3px tall — matches the intrinsic SVG ratio: 256/1284 × 112 */
  height: calc(22.3px * var(--icon-scale));
  width: auto;
}

/* ----- Sidebar trigger button ----- */
.btn--sidebar {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.15s ease;
  display: block;
}
.btn--sidebar:hover { background: rgba(26, 46, 0, 0.08); }
.btn--sidebar:active { background: rgba(26, 46, 0, 0.14); }

/* ----- Back button (mirror of the sidebar trigger) ----- */
.btn--back {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.15s ease;
  display: block;
  text-decoration: none;
}
.btn--back:hover { background: rgba(26, 46, 0, 0.08); text-decoration: none; }
.btn--back:active { background: rgba(26, 46, 0, 0.14); }
.back-icon {
  display: block;
  /* matches .sidebar-icon's rendered width exactly
     (sidebar-icon: 22.3px tall × intrinsic aspect 293/256 ≈ 25.5px wide) */
  width: calc(22.3px * 293 / 256 * var(--icon-scale));
  height: auto;
}

/* ----- Header with centered logo + side actions ----- */
.header--center {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  z-index: 2; /* always paints above the map backdrop */
}
.header--center > :first-child { justify-self: start; }
.header--center > [aria-hidden="true"] { visibility: hidden; }
.header--center .logo-img { justify-self: center; }
.header--center > .btn--sidebar { justify-self: end; }
.header--center .stat-grid {
  grid-column: 1 / -1;
  margin-top: 40px; /* preserves the current visual gap to the logo row */
}
/* Board title row sits between the logo row and the stat grid */
.header--center .board-title {
  grid-column: 1 / -1;
  text-align: left;
  margin-top: 40px;
  letter-spacing: -0.02em;
}
.header--center .board-title + .stat-grid {
  margin-top: var(--space-4); /* tighter gap below the title */
}

/* ----- Hamburger button ----- */
.btn--hamburger {
  width: 44px;
  height: 44px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.btn--hamburger:hover { background: rgba(26, 46, 0, 0.08); }
.btn--hamburger:active { background: rgba(26, 46, 0, 0.14); }
.btn--hamburger span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--dark);
  border-radius: 2px;
}

/* ----- Sidebar (off-canvas right) ----- */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 46, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sidebar-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 88vw;
  background: var(--bg); /* lime UI brand color */
  z-index: 70;
  padding: var(--space-4) var(--space-4) var(--space-5);
  transform: translateX(100%);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  overflow-y: auto;
}
.sidebar.is-open {
  transform: translateX(0);
  box-shadow: -12px 0 36px rgba(26, 46, 0, 0.28);
}

.sidebar-head {
  display: flex;
  justify-content: flex-end;
}
.sidebar-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 26px;
  color: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.sidebar-close:hover { background: var(--surface-3); }

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sidebar-email {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  padding: var(--space-3);
  background: var(--surface-3); /* matches the pressed/active lime-deep tint */
  border-radius: var(--radius-sm);
  word-break: break-all;
}

/* Sidebar buttons — compact pill, content-width (not full-width) */
.sidebar .btn {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  min-height: auto;
  width: auto;            /* override .btn--block's 100% */
  align-self: flex-start; /* keep them left-aligned in the column */
}

/* Sidebar inputs — pill-shaped, same lime-deep tint as the email box */
.sidebar .input {
  background: var(--surface-3);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 15px;
}
/* OTP keeps its monospace look but slimmed down to match the email's height */
.sidebar .input--otp {
  font-size: 22px;
  letter-spacing: 8px;
  padding: 10px 18px;
}
.map-legend {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  color: var(--dark);
}
.map-legend .item { display: flex; align-items: center; gap: 6px; }
.map-legend .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--dark);
  flex-shrink: 0;
}
.map-legend .swatch--own { background: var(--lime); border-color: var(--dark); }
.map-legend .swatch--scanned { background: var(--dark); border-color: var(--lime); }
.map--tall { height: 360px; }
.map--short { height: 240px; }

.leaflet-container {
  font-family: inherit !important;
  background: var(--surface-2) !important;
}

.leaflet-control-attribution {
  font-size: 10px !important;
  background: rgba(255,255,255,0.85) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--dark) !important; }

.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--dark) !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover {
  background: var(--surface-2) !important;
}

.pin {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--dark);
  background: var(--lime);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  /* the pin fills its Leaflet icon container exactly; the container is
     anchored at its center, so the pin's center lands on lat/lng directly */
}
.pin--own { background: var(--lime); border-color: var(--dark); }
.pin--scanned { background: var(--dark); border-color: var(--lime); }
.pin--placing {
  width: 32px; height: 32px;
  background: var(--lime);
  border-color: var(--dark);
  animation: pinBounce 0.4s ease;
}
@keyframes pinBounce {
  0%   { transform: translateY(-200%); }
  100% { transform: translateY(0); }
}

.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  color: var(--dark) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
}
.leaflet-popup-tip { background: var(--surface) !important; }
.leaflet-popup-content {
  margin: 12px 14px !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
}
.leaflet-popup-content b { font-size: 14px; }
.leaflet-popup-content a {
  color: var(--dark) !important;
  font-weight: 600;
}

/* ----- Board ----- */
.board-header { padding: 0 0 var(--space-3); }
.board-header h1 { font-size: 24px; }
.board-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.board-loc { color: var(--muted); font-size: 14px; margin-top: 6px; }
.board-desc { margin-top: var(--space-3); }

.board-stats {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: 13px;
  color: var(--muted);
}
.board-stats .stat .v { color: var(--text); font-weight: 700; }

/* ----- Feed: 3-column square grid ----- */
.feed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: var(--space-3) 0 120px;
}

.post {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease;
}
.post:hover { transform: scale(0.985); }
.post:active { transform: scale(0.96); }

.post .photo {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--surface-2);
  object-fit: cover;
}

.post .note {
  width: 100%;
  height: 100%;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  text-align: left;
  color: var(--text);
  background: var(--surface-3); /* lime-deep — UI brand fill */
  white-space: pre-wrap;
  word-break: break-word;
  overflow: hidden;
}
/* Dynamic note sizes by character count */
.post .note--xxl { font-size: 30px; line-height: 1.08; font-weight: 700; letter-spacing: -0.02em; padding: 14px; }
.post .note--xl  { font-size: 22px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; padding: 14px; }
.post .note--lg  { font-size: 16px; line-height: 1.2;  font-weight: 600; padding: 12px; }
.post .note--md  { font-size: 13px; line-height: 1.3;  font-weight: 500; padding: 10px; }
.post .note--sm  { font-size: 11px; line-height: 1.35; font-weight: 500; padding: 9px; }

/* Tiny like-count overlay on the grid tile */
.post .like-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(26, 46, 0, 0.65);
  color: var(--lime);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: none;
}

/* Grid empty state spans all three columns */
.feed .empty,
.feed .list-empty {
  grid-column: 1 / -1;
}

/* ----- Post detail modal ----- */
.post-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(26, 46, 0, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-4) calc(env(safe-area-inset-bottom, 0px) + var(--space-4));
  gap: var(--space-4);
  animation: fadeIn 0.15s ease;
}
.post-modal.hidden { display: none; }
.modal-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-3));
  right: var(--space-4);
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: none;
  color: var(--dark);
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: var(--shadow);
}
.modal-stage {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  max-width: min(540px, 100%);
  max-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
}
.modal-stage img {
  max-width: 100%;
  max-height: 72vh;
  display: block;
}
.modal-stage .note {
  padding: var(--space-5);
  width: min(420px, 90vw);
  min-height: 220px;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 18px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-3); /* lime-deep — UI brand fill */
  font-weight: 500;
  overflow-y: auto;
  max-height: 72vh;
}
.modal-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow);
}
.modal-info .like-btn,
.modal-info .del-btn {
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--dark);
  font-weight: 700;
  font-size: 13px;
}
.modal-info .like-btn:hover { background: var(--surface-2); }
.modal-info .like-btn.liked {
  background: var(--dark);
  color: var(--lime);
  border-color: var(--dark);
}
.modal-info .del-btn:hover { color: var(--error); border-color: rgba(179, 58, 44, 0.3); }
.modal-time {
  color: var(--muted);
  font-size: 12px;
  padding: 0 6px;
}

.like-btn, .del-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.15s ease;
}
.like-btn:hover { color: var(--dark); border-color: var(--border-strong); }
.like-btn.liked { color: var(--lime); border-color: var(--dark); background: var(--dark); }
.del-btn:hover { color: var(--error); border-color: var(--error); }

/* Floating compose button */
.fab {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: var(--dark);
  color: var(--lime);
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  padding: 14px 24px;
  box-shadow: 0 8px 24px rgba(26,46,0,0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 10;
  cursor: pointer;
  text-decoration: none;
}
.fab:hover { background: var(--dark-3); text-decoration: none; }
.fab:active { transform: translateX(-50%) scale(0.96); }

.fab--round {
  width: 60px;
  height: 60px;
  padding: 0;
  font-size: 32px;
  line-height: 1;
  font-weight: 400;
}
.fab--round span { display: block; margin-top: -3px; }

.page--has-fab { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 120px); }

/* Modal */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26,46,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-4) calc(env(safe-area-inset-bottom, 0px) + var(--space-5));
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: slideUp 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.tabs button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  padding: 10px;
  border-radius: 6px;
  font-family: inherit;
}
.tabs button.active {
  background: var(--surface);
  color: var(--dark);
  box-shadow: var(--shadow-sm);
}

.file-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-5);
  text-align: center;
  color: var(--muted);
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
}
.file-drop input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.file-drop.has-file { color: var(--dark); border-color: var(--dark); background: var(--lime-soft); }

.preview-img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: var(--space-3);
}

/* Notices */
.notice {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text);
}
.notice--error { border-color: var(--error); color: var(--error); background: var(--error-bg); }
.notice--ok    { border-color: var(--dark); background: var(--surface-2); color: var(--dark); }

.hidden { display: none !important; }

/* Spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(26,46,0,0.2);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.btn--primary .spinner { border-color: rgba(219,255,176,0.3); border-top-color: var(--lime); }
.btn--ghost .spinner { border-color: rgba(26,46,0,0.2); border-top-color: var(--dark); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Location bar (over map on setup) */
.map-controls {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.locate-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: var(--dark);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
}
.locate-btn:hover { background: var(--surface-2); }
.locate-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.coord-display {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* Skeleton on map load */
.map-skel {
  width: 100%;
  height: 320px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--lime-soft) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
