:root {
  /* Elos "Herbário" — a warm, diary-like skin. Colours that rest the eyes:
     low saturation, warm paper, espresso ink, dusty rose for affection and
     sage for growth. X/TikTok marks are black — flipped light in candlelight
     mode below, or they vanish. */
  --brand-x: #000000;
  --brand-tiktok: #111111;
  --bg: #f3ede2;          /* oat-linen paper */
  --card: #fcf8f0;        /* warm ivory — never pure white */
  --primary: #946a1e;     /* deep honey/amber — afeto sem gênero (AA on ivory & as button) */
  --primary-dark: #7c5917;
  --sage: #6f8663;        /* muted sage — crescimento, orgânico; drives the thread */
  --honey: #c68f35;       /* bright honey glow — third voice, the fio's warm midpoint */
  --danger: #c0392b;      /* clean red — kept clearly apart from the amber affection */
  --text: #3b2f26;        /* warm espresso — never cold black */
  --muted: #7c6a58;       /* warm taupe */
  --border: #e6d9c6;      /* soft sand hairline */
  --accent-bg: #f2e7d2;   /* faint honey-cream */
  --accent: #efe6d6;      /* warm neutral */
  --input-bg: #fffcf6;    /* warm near-white */
  --toast-bg: #3b2f26;
  --toast-text: #fcf8f0;
  --mix: #fcf8f0;
  /* Warm-tinted shadows — afternoon light, not camera flash. */
  --shadow: 22px 20px 50px -30px rgba(74, 48, 30, 0.42);
  --shadow-soft: 8px 10px 26px -18px rgba(74, 48, 30, 0.32);
  /* Barely-there paper grain — one grayscale noise reads on both grounds
     (dark specks on paper, light specks on candlelight). CSP allows data: imgs. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23g)' opacity='0.05'/%3E%3C/svg%3E");
  --radius: 18px;
  /* Self-hosted (see fonts.css). Fraunces = display + reading; Figtree = UI.
     Non-Latin scripts fall through to the system stack. */
  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-sans: 'Figtree', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-read: 'Fraunces', 'Iowan Old Style', Palatino, Georgia, 'Times New Roman', serif;
}

[data-theme="dark"] {
  /* Candlelight — warm dark, never cold black. */
  --brand-x: #efe4d4;
  --brand-tiktok: #efe4d4;
  --bg: #1d1714;
  --card: #29211b;
  --primary: #e3b25c;     /* glowing honey/amber (dark CTA text overridden below) */
  --primary-dark: #ce9a45;
  --sage: #aec299;
  --honey: #dba95e;
  --danger: #e8836f;
  --text: #f0e5d5;        /* warm parchment */
  --muted: #ac9a85;
  --border: #3c3128;
  --accent-bg: #37301f;
  --accent: #2e2620;
  --input-bg: #181310;
  --toast-bg: #f0e5d5;
  --toast-text: #29211b;
  --mix: #29211b;
  --shadow: 22px 20px 50px -30px rgba(0, 0, 0, 0.6);
  --shadow-soft: 8px 10px 26px -18px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg);
  background-image: var(--grain);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
}

/* A gentle settle on load — the page arrives softly, like opening a notebook. */
@keyframes riseIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.container { animation: riseIn 0.45s ease both; }

/* Visible keyboard focus everywhere it wasn't already handled. */
a:focus-visible, .btn:focus-visible, button:focus-visible, summary:focus-visible,
[role="menuitem"]:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .container { animation: none; }
  .support-fab svg, .plan .f-icon.heart { animation: none; }
  * { scroll-behavior: auto !important; }
}

.ico-sun, .ico-moon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
html[data-theme="dark"] .ico-moon { display: none; }
html:not([data-theme="dark"]) .ico-sun { display: none; }

