/* ---------- Tokens ---------- */
:root {
  --ink: #0E3B2E;
  --ink-soft: #14493A;
  --leaf: #2FA36B;
  --leaf-dark: #22824F;
  --marigold: #E8A33D;
  --paper: #FBF8F2;
  --paper-dim: #F1ECDF;
  --text: #1A1F1C;
  --text-soft: #55625B;
  --line: #E3DDCC;
  --danger: #B3432B;
  --radius: 18px;
  --radius-sm: 10px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --shadow: 0 8px 24px rgba(14, 59, 46, 0.10);
  --shadow-lg: 0 16px 48px rgba(14, 59, 46, 0.18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 650; line-height: 1.15; margin: 0 0 .5rem; color: var(--ink); }
h1 { font-size: clamp(1.7rem, 5vw, 2.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--ink); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code { font-family: var(--font-mono); background: var(--paper-dim); padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }
:focus-visible { outline: 3px solid var(--marigold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; background: var(--paper);
  position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); position: relative; flex-shrink: 0; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--leaf); }
.brand-name { font-family: var(--font-display); font-weight: 650; font-size: 1.05rem; color: var(--ink); }
.topnav { display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; }
.topnav a { text-decoration: none; color: var(--text-soft); font-weight: 500; }
.topnav a.btn-ghost { color: var(--ink); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--font-body); font-weight: 600; font-size: .95rem;
  padding: .85rem 1.3rem; border-radius: 999px; border: none; cursor: pointer;
  text-decoration: none; transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
}
.btn-primary { background: var(--leaf); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--leaf-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.full { width: 100%; }

/* ---------- Flash / alerts ---------- */
.flash-wrap { max-width: 720px; margin: .75rem auto 0; padding: 0 1.25rem; }
.flash { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: .6rem; font-size: .9rem; transition: opacity .4s ease; }
.flash-error { background: #FBE7E1; color: var(--danger); }
.flash-success { background: #E4F3EA; color: var(--leaf-dark); }

/* ---------- Layout ---------- */
.main { max-width: 720px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---------- Hero (homepage) ---------- */
.hero { padding: 2.5rem 0 2rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 600; color: var(--leaf-dark); margin-bottom: .5rem; }
.lede { color: var(--text-soft); font-size: 1.05rem; max-width: 46ch; }
.accent { color: var(--leaf-dark); }
.hero-actions { display: flex; gap: .75rem; margin-top: 1.25rem; flex-wrap: wrap; }

/* ---------- Campaign grid ---------- */
.campaign-grid-wrap { padding: 1rem 0 2rem; }
.campaign-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .campaign-grid { grid-template-columns: 1fr 1fr; } }
.campaign-card { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease; }
.campaign-card:hover { transform: translateY(-2px); }
.campaign-card-media { height: 150px; background: var(--paper-dim); position: relative; display: flex; align-items: flex-end; overflow: hidden; }
.campaign-card-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.campaign-card-body { padding: 1rem; }
.campaign-card-body h3 { margin-bottom: .15rem; font-size: 1.05rem; }
.organizer { color: var(--text-soft); font-size: .85rem; margin-bottom: .5rem; }
.stat-line { font-size: .85rem; color: var(--text-soft); margin: 0; }
.empty-state { color: var(--text-soft); padding: 2rem 0; }

/* ---------- Progress ---------- */
.progress-rail { height: 6px; background: rgba(255,255,255,.55); border-radius: 999px; width: 100%; overflow: hidden; }
.progress-rail.on-hero { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: rgba(255,255,255,.4); border-radius: 0; }
.campaign-card-media .progress-rail { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--leaf), var(--marigold)); border-radius: inherit; }

/* ---------- Campaign detail page ---------- */
.campaign-hero { height: 46vw; max-height: 320px; min-height: 190px; background: var(--ink); position: relative; margin: -1.5rem -1.25rem 0; overflow: hidden; }
.campaign-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.campaign-body { padding-top: 1.25rem; }
.stat-row { display: flex; gap: 1.5rem; margin: 1rem 0; flex-wrap: wrap; }
.stat-row > div { display: flex; flex-direction: column; }
.big { font-size: 1.25rem; font-weight: 600; color: var(--ink); }
.stat-label { font-size: .78rem; color: var(--text-soft); }
.story { margin-top: 1.25rem; color: var(--text); }
.btn-copy.full { margin: .5rem 0 0; }

/* ---------- Donor wall ---------- */
.donor-wall { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1.25rem; }
.donor-wall ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .9rem; }
.donor-wall li { padding-bottom: .9rem; border-bottom: 1px dashed var(--line); }
.donor-name { font-weight: 600; }
.donor-amount { float: right; color: var(--leaf-dark); }
.donor-message { color: var(--text-soft); font-size: .9rem; margin: .3rem 0 0; clear: both; }

/* ---------- Donate bar + sheet ---------- */
.donate-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: .85rem 1.25rem calc(.85rem + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); z-index: 40; }
.donate-bar-closed { text-align: center; color: var(--text-soft); font-size: .9rem; }

