:root {
  --bg: #f3f2f2;
  --surface: #ffffff;
  --ink: #201e1d;
  --ink-dim: #3d3a37;
  --ink-muted: #55514d;
  --ink-faint: #686561; /* P4-5: was #8a8580 (3.3:1 on --bg); now ≥4.6:1 on every surface it's used on */
  --placeholder: #a6a29e;
  --border: #eceae8;

  /* Cyan — "your" identity color, and the app's interactive accent */
  --accent: #0088b0;
  --accent-strong: #007ea3; /* P4-5: fills behind white text (4.65:1); --accent stays for dots, bars and focus rings */
  --accent-ink: #00607c;
  --accent-ink-deep: #00475c;
  --accent-soft: #cfe6ee;
  --accent-soft-2: #e2eff4;
  --accent-bright: #5ec4e0;

  /* Magenta — co-parent identity, and the rarer second voice */
  --accent-2: #d6006c;
  --accent-2-ink: #a30553;
  --accent-2-ink-deep: #7c0340;
  --accent-2-soft: #f6d7e7;
  --accent-2-soft-2: #f7e2ec;

  /* Warm tertiary — attention/upcoming, never parent identity */
  --amber-ink: #8c5b12; /* P4-5: was #9c6614 (4.07:1 on --amber-soft-2) */
  --amber-ink-deep: #7a4e0d;
  --amber-soft: #f5e3c4;
  --amber-soft-2: #f6ead2;

  --neutral-soft: #e8e6e4;
  /* Positive / cooperative moments (P2-5) */
  --positive-ink: #2c6e3f;
  --positive-soft: #e6f2e8;
  --neutral-soft-2: #efedec;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 22px;
  --radius-xl: 26px;
  --radius-full: 999px;

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 20px;
  --space-6: 28px;

  --shadow-sm: 0 1px 4px rgba(32, 30, 29, 0.08);
  --shadow-md: 0 3px 12px rgba(32, 30, 29, 0.1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  overflow: hidden;
}
h1, h2, h3 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; }
button { all: unset; cursor: pointer; box-sizing: border-box; }
/* `all: unset` above (and any author `display`) outranks the UA's [hidden] rule — keep the attribute meaningful everywhere. */
[hidden] { display: none !important; }
button:active { transform: scale(0.98); }
input { font-family: inherit; }
input::placeholder { color: var(--placeholder); }
a { color: var(--accent-ink); }
a:hover { color: var(--accent); }
.muted { color: var(--ink-faint); }

.screen { height: 100dvh; width: 100%; }
.screen[hidden] { display: none; }
/* #login-screen / #app-screen below set `display: flex` unconditionally via an
   ID selector, which outranks the class+attribute rule above — without this,
   [hidden] is set on the element but never actually hides it. */
#login-screen[hidden], #app-screen[hidden] { display: none; }

/* ---- Login ---- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}
.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
}
.brand-mark { margin-bottom: var(--space-2); }
.login-card .wordmark-small { font-size: 17px; font-weight: 600; letter-spacing: 0.01em; margin: 0; color: var(--ink-faint); }
.login-card input, .login-card select {
  width: 100%;
  margin-top: var(--space-2);
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  font-family: 'Nunito', system-ui, sans-serif;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  color: var(--ink);
}
.login-card input:focus-visible, .login-card select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.password-field { position: relative; width: 100%; margin-top: var(--space-2); }
.password-field input { margin-top: 0; padding-right: 46px; width: 100%; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.pw-toggle i { font-size: 19px; color: var(--ink-faint); }
.pw-toggle:hover i { color: var(--ink-muted); }

.onboarding-overlay {
  position: absolute; inset: 0; z-index: 25;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  overflow-y: auto;
}
.onboarding-overlay[hidden] { display: none; }
.primary-btn {
  width: 100%;
  margin-top: var(--space-1);
  padding: 17px;
  border-radius: var(--radius-full);
  background: var(--accent-strong);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  text-align: center;
}
.primary-btn:hover { background: var(--accent-ink); }
.error-text { color: var(--accent-2-ink); font-size: 13px; min-height: 18px; font-weight: 700; }
.success-text { color: var(--accent-ink-deep); font-size: 13px; font-weight: 700; background: var(--accent-soft-2); border-radius: var(--radius-sm); padding: 10px 14px; }
.link-btn { font-size: 13px; font-weight: 700; color: var(--ink-faint); text-decoration: underline; margin-top: 2px; }

.auth-seg[hidden] { display: none; }
.auth-seg {
  display: flex;
  background: var(--neutral-soft);
  border-radius: var(--radius-full);
  padding: 4px;
  width: 100%;
  margin-top: var(--space-2);
}
.auth-seg-btn {
  flex: 1;
  border-radius: var(--radius-full);
  padding: 11px;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-muted);
  text-align: center;
}
.auth-seg-btn.active { background: var(--ink); color: var(--bg); }
.auth-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.auth-form[hidden] { display: none; }
.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--accent-soft-2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: var(--space-2);
  text-align: left;
}
.privacy-note i { font-size: 20px; color: var(--accent-ink-deep); flex: none; margin-top: 1px; }
.privacy-note span { font-size: 13px; line-height: 1.5; font-weight: 600; color: var(--accent-ink-deep); }

/* ---- App shell ---- */
#app-screen {
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-4)) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.content::-webkit-scrollbar { display: none; }
/* Scrolling flex columns: children keep their natural height. With the default
   flex-shrink: 1 a tall screen squashed its cards (e.g. the Expenses summary collapsed
   to 44px and its text spilled over the chips and list below). */
.content > *, .sheet-body > *, .chat-messages > *, .sc-upload-list > * { flex-shrink: 0; }

.section-label {
  font-size: 12.5px; font-weight: 800; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn i { font-size: 20px; color: var(--ink); }

/* ---- Home ---- */
.home-header { display: flex; align-items: center; gap: 12px; }
.home-header .avatar-mark {
  width: 44px; height: 44px; border-radius: 50%; background: var(--surface);
  box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; flex: none;
}
.home-header .greeting { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.home-header .date-label { font-size: 13px; font-weight: 700; color: var(--ink-faint); }
.home-header .greeting-text { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 24px; line-height: 1.15; }

.today-card {
  background: var(--accent-strong);
  color: #fff;
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.today-card.theirs { background: var(--accent-2); }
.today-card-top { display: flex; justify-content: space-between; align-items: center; }
.today-card-kicker { font-size: 12.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; }
.today-card-pill { background: rgba(0,0,0,0.22); font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); }
.today-card-headline { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 19px; line-height: 1.3; }
.today-card-detail {
  display: flex; align-items: center; gap: 8px; background: #fff; color: var(--ink);
  border-radius: 14px; padding: 8px 12px; align-self: flex-start;
}
.today-card-detail i { font-size: 18px; color: var(--accent); }
.today-card.theirs .today-card-detail i { color: var(--accent-2); }
.today-card-detail span { font-size: 13px; font-weight: 700; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-tile {
  text-align: left; border-radius: var(--radius-lg); padding: 16px 14px;
  display: flex; flex-direction: column; gap: 12px; text-decoration: none;
}
.quick-tile i { font-size: 26px; }
.quick-tile span { font-size: 14px; font-weight: 800; }
.quick-tile.tile-cyan { background: var(--accent-soft); }
.quick-tile.tile-cyan i, .quick-tile.tile-cyan span { color: var(--accent-ink-deep); }
.quick-tile.tile-magenta { background: var(--accent-2-soft); }
.quick-tile.tile-magenta i, .quick-tile.tile-magenta span { color: var(--accent-2-ink-deep); }
.quick-tile.tile-amber { background: var(--amber-soft); }
.quick-tile.tile-amber i, .quick-tile.tile-amber span { color: var(--amber-ink-deep); }
.quick-tile.tile-ink { background: var(--ink); }
.quick-tile.tile-ink i, .quick-tile.tile-ink span { color: var(--bg); }

.ask-bar {
  background: var(--surface); border-radius: var(--radius-full); padding: 13px 18px;
  display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-sm); text-align: left;
}
.ask-bar i { font-size: 20px; color: var(--accent); flex: none; }
.ask-bar span.label { font-size: 14px; font-weight: 700; color: var(--ink-muted); flex: 1; }
.ask-bar .ai-pill { background: var(--accent-soft); color: var(--accent-ink-deep); font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); }

.biff-preview-card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.biff-preview-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.biff-preview-kicker { font-size: 12.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent-2-ink); }
.biff-preview-close { border: none; background: none; cursor: pointer; padding: 4px; }
.biff-preview-close i { font-size: 18px; color: var(--ink-faint); }
.biff-preview-text { font-size: 14px; line-height: 1.55; }
.biff-preview-actions { display: flex; gap: 8px; }
.pill-btn {
  border: none; font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 800;
  padding: 10px 16px; border-radius: var(--radius-full); cursor: pointer;
}
.pill-btn.magenta { background: var(--accent-2-soft); color: var(--accent-2-ink-deep); }
.pill-btn.neutral { background: var(--neutral-soft); color: var(--ink); }