a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; line-height: 1.15; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.12rem; line-height: 1.2; margin: 0 0 0.6rem; }
/* The intimate surface: what you write about people, set like a book. */
.notes, .tl-body p, .diary-scroll .notes { font-family: var(--font-read); font-size: 0.98rem; line-height: 1.65; }
code.wrap { word-break: break-all; font-size: 0.8rem; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem;
  padding-top: calc(0.7rem + env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; letter-spacing: 0; color: var(--primary); }
.topbar { align-items: center; min-height: 3.2rem; }
.topbar > *, .top-actions > *, .top-links > * {
  display: inline-flex; align-items: center; line-height: 1; margin: 0;
}
.top-actions { display: flex; align-items: center; gap: 0.9rem; }
.top-links { display: flex; align-items: center; gap: 0.7rem; }
.topbar svg { display: block; }
.topbar details {
  display: inline-flex; align-items: center; height: 2rem;
}
.topbar details > summary {
  display: inline-flex; align-items: center; justify-content: center;
  height: 100%; padding: 0 0.5rem; box-sizing: border-box; margin: 0;
}
.topbar details > summary::marker,
.topbar details > summary::-webkit-details-marker { display: none; content: ""; }
.lang-toggle { font-weight: 700; font-size: 0.8rem; color: var(--muted); }

.container { max-width: 640px; margin: 0 auto; padding: 1rem; }
.container.has-nav { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 0.66rem; padding: 0.2rem 0.6rem; min-width: 56px;
}
.bottomnav a.active { color: var(--primary); }
.bottomnav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Cards & lists */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow-soft); }
.card-head, .page-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; }
.page-head h1 { margin: 0; }
.person-head { display: flex; align-items: center; gap: 0.7rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list .row { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.list .row:last-child { border-bottom: none; }
.row-body { flex: 1; min-width: 0; }
.row-body a { font-weight: 600; color: var(--text); }
.row-icon { font-size: 1.2rem; }

.avatar {
  flex-shrink: 0;
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--primary); font-weight: 700;
}
.avatar.big { width: 52px; height: 52px; font-size: 1.3rem; }

.dot { flex-shrink: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--chip, var(--primary)); }
.dot.big { width: 22px; height: 22px; }

.date-badge {
  flex-shrink: 0; width: 44px; text-align: center;
  background: var(--accent-bg); border-radius: 10px; padding: 0.3rem 0;
  color: var(--primary);
}
.date-badge strong { display: block; font-size: 1.05rem; line-height: 1; }
.date-badge span { font-size: 0.68rem; }

.badge {
  flex-shrink: 0; font-size: 0.7rem; font-weight: 600;
  background: var(--accent-bg); color: var(--primary);
  border-radius: 999px; padding: 0.25rem 0.6rem;
}
.badge-hot { background: var(--primary); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.chip {
  display: inline-block; font-size: 0.75rem; font-weight: 600;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  background: color-mix(in srgb, var(--chip, var(--primary)) 14%, var(--mix));
  color: color-mix(in srgb, var(--chip, var(--primary)) 75%, var(--text));
  border: 1px solid color-mix(in srgb, var(--chip, var(--primary)) 35%, var(--mix));
}
.chip-grid { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip-check input { position: absolute; opacity: 0; }
.chip-check input:checked + .chip { outline: 2px solid var(--chip, var(--primary)); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 0.85rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; }
/* Same look as a label, but NOT a <label> — so clickable dropdown options inside
   it aren't hijacked by the label and redirected to the input. */
.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 600; }
input, textarea, select {
  font: inherit; font-weight: 400;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--input-bg); color: var(--text);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* Writing about someone should feel like a diary page, not a form field. */
textarea.note-edit, textarea[name="notes"] { font-family: var(--font-read); font-size: 1rem; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); border-color: transparent; }
input[type="color"] { padding: 0.15rem; height: 42px; width: 64px; }
/* Keyboard-friendly date field (app.js [data-date]): a text input the user can
   type into (dd-mm-yyyy / mm-dd-yyyy per their setting) with a 📅 button that
   opens the native picker. The hidden ISO field is what actually submits. */
