/* Impact Ledger. 8px spacing grid; colours only from the tokens below. */
:root {
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-muted: #eef2f3;
  --ink: #0f172a;
  --ink-muted: #475569;
  --ink-faint: #5b677a;
  --border: #d9e1e5;
  --border-faint: #e9eef0;
  --teal: #0f766e;
  --teal-strong: #1e40af;
  --teal-light: #e8f7f4;
  --blue: #0369a1;
  --blue-light: #eef7fd;
  --amber: #92400e;
  --amber-light: #fdf3e1;
  --rose: #be123c;
  --rose-light: #fff1f2;
  --on-teal: #ffffff;
  --toast-bg: #1e293b;
  --toast-ink: #ffffff;
  --toast-error-bg: #9f1239;
  --overlay: rgba(15, 23, 42, 0.45);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-up: 0 -8px 32px rgba(15, 23, 42, 0.16);
  --fab-shadow: 0 6px 16px rgba(15, 118, 110, 0.32);
  --pulse: rgba(37, 99, 235, 0.4);
  --pulse-0: rgba(37, 99, 235, 0);
  --toast-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  --focus-ring: 0 0 0 3px var(--teal-light);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --nav-height: 0px; /* no bottom nav: Settings opens from the gear in the header */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-total: calc(var(--nav-height) + var(--safe-bottom));
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1115;
  --surface: #131d22;
  --surface-muted: #1a272d;
  --ink: #f1f5f9;
  --ink-muted: #a8b6c7;
  --ink-faint: #93a1b5;
  --border: #2a3b43;
  --border-faint: #1f2e35;
  --teal: #2dd4bf;
  --teal-strong: #a8c8ff;
  --teal-light: #0f2b2a;
  --blue: #38bdf8;
  --blue-light: #0c2433;
  --amber: #fbbf24;
  --amber-light: #2b2008;
  --rose: #fb7185;
  --rose-light: #2a0f16;
  --on-teal: #042f2e;
  --toast-bg: #e2e8f0;
  --toast-ink: #0f172a;
  --toast-error-bg: #fecdd3;
  --overlay: rgba(0, 0, 0, 0.62);
  --shadow: none;
  --shadow-up: 0 -8px 32px rgba(0, 0, 0, 0.5);
  --fab-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--teal); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
svg { flex: none; }

.muted { color: var(--ink-muted); }
.warn { color: var(--amber); }