.donate-sheet { position: fixed; inset: 0; z-index: 50; background: rgba(14,59,46,.35); display: flex; align-items: flex-end; opacity: 0; transition: opacity .2s ease; }
.donate-sheet.open { opacity: 1; }
.donate-sheet-inner { background: var(--paper); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 24px 24px 0 0; padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto; transform: translateY(12px); transition: transform .2s ease; position: relative; }
.donate-sheet.open .donate-sheet-inner { transform: translateY(0); }
@media (min-width: 640px) { .donate-sheet { align-items: center; } .donate-sheet-inner { border-radius: 24px; } }
.sheet-close { position: absolute; top: 1rem; right: 1rem; background: var(--paper-dim); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; color: var(--text-soft); }

.amount-chips { display: flex; flex-wrap: wrap; gap: 0; margin: .75rem 0 1rem; position: relative; }
.chip {
  font-family: var(--font-mono); font-size: .85rem; font-weight: 600;
  background: #fff; border: 1.5px solid var(--line); color: var(--ink);
  padding: .55rem .9rem; border-radius: 999px; cursor: pointer; margin: 0 .4rem .4rem 0;
  position: relative;
}
.chip:not(:last-child)::after { content: ""; position: absolute; right: -0.55rem; top: 50%; width: .7rem; height: 1.5px; background: var(--line); }
.chip.active { background: var(--leaf); border-color: var(--leaf); color: #fff; }
.chip.active::after { background: var(--leaf); }
.chip-other { border-style: dashed; color: var(--text-soft); }
.chip-other.active { border-style: solid; }
.no-account-hint { margin: 0 0 .25rem; font-size: .82rem; color: var(--leaf-dark); font-weight: 600; }

.stack-form { display: flex; flex-direction: column; gap: .9rem; margin-top: 1rem; }
.stack-form label { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; font-weight: 600; color: var(--ink); }
.stack-form input, .stack-form textarea, .stack-form select {
  font-family: var(--font-body); font-size: 1rem; padding: .75rem .9rem;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: #fff; color: var(--text);
  font-weight: 400;
}
.stack-form input:focus, .stack-form textarea:focus, .stack-form select:focus { border-color: var(--leaf); }
.check-row { flex-direction: row !important; align-items: center; gap: .5rem !important; }
.check-row input { width: auto; }
#donate-amount { font-family: var(--font-mono); font-weight: 600; }

.waiting-anim { width: 52px; height: 52px; border-radius: 50%; border: 4px solid var(--paper-dim); border-top-color: var(--leaf); margin: 0 auto 1rem; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth / forms ---------- */
.auth-wrap { padding: 2rem 0; display: flex; justify-content: center; }
.auth-card { background: #fff; border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 560px; }
.hint { color: var(--text-soft); font-size: .88rem; }
.cover-preview { max-width: 220px; max-height: 140px; width: auto; height: auto; object-fit: contain; border-radius: 12px; margin-bottom: .5rem; background: var(--paper-dim); display: block; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1.75rem; }
.stat-card { background: #fff; border-radius: var(--radius-sm); padding: 1rem; text-align: center; box-shadow: var(--shadow); }
.stat-num { display: block; font-size: 1.2rem; font-weight: 600; color: var(--ink); }
.dash-list { display: flex; flex-direction: column; gap: 1rem; }
.dash-row { background: #fff; border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .85rem; }
.dash-row h3 { display: flex; align-items: center; gap: .5rem; }
.badge { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; padding: .2rem .55rem; border-radius: 999px; font-family: var(--font-body); font-weight: 700; }
.badge-active { background: #E4F3EA; color: var(--leaf-dark); }
.badge-paused { background: #FBF1DE; color: #9A6B12; }
.badge-ended { background: #EFEAE0; color: var(--text-soft); }
.dash-row-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.dash-row-actions .btn-ghost { padding: .5rem .9rem; font-size: .82rem; }

/* ---------- Footer ---------- */
.footer { text-align: center; color: var(--text-soft); font-size: .8rem; padding: 2rem 1rem 6rem; }

/* ---------- Installer ---------- */
.install-body { background: var(--ink); }
.install-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.install-card { background: var(--paper); border-radius: var(--radius); padding: 2rem; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); }
.install-form { display: flex; flex-direction: column; gap: .9rem; margin-top: .5rem; }
.install-form h2 { font-size: .95rem; margin-top: .5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.install-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; color: var(--ink); }
.install-form input { font-family: var(--font-body); font-size: 1rem; padding: .7rem .85rem; border-radius: var(--radius-sm); border: 1.5px solid var(--line); }
.check-list { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-direction: column; gap: .5rem; }
.check-list li { font-size: .92rem; padding: .5rem .75rem; border-radius: var(--radius-sm); }
.check-list li.ok { background: #E4F3EA; color: var(--leaf-dark); }
.check-list li.fail { background: #FBE7E1; color: var(--danger); }
