/* Active Impact — design system. No build step; one accent + clean spacing do the
   "inviting" work. Light/white is the DEFAULT; dark is an opt-in toggle (Me → Dark mode). */
:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --card: #ffffff;
  --ink: #20241f;
  --muted: #6b7280;
  --green: #2e7d5b;
  --green-ink: #ffffff;
  --amber: #b8860b;
  --red: #b4452f;
  --line: #e3e6e1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --radius: 12px;
}
/* Dark is OPT-IN only, applied via a data-theme attribute set from the Me toggle.
   The OS 'prefers-color-scheme: dark' no longer forces it — light/white is default. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141613; --card: #1e211d; --ink: #e8eae6; --muted: #9aa39a;
  --green: #57b083; --green-ink: #0d130f; --amber: #d8a63a; --red: #e0745c;
  --line: #2c302b; --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
a { color: var(--green); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .4rem 0; }
img { max-width: 100%; }

/* ---- top bar ---- */
#topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .5rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: var(--card); border-bottom: 1px solid var(--line);
}
#topbar .brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; }
#topbar .spacer { flex: 1; }
#topbar .balance { font-weight: 700; color: var(--green); white-space: nowrap; }
/* Scan-to-check-in. A 44px hit target (the phone minimum) around a 22px glyph. */
#topbar .icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; margin: -11px 0;
  color: var(--green); border-radius: 10px;
}
#topbar .icon-btn:active { background: color-mix(in srgb, var(--green) 14%, transparent); }
/* The bell, with an unread dot drawn from its data-count (SOCIAL.md S6). */
#topbar .bell { position: relative; font-size: 1.15rem; text-decoration: none; }
#topbar .bell.has-unread::after {
  content: attr(data-count); position: absolute; top: 2px; right: 2px;
  min-width: 16px; padding: 0 3px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: .65rem; font-weight: 700;
  line-height: 16px; text-align: center;
}
/* Four tabs on a 390px phone: trim the horizontal padding rather than let the
   labels collide, and let each shrink evenly. */
.tabs .act { padding-left: .35rem; padding-right: .35rem; font-size: .92rem; min-width: 0; }

/* Followers / Following: two tabs that expand IN PLACE inside the card. The rows
   are plain (no nested card chrome) and sit under a hairline, so an open list
   reads as part of the card it dropped out of. */
.follow-panel { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.follow-panel .card.row { border: none; box-shadow: none; padding: .45rem 0; background: none; }
.follow-panel .card.row + .card.row { margin-top: 0; border-top: 1px solid var(--line); }
.follow-panel .empty { padding: 1rem .5rem; }

/* The iOS "add to Home Screen" steps: numbered, readable, not a wall of prose. */
.steps { margin: .4rem 0 0; padding-left: 1.2rem; font-size: .9rem; }
.steps li + li { margin-top: .25rem; }

/* An activity card is a line, not a photo — it must not shout over the feed. */
.card.activity { padding-top: .7rem; padding-bottom: .7rem; }
.card.activity .row { align-items: center; }

/* ---- layout ---- */
main { max-width: 640px; margin: 0 auto; padding: 1rem; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: .75rem; }
.card h3 a { color: var(--ink); }
/* Uniform, bounded cover: fixed 16/9 frame, cropped to fill. Works standalone
   (detail header) and inside a .card (list cards). */
.cover { display: block; width: 100%; aspect-ratio: 16 / 9; height: auto; object-fit: cover; border-radius: 8px; background: var(--bg); }
.card .cover { margin-bottom: .6rem; }
.thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; display: block; }

/* Image thumbs: a 72px square with compact corner controls overlaid.
   ★ (green) marks the cover; ☆ sets a photo as cover; ✕ removes it. */