/* ---------- Header: read-only, compact ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  padding: calc(var(--safe-top) + 12px) 16px 8px;
}
.app-title {
  max-width: 1040px;
  margin: 0 auto;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 32px;
}

/* ---------- Main area ---------- */
.app-main {
  max-width: 1040px;
  margin: 0 auto;
  /* bottom: room for the nav, plus the "Log a deed" button floating above it */
  padding: 8px 16px calc(var(--nav-total) + 96px);
}
.tab-page { display: none; }
.tab-page.active { display: block; animation: fadeIn 0.15s ease-out; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.page-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; }
.page-col { min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.card-empty, .card-note {
  font-size: 14px;
  color: var(--ink-muted);
}
.card-note { margin-top: 12px; }
.body-text { font-size: 14.5px; color: var(--ink-muted); margin-bottom: 8px; }
.body-text b { color: var(--ink); }

/* ---------- Home: summary ---------- */
.summary {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 16px 16px 16px;
  margin-bottom: 16px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.pill-goal { font-size: 12px; color: var(--ink-muted); text-align: center; }
.pill-bars { margin: 8px 0 4px; }
.month-count { font-size: 14px; color: var(--ink-muted); margin: 12px 0 0; }
.headline { margin-top: 0; }
.headline-big {
  font-size: 52px;
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.headline-big.is-words { font-size: 32px; line-height: 1.15; }
.headline-label { font-size: 18px; font-weight: 500; color: var(--ink); margin-top: 2px; }
.headline-sub { font-size: 14px; color: var(--ink-muted); }
.headline-sub:empty { display: none; }
.given-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.given-row:empty { display: none; }
.given-chip {
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface-muted);
  border-radius: 999px;
  padding: 4px 12px;
}

.empty-card { padding: 24px 20px; }
.empty-lead { font-size: 20px; line-height: 1.35; font-weight: 500; letter-spacing: -0.01em; }
.empty-hint { font-size: 15px; color: var(--ink-muted); margin-top: 8px; }
.empty-card .btn-text { margin: 8px 0 -8px -4px; }

.nudge-card { background: var(--blue-light); border-color: transparent; margin-top: 16px; }
.nudge-text { font-size: 14.5px; color: var(--ink); }
.nudge-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- Home: timeline ---------- */
.list-tools { margin-bottom: 8px; }
.search-box { margin-bottom: 8px; }
.search-box input { -webkit-appearance: none; appearance: none; }
.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px 4px;
}
.pill-row::-webkit-scrollbar { display: none; }
.pill-item {
  flex: none;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
}
.pill-item.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.month-head {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  margin: 8px 4px 8px;
}
.deed-list + .month-head { margin-top: 24px; }
.deed-list {
  background: var(--surface);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.deed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  text-align: left;
}
.deed-row + .deed-row { border-top: 1px solid var(--border-faint); }
.deed-row:active { background: var(--surface-muted); }
.deed-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-light);
  color: var(--teal);
  flex: none;
}
.deed-icon svg, .tile-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.deed-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.deed-name {
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.deed-line { font-size: 13.5px; color: var(--ink-muted); line-height: 1.4; margin-top: 2px; overflow-wrap: anywhere; }
.deed-date { flex: none; font-size: 13px; color: var(--ink-faint); align-self: flex-start; padding-top: 2px; }
.empty-filter { font-size: 14px; color: var(--ink-muted); text-align: center; padding: 24px 0; }

/* ---------- Impact tab ---------- */
.detail-list { margin-top: 8px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 0;
}
.detail-row + .detail-row { border-top: 1px solid var(--border-faint); }
.detail-row dt { font-size: 14.5px; font-weight: 500; min-width: 0; }
.detail-note { display: block; font-size: 13px; font-weight: 400; color: var(--ink-muted); margin-top: 2px; }
.detail-row dd { text-align: right; flex: none; max-width: 45%; }
.detail-val { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.detail-val-words { font-size: 15px; line-height: 1.35; }
.detail-sub { display: block; font-size: 12.5px; color: var(--ink-muted); }
.detail-sub:empty { display: none; }

.bars { margin-top: 8px; }
.bar-row + .bar-row { margin-top: 12px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 4px; }
.bar-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-val { flex: none; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; border-radius: 5px; background: var(--surface-muted); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; background: var(--teal); }
.bar-fill.is-longshot { background: repeating-linear-gradient(135deg, var(--teal) 0 4px, transparent 4px 8px); }

.how-steps { padding-left: 20px; margin: 4px 0 12px; font-size: 14.5px; color: var(--ink-muted); }
.how-steps li { margin-bottom: 6px; }
.how-steps b { color: var(--ink); font-weight: 500; }

.sample-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}
.sample-row + .sample-row { border-top: 1px solid var(--border-faint); }
.sample-text { flex: 1 1 auto; min-width: 0; }
.sample-name { font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.sample-meta { font-size: 13px; color: var(--ink-muted); }

/* ---------- Settings ---------- */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}
.seg-btn {
  flex: 1 1 0;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-muted);
  font-size: 14.5px;
  font-weight: 500;
}
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }
.stack-btns { display: grid; gap: 8px; margin-top: 12px; }
.link-list { list-style: none; }
.link-list a { display: flex; align-items: center; min-height: 44px; font-size: 14.5px; }