.entry-row-card {
  background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.entry-row-icon { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.entry-row-icon i { font-size: 19px; }
.entry-row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entry-row-title { font-size: 14px; font-weight: 800; }
.entry-row-desc { font-size: 13px; color: var(--ink-muted); line-height: 1.45; }
.entry-row-meta { font-size: 12px; font-weight: 700; color: var(--ink-faint); }

/* ---- Chips (used on Log filters + chat suggestions) ---- */
/* These rows can overflow horizontally (more chips than fit on screen). The
   scrollbar itself is hidden (mobile browsers already suppress it), so
   without a visual cue a partially-cut-off last chip reads as a layout bug
   rather than "swipe for more" — the fade-left/fade-right classes below are
   toggled by updateChipRowFade() in app.js to hint at that scrollability. */
.chip-row {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: 2px; /* was 40px — a spacer for chips being squashed; fixed at the root (flex-shrink: 0 on .content children) */
  scroll-padding-inline: var(--space-4);
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row.fade-right { mask-image: linear-gradient(to right, black calc(100% - 28px), transparent); -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent); }
.chip-row.fade-left { mask-image: linear-gradient(to left, black calc(100% - 28px), transparent); -webkit-mask-image: linear-gradient(to left, black calc(100% - 28px), transparent); }
.chip-row.fade-left.fade-right {
  mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, transparent, black 28px, black calc(100% - 28px), transparent);
}
.chip {
  flex: 0 0 auto;
  padding: 10px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 800;
  height: 36px;
  white-space: nowrap;
  background: var(--surface);
  color: var(--accent-ink-deep);
  box-shadow: var(--shadow-sm);
}
.chip.filter { background: var(--surface); color: var(--ink-muted); box-shadow: none; }
.chip.filter.active { background: var(--ink); color: var(--bg); }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.export-buttons { display: flex; gap: 8px; flex: 0 0 auto; }
.export-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; border-radius: var(--radius-full);
  background: var(--surface); box-shadow: var(--shadow-sm);
  color: var(--ink); font-size: 13px; font-weight: 800;
  text-decoration: none; cursor: pointer;
}
.export-btn i { font-size: 16px; color: var(--accent); }

/* ---- Chat overlay ---- */
.chat-overlay {
  position: absolute; inset: 0; z-index: 20;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
.chat-overlay[hidden] { display: none; }
.chat-overlay-header { display: flex; align-items: center; gap: 10px; padding: var(--space-3) var(--space-4) var(--space-2); }
.chat-overlay-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; flex: none; }
.chat-overlay-title { display: flex; flex-direction: column; }
.chat-overlay-title .title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 18px; }
.chat-overlay-title .subtitle { font-size: 12px; font-weight: 700; color: var(--ink-faint); }

.chat-messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px var(--space-4); }
.chat-messages::-webkit-scrollbar { display: none; }