.thumb-wrap { position: relative; width: 72px; height: 72px; flex: none; }
.thumb-btn {
  position: absolute; width: 22px; height: 22px; min-width: 0; padding: 0;
  border: none; border-radius: 999px; display: grid; place-items: center;
  font-size: .78rem; line-height: 1; background: rgba(0, 0, 0, .55); color: #fff;
  box-shadow: var(--shadow);
}
.thumb-del { top: 3px; right: 3px; }
.thumb-star { top: 3px; left: 3px; }
.primary-badge {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  display: grid; place-items: center; border-radius: 999px; font-size: .72rem;
  background: var(--green); color: var(--green-ink); box-shadow: var(--shadow);
}
.thumb-add {
  width: 72px; height: 72px; flex: none; border: 1px dashed var(--line);
  border-radius: 8px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .1rem; font-size: .7rem; font-weight: 600;
  color: var(--muted); cursor: pointer; background: var(--card);
}
.thumb-add .big { font-size: 1.4rem; line-height: 1; }

/* ---- pills / tags ---- */
.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill.green { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.pill.amber { background: color-mix(in srgb, var(--amber) 20%, transparent); color: var(--amber); }
.pill.red { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.pill.muted { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .9rem; }
/* Project meta (location / time / duration / count) — one item per line. */
.meta { display: flex; flex-direction: column; gap: .35rem; }
.tokens { font-weight: 700; color: var(--green); }

/* ---- buttons ---- */
button, .act {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  padding: .55rem .9rem; border-radius: 10px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
button:active, .act:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
.act.primary { background: var(--green); color: var(--green-ink); border-color: var(--green); }
.act.ghost { background: transparent; }
.act.del { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.act.block { width: 100%; }
.act.big { padding: .8rem 1rem; font-size: 1.05rem; }
/* Compact action to the right of project details (detail head + list cards).
   The details column shrinks (.grow/min-width:0); the action stays put. */
.action-cell { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }
.action-cell .act { white-space: nowrap; }

/* ---- forms ---- */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin: .5rem 0 .2rem; }
input, textarea, select {
  font: inherit; width: 100%; padding: .6rem .7rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--green) 40%, transparent); outline-offset: 0; }
textarea { min-height: 5rem; resize: vertical; }
form.add { border: 1px dashed var(--line); border-radius: var(--radius); padding: 1rem; background: var(--card); }
.field-error { color: var(--red); font-size: .85rem; }
.field-msg { color: var(--red); font-size: .85rem; margin-top: .25rem; }
input.invalid, textarea.invalid { border-color: var(--red); outline-color: color-mix(in srgb, var(--red) 40%, transparent); }

/* ---- toggle switch (event-leader designation) ---- */
.switch { display: inline-flex; align-items: center; gap: .35rem; margin: 0; cursor: pointer; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { position: relative; width: 36px; height: 20px; flex: none; background: var(--line); border-radius: 999px; transition: background .15s; }
.switch .slider::before { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid color-mix(in srgb, var(--green) 40%, transparent); outline-offset: 2px; }

/* ---- avatar (initials) ---- */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }

/* ---- QR ---- */
.qr { background: #fff; padding: 1rem; border-radius: var(--radius); display: grid; place-items: center; }
.qr svg, .qr img { width: 100%; max-width: 280px; height: auto; }
.code { font-family: ui-monospace, monospace; font-size: 1.1rem; letter-spacing: .1em; }

/* ---- in-app QR scanner (CHECKIN_PROOF.md §7) ----
   Full-viewport takeover: the camera IS the screen while it is up. */
.scanner {
  position: fixed; inset: 0; z-index: 100; background: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1rem calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
  gap: 1rem;
}
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* The viewfinder + hint + Cancel ride ABOVE the video. */
.scanner-frame {
  position: relative; width: min(72vw, 300px); aspect-ratio: 1;
  border: 3px solid #fff; border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45);
}
.scanner-hint { position: relative; color: #fff; text-align: center; margin: 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.scanner .act { position: relative; max-width: 320px; }

/* Asserted vs attested presence. Neutral wording both ways — self-reported is a
   legitimate outcome, not a failure (CHECKIN_PROOF.md §7.3). */
.pill.verified { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.pill.selfreported { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }

/* ---- bottom nav ---- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav a {
  flex: 1; text-align: center; padding: .5rem 0; color: var(--muted);
  font-size: .66rem; display: flex; flex-direction: column; align-items: center; gap: .1rem;
  white-space: nowrap; min-width: 0;
}
#nav a .ico { font-size: 1.3rem; }
#nav a.active { color: var(--green); }

/* ---- misc ---- */
.section-label {
  font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700;
  margin: 1.4rem 0 .5rem; padding-top: .9rem;
  border-top: 1px solid var(--line);   /* the line that says "new section" */
}
/* The first section on a screen needs no rule above it — there is nothing to
   separate it from. */
.stack > .section-label:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.banner { padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; }
.banner.info { background: color-mix(in srgb, var(--green) 12%, transparent); }
.banner.warn { background: color-mix(in srgb, var(--amber) 15%, transparent); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.spinner { text-align: center; color: var(--muted); padding: 2rem; }
.strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .3rem; }

/* ---- service log (records) ---- */
/* Photo-forward card: the image is the star. Bounded so a portrait shot can't
   dominate the viewport; the feed and the log preview share this class. */
.record-photo {
  display: block; width: 100%; max-height: 70vh; object-fit: cover;
  border-radius: 8px; background: var(--bg);
}
.card.record .record-photo { margin-bottom: .6rem; }
.record-photo-link { display: block; }
.record-author { color: var(--ink); font-weight: 700; }
.record-caption { white-space: pre-wrap; margin: .1rem 0 .2rem; }
.cheer.primary { background: var(--green); color: var(--green-ink); border-color: var(--green); }
.cheer .cheer-count { font-weight: 700; }

/* "at Riverside Cleanup · Sat 10:00" — a record's event, one tap away. */
.record-event { display: block; color: var(--green); font-weight: 600; margin: .1rem 0 .3rem; }

/* ---- the merged feed: an event's photos INSIDE the project card (FEED.md F3) ----
   Not nested cards — a hairline rule and a two-up grid, so a project scrolls past
   as one thing: details, then a picture or two, then the next project. */
.event-records:not(:empty) { margin-top: .7rem; padding-top: .7rem; border-top: 1px solid var(--line); }
.record-strip { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.record-strip.one { grid-template-columns: 1fr; }
.record-mini { min-width: 0; }
.record-mini-photo { display: block; }
.record-mini-photo img {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 8px; background: var(--bg);
}
.record-strip.one .record-mini-photo img { aspect-ratio: 16 / 9; }
.record-mini-cap {
  margin: .3rem 0 .1rem; font-size: .88rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.record-mini-foot { align-items: center; gap: .35rem; }
.record-mini-foot .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cheer.small { padding: .15rem .45rem; font-size: .8rem; }

/* The next event up on a project page — findable at a glance. */
.card.next-up { border-color: var(--green); box-shadow: 0 0 0 1px var(--green) inset; }
.next-up-tag {
  align-self: flex-start; font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--green);
}

/* "Which event?" picker — the log screen's Change link and the attach affordance. */
.picker-item {
  display: flex; width: 100%; text-align: left; align-items: center; gap: .5rem;
  padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); font: inherit; cursor: pointer;
}
.picker-item:hover { border-color: var(--green); }
.picker-item.muted { color: var(--muted); justify-content: center; font-weight: 600; }

/* Overflow "⋯" menu (report / delete-if-mine). */
.menu-wrap { position: relative; flex: none; }
.menu-btn { padding: .3rem .55rem; }
.menu {
  position: absolute; right: 0; top: 100%; z-index: 20; min-width: 168px;
  margin-top: .25rem; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); overflow: hidden;
}
.menu-item {
  display: block; width: 100%; text-align: left; border: none; border-radius: 0;
  background: var(--card); padding: .6rem .85rem; font-weight: 600;
}
.menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item.del { color: var(--red); }

/* The log-screen photo picker (bigger sibling of .thumb-add). */
.photo-pick {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .25rem; padding: 1.6rem 1rem; border: 1px dashed var(--line);
  border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer;
  background: var(--card);
}
.photo-pick .big { font-size: 2rem; line-height: 1; }

/* ＋ Log floating action button (over the feed / a record). */
.fab {
  position: fixed; right: 16px; bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 30; width: 56px; height: 56px; border-radius: 50%;
  background: var(--green); color: var(--green-ink); border: none;
  display: grid; place-items: center; font-size: 1.9rem; line-height: 1;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .28);
}
.fab:active { transform: translateY(1px); }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 999px;
  font-size: .9rem; box-shadow: 0 4px 12px rgba(0,0,0,.2); max-width: 90%;
}