/* ---------- Buttons ---------- */
.btn-solid, .btn-outline {
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  font-size: 15.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.btn-solid { background: var(--teal); color: var(--on-teal); border: 0; }
.btn-solid:active { background: var(--teal-strong); }
.btn-solid:disabled { opacity: 0.55; cursor: default; }
.btn-outline { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-outline:active { background: var(--surface-muted); }
.btn-block { width: 100%; }
.btn-tall { min-height: 52px; font-size: 16.5px; }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 14.5px; }
.btn-quiet, .btn-text, .btn-link {
  min-height: 44px;
  padding: 0 4px;
  background: transparent;
  border: 0;
  font-size: 14.5px;
}
.btn-quiet { color: var(--ink-muted); font-weight: 500; padding: 0 12px; border-radius: var(--radius-md); }
.btn-quiet:active { background: var(--surface-muted); }
.btn-danger { color: var(--rose); }
.btn-text { color: var(--teal); font-weight: 500; }
.btn-link { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; text-align: left; }

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  display: grid;
  place-items: center;
}
.icon-button:active { background: var(--surface-muted); color: var(--ink); }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- "Log a deed": in the thumb zone, above the nav ---------- */
.fab {
  position: fixed;
  right: max(16px, calc((100vw - 1040px) / 2 + 16px));
  bottom: calc(var(--nav-total) + 16px);
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: 28px;
  background: var(--teal);
  color: var(--on-teal);
  font-size: 16px;
  font-weight: 500;
  box-shadow: var(--fab-shadow);
}
.fab:active { background: var(--teal-strong); transform: scale(0.98); }
.fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- Modals and sheets ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: var(--overlay);
  padding-top: calc(var(--safe-top) + 16px);
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 16px calc(16px + var(--safe-bottom));
  box-shadow: var(--shadow-up);
  animation: slideUp 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 18px; font-weight: 500; margin-bottom: 8px; }
.modal-body {
  font-size: 14.5px;
  color: var(--ink-muted);
  margin-bottom: 16px;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.modal-note { font-size: 13px; color: var(--ink-muted); margin-bottom: 16px; }
.modal-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.modal-btns .btn-solid { flex: 1 1 auto; }
.import-preview { white-space: normal; }
.import-preview p { margin-bottom: 8px; }
.import-preview ul { padding-left: 20px; margin-bottom: 8px; }
.import-preview b { color: var(--ink); }
.fix-list { font-size: 13px; }

/* The deed sheet: head, scrolling body, Save always at the bottom */
.deed-sheet {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  height: auto;
}
.sheet-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 4px;
  flex: none;
}
.sheet-head::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 36px;
  height: 4px;
  margin-left: -18px;
  border-radius: 2px;
  background: var(--border);
}
.sheet-head #sheetBackBtn { grid-column: 1; }
.sheet-title { grid-column: 2; text-align: center; font-size: 17px; font-weight: 500; overflow-wrap: anywhere; }
.sheet-head #sheetCloseBtn { grid-column: 3; }
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 16px 16px;
}
.sheet-foot {
  flex: none;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border-faint);
  background: var(--surface);
}

/* Step 1: tiles */
.tile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-bottom: 8px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 112px;
  padding: 12px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}
.tile:active { background: var(--surface-muted); transform: scale(0.98); }
.tile-text { display: flex; flex-direction: column; gap: 4px; }
.tile-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal-light);
  color: var(--teal);
  margin-bottom: 4px;
}
.tile-label { font-size: 15px; font-weight: 500; line-height: 1.25; overflow-wrap: anywhere; }
.tile-sub { font-size: 12.5px; color: var(--ink-muted); line-height: 1.35; }

/* Step 2: form */
.field-group { margin-bottom: 16px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; margin-bottom: 4px; }
.field-label { font-size: 14.5px; font-weight: 500; color: var(--ink); }
.optional { font-weight: 400; color: var(--ink-muted); }
.field-hint { font-size: 13px; color: var(--ink-muted); margin-top: 4px; line-height: 1.45; }
.help-dot {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -10px -8px 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle, var(--surface-muted) 0 12px, transparent 12.5px);
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 600;
}
.help-dot:active { background: radial-gradient(circle, var(--border) 0 12px, transparent 12.5px); }