.bubble {
  max-width: 84%;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.bubble.assistant { align-self: flex-start; background: var(--surface); border-radius: 18px 18px 18px 6px; }
.bubble.user { align-self: flex-end; background: var(--accent-strong); color: #fff; border-radius: 18px 18px 6px 18px; }
.bubble img { max-width: 100%; border-radius: var(--radius-sm); margin-bottom: 6px; display: block; }
.bubble.pending { opacity: 0.6; font-style: italic; }
.bubble table { border-collapse: collapse; font-size: 12.5px; margin-top: 4px; }
.bubble th, .bubble td { border: 1px solid color-mix(in srgb, currentColor 20%, transparent); padding: 4px 8px; text-align: left; }

.typing-dots { display: flex; gap: 5px; align-items: center; align-self: flex-start; background: var(--surface); border-radius: 18px 18px 18px 6px; padding: 12px 16px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--placeholder); animation: p1pulse 1s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes p1pulse { 0%, 100% { opacity: 0.35; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.chat-chip-row { padding: 0 var(--space-4) 40px; }

.ai-banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--amber-soft); color: var(--amber-ink-deep);
  margin: 0 var(--space-4) 10px; padding: 12px 14px; border-radius: var(--radius-md);
}
.ai-banner[hidden] { display: none; }
.ai-banner i { font-size: 19px; flex: none; }
.ai-banner span { font-size: 13px; font-weight: 700; line-height: 1.4; }

.chat-bar.disabled #chat-text,
.chat-bar.disabled #send-btn,
.chat-bar.disabled .attach-btn { opacity: 0.5; pointer-events: none; }
.chat-chip-row.disabled { opacity: 0.5; pointer-events: none; }

.chat-bar {
  flex: 0 0 auto;
  padding: var(--space-2) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.attach-btn { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 4px; }
.attach-btn i { font-size: 22px; color: var(--ink-faint); }
#chat-text {
  flex: 1;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-full);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}
#chat-text:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#send-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--accent-strong);
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
}
#send-btn i { font-size: 20px; color: #fff; }
.pending-image { position: relative; flex: 0 0 auto; }
.pending-image img { width: 38px; height: 38px; object-fit: cover; border-radius: var(--radius-sm); display: block; }
.pending-image button {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
}
.pending-image button i { font-size: 10px; color: #fff; }

/* ---- Schedule ---- */

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-card { min-width: 0; min-height: 44px; border-radius: 16px; padding: 10px 0 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.day-card.is-today { box-shadow: inset 0 0 0 2px var(--ink); }
.day-card .dow { font-size: 11px; font-weight: 800; }
.day-card .num { font-size: 17px; font-weight: 800; color: var(--ink); }
.day-card .today-label { font-size: 9px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink); min-height: 11px; }
.day-card .dot { width: 7px; height: 7px; border-radius: 50%; }
/* Distinct marker for a day with a schedule exception (P0-3) — a small badge in the
   card's corner, separate from the overnight-parent .dot so both can show at once. */
.exception-marker {
  position: absolute; top: 3px; right: 3px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--amber-ink); display: flex; align-items: center; justify-content: center;
}
.exception-marker i { font-size: 9px; color: #fff; }
.legend-row { display: flex; gap: var(--space-4); padding: 0 4px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; }

.week-card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.week-card-top { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.week-card-range { font-size: 14px; font-weight: 800; }

.run-card { background: var(--surface); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.run-icon { width: 40px; height: 40px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: none; }
.run-icon i { font-size: 20px; }
.run-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.run-title { font-size: 14px; font-weight: 800; }
.run-sub { font-size: 13px; color: var(--ink-muted); }
.run-pill { color: #fff; font-size: 12px; font-weight: 800; padding: 5px 12px; border-radius: var(--radius-full); flex: none; }

.exception-card {
  background: var(--amber-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.exception-card i { font-size: 22px; color: var(--amber-ink); flex: none; margin-top: 1px; }
.exception-card .title { font-size: 14px; font-weight: 800; color: var(--amber-ink-deep); }
.exception-card .body { font-size: 13px; line-height: 1.5; margin-top: 3px; color: var(--amber-ink-deep); }

/* ---- Log ---- */
.entry-card {
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.entry-top { display: flex; justify-content: space-between; align-items: center; }
.entry-cat-label { display: flex; align-items: center; gap: 8px; }
.entry-cat-label i { font-size: 20px; }
.entry-cat-label span { font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.entry-date { font-size: 12px; font-weight: 700; color: var(--ink-faint); }
.legal-pill { display: flex; align-items: center; gap: 4px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); }
.legal-pill i { font-size: 13px; }
.entry-desc { font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.severity-row { display: flex; align-items: center; gap: 6px; }
.severity-row .dot { width: 8px; height: 8px; }
.severity-row span { font-size: 12px; color: var(--ink-faint); font-weight: 700; }

/* ---- Expenses ---- */
.summary-card {
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.summary-card .month-label { font-size: 12.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--placeholder); }
.summary-stats { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.summary-stat .value { font-family: 'Source Serif 4', Georgia, serif; font-size: 28px; font-weight: 600; }
.summary-stat .value.bright { color: var(--accent-bright); }
.summary-stat .label { font-size: 12px; font-weight: 700; color: var(--placeholder); margin-top: 2px; }
.summary-bar { height: 8px; border-radius: var(--radius-full); background: rgba(255,255,255,0.15); overflow: hidden; }
.summary-bar-fill { height: 100%; background: var(--accent-bright); border-radius: var(--radius-full); }

.expense-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.expense-icon { width: 40px; height: 40px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: none; }
.expense-icon i { font-size: 20px; }
.expense-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.expense-merchant { font-weight: 800; font-size: 14px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.expense-meta { font-size: 12px; color: var(--ink-faint); font-weight: 700; margin-top: 1px; }
.expense-amount-col { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.expense-amount { font-weight: 800; font-size: 15px; white-space: nowrap; }
.expense-badge { font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: var(--radius-full); }

.empty-state { color: var(--ink-faint); font-size: 14px; padding: var(--space-6) 0; text-align: center; }

/* ---- Account ---- */
.profile-card { background: var(--surface); border-radius: var(--radius-lg); padding: 18px; display: flex; align-items: center; gap: 14px; }
.profile-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 22px; color: var(--accent-ink-deep); flex: none; }
.profile-name { font-size: 17px; font-weight: 800; }
.profile-email { font-size: 13px; font-weight: 700; color: var(--ink-faint); }
.unverified-note { font-size: 12px; font-weight: 700; color: var(--amber-ink); margin-top: 3px; }
.resend-verify-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0; font-size: 13px; }
.resend-verify-btn:disabled { opacity: 0.55; cursor: default; }
.resend-verify-status { font-size: 12px; margin-top: 2px; }
.resend-verify-status:empty { display: none; }

.list-card { background: var(--surface); border-radius: var(--radius-lg); padding: 4px 18px; display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.list-row-icon { width: 36px; height: 36px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.list-row-icon i { font-size: 18px; }
.list-row-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-row-title { font-size: 14px; font-weight: 800; }
.list-row-sub { font-size: 12px; color: var(--ink-faint); font-weight: 700; }
.list-row > i { font-size: 16px; color: var(--placeholder); }
.list-row-link { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }

.signout-btn { width: 100%; background: var(--accent-2-soft); color: var(--accent-2-ink-deep); font-size: 15px; font-weight: 800; padding: 15px; border-radius: var(--radius-full); text-align: center; }

/* ---- Scroll-to-top ---- */
.scroll-top-btn {
  position: absolute;
  right: var(--space-3);
  bottom: 90px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--ink);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.scroll-top-btn[hidden] { display: none; }
.scroll-top-btn i { font-size: 18px; color: var(--bg); }

/* ---- Sheet overlay (profile/schedule editor, expense entry) ---- */
.sheet-overlay {
  position: absolute; inset: 0; z-index: 22;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
.sheet-overlay[hidden] { display: none; }
.sheet-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: var(--space-3) var(--space-4) var(--space-2);
}
.sheet-title { flex: 1; font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 18px; text-align: center; }
.sheet-save-btn {
  flex: none; background: var(--accent-strong); color: #fff;
  font-size: 13px; font-weight: 800; padding: 10px 18px; border-radius: var(--radius-full);
}
.sheet-save-btn:hover { background: var(--accent-ink); }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: var(--space-4); }
.sheet-body::-webkit-scrollbar { display: none; }

.field-group { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 10px; }
.field-row { display: flex; flex-direction: column; gap: 5px; }
.field-row.two-col { flex-direction: row; gap: 10px; }
.field-row.two-col > * { flex: 1; min-width: 0; }
.field-label { font-size: 11.5px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.field-input, .field-select, .field-textarea {
  width: 100%; border: none; background: var(--neutral-soft-2); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 14px; font-weight: 600; font-family: 'Nunito', system-ui, sans-serif; color: var(--ink);
  appearance: none; -webkit-appearance: none;
}
.field-textarea { resize: vertical; min-height: 64px; font-weight: 500; }
.field-input:focus-visible, .field-select:focus-visible, .field-textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-checkbox-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.field-checkbox-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.field-checkbox-row label { font-size: 14px; font-weight: 700; }

.editor-child-card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 10px; position: relative; }
.editor-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* In the card's flow (it used to be absolutely positioned over the Name field's corner). */
.editor-remove-btn {
  min-height: 44px; padding: 0 14px; border-radius: var(--radius-full);
  background: var(--accent-2-soft); color: var(--accent-2-ink-deep); font-size: 13px; font-weight: 800;
  display: inline-flex; align-items: center; gap: 6px;
}
.editor-remove-btn i { font-size: 14px; color: var(--accent-2-ink-deep); }
.add-row-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--neutral-soft); color: var(--ink-muted); font-size: 13px; font-weight: 800;
  padding: 12px; border-radius: var(--radius-md);
}
.add-row-btn i { font-size: 16px; }

.day-edit-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.day-edit-row:last-child { border-bottom: none; }
.day-edit-label { width: 44px; flex: none; font-size: 12.5px; font-weight: 800; color: var(--ink-faint); }
.day-edit-row .field-select { flex: 1; padding: 10px 12px; font-size: 13px; }

/* ---- Expense widget ---- */
.expense-sub { font-size: 11.5px; color: var(--ink-faint); font-weight: 700; }
.expense-delete-btn { flex: none; width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.expense-delete-btn i { font-size: 13px; color: var(--placeholder); }
.fab-btn {
  align-self: flex-end; display: flex; align-items: center; gap: 8px;
  background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 800;
  padding: 12px 18px; border-radius: var(--radius-full); box-shadow: var(--shadow-md);
}
.fab-btn i { font-size: 17px; }

/* ---- Tab bar (v2): edge to edge, thin top rule, home-indicator space, tinted active pill ---- */
.tab-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-top: 1px solid #e3e0dd;
  padding: 8px 8px max(env(safe-area-inset-bottom, 0px), 10px);
  position: relative;
  z-index: 15;
}
.tab-btn {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tab-pill {
  width: 58px; height: 32px; border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.tab-pill i { font-size: 23px; color: #6f6a66; }
.tab-label { font-size: 12px; font-weight: 700; color: #6f6a66; white-space: nowrap; }
.tab-btn.active .tab-pill { background: var(--accent-soft); }
.tab-btn.active .tab-pill i { color: var(--accent-ink); }
.tab-btn.active .tab-label { color: var(--ink); font-weight: 800; }
.tab-add .tab-pill { background: var(--ink); }
.tab-add .tab-pill i { font-size: 20px; color: #fff; }
.tab-add .tab-label { color: var(--ink); font-weight: 800; }

/* ---- Add sheet (v2) ---- */
.fab-menu-overlay { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
.fab-menu-overlay[hidden] { display: none; }
.fab-menu-backdrop { position: absolute; inset: 0; background: rgba(32, 30, 29, 0.32); }
.fab-menu-sheet {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto;
  background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 10px var(--space-4) calc(20px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
.sheet-grabber { width: 40px; height: 5px; border-radius: var(--radius-full); background: #d4d1ce; align-self: center; }
.add-sheet-title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 22px; }
.add-sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.add-tile {
  border-radius: var(--radius-lg); padding: 16px 14px; min-height: 100px;
  display: flex; flex-direction: column; gap: 10px; text-align: left;
}
.add-tile i { font-size: 26px; }
.add-tile-label { font-size: 15px; font-weight: 800; margin-bottom: -8px; }
.add-tile-sub { font-size: 12px; font-weight: 600; }
.add-tile.tile-cyan { background: var(--accent-soft); color: var(--accent-ink-deep); }
.add-tile.tile-cyan i { color: var(--accent-ink); }
.add-tile.tile-amber { background: var(--amber-soft); color: #5c3a09; }
.add-tile.tile-amber i { color: var(--amber-ink); }
.add-tile.tile-magenta { background: var(--accent-2-soft); color: var(--accent-2-ink-deep); }
.add-tile.tile-magenta i { color: var(--accent-2-ink); }
.add-tile.tile-ink { background: var(--ink); color: var(--bg); }
.add-tile.tile-ink i { color: var(--accent-bright); }
.fab-menu-cancel {
  background: var(--neutral-soft); color: var(--ink); font-size: 15px; font-weight: 800;
  padding: 15px; border-radius: var(--radius-full); text-align: center;
}

/* Delete-undo toast (simple version of P0-4's generalized Undo/Trash) */
.undo-toast {
  position: fixed; left: var(--space-4); right: var(--space-4);
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  z-index: 45; background: var(--ink); color: var(--bg);
  border-radius: var(--radius-full); box-shadow: var(--shadow-md);
  padding: 14px 10px 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.undo-toast[hidden] { display: none; }
.undo-toast span { font-size: 13.5px; font-weight: 700; }
.undo-toast button {
  font-size: 13.5px; font-weight: 800; color: var(--accent-bright);
  padding: 6px 14px; border-radius: var(--radius-full);
}

/* ---- Entry card additions: both timestamps, edited badge, overflow menu (P0-1) ---- */
.entry-timestamps { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.entry-timestamps span { font-size: 11.5px; font-weight: 700; color: var(--ink-faint); }
.edited-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800;
  color: var(--accent-ink-deep); background: var(--accent-soft); padding: 3px 9px;
  border-radius: var(--radius-full); align-self: flex-start; margin-top: 4px;
}
.entry-menu-wrap { position: relative; flex: none; }
.entry-menu-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.entry-menu-btn i { font-size: 17px; color: var(--ink-faint); }
.entry-menu-dropdown {
  position: absolute; right: 0; top: 32px; z-index: 5;
  background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; padding: 4px; min-width: 140px;
}
.entry-menu-dropdown[hidden] { display: none; }
.entry-menu-dropdown button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  font-size: 13.5px; font-weight: 700; border-radius: var(--radius-sm); text-align: left;
}
.entry-menu-dropdown button i { font-size: 16px; color: var(--ink-faint); }
.entry-menu-dropdown button.danger i, .entry-menu-dropdown button.danger span { color: var(--accent-2-ink); }

/* Witness/tag chip input (add via Enter, remove via ×) */
.chip-input-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-removable {
  display: flex; align-items: center; gap: 6px; background: var(--neutral-soft); color: var(--ink-dim);
  font-size: 12.5px; font-weight: 700; padding: 6px 8px 6px 12px; border-radius: var(--radius-full);
}
.chip-removable button { display: flex; align-items: center; justify-content: center; }
.chip-removable button i { font-size: 12px; color: var(--ink-faint); }
.chip-input-row input {
  flex: 1; min-width: 100px; border: none; background: none; font-size: 13.5px;
  font-family: inherit; padding: 6px 2px; color: var(--ink);
}
.chip-input-row input:focus-visible { outline: none; }

.ai-draft-link {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--accent-ink); padding: 6px;
}
.ai-draft-link i { font-size: 16px; }
.ai-draft-link[hidden] { display: none; }

/* Read-only version-history entries */
.version-card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 6px; }
.version-card .version-meta { font-size: 12px; font-weight: 700; color: var(--ink-faint); }
.version-card .version-reason { font-size: 12.5px; font-weight: 700; color: var(--ink-muted); font-style: italic; }
.version-card .version-field { font-size: 13px; line-height: 1.5; }
.version-card .version-field b { font-weight: 800; }

/* ---- Search + composable filters (P0-2) ---- */
mark { background: var(--amber-soft); color: var(--ink); border-radius: 3px; padding: 0 1px; }

.search-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: var(--radius-full); padding: 10px 16px; }
.search-row i { font-size: 18px; color: var(--ink-faint); flex: none; }
.search-row input { flex: 1; border: none; background: none; font-size: 14px; font-family: inherit; color: var(--ink); }
.search-row input:focus-visible { outline: none; }
.search-row .filters-toggle-btn { flex: none; display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; }
.search-row .filters-toggle-btn.active { background: var(--accent-soft); }
.search-row .filters-toggle-btn i { color: var(--ink-faint); font-size: 17px; }
.search-row .filters-toggle-btn.active i { color: var(--accent-ink-deep); }

.log-filters-panel { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 10px; }
.log-filters-panel[hidden] { display: none; }
.log-filters-panel .clear-filters-btn { align-self: flex-start; font-size: 13px; font-weight: 700; color: var(--accent-2-ink); }

.clear-filters-empty-btn {
  display: block; margin: 10px auto 0; font-size: 13.5px; font-weight: 800;
  color: var(--accent-ink); background: var(--accent-soft); padding: 10px 18px; border-radius: var(--radius-full);
}

/* ---- Home global search (P0-2) ---- */
.home-search-results { display: flex; flex-direction: column; gap: 12px; }
.home-search-group-label { font-size: 12.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--placeholder); }

/* ---- Confirm dialog (P0-4) — the one place a blocking dialog is still used, for the
   irreversible "Delete forever" action; everything else uses the Undo toast. ---- */
.confirm-dialog-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.confirm-dialog-overlay[hidden] { display: none; }
.confirm-dialog-backdrop { position: absolute; inset: 0; background: rgba(32, 30, 29, 0.45); }
.confirm-dialog-card {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: var(--space-4); width: calc(100% - 48px); max-width: 340px;
  display: flex; flex-direction: column; gap: 10px;
}
.confirm-dialog-title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 18px; }
.confirm-dialog-body { font-size: 13.5px; line-height: 1.5; color: var(--ink-muted); margin: 0; }
.confirm-dialog-actions { display: flex; gap: 10px; margin-top: 6px; }
.confirm-dialog-btn { flex: 1; text-align: center; padding: 12px; border-radius: var(--radius-full); font-size: 14px; font-weight: 800; }
.confirm-dialog-btn.cancel { background: var(--neutral-soft); color: var(--ink); }
.confirm-dialog-btn.danger { background: var(--accent-2); color: #fff; }
.confirm-dialog-btn.primary { background: var(--accent-strong); color: #fff; }

/* ---- Trash (P0-4) ---- */
.trash-card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; align-items: center; gap: 12px; }
.trash-card-body { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.trash-card-title { font-size: 14px; font-weight: 800; }
.trash-card-summary { font-size: 13px; color: var(--ink-muted); }
.trash-card-meta { font-size: 11.5px; font-weight: 700; color: var(--ink-faint); }
.trash-card-actions { display: flex; flex-direction: column; gap: 6px; flex: none; }
.trash-card-actions button { font-size: 12px; font-weight: 800; padding: 7px 12px; border-radius: var(--radius-full); text-align: center; }
.trash-restore-btn { background: var(--accent-soft); color: var(--accent-ink-deep); }
.trash-delete-btn { background: var(--accent-2-soft); color: var(--accent-2-ink); }

/* ---- Pull-to-refresh (P0-5) ---- */
.ptr-indicator {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center; z-index: 12;
  transition: opacity 0.15s;
}
.ptr-indicator[hidden] { display: none; }
.ptr-indicator i { font-size: 18px; color: var(--accent); }
.ptr-indicator.spinning i { animation: ptr-spin 0.7s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ---- Infinite-scroll "Load more" fallback (Log/Expenses, P0-5) reuses .add-row-btn */

/* ---- v2 screen header, avatar, shared bits ---- */
.screen-header { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.screen-title { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 30px; line-height: 1.1; margin: 0; flex: 1; min-width: 0; }
.screen-header .icon-btn { width: 44px; height: 44px; }
.account-avatar-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 18px;
}
.list-count { font-size: 13px; font-weight: 700; color: #6f6a66; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.clamp-2, .clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { -webkit-line-clamp: 2; line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; line-clamp: 3; }
.clamp-3.expanded { -webkit-line-clamp: unset; line-clamp: unset; display: block; }

/* Buttons are `all: unset` above, which drops the focus ring — restore a visible one. */
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- v2 Log cards ---- */
.entry-top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.legal-pill { white-space: nowrap; flex: none; }
.severity-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.entry-title { font-size: 16px; font-weight: 800; line-height: 1.3; }
.entry-desc { color: var(--ink-dim); line-height: 1.55; }
.read-more-btn {
  align-self: flex-start; font-size: 13px; font-weight: 800; color: var(--ink);
  text-decoration: underline; text-underline-offset: 3px; padding: 2px 0 6px; min-height: 28px;
}
.entry-timestamps span { font-size: 12px; color: #6f6a66; white-space: nowrap; }

/* ---- v2 Schedule upcoming card ---- */
.exception-icon { width: 42px; height: 42px; border-radius: 50%; background: #fbf1df; display: flex; align-items: center; justify-content: center; flex: none; }
.exception-card .exception-icon i { margin: 0; }
.exception-card .when { font-size: 13px; font-weight: 700; color: var(--amber-ink-deep); }
.run-pill { white-space: nowrap; }
.week-card-range { white-space: nowrap; }
.today-card-kicker, .today-card-pill, .today-card-detail span { white-space: nowrap; }
.today-card-kicker { color: #fff; } /* P4-5: full white for AA contrast */
.today-card-headline { font-size: 22px; line-height: 1.25; }
.run-pill-split { display: flex; padding: 0; overflow: hidden; }
.run-pill-split span { padding: 5px 8px 5px 12px; }
.run-pill-split span + span { padding: 5px 12px 5px 6px; }
.tab-add .tab-pill i { font-size: 18px; }

/* ---- P1-1 tamper-evident journal ---- */
.hash-chip { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 11.5px; font-weight: 600; background: rgba(32, 30, 29, 0.07); color: var(--ink-dim); padding: 1px 6px; border-radius: 6px; }
.version-card.current { background: var(--accent-soft-2); }
.version-card .version-note { font-size: 12.5px; color: var(--ink-muted); }
.version-card .version-hashes { font-size: 12px; color: var(--ink-faint); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.diff-field { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--border); }
.diff-label { font-size: 12px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.diff-old { font-size: 13.5px; line-height: 1.5; color: var(--accent-2-ink-deep); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff-new { font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.diff-old em, .diff-new em { color: var(--ink-faint); text-decoration: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.integrity-status { font-size: 12px; font-weight: 700; }
.integrity-status.ok { color: #2c6e3f; }
.integrity-status.bad { color: var(--accent-2-ink); }

/* ---- P1-2 structured incident template ---- */
.wizard-progress { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.wizard-progress-bar { height: 6px; border-radius: var(--radius-full); background: var(--neutral-soft); overflow: hidden; }
.wizard-progress-bar div { height: 100%; background: var(--amber-ink); border-radius: var(--radius-full); transition: width 0.2s; }
.wizard-step-label { font-size: 12.5px; font-weight: 800; color: var(--amber-ink-deep); }
.field-textarea.tall { min-height: 160px; }
.field-hint { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-muted); }
.field-hint i { font-size: 16px; color: var(--amber-ink); flex: none; margin-top: 1px; }
.field-hint.nudge { background: var(--amber-soft-2); color: var(--amber-ink-deep); padding: 10px 12px; border-radius: var(--radius-sm); font-weight: 700; }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.wizard-back { font-size: 15px; font-weight: 800; color: var(--ink); padding: 14px 18px; border-radius: var(--radius-full); background: var(--neutral-soft); }
.wizard-next { flex: 1; max-width: 240px; margin-left: auto; text-align: center; }
.review-section { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--border); }
.review-section:first-child { border-top: none; }
.review-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); }
.review-edit { font-size: 13px; font-weight: 800; color: var(--accent-ink); text-transform: none; letter-spacing: 0; padding: 6px 0 6px 12px; min-height: 32px; }
.review-body { font-size: 14px; line-height: 1.5; white-space: pre-line; }
.review-body em { color: var(--ink-faint); }
.positive-prompt {
  position: fixed; left: var(--space-4); right: var(--space-4); max-width: 440px; margin: 0 auto;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 46;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
}
.positive-prompt > i { font-size: 22px; color: var(--amber-ink); }
.positive-prompt > span { flex: 1; min-width: 180px; font-size: 14px; font-weight: 700; line-height: 1.4; }
.positive-prompt-actions { display: flex; gap: 8px; margin-left: auto; }
.positive-prompt-actions button { font-size: 13.5px; font-weight: 800; padding: 10px 14px; border-radius: var(--radius-full); min-height: 40px; }
#positive-prompt-dismiss { color: var(--ink-muted); }
#positive-prompt-add { background: var(--accent-soft); color: var(--accent-ink-deep); }

/* ---- P1-3 actual vs. scheduled ---- */
.deviation-card { background: var(--ink); color: var(--bg); border-radius: var(--radius-xl); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.deviation-kicker { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--placeholder); }
.deviation-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.deviation-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.deviation-num { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; font-size: 26px; line-height: 1.1; }
.deviation-label { font-size: 11.5px; font-weight: 700; color: var(--placeholder); line-height: 1.3; }
.deviation-tally { font-size: 13px; line-height: 1.5; color: #d9d6d3; }
.deviation-tally b { color: var(--bg); font-weight: 800; margin-right: 4px; }
.deviation-tally.muted { color: var(--placeholder); }
.handoff-card { background: var(--surface); border-radius: var(--radius-lg); padding: 4px 16px; display: flex; flex-direction: column; }
.handoff-row { display: flex; flex-direction: column; gap: 10px; padding: 14px 0; border-top: 1px solid var(--border); }
.handoff-row:first-child { border-top: none; }
.handoff-row.saving { opacity: 0.6; pointer-events: none; }
.handoff-row-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.handoff-day { font-size: 14px; font-weight: 800; }
.handoff-route { font-size: 12.5px; font-weight: 700; color: var(--ink-muted); white-space: nowrap; }
.status-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.status-chip { font-size: 13px; font-weight: 800; padding: 9px 13px; min-height: 40px; border-radius: var(--radius-full); background: var(--neutral-soft-2); color: var(--ink-dim); display: inline-flex; align-items: center; }
.status-chip.active { background: var(--ink); color: var(--bg); }
.status-chip.pending { background: var(--amber-soft); color: var(--amber-ink-deep); box-shadow: inset 0 0 0 2px var(--amber-ink); }
.late-minutes-row { display: flex; gap: 8px; align-items: center; }
.late-minutes-input { max-width: 150px; }
.late-minutes-save { font-size: 14px; font-weight: 800; padding: 11px 18px; border-radius: var(--radius-full); background: var(--accent-strong); color: #fff; }
.handoff-logged { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: #2c6e3f; }
.handoff-logged i { font-size: 16px; }
.handoff-error:empty { display: none; }

/* ---- P1-4 GPS check-ins ---- */
.checkin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.checkin-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 800; padding: 10px 16px; min-height: 42px; border-radius: var(--radius-full); background: var(--accent-strong); color: #fff; }
.checkin-btn i { font-size: 17px; }
.checkin-btn[disabled] { opacity: 0.6; }
.checkin-list { display: flex; flex-direction: column; gap: 4px; }
.checkin-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--accent-ink-deep); }
.checkin-item i { font-size: 15px; }
.checkin-item.pending { color: var(--amber-ink-deep); }
.checkin-item.no-location { color: var(--ink-muted); }
.checkin-status { font-size: 12.5px; font-weight: 700; color: var(--ink-muted); }
.tab-btn .pending-dot { position: absolute; top: 2px; right: calc(50% - 30px); width: 9px; height: 9px; border-radius: 50%; background: var(--amber-ink); box-shadow: 0 0 0 2px #fff; }
.tab-btn { position: relative; }

/* ---- P1-5 ExportDialog ---- */
.export-preview { margin: 14px 0 4px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--accent-soft-2); color: var(--accent-ink-deep); font-size: 13.5px; font-weight: 700; }
.export-preview.warn { background: var(--amber-soft-2); color: var(--amber-ink-deep); }
.export-actions { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.export-download { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; min-height: 48px; }
.export-download i { font-size: 18px; }
.export-download.secondary { background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 800; border-radius: var(--radius-full); padding: 13px; box-shadow: var(--shadow-sm); }

/* ---- P2-6 expenses ---- */
.balance-detail { font-size: 12px; font-weight: 700; color: var(--placeholder); line-height: 1.4; }
.overdue-flag { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 800; color: #fff; background: var(--accent-2); border-radius: var(--radius-sm); padding: 8px 12px; align-self: flex-start; }
.overdue-flag i { font-size: 16px; }
.receipt-mark { font-size: 14px; color: var(--ink-faint); margin-right: 4px; vertical-align: -2px; }

/* ---- P2-1 patterns ---- */
.patterns-banner { display: flex; align-items: center; gap: 10px; width: 100%; background: var(--amber-soft); color: var(--amber-ink-deep); border-radius: var(--radius-md); padding: 12px 14px; font-size: 13.5px; min-height: 48px; text-align: left; }
.patterns-banner > i:first-child { font-size: 20px; color: var(--amber-ink); flex: none; }
.patterns-banner span { flex: 1; min-width: 0; line-height: 1.4; }
.patterns-banner b { font-weight: 800; }
.patterns-list { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.pattern-card { background: var(--surface); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.pattern-head { display: flex; gap: 12px; align-items: flex-start; }
.pattern-icon { width: 40px; height: 40px; border-radius: 14px; background: var(--amber-soft); display: flex; align-items: center; justify-content: center; flex: none; }
.pattern-icon i { font-size: 20px; color: var(--amber-ink); }
.pattern-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pattern-behavior { font-size: 15px; font-weight: 800; line-height: 1.3; }
.pattern-meta { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); }
.pattern-links { display: flex; flex-wrap: wrap; gap: 6px; }
.pattern-link { font-size: 12.5px; font-weight: 800; color: var(--accent-ink-deep); background: var(--accent-soft-2); padding: 7px 11px; border-radius: var(--radius-full); min-height: 32px; }

/* ---- P2-5 positive moments ---- */
.positive-pill { display: flex; align-items: center; gap: 4px; background: var(--positive-ink); color: #fff; font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); white-space: nowrap; flex: none; }
.positive-pill i { font-size: 13px; }
.entry-card.is-positive { box-shadow: inset 4px 0 0 var(--positive-ink); }
.positive-mark { display: inline-flex; align-items: center; gap: 3px; color: var(--positive-ink); font-weight: 800; }
.positive-mark i { font-size: 13px; }
.compact-select { width: auto; max-width: 150px; flex: none; }

/* ---- P2-2 evidence vault ---- */
.evidence-date { margin-top: 12px; display: block; }
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 8px; }
.evidence-tile { position: relative; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: var(--radius-md); padding: 6px; min-width: 0; }
.evidence-tile img, .evidence-file { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: var(--neutral-soft); display: flex; align-items: center; justify-content: center; }
.evidence-file i { font-size: 34px; color: var(--ink-muted); }
.evidence-caption { font-size: 11.5px; font-weight: 700; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px 2px; }
.evidence-badge { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; background: rgba(255, 255, 255, 0.92); display: flex; align-items: center; justify-content: center; }
.evidence-badge i { font-size: 14px; color: var(--accent-ink); }
.evidence-full { width: 100%; max-height: 60vh; object-fit: contain; border-radius: var(--radius-lg); background: var(--neutral-soft); margin-bottom: 12px; }
.label-row { display: flex; gap: 8px; align-items: center; }
.exif-table { gap: 0; }
.exif-row { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); align-items: baseline; }
.exif-row:first-child { border-top: none; }
.exif-label { flex: 0 0 92px; font-size: 12px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.exif-value { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.45; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.exif-note { font-size: 12px; color: var(--ink-faint); font-weight: 600; }
.hash-full { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 11.5px; word-break: break-all; }
.integrity-ok, .integrity-bad { display: inline-flex; gap: 6px; align-items: center; font-weight: 800; }
.integrity-ok { color: var(--positive-ink); }
.integrity-bad { color: var(--accent-2-ink); }

/* ---- P2-4 message import ---- */
.add-row-wide { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: var(--radius-lg); padding: 14px 16px; text-align: left; min-height: 56px; }
.add-row-wide i { font-size: 24px; color: var(--accent-ink); flex: none; }
.add-row-wide span { font-size: 12.5px; color: var(--ink-muted); line-height: 1.4; display: flex; flex-direction: column; }
.add-row-wide b { font-size: 15px; font-weight: 800; color: var(--ink); }
.import-seg { margin-bottom: 14px; }
.import-mark { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: var(--ink-muted); }
.import-mark i { font-size: 15px; color: var(--accent-ink); }
.entry-desc { white-space: pre-line; } /* P2-4: pasted threads keep their line breaks */

/* ---- P2-3 share links ---- */
.share-cats { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.share-cats legend { margin-bottom: 6px; }
.share-cat { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; min-height: 32px; }
.share-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.share-card, .share-created { background: var(--surface); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.share-created { margin: 14px 0; box-shadow: inset 0 0 0 2px var(--accent); }
.share-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.share-label { font-size: 15px; font-weight: 800; }
.share-status { font-size: 11.5px; font-weight: 800; padding: 3px 10px; border-radius: var(--radius-full); white-space: nowrap; }
.share-status.active { background: #e0efe3; color: var(--positive-ink); }
.share-status.expired, .share-status.revoked { background: var(--neutral-soft); color: var(--ink-muted); }
.share-meta { font-size: 12.5px; color: var(--ink-muted); font-weight: 600; }
.share-actions { display: flex; gap: 8px; margin-top: 4px; }
.pattern-link.danger { background: var(--accent-2-soft); color: var(--accent-2-ink-deep); }
.share-log { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 6px; }
.share-log-row { display: grid; grid-template-columns: 1fr 1.3fr auto; gap: 8px; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--border); }

/* ---- P3-1 DraftsView ---- */
.drafts-banner { display: flex; gap: 10px; align-items: flex-start; background: var(--amber-soft-2); color: var(--amber-ink-deep); padding: 12px 14px; border-radius: var(--radius-lg); font-size: 13px; line-height: 1.5; }
.drafts-banner i { font-size: 20px; flex: none; margin-top: 1px; }
.drafts-banner b { display: block; font-size: 14px; }
.draft-card.is-new { box-shadow: inset 0 0 0 2px var(--accent); }
.draft-text { min-height: 140px; }
.draft-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.draft-actions .pattern-link { min-height: 44px; padding: 10px 14px; }
.draft-actions .pattern-link[hidden] { display: none; }
.draft-chip { display: flex; align-items: center; gap: 6px; margin-top: 10px; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-full); background: var(--amber-soft-2); color: var(--amber-ink-deep); font-size: 13px; font-weight: 800; text-align: left; }
.draft-chip i { font-size: 16px; flex: none; }
.draft-save-hint { margin-bottom: 12px; }
.draft-status:empty { display: none; }

/* ---- P3-2 SummariesView ---- */
.working-notes-banner { background: var(--accent-2-soft); color: var(--accent-2-ink-deep); }
.list-card-btn { text-align: left; min-height: 44px; }
.summary-back { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.summary-detail { gap: 8px; }
.summary-overview { margin: 4px 0; font-style: italic; line-height: 1.5; }
.summary-heading { font-size: 15px; font-weight: 800; margin: 10px 0 2px; }
.summary-points { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; line-height: 1.5; }
.summary-cites { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 6px; vertical-align: middle; }
.cite-chip { min-width: 44px; min-height: 32px; padding: 4px 10px; border-radius: var(--radius-full); background: var(--accent-soft-2); color: var(--accent-ink-deep); font-size: 12.5px; font-weight: 800; }
.cite-chip.changed { background: var(--amber-soft-2); color: var(--amber-ink-deep); }
.cite-chip[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.summary-source { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--neutral-soft); font-size: 13px; }
.summary-source[hidden] { display: none; }
.source-meta { font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.source-status { font-size: 12px; font-weight: 800; color: var(--amber-ink-deep); }
.xd-ai-list { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 6px; }

/* ---- P3-3 School calendar + school-aware schedule ---- */
.no-school-marker { position: absolute; bottom: 4px; left: 6px; font-size: 13px; color: var(--amber-ink-deep); }
.day-off-list { display: flex; flex-direction: column; gap: 6px; }
.day-off-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px; }
.day-off-date { font-size: 13px; font-weight: 800; min-width: 92px; }
.day-off-label { flex: 1; font-size: 13px; color: var(--ink-muted); min-width: 0; }
.school-cal-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.school-cal-row { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: var(--radius-sm); padding: 8px 8px 8px 12px; border-left: 4px solid var(--accent); }
.school-cal-row.kind-makeup { border-left-color: var(--amber-ink); }
.school-cal-row.kind-first_day, .school-cal-row.kind-last_day { border-left-color: var(--positive-ink, #2c6e3f); }
.school-cal-row-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.school-cal-dates { font-size: 14px; font-weight: 800; }
.school-cal-label { font-size: 12.5px; color: var(--ink-muted); }
.sc-preview-list, .sc-errors { margin: 4px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.sc-errors { color: var(--accent-2-ink-deep); }
.sc-upload-list { border: 0; padding: 0; margin: 4px 0; display: flex; flex-direction: column; gap: 2px; max-height: 360px; overflow-y: auto; }
.sc-upload-item { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 8px 4px; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.sc-upload-item input { margin-top: 3px; width: 20px; height: 20px; flex: none; }

/* ---- P3-4 Witnesses & contacts ---- */
.share-status.pending { background: var(--amber-soft-2); color: var(--amber-ink-deep); }
.witness-field { margin: 2px 0; font-size: 14px; line-height: 1.5; }
.witness-field b { display: block; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); }
.witness-picker { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.witness-picker[hidden] { display: none; }
.witness-picker-label { font-size: 12px; font-weight: 800; color: var(--ink-muted); }
.witness-pick { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; border-radius: var(--radius-full); background: var(--accent-soft-2); color: var(--accent-ink-deep); font-size: 13px; font-weight: 700; }
.witness-pick i { font-size: 15px; }

/* ---- P3-5 Court-order compliance ---- */
.clause-ref { color: var(--accent-2-ink-deep); font-weight: 800; }
.clause-count { min-width: 32px; height: 32px; border-radius: var(--radius-full); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; background: var(--neutral-soft); color: var(--ink-muted); }
.clause-count.has { background: var(--accent-2-soft); color: var(--accent-2-ink-deep); }
.clause-text { margin: 4px 0; padding: 8px 12px; border-left: 3px solid var(--accent-2); background: var(--neutral-soft); border-radius: var(--radius-sm); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.clause-months { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.clause-month { display: grid; grid-template-columns: 84px 1fr 28px; align-items: center; gap: 8px; font-size: 12.5px; }
.clause-bar { height: 8px; border-radius: 4px; background: var(--accent-2); min-width: 4px; }
.clause-month b { text-align: right; }
.clause-mark i { color: var(--accent-2-ink-deep); }

/* ---- P4-1 Reminders ---- */
.header-actions { display: flex; align-items: center; gap: 8px; }
.inbox-btn { position: relative; width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--ink); font-size: 22px; flex: none; }
.inbox-badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent-2); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.inbox-item { text-align: left; min-height: 44px; }
.inbox-item.unread { box-shadow: inset 4px 0 0 var(--accent); }
.inbox-body { font-size: 14px; line-height: 1.45; }
.setting-hint { display: block; font-size: 12px; color: var(--ink-muted); font-weight: 500; margin-top: 2px; }


/* ---- P4-5 accessibility pass (spec §3: 44×44 targets, visible focus, one-handed) ---- */

/* Touch targets: at least 44×44 px. */
.export-btn, .status-chip, .checkin-btn, .pattern-link, .fab-btn, .edited-badge, .sheet-save-btn,
.ai-draft-link, .add-row-btn, .auth-seg-btn, .late-minutes-save, .read-more-btn, .chip, .witness-pick,
.cite-chip, .draft-chip, .filters-toggle-btn, .link-btn { min-height: 44px; }
.link-btn { display: inline-flex; align-items: center; }
.pw-toggle { min-width: 44px; min-height: 44px; }
.export-btn, .edited-badge, .read-more-btn { display: inline-flex; align-items: center; }
.field-input, .field-select { min-height: 44px; }
.expense-delete-btn, .entry-menu-btn, .filters-toggle-btn, .attach-btn, .chip-removable button {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
}
.chip-removable { min-height: 44px; }
.field-checkbox-row { min-height: 44px; align-items: center; }
.field-checkbox-row label { padding: 10px 0; flex: 1; }
.field-checkbox-row input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.search-row input, #home-search-input, #log-search-input { min-height: 44px; }

/* Focus: inputs whose own outline is off get it on their container instead. */
.search-row:focus-within, .chip-input-row:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.chip:focus-visible, .field-checkbox-row input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One-handed use on phones: a sheet's Save sits at the bottom of the screen, in thumb reach. */
@media (max-width: 600px) {
  .sheet-header .sheet-save-btn {
    position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 30;
    min-height: 52px; border-radius: var(--radius-full); font-size: 16px; box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center;
  }
  .sheet-header .sheet-save-btn[hidden] { display: none; }
  .sheet-overlay:has(.sheet-save-btn:not([hidden])) .sheet-body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}

/* Respect "reduce motion". */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* Buttons used as cards keep the ink color (their text was inheriting the light button color). */
button.share-card { color: var(--ink); }

/* ---- P4-2 passkeys ---- */
.passkey-btn { width: 100%; min-height: 48px; margin-top: 10px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 15px; background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--border); }
.passkey-btn i { font-size: 20px; color: var(--accent-ink); }
.passkey-btn[hidden] { display: none; }

/* ---- P4-3 offline-first: sync bar, Sync & review sheet, offline screen ---- */
.secondary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius-full);
  background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 800;
  box-shadow: inset 0 0 0 1.5px var(--border);
}
.secondary-btn:disabled, .primary-btn:disabled { opacity: 0.55; }
.link-btn.danger { color: var(--accent-2-ink); min-height: 44px; }

.sync-bar { flex: none; padding: calc(env(safe-area-inset-top, 0px) + 8px) var(--space-4) 0; }
.sync-bar[hidden] { display: none; }
/* The bar already covers the top safe area, so the screen below doesn't add it again. */
.sync-bar:not([hidden]) ~ .content { padding-top: var(--space-3); }
.sync-bar-btn {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: var(--radius-full);
  background: var(--neutral-soft); color: var(--ink); font-size: 13.5px; font-weight: 800; text-align: left;
}
.sync-bar-btn span { flex: 1; min-width: 0; }
.sync-bar-btn i { font-size: 18px; flex: none; }
.sync-bar.attention .sync-bar-btn { background: var(--amber-soft-2); color: var(--amber-ink-deep); }

.sync-note { font-size: 13px; line-height: 1.5; margin: 0; }
.sync-card { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 8px; }
.sync-card-title { font-size: 14.5px; font-weight: 800; overflow-wrap: anywhere; }
.sync-card-meta { font-size: 12px; font-weight: 700; color: var(--ink-faint); }
.sync-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sync-card-actions .primary-btn { width: auto; margin: 0; padding: 0 18px; min-height: 48px; flex: 1 1 140px; }
.sync-card-actions .secondary-btn { flex: 1 1 140px; }
.sync-card .error-text:empty { display: none; }
.pending-pill { align-self: flex-start; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); background: var(--amber-soft-2); color: var(--amber-ink-deep); }

.sync-diff { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.sync-diff-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.sync-diff-row dt { grid-column: 1 / -1; font-size: 11.5px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); }
.sync-diff-row dd { margin: 0; font-size: 13.5px; line-height: 1.4; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--neutral-soft); overflow-wrap: anywhere; min-width: 0; }
.sync-diff-row dd.mine { background: var(--accent-soft); }
.sync-diff-label { display: block; font-size: 11px; font-weight: 800; color: var(--ink-faint); margin-bottom: 2px; }

.offline-card { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-4); }
.offline-card i { font-size: 26px; color: var(--ink-muted); flex: none; }
.offline-card p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-muted); }
.offline-actions { display: flex; flex-direction: column; gap: 10px; }
.offline-actions .primary-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; }

/* ---- P4-6 pricing page ---- */
.pricing-banner { display: flex; gap: 10px; align-items: flex-start; background: var(--neutral-soft); color: var(--ink); padding: 12px 14px; border-radius: var(--radius-lg); font-size: 13px; line-height: 1.5; }
.pricing-banner.draft { background: var(--amber-soft-2); color: var(--amber-ink-deep); }
.pricing-banner i { font-size: 18px; flex: none; margin-top: 1px; }
.pricing-hero h2 { font-family: 'Source Serif 4', Georgia, serif; font-size: 26px; font-weight: 600; margin: 4px 0 6px; }
.pricing-hero p { margin: 0; color: var(--ink-muted); font-size: 14.5px; line-height: 1.5; }
.pricing-period { display: flex; gap: var(--space-2); }
.plan-card { background: var(--surface); border-radius: var(--radius-xl); padding: var(--space-4); display: flex; flex-direction: column; gap: 10px; }
.plan-card.featured { box-shadow: inset 0 0 0 2px var(--accent-strong); }
.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.plan-current { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: var(--radius-full); background: var(--accent-soft); color: var(--accent-ink-deep); }
.plan-tagline { margin: 0; color: var(--ink-muted); font-size: 14px; line-height: 1.45; }
.plan-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.plan-amount { font-family: 'Source Serif 4', Georgia, serif; font-size: 34px; font-weight: 600; }
.plan-per { font-size: 14px; font-weight: 700; color: var(--ink-faint); }
.plan-price-note { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); margin-top: -6px; }
.plan-features { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.plan-features li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.4; }
.plan-features i { font-size: 18px; color: var(--accent-strong); flex: none; margin-top: 1px; }
.plan-feature-detail { display: block; font-weight: 600; color: var(--ink-muted); font-size: 12.5px; margin-top: 1px; }
.plan-card .primary-btn { margin-top: 6px; }
.pricing-faq { display: flex; flex-direction: column; gap: 8px; }
.pricing-faq details { background: var(--surface); border-radius: var(--radius-lg); padding: 0 var(--space-4); }
.pricing-faq summary { min-height: 48px; display: flex; align-items: center; font-weight: 800; font-size: 14px; cursor: pointer; }
.pricing-faq details p { margin: 0 0 var(--space-3); color: var(--ink-muted); font-size: 13.5px; line-height: 1.5; }

/* ---- Add / change account email ---- */
.account-email-form { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.account-email-form[hidden] { display: none; }
.account-email-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.account-email-actions .primary-btn { width: auto; flex: 1 1 140px; margin: 0; padding: 0 18px; min-height: 48px; }
.account-email-actions .secondary-btn { flex: 1 1 100px; }
.account-email-form .error-text:empty { display: none; }
.resend-verify-btn + .resend-verify-btn { margin-left: 16px; }
