:root {
  --ink: #1b2321;
  --muted: #5b6b66;
  --paper: #faf8f3;
  --card: #ffffff;
  --line: #e6e1d6;
  --brand: #1c6e6f;
  --brand-dark: #0f3d3e;
  --accent: #d97a3f;
  --danger: #b3413b;
  --ok: #2f7d4f;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--brand); }

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 64px;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.topbar .cta {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.topbar .cta:hover { background: var(--brand-dark); }
@media (max-width: 420px) {
  .topbar .cta { padding: 9px 14px; font-size: 0.85rem; }
  .brand { font-size: 1rem; }
}

/* ---------- hero ---------- */
.hero { padding: 28px 0 8px; }
.hero-identity {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.hero-text { min-width: 0; }
.hero-excerpt {
  margin: 20px 0 0;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink);
}
.hero-read-more {
  background: none;
  border: none;
  padding: 0;
  margin-top: 10px;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.hero-read-more:hover { text-decoration: underline; }
.hero-portrait {
  width: 96px;
  height: 128px;
  flex-shrink: 0;
  object-fit: cover;
  object-position: center top;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: block;
  background: var(--brand-dark);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  margin-top: 0;
}
@media (max-width: 800px) {
  /* Below this width the grid is already one column (photo+title+excerpt,
     then the donate box) — instead of leaving them as separate floating
     blocks, merge them into one intro card so the whole "what is this and
     how do I help" story reads as a single unit before the tabs below. */
  .hero-grid {
    grid-template-columns: 1fr;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    gap: 0;
  }
  .hero-identity { flex-direction: column; gap: 12px; }
  .hero-portrait {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background: linear-gradient(180deg, var(--brand-dark), var(--brand));
  }
  .hero-excerpt { margin-top: 12px; }
  .hero-read-more { margin-bottom: 4px; }
  .donate-card {
    border: none;
    border-radius: 0;
    border-top: 1px solid var(--line);
    padding: 18px 0 0;
    margin-top: 18px;
  }
}
.eyebrow {
  display: inline-block;
  color: var(--brand);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #eaf4f3;
  padding: 3px 10px;
  border-radius: 999px;
}
h1 { font-size: 1.9rem; line-height: 1.25; margin: 10px 0 6px; }
@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
}
.byline { color: var(--muted); font-size: 0.95rem; margin-bottom: 4px; }

/* donate card */
.donate-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  height: fit-content;
  position: sticky;
  top: 84px;
}
@media (max-width: 800px) {
  .donate-card { position: static; }
}
.amount-raised { font-size: 1.7rem; font-weight: 800; color: var(--brand-dark); }
.amount-goal { color: var(--muted); font-size: 0.95rem; margin-bottom: 12px; }
.progress-track {
  height: 10px;
  background: #eee7d8;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 18px;
}
.stats-row strong { color: var(--ink); }
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  margin-bottom: 10px;
}
.btn-primary:hover { filter: brightness(0.95); }
.btn-secondary {
  width: 100%;
  background: transparent;
  color: var(--brand-dark);
  border: 1.5px solid var(--line);
  padding: 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.no-fee-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--ok);
  margin-top: 14px;
  font-weight: 600;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 36px 0 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none;
  border: none;
  padding: 12px 16px;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn.active { color: var(--brand-dark); border-bottom-color: var(--accent); }
.tab-panel { display: none; padding-bottom: 60px; }
.tab-panel.active { display: block; }

.story { white-space: pre-line; font-size: 1.02rem; }

.update-item, .donor-item {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.update-item h4 { margin: 0 0 6px; }
.update-item time, .donor-item time { color: var(--muted); font-size: 0.82rem; }
.donor-item .name { font-weight: 700; }
.donor-item .amount { color: var(--brand-dark); font-weight: 700; }
.empty-state { color: var(--muted); font-style: italic; padding: 20px 0; }

.disclaimer {
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding: 24px 0 60px;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 18, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 26px;
  position: relative;
}
@media (max-width: 420px) {
  .modal-backdrop { padding: 10px; }
  .modal { padding: 18px; }
}
.modal h2 { margin-top: 0; font-size: 1.3rem; }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 6px; }
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="tel"],
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.amount-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.amount-chip {
  border: 1.5px solid var(--line);
  background: none;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.amount-chip.active { border-color: var(--accent); background: #fdf1e6; color: var(--accent); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; }
.checkbox-row input { width: auto; }

.qr-wrap { text-align: center; margin: 14px 0; }
.qr-wrap img {
  width: 220px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.upi-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.upi-detail span { min-width: 0; overflow-wrap: anywhere; }
.upi-detail button {
  border: none;
  background: var(--brand);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  flex-shrink: 0;
}
.step-label { color: var(--muted); font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.form-error { color: var(--danger); font-size: 0.88rem; margin-bottom: 10px; }
.thank-you { text-align: center; padding: 10px 0; }
.thank-you .big-check { font-size: 2.4rem; margin-bottom: 8px; }

.footer-note { text-align: center; padding: 24px 0; color: var(--muted); font-size: 0.85rem; }

/* ---------- live indicator ---------- */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ok);
  margin-bottom: 10px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.live-indicator.connected { opacity: 1; }
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(47, 125, 79, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(47, 125, 79, 0); }
}

/* ---------- recent activity ticker ---------- */
.recent-activity { margin-top: 16px; }
.recent-activity-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  padding: 7px 0;
  border-top: 1px dashed var(--line);
  animation: activity-in 0.4s ease;
}
.recent-activity-item .who { font-weight: 600; }
.recent-activity-item .amt { color: var(--brand-dark); font-weight: 700; white-space: nowrap; }
@keyframes activity-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- milestone banner ---------- */
.milestone-banner {
  display: none;
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: 12px;
  background: linear-gradient(90deg, #fdf1e0, #fbe6d3);
  border: 1px solid #f0d3ab;
  color: #7a4a12;
  font-weight: 700;
  text-align: center;
  animation: activity-in 0.5s ease;
}
.milestone-banner.show { display: block; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
  max-width: min(320px, calc(100vw - 36px));
}
.toast {
  background: var(--brand-dark);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(15, 61, 62, 0.25);
  animation: toast-in 0.35s ease, toast-out 0.35s ease 4.2s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  width: 100vw;
  height: 100vh;
}

/* ---------- add-to-home-screen banner ---------- */
/* Shown to iOS Safari visitors (who get no install prompt from the OS) and
   to Chromium browsers that fire beforeinstallprompt. */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  /* Sits above the iOS Safari toolbar so the Share button it points at
     isn't hidden behind the banner. */
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 61, 62, 0.18);
  transform: translateY(140%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.4s ease;
}
.install-banner.show { transform: translateY(0); opacity: 1; }

.install-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  flex: 0 0 auto;
}
.install-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}
.install-banner-text strong { font-size: 0.92rem; }
.install-banner-text span { font-size: 0.8rem; color: var(--muted); }

.install-banner-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.install-banner-btn {
  background: var(--brand);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.install-banner-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}

@media (max-width: 420px) {
  .install-banner { gap: 10px; padding: 10px 12px; }
  .install-banner-text span { font-size: 0.75rem; }
}

/* The banner is a browser-install affordance; it has no meaning once the
   app is already running from the home screen. */
@media all and (display-mode: standalone) {
  .install-banner { display: none; }
}