.input-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: text;
}
.input-box:focus-within { border-color: var(--teal); box-shadow: var(--focus-ring); }
.input-box.invalid { border-color: var(--rose); }
.input-box input, .input-box select {
  flex: 1 1 auto;
  min-width: 0;
  height: 50px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 16px; /* 16px stops phones zooming in on focus */
  color: var(--ink);
}
.input-box select { -webkit-appearance: none; appearance: none; cursor: pointer; }
.input-box:has(select) { background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-box input::placeholder { color: var(--ink-faint); opacity: 1; }
.unit { flex: none; font-size: 15px; color: var(--ink-muted); }
.unit-pre { color: var(--ink); font-weight: 500; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 15px;
  color: var(--ink);
}
/* Yes/no switch and two-option segmented control (drawn by theme-neu.css) */
.toggle-head { min-height: 44px; }
.toggle-text { display: flex; align-items: center; gap: 8px; min-width: 0; }
.field-group .field-seg { display: flex; width: 100%; }
.field-group .field-seg > .seg-opt { flex: 1 1 0; padding: 0 12px; font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--teal-light); border-color: var(--teal); color: var(--teal-strong); font-weight: 500; }

.result-line {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--teal-light);
  margin-bottom: 8px;
}
.result-kicker { font-size: 13px; color: var(--ink-muted); }
.result-text { font-size: 17px; font-weight: 500; line-height: 1.35; color: var(--ink); overflow-wrap: anywhere; }
.result-sub { font-size: 13px; color: var(--ink-muted); }

.form-problems {
  background: var(--rose-light);
  color: var(--rose);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 8px;
}
.warn-list { list-style: none; display: grid; gap: 8px; margin-bottom: 8px; }
.warn-item { font-size: 14px; line-height: 1.45; padding: 10px 14px; border-radius: var(--radius-md); }
.warn-item.is-warn { background: var(--amber-light); color: var(--amber); }
.warn-item.is-bad { background: var(--rose-light); color: var(--rose); }

.fold { border-top: 1px solid var(--border-faint); margin-top: 8px; }
.fold > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  font-size: 15px;
  font-weight: 500;
  color: var(--teal);
  cursor: pointer;
  user-select: none;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}
.fold[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.fold-body { padding: 4px 0 8px; }
.card .fold { margin-top: 4px; }
.why-text {
  font-size: 14px;
  color: var(--ink-muted);
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}

/* "Let AI estimate them": the second action in the sheet, below the fields. */
.ai-card { margin: 8px 0 8px; }
.ai-start {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}
.ai-start:active { background: var(--surface-muted); }
.ai-icon { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-light); color: var(--blue); }
.ai-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.ai-start-text { display: flex; flex-direction: column; min-width: 0; }
.ai-start-title { font-size: 15px; font-weight: 500; line-height: 1.3; }
.ai-start-sub { font-size: 14px; color: var(--blue); font-weight: 500; line-height: 1.3; }
.ai-paste { min-height: 96px; margin-bottom: 12px; }
.ai-result { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 8px 8px 14px; border-radius: var(--radius-md); background: var(--blue-light); font-size: 14px; line-height: 1.45; color: var(--ink); }
.ai-result p { flex: 1 1 auto; min-width: 0; }

/* "Something else": a word in the text suggests a type with a real number. */
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -4px 0 16px; padding: 10px 12px 10px 14px; border-radius: var(--radius-md); background: var(--blue-light); }
.suggest-text { flex: 1 1 160px; font-size: 14px; line-height: 1.45; color: var(--ink); }

