:root {
  --forest-900: #1b3a2b;
  --forest-700: #2d6a4f;
  --forest-500: #40916c;
  --sage-400: #74c69d;
  --sage-200: #d8f3dc;
  --sun-500: #f4a533;
  --sun-400: #ffb703;
  --bark-800: #3a2e26;
  --paper-50: #faf7f0;
  --paper-100: #f3efe4;
  --ink-900: #1f2921;
  --ink-600: #4b5a51;
  --danger: #c1440e;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 30px rgba(27, 58, 43, 0.08);
  --shadow-lift: 0 16px 40px rgba(27, 58, 43, 0.16);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink-900);
  background:
    radial-gradient(circle at 100% 0%, var(--sage-200) 0%, transparent 45%),
    radial-gradient(circle at 0% 100%, #fff3d6 0%, transparent 40%),
    var(--paper-50);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

h1, h2, h3, .brand {
  font-family: 'Fraunces', Georgia, serif;
}

a { color: var(--forest-700); }

/* Decorative leaves */
.leaf-decor {
  position: fixed;
  width: 260px;
  height: 260px;
  color: var(--sage-400);
  pointer-events: none;
  z-index: 0;
}
.leaf-decor-tl { top: -60px; left: -70px; transform: rotate(-25deg); opacity: 0.35; }
.leaf-decor-br { bottom: -70px; right: -80px; transform: rotate(160deg); color: var(--sun-400); opacity: 0.25; }

/* Nav */
.topnav {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: rgba(250, 247, 240, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(45, 106, 79, 0.1);
}
.brand {
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--forest-900);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-mark { font-size: 1.4rem; }
.brand-mark.large { font-size: 3rem; }
.nav-links { display: flex; align-items: center; gap: 22px; white-space: nowrap; }
.nav-links a {
  text-decoration: none;
  color: var(--ink-600);
  font-weight: 500;
  padding: 6px 4px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--forest-700);
  border-bottom-color: var(--sun-500);
}
.logout-form { display: inline; margin: 0; }
.link-btn {
  background: none;
  border: none;
  font: inherit;
  color: var(--ink-600);
  cursor: pointer;
  padding: 6px 4px;
}
.link-btn:hover { color: var(--danger); }

.page {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* Auth pages */
.auth-page { max-width: 460px; padding-top: 48px; }
.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 40px 36px;
}
.brand-hero { text-align: center; margin-bottom: 28px; }
.brand-hero h1 { margin: 8px 0 2px; color: var(--forest-900); font-size: 2rem; }
.tagline { color: var(--ink-600); margin: 0; }
.auth-card h2 { margin-top: 0; color: var(--forest-900); }

form label {
  display: block;
  font-weight: 500;
  margin-bottom: 16px;
  color: var(--ink-600);
  font-size: 0.9rem;
}
form input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1.5px solid #e2ddd0;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--paper-100);
  transition: border-color .15s, background .15s;
}
form input:focus {
  outline: none;
  border-color: var(--sage-400);
  background: #fff;
}

.btn-primary, .btn-secondary {
  display: inline-block;
  width: 100%;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform .1s, box-shadow .15s, opacity .15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--forest-500), var(--forest-700));
  color: #fff;
  box-shadow: 0 8px 20px rgba(45, 106, 79, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(45, 106, 79, 0.38); }
.btn-secondary {
  background: var(--sun-400);
  color: var(--forest-900);
  margin-top: 12px;
}
.btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary:not(:disabled):hover { transform: translateY(-1px); }

.switch-auth { text-align: center; margin-top: 22px; color: var(--ink-600); font-size: 0.92rem; }

.banner {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.banner-success { background: var(--sage-200); color: var(--forest-900); }
.banner-error { background: #fbe4dd; color: var(--danger); }

/* Capture page */
.hero-capture { text-align: center; margin-bottom: 28px; }
.hero-capture h1 { color: var(--forest-900); margin-bottom: 6px; font-size: 2rem; }

.capture-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 28px;
  max-width: 460px;
  margin: 0 auto 40px;
  text-align: center;
}
.preview-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--paper-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  border: 2px dashed #dcd4c2;
}
.preview-wrap img { width: 100%; height: 100%; object-fit: cover; }
.preview-placeholder { color: #a49c88; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.preview-icon { font-size: 2.4rem; }
.capture-actions { display: flex; flex-direction: column; gap: 4px; }
.location-status { font-size: 0.85rem; color: var(--ink-600); margin: 14px 0 0; }

.queue-section { max-width: 700px; margin: 0 auto; }
.queue-section h2 { color: var(--forest-900); font-size: 1.3rem; }
.discoveries-list { display: flex; flex-direction: column; gap: 12px; }
.discovery-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-soft);
}
.discovery-row img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--paper-100); }
.discovery-info { flex: 1; }
.discovery-name { font-weight: 600; color: var(--forest-900); }
.discovery-meta { font-size: 0.8rem; color: var(--ink-600); }
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 999px;
}
.status-pending, .status-uploaded { background: #fff3d6; color: var(--sun-500); }
.status-identified { background: var(--sage-200); color: var(--forest-700); }
.status-needs_review { background: #fde2c8; color: #b5651d; }
.status-failed { background: #fbe4dd; color: var(--danger); }

.empty-state { color: var(--ink-600); text-align: center; padding: 24px; }

/* Achievements */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}
.achievement-card {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 20px 16px;
  text-align: center;
}
.achievement-icon { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.achievement-name { font-weight: 700; color: var(--forest-900); }
.achievement-sci { font-size: 0.78rem; font-style: italic; color: var(--ink-600); margin: 2px 0 6px; }
.achievement-date { font-size: 0.72rem; color: #a49c88; }

/* Leaderboard */
.leaderboard-list { display: flex; flex-direction: column; gap: 10px; max-width: 560px; margin: 0 auto; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-soft);
}
.leaderboard-rank {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--forest-700);
  width: 34px;
}
.leaderboard-row:nth-child(1) .leaderboard-rank { color: var(--sun-500); }
.leaderboard-name { flex: 1; font-weight: 600; }
.leaderboard-count { color: var(--ink-600); font-weight: 600; }
.leaderboard-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--paper-100);
}
.leaderboard-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--sage-200);
}