.date-field { position: relative; display: block; width: 100%; }
.date-field .date-text { padding-inline-end: 2.6rem; }
.date-cal {
  position: absolute; inset-inline-end: 0.35rem; top: 50%; transform: translateY(-50%);
  width: 2rem; height: 2rem; padding: 0; border: none; background: none; cursor: pointer;
  font-size: 1.15rem; line-height: 1; opacity: 0.7; border-radius: 8px;
}
.date-cal:hover { opacity: 1; }
.date-cal:focus-visible { outline: 2px solid var(--primary); opacity: 1; }
/* Present for showPicker() but out of the layout/tab-flow. */
.date-native {
  position: absolute; inset-inline-end: 0.5rem; bottom: 0;
  width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none;
}
/* Password reveal toggle (injected by app.js around every password input). */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap input { padding-right: 2.7rem; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 2.7rem;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 0 10px 10px 0;
  background: none; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* Password strength meter (injected by app.js under new-password fields). */
.pw-strength { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.pw-bars { display: flex; gap: 3px; flex: 1; }
.pw-bars i { height: 4px; flex: 1; border-radius: 2px; background: var(--border); transition: background 0.15s; }
.pw-level { font-size: 0.72rem; font-weight: 700; color: var(--muted); min-width: 4.5em; text-align: end; }
.pw-strength[data-level="1"] .pw-bars i.on { background: #e11d48; }
.pw-strength[data-level="1"] .pw-level { color: #e11d48; }
.pw-strength[data-level="2"] .pw-bars i.on { background: #f59e0b; }
.pw-strength[data-level="2"] .pw-level { color: #f59e0b; }
.pw-strength[data-level="3"] .pw-bars i.on { background: #84cc16; }
.pw-strength[data-level="3"] .pw-level { color: #65a30d; }
.pw-strength[data-level="4"] .pw-bars i.on { background: #16a34a; }
.pw-strength[data-level="4"] .pw-level { color: #16a34a; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem; }
legend { font-size: 0.85rem; font-weight: 600; padding: 0 0.3rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  font: inherit; font-weight: 600; font-size: 0.9rem;
  padding: 0.62rem 1.05rem; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  cursor: pointer; text-align: center;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--primary) 70%, transparent); }
.btn.primary:active { background: var(--primary-dark); }
/* In candlelight the amber is light, so white text on it is weak — use deep ink. */
[data-theme="dark"] .btn.primary { color: #241a08; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white); }
.btn.small-btn { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-row { display: flex; gap: 0.6rem; }
.icon-btn {
  border: none; background: none; color: var(--muted);
  font-size: 1.2rem; cursor: pointer; padding: 0.2rem 0.5rem;
}
.linklike { border: none; background: none; color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 700; cursor: pointer; padding: 0; }

.searchbar { margin-bottom: 1rem; }
.group-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.group-filter .chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.82rem; cursor: pointer;
  line-height: 1.4;
}
.group-filter .chip:hover { border-color: var(--primary); }
.group-filter .chip.active {
  background: var(--chip, var(--primary)); color: #fff; border-color: transparent;
}
.list .row[hidden] { display: none; }
.combobox { position: relative; }
.combobox-input { width: 100%; }
.combobox-list {
  position: absolute; z-index: 20; inset-inline: 0; top: 100%;
  margin: 3px 0 0; padding: 0; list-style: none;
  max-height: 240px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
}
.combobox-opt { padding: 0.5rem 0.7rem; cursor: pointer; }
.combobox-opt:hover, .combobox-opt.active { background: var(--accent); }
.combobox-opt[hidden] { display: none; }
.check-inline { display: flex; align-items: center; gap: 0.45rem; margin: -0.3rem 0 0.2rem; }
.check-inline input { width: auto; }
input.linked { opacity: 0.6; }
/* Phone line with an inline "same number for WhatsApp + Telegram" toggle. */
.phone-row { display: flex; align-items: center; gap: 0.55rem; }
.phone-input { flex: 1 1 auto; min-width: 0; }
/* flex-direction beats the global `label { flex-direction: column }` above —
   without it the checkbox + icons stack vertically. */
.phone-link { flex: none; display: inline-flex; flex-direction: row; align-items: center; gap: 0.4rem; cursor: pointer; font-weight: 400; }
.phone-link input { width: auto; margin: 0; cursor: pointer; }
.phone-ic { display: inline-flex; }
.phone-ic svg { width: 22px; height: 22px; display: block; }
.phone-ic.wa { color: #25d366; }
.phone-ic.tg { color: #2aabee; }
.phone-link input:not(:checked) ~ .phone-ic { color: var(--muted); opacity: 0.4; }
.tag-input { border: 1px solid var(--border); border-radius: 10px; padding: 0.4rem; background: var(--card); }
.tag-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tag-chips:not(:empty) { margin-bottom: 0.35rem; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem;
  background: var(--accent); color: var(--text); padding: 0.2rem 0.2rem 0.2rem 0.55rem;
  border-radius: 999px;
}
.tag-x { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 0.25rem; }
.tag-x:hover { color: var(--warn, #dc2626); }
.tag-entry { width: 100%; border: none; background: transparent; padding: 0.25rem; }
.tag-entry:focus { outline: none; }
.pf-extra { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pf-extra:not(:empty) { margin-bottom: 1rem; }
.pf-extra .group-filter { margin-bottom: 0; }
.pf-city { max-width: 240px; }
.chip-plain { background: var(--accent); color: var(--muted); border-color: var(--border); }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
/* Bulk selection (People page): a checkbox per row + a floating action bar.
   Everything is hidden until the "select" toggle adds .bulk-on to the root. */
.bulk-box { display: none; }
.bulk-on .bulk-box { display: flex; align-items: center; flex: 0 0 auto; }
.bulk-box input { width: 21px; height: 21px; margin: 0; accent-color: var(--primary); cursor: pointer; }
.bulk-bar {
  position: fixed; inset-inline: 0.8rem; z-index: 30;
  bottom: calc(4.1rem + env(safe-area-inset-bottom));
  max-width: 600px; margin: 0 auto; padding: 0.55rem 0.7rem;
  display: none; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.bulk-on .bulk-bar { display: flex; } /* shown only in selection mode */
.bulk-bar select { flex: 1 1 120px; width: auto; padding: 0.4rem 0.5rem; font-size: 0.83rem; }
.bulk-count { font-weight: 700; font-size: 0.85rem; }
.bulk-on .pf-list { margin-bottom: 10rem; } /* keep the last rows reachable under the bar */
.ic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
}
.ic-btn svg { width: 17px; height: 17px; }
.social-ic { background: var(--chip, var(--primary)); color: #fff; }
/* Light badge in dark mode needs a dark glyph. */
[data-theme="dark"] .social-ic.s-x,
[data-theme="dark"] .social-ic.s-tiktok { color: #10131a; }
.edit-ic { background: var(--accent); color: var(--muted); }
.edit-ic:hover { color: var(--primary); }
details > summary { list-style: none; width: fit-content; margin-bottom: 0.6rem; }
details > summary::-webkit-details-marker { display: none; }

/* Key-value lists */
.kv { list-style: none; margin: 0; padding: 0; }
.kv li { display: flex; gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; align-items: baseline; }
.kv li:last-child { border-bottom: none; }
.kv li > span:first-child { flex-shrink: 0; width: 100px; color: var(--muted); font-size: 0.8rem; }
.notes { white-space: pre-wrap; margin: 0.7rem 0 0; font-size: 0.92rem; }

/* Timeline — "o fio": a single warming thread the beads sit on. Its colour is
   set per person by data-warmth (see person_detail): rose when contact is
   recent, cooling through honey to sage as the bond falls asleep. */
.timeline { list-style: none; margin: 0.6rem 0 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 4.5px; top: 7px; bottom: 7px; width: 2.5px;
  border-radius: 3px; opacity: 0.6;
  background: linear-gradient(var(--primary), var(--sage));
}
.timeline[data-warmth="warm"]::before { opacity: 0.8; background: linear-gradient(var(--primary), var(--honey)); }
.timeline[data-warmth="mild"]::before { opacity: 0.7; background: linear-gradient(var(--honey), var(--sage)); }
.timeline[data-warmth="cool"]::before { opacity: 0.5; background: linear-gradient(var(--sage), var(--border)); }
.timeline li { display: flex; gap: 0.7rem; }
.tl-dot {
  flex-shrink: 0; width: 12px; height: 12px; margin-top: 5px; border-radius: 50%;
  background: var(--card); border: 2.5px solid var(--primary);
  box-shadow: 0 0 0 3px var(--bg); position: relative; z-index: 1;
}
/* The newest bead is filled — the warmth of the last time you met. */
.timeline li:first-child .tl-dot { background: var(--primary); }
.timeline[data-warmth="cool"] li:first-child .tl-dot { background: var(--sage); border-color: var(--sage); }
.timeline[data-warmth="cool"] .tl-dot { border-color: var(--sage); }
.tl-body { flex: 1; padding-bottom: 1rem; position: relative; }
.tl-body p { margin: 0.2rem 0 0; font-size: 0.92rem; white-space: pre-wrap; }
.tl-body > form { position: absolute; top: 0; inset-inline-end: 0; }

/* Inline "edit" disclosure on list & timeline rows (dates, links, interactions). */
.row-edit { margin-top: 0.35rem; }
.row-edit > summary {
  display: inline-flex; align-items: center; gap: 0.3rem;
  cursor: pointer; color: var(--muted); font-size: 0.82rem; list-style: none; width: max-content;
}
.row-edit > summary::-webkit-details-marker { display: none; }
.row-edit > summary::before { content: "\270E"; }
.row-edit > summary:hover, .row-edit[open] > summary { color: var(--primary); }
.row-edit > form { margin-top: 0.6rem; }

/* Feedback */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(5.2rem + env(safe-area-inset-bottom));
  background: var(--toast-bg); color: var(--toast-text);
  padding: 0.55rem 1.1rem; border-radius: 999px; font-size: 0.85rem;
  z-index: 20; transition: opacity 0.4s;
}
.alert {
  background: color-mix(in srgb, var(--danger) 12%, var(--mix));
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--mix));
  border-radius: 10px;
  padding: 0.6rem 0.9rem; font-size: 0.88rem; margin-bottom: 1rem;
}

/* Auth pages */
.auth-wrap { max-width: 420px; margin: 0 auto; padding-top: 1.5rem; }
.auth-hero { text-align: center; margin-bottom: 1.4rem; }
.auth-hero .logo { width: 64px; height: 64px; }
.auth-hero h1 { margin: 0.5rem 0 0.2rem; }
.divider { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.8rem; margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.muted { color: var(--muted); }
.small { font-size: 0.78rem; }
.center { text-align: center; }
.right { text-align: end; margin: -0.3rem 0 0; }
.center-row { justify-content: center; }

/* Language menu */
.lang-menu { position: relative; }
.lang-menu > summary {
  list-style: none; cursor: pointer;
  font-weight: 700; font-size: 0.8rem; color: var(--muted);
  padding: 0.25rem 0.4rem;
}
.lang-menu > summary::-webkit-details-marker { display: none; }
.lang-list {
  position: absolute; inset-inline-end: 0; top: 1.9rem; z-index: 30;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 10rem; padding: 0.3rem; display: flex; flex-direction: column;
}
.lang-list a { padding: 0.45rem 0.7rem; border-radius: 8px; color: var(--text); font-size: 0.88rem; }
.lang-list a.active { color: var(--primary); font-weight: 700; background: var(--accent-bg); }
.lang-list a:hover { background: var(--accent-bg); }

#theme-toggle { color: var(--muted); display: inline-flex; align-items: center; padding: 0.35rem; }

/* Topbar links + share menu */
.top-links a { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
@media (max-width: 560px) { .top-links { display: none; } }
.share-menu > summary svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; vertical-align: middle;
}
.share-menu .lang-list button {
  font: inherit; font-size: 0.88rem; text-align: start; color: var(--text);
  background: none; border: none; cursor: pointer;
  padding: 0.45rem 0.7rem; border-radius: 8px;
}
.share-menu .lang-list button:hover { background: var(--accent-bg); }
.share-title { padding: 0.3rem 0.7rem; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; align-items: center; margin-top: 0.7rem; }

/* Diary */
.diary-filter { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.diary-filter input { max-width: 160px; }
.diary-totals { margin-bottom: 0.6rem; }
.diary-scroll { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 0 0.7rem; }

/* Stats picker */
.stats-picker { position: relative; }
.stats-form { text-align: start; margin-top: 0.5rem; background: var(--accent-bg); border-radius: 10px; padding: 0.7rem; }
.section-gap { margin-top: 1.2rem; }

/* Social handles grid (person form) */
.social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
@media (max-width: 480px) { .social-grid { grid-template-columns: 1fr; } }

/* Landing */
.landing { text-align: center; }
.landing .hero { text-align: center; padding: 2.2rem 0 1.6rem; }
.landing .hero .logo { width: 72px; height: 72px; }
.landing .hero h1 { font-size: clamp(2rem, 6vw, 2.7rem); line-height: 1.12; margin: 0.9rem 0 0.6rem; }
.landing .hero-sub { color: var(--muted); max-width: 34rem; margin: 0 auto 1.2rem; }
.landing .small-hero { padding: 1rem 0 2rem; }
.landing-title { text-align: center; margin: 1rem 0; font-size: 1.15rem; }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 1rem; }
@media (max-width: 520px) { .feature-grid { grid-template-columns: 1fr; } }
.feature { margin-bottom: 0; }
.feature .f-icon { font-size: 1.5rem; }
.feature h3 { margin: 0.4rem 0 0.3rem; font-size: 0.95rem; }
.feature p { margin: 0; font-size: 0.85rem; }
.landing-privacy { padding: 1.4rem; }
.landing-privacy .btn { margin-top: 0.6rem; }

/* Support banner + FAB */
.support-banner {
  position: sticky; top: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 0.5rem 0.7rem;
  padding: 0.55rem 2.6rem;
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 30%, var(--card));
  font-size: 0.82rem;
}
.support-banner span { text-align: center; }
.support-banner .icon-btn {
  position: absolute; inset-inline-end: 0.6rem; top: 50%; transform: translateY(-50%);
}
/* The flex display above would otherwise override the hidden attribute. */
.support-banner[hidden], .support-fab[hidden], .quick-menu[hidden] { display: none; }

/* Bottom-right floating action stack: quick-add (+) always, support (♥) above
   it for free users. Sits just above the bottom nav. */
.fab-stack {
  position: fixed; z-index: 15;
  inset-inline-end: 1rem;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.7rem;
}
.support-fab {
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.support-fab svg {
  width: 26px; height: 26px; fill: #e11d48; stroke: none;
  animation: heartbeat 1.3s ease-in-out infinite;
  transform-origin: center;
}
@keyframes heartbeat {
  0%, 40%, 100% { transform: scale(1); }
  10% { transform: scale(1.22); }
  20% { transform: scale(1); }
  30% { transform: scale(1.15); }
}

/* Quick-add (+) button + its pop-up menu */
.quick-fab-wrap { position: relative; }
.quick-fab {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary); border: none; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.quick-fab svg {
  width: 27px; height: 27px; fill: none; stroke: #fff; stroke-width: 2.4;
  stroke-linecap: round; transition: transform 0.2s ease;
}
.quick-fab[aria-expanded="true"] svg { transform: rotate(45deg); }
.quick-menu {
  position: absolute; inset-inline-end: 0; bottom: calc(100% + 0.6rem);
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.45rem;
}
.quick-menu-item {
  display: inline-flex; align-items: center; gap: 0.55rem; white-space: nowrap;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0.55rem 0.95rem; font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  animation: quickPop 0.16s ease both;
}
.quick-menu-item svg {
  width: 19px; height: 19px; fill: none; stroke: var(--primary);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.quick-menu-item:hover { border-color: var(--primary); color: var(--primary); }
.quick-menu-item:hover svg { stroke: var(--primary); }
@keyframes quickPop {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Icon picker for the "first interaction" kind on the quick new-contact form */
.kind-picker { border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; margin: 0; }
.kind-picker legend { padding: 0 0.4rem; font-size: 0.9rem; font-weight: 600; }
.kind-opts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.kind-opt {
  display: inline-flex; flex-direction: column; align-items: center; gap: 0.25rem;
  min-width: 4.2rem; cursor: pointer; padding: 0.5rem 0.6rem;
  border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.kind-radio { position: absolute; opacity: 0; width: 0; height: 0; }
.kind-opt:has(.kind-radio:checked) {
  border-color: var(--primary); color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--card));
}
.kind-radio:focus-visible + .kind-ic { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.kind-ic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kind-lbl { font-size: 0.78rem; }

/* Relationship temperature */
.temp { flex-shrink: 0; font-size: 1rem; cursor: default; }
.tools-row { display: flex; gap: 0.6rem; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; }
.import-box form { margin-top: 0.5rem; }

/* Testimonial */
.landing-quote-box {
  text-align: center;
  border-inline-start: 4px solid var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
  padding: 1.4rem 1.2rem;
}
.landing-quote-box .quote {
  margin: 0.6rem auto 0; max-width: 36rem;
  font-family: var(--font-read);
  font-style: italic; font-size: 1.15rem; line-height: 1.65;
}
.landing-quote-box .quote footer { margin-top: 0.7rem; font-style: normal; font-size: 0.85rem; font-weight: 600; }
.cause { font-size: 0.9rem; color: var(--primary); font-weight: 600; }
.cause-hero { max-width: 36rem; margin: 0.8rem auto 0; }

/* Pricing page */
.pricing-page .pricing-hero { padding: 1.2rem 0 0.6rem; }
.pricing-page .pricing-hero .logo { width: 56px; height: 56px; }
.pricing-page .plans { text-align: center; margin-top: 1.2rem; }
.plan .f-icon { font-size: 1.7rem; }
/* Supporter card: red, beating heart (reuses the @keyframes heartbeat above). */
.plan .f-icon.heart {
  color: #e11d48;
  display: inline-block;
  transform-origin: center;
  animation: heartbeat 1.3s ease-in-out infinite;
}
.plan-features { font-size: 0.85rem; }
.plan-cta { margin-top: auto; }

/* Tutorial */
.tut-title { font-weight: 700; cursor: pointer; }
.tut-body { white-space: pre-line; font-size: 0.92rem; line-height: 1.6; }

/* Roadmap */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin-top: 0.6rem; }
@media (max-width: 480px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--accent-bg); border-radius: 12px; padding: 0.8rem 0.4rem; display: flex; flex-direction: column; gap: 0.15rem; }
.stat strong { font-size: 1.3rem; color: var(--primary); }
.stat span { font-size: 0.72rem; color: var(--muted); }
.roadmap-list { margin: 0; padding-inline-start: 1.2rem; line-height: 1.9; font-size: 0.92rem; }
.newsletter-row { display: flex; gap: 0.5rem; max-width: 26rem; margin: 0.4rem auto 0; }
.footer-links { padding: 1rem 0 2rem; }
.check-row { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; }
.check-row input { width: auto; }

/* Pricing */
.region-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.8rem 0 0.2rem; }
.chip-active { outline: 2px solid var(--chip, var(--primary)); }
.btn-col { display: flex; flex-direction: column; gap: 0.5rem; }
.donate-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.donate-custom { display: flex; gap: 0.5rem; align-items: center; flex: 1; min-width: 220px; }
.donate-custom input { max-width: 160px; }
@media (max-width: 520px) {
  .donate-row { justify-content: center; }
  /* On phones, drop the custom amount + submit onto their own centered line. */
  .donate-custom { flex-basis: 100%; min-width: 0; justify-content: center; }
}
.crypto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
@media (max-width: 520px) { .crypto-grid { grid-template-columns: 1fr; } }
.crypto-box { text-align: center; display: flex; flex-direction: column; gap: 0.4rem; align-items: center; }
.crypto-box .qr { background: #fff; padding: 6px; border-radius: 10px; }
.crypto-box .qr svg { display: block; width: 140px; height: 140px; }

/* Pricing plans */
/* Inverted-T layout: Free + Supporter side by side, Donate spanning below. */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 1rem; align-items: stretch; }
.plan-donate { grid-column: 1 / -1; }
@media (max-width: 560px) { .plans { grid-template-columns: 1fr; } .plan-donate { grid-column: auto; } }
.plan { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0; }
.plan h2 { margin: 0; }
.plan .price { font-size: 1.6rem; font-weight: 800; }
.plan-featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan .badge { align-self: flex-start; }