/* Edge cases under More detail */
.flag-box { margin: 8px 0 16px; padding-top: 8px; border-top: 1px solid var(--border-faint); }
.fold-subhead { font-size: 15px; font-weight: 500; margin-bottom: 12px; color: var(--ink); }
.flag-note { margin: -8px 0 16px; }

.textarea {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  margin-top: 4px;
}
.textarea:focus { border-color: var(--teal); box-shadow: var(--focus-ring); }
.code-box { font-family: var(--font-mono); font-size: 13px; min-height: 120px; margin-bottom: 12px; }

.how-formula { font-family: var(--font-mono); font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; overflow-wrap: anywhere; }
.waterfall { margin-bottom: 12px; }
.waterfall-step {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(48px, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
}
.waterfall-label { color: var(--ink-muted); }
.waterfall-bar { height: 6px; border-radius: 3px; background: var(--surface-muted); overflow: hidden; display: block; }
.waterfall-fill { display: block; height: 100%; background: var(--teal); border-radius: 3px; }
.waterfall-val { font-family: var(--font-mono); font-size: 13px; text-align: right; min-width: 40px; }

.sheet-extra {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border-faint);
}

/* After saving */
.celebrate-sheet { text-align: center; padding-top: 32px; }
.celebrate-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--teal-light);
  color: var(--teal);
  display: grid;
  place-items: center;
  animation: pop 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.celebrate-mark svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
.celebrate-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.celebrate-line { font-size: 17px; line-height: 1.45; color: var(--ink); margin: 8px auto 24px; max-width: 34ch; }
.celebrate-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; margin-bottom: 24px; }
.cel-stat { display: flex; flex-direction: column; background: var(--surface-muted); border-radius: var(--radius-md); padding: 12px 8px; }
.cel-val { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cel-label { font-size: 13px; color: var(--ink-muted); line-height: 1.3; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-total) + 88px);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: var(--toast-shadow);
}
.toast.is-error { background: var(--toast-error-bg); color: var(--toast-ink); }
.toast.has-action { pointer-events: auto; }
.toast-action {
  min-height: 44px;
  min-width: 44px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}
/* While a sheet is open at the bottom, show messages at the top instead */
.modal-open .toast { bottom: auto; top: calc(var(--safe-top) + 12px); }

/* ---------- Tablet: two columns instead of a narrow strip ---------- */
@media (min-width: 760px) {
  .app-header, .app-main { padding-left: 32px; padding-right: 32px; }
  .page-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .modal-overlay { align-items: center; padding: 32px; }
  .modal-sheet { border-radius: var(--radius-xl); padding-bottom: 20px; }
  .sheet-foot { padding-bottom: 16px; }
  .deed-sheet { max-height: min(820px, 100%); }
  .fab { right: max(32px, calc((100vw - 1040px) / 2 + 32px)); }
}

/* ---------- Landscape phone: compact header and nav ---------- */
@media (orientation: landscape) and (max-height: 500px) {
  .app-header { padding-top: calc(var(--safe-top) + 4px); padding-bottom: 4px; }
  .app-title { font-size: 17px; line-height: 28px; }
  .tile { min-height: 88px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Fit with theme-neu.css (loaded after this file) ---------- */
/* The box is the inset pill; the input inside it stays flat. */
.input-box input:not([type="checkbox"]):not([type="radio"]), .input-box select {
  box-shadow: none; background: transparent; border-radius: 0; padding: 0; min-height: 0; width: auto;
}
.card .theme-seg { display: flex; }
.card .theme-seg > .seg-btn { flex: 1 1 0; padding: 0 8px; }
.result-line { box-shadow: var(--neu-inset, none); }
.celebrate-sheet .celebrate-mark { display: flex; width: 64px; height: 64px; }
.celebrate-sheet .celebrate-mark svg { width: 32px; height: 32px; }

/* "Your impact in detail": a fold at the bottom of Home, closed until tapped. */
.fold-card { padding: 0; margin-top: 16px; }
.fold-card > :not(summary) { margin-left: 16px; margin-right: 16px; }
.fold-card > :last-child { margin-bottom: 16px; }
.fold-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 16px; cursor: pointer; list-style: none; }
.fold-summary::-webkit-details-marker { display: none; }
.fold-summary .card-title { margin: 0; }
.fold-chev { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--ink-muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.fold-card[open] .fold-chev { transform: rotate(180deg); }

/* Header: title, gear (Home) or back arrow (Settings) */
.header-row { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: 8px; }
.header-row .app-title { flex: 1 1 auto; margin: 0; min-width: 0; }
.header-btn { flex: none; width: 44px; height: 44px; }
#headerBack { margin-left: -10px; }
#headerGear { margin-right: -6px; }

/* Sections inside the detail fold */
.fold-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-faint); }
.fold-sub { font-size: 16px; font-weight: 600; margin: 0 0 8px; }