/* Profile */
.profile-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 32px 36px;
  max-width: 520px;
  margin: 0 auto 24px;
}
.avatar-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}
.avatar-preview-wrap {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--sage-200);
}
.avatar-preview { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.avatar-choose-btn { width: auto; padding: 9px 18px; }
.avatar-hint { font-size: 0.78rem; color: var(--ink-600); margin: 8px 0 0; }
.profile-card textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1.5px solid #e2ddd0;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--paper-100);
  resize: vertical;
}
.profile-email { font-size: 0.85rem; color: var(--ink-600); margin: 18px 0 0; }
.danger-zone h2 { margin-top: 0; color: var(--danger); font-size: 1.1rem; }
.danger-zone p { color: var(--ink-600); font-size: 0.9rem; }
.delete-trigger-btn { width: auto; padding: 10px 20px; color: var(--danger); }
.danger-btn { background: var(--danger); }

.checkbox-label {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem !important;
}
.checkbox-label input[type="checkbox"] {
  width: auto !important;
  margin-top: 3px;
  flex-shrink: 0;
}
.checkbox-label span { line-height: 1.4; }
.checkbox-label a { color: var(--forest-700); }

/* Legal pages (terms/privacy) */
.legal-doc {
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 40px 44px 56px;
}
.legal-doc h1 { color: var(--forest-900); margin-bottom: 4px; }
.legal-updated { color: var(--ink-600); font-size: 0.85rem; margin-top: 0; }
.legal-doc h2 { color: var(--forest-700); font-size: 1.15rem; margin-top: 32px; }
.legal-doc p, .legal-doc li { color: var(--ink-900); line-height: 1.6; }
.legal-doc ul { padding-left: 22px; }
.legal-doc a { color: var(--forest-700); }

.site-footer {
  text-align: center;
  padding: 24px 16px 90px;
  font-size: 0.8rem;
  color: var(--ink-600);
}
.site-footer a { color: var(--ink-600); text-decoration: underline; }

/* Admin */
.admin-tabs {
  display: flex;
  gap: 4px;
  max-width: 900px;
  margin: 0 auto 24px;
  border-bottom: 1.5px solid #e2ddd0;
}
.admin-tab {
  padding: 10px 18px;
  text-decoration: none;
  color: var(--ink-600);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1.5px;
}
.admin-tab:hover { color: var(--forest-700); }
.admin-tab.active { color: var(--forest-700); border-bottom-color: var(--sun-500); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto 28px;
}
.stat-tile {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 20px 16px;
  text-align: center;
}
.stat-value { font-family: 'Fraunces', serif; font-size: 2rem; font-weight: 700; color: var(--forest-700); }
.stat-label { font-size: 0.82rem; color: var(--ink-600); margin-top: 4px; }

.admin-panel {
  max-width: 900px;
  margin: 0 auto 28px;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 22px 26px;
}
.admin-panel h2 { margin-top: 0; color: var(--forest-900); font-size: 1.1rem; }
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--paper-100);
}
.status-row:last-child { border-bottom: none; }

.admin-table-wrap {
  max-width: 1000px;
  margin: 0 auto;
  overflow-x: auto;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th, .admin-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--paper-100);
  white-space: nowrap;
}
.admin-table th { color: var(--ink-600); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-actions { display: flex; gap: 10px; }
.admin-actions .link-btn { padding: 0; }
.link-btn.danger:hover { color: var(--danger); }
.admin-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 58, 43, 0.45);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lift);
}
.modal-card h2 { margin-top: 0; color: var(--forest-900); }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { width: auto; flex: 1; margin-top: 0; }

/* Cookie consent banner */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--forest-900);
  color: var(--paper-50);
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.15);
}
.cookie-banner p { margin: 0; max-width: 640px; font-size: 0.88rem; line-height: 1.4; }
.cookie-accept-btn { width: auto; padding: 10px 22px; flex-shrink: 0; }

/* Mobile: minimalistic but practical */
@media (max-width: 640px) {
  .topnav { padding: 14px 16px; }
  .nav-links { gap: 12px; font-size: 0.85rem; }
  .brand span:last-child { display: none; }
  .page { padding: 20px 14px 60px; }
  .auth-card { padding: 28px 22px; }
  .capture-card { padding: 20px; }
  .hero-capture h1 { font-size: 1.5rem; }
  .leaf-decor { width: 160px; height: 160px; }
  .achievements-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}