/* At-a-glance bars: one colour per measure */
.pill-people { --fill-a: #e8455f; --fill-b: #ff9a7a; }
.pill-co2    { --fill-a: #12965f; --fill-b: #5fd68f; }
.pill-hours  { --fill-a: #6d3fe0; --fill-b: #b18cff; }
.pill-money  { --fill-a: #d97706; --fill-b: #fbbf24; }
.pill-bar .pill-fill { background: linear-gradient(0deg, var(--fill-a), var(--fill-b)); }
.given-row:empty { display: none; }

/* AI help: its own step in the sheet */
.ai-start { position: relative; }
.ai-go { width: 22px; height: 22px; margin-left: auto; flex: none; fill: none; stroke: var(--ink-muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ai-intro { font-size: 15px; color: var(--ink-muted); margin: 4px 0 16px; }
.ai-flow { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 20px; }
.ai-step { display: flex; gap: 14px; align-items: flex-start; }
.ai-num { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 15px; color: var(--ink); background: var(--surface); box-shadow: var(--neu-raised-sm, none); }
.ai-step-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-step-title { font-size: 16px; font-weight: 600; margin: 4px 0 0; }
.ai-step-note { font-size: 14px; color: var(--ink-muted); margin: 0; }
.ai-question { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; margin: 8px 0 0; padding: 12px; border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--neu-inset, none); max-height: 260px; overflow-y: auto; }
.kb-open .fab { display: none; }

/* "Your log" on Home: newest few deeds + See all */
.log-section { margin-top: 8px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 4px 8px; }
.section-title { font-size: 17px; font-weight: 600; margin: 0; }
.section-link { min-height: 44px; padding: 0 4px; }
.page-narrow { max-width: 640px; margin: 0 auto; }
.on-settings .fab { display: none; }

/* ---------- Auth Overlay & Card ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.auth-overlay[hidden] {
  display: none !important;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 24px;
  background: var(--surface);
  border-radius: var(--radius-lg, 16px);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.1));
  display: flex;
  flex-direction: column;
}
.auth-icon {
  font-size: 40px;
  text-align: center;
  margin-bottom: 8px;
}
.auth-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 6px;
  color: var(--ink);
}
.auth-sub {
  font-size: 14px;
  text-align: center;
  color: var(--ink-muted);
  margin: 0 0 20px;
  line-height: 1.45;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-error {
  padding: 10px 14px;
  border-radius: var(--radius-md, 8px);
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
}
.auth-toggle-row {
  margin-top: 18px;
  text-align: center;
}

/* ---------- Badge Section ---------- */
.badge-preview-wrap {
  margin: 14px 0 16px;
  padding: 20px 14px;
  background: var(--surface-sunken, rgba(0,0,0,0.03));
  border-radius: var(--radius-md, 10px);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60px;
}
.badge-preview-wrap img {
  max-width: 100%;
  height: 28px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.08));
}
.badge-placeholder {
  font-size: 13px;
  color: var(--ink-muted);
}
.badge-input-box {
  margin-bottom: 12px;
}
.badge-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.4;
  height: 56px;
}

