/* Mob Check interface components. Uses tokens.css only. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--line);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary); font-weight: 600; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--text-heading); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: var(--text-title); font-weight: 600; line-height: 1.25; }
h3 { font-size: var(--text-lg); font-weight: 600; line-height: 1.3; }
p + p { margin-top: var(--space-3); }

.muted { color: var(--color-text-secondary); }
.small { font-size: var(--text-sm); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: 8px;
}

.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: 100;
  background: var(--color-primary); color: var(--color-on-primary);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-input);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: var(--space-4); }

/* ---------- Prototype banner ---------- */
.proto-banner {
  display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-1) var(--gutter);
  padding-top: var(--space-1);
  background: var(--color-sand);
  color: var(--color-text);
  font-size: var(--text-sm);
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}
.proto-banner button {
  min-height: 40px; padding: 0 var(--space-3);
  background: transparent; border: 1px solid var(--color-primary);
  border-radius: var(--radius-pill); cursor: pointer; font-weight: 600; font-size: var(--text-sm);
}

/* ---------- App shell ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) calc(var(--gutter) - 8px);
  padding-left: max(calc(var(--gutter) - 8px), env(safe-area-inset-left));
  padding-right: max(calc(var(--gutter) - 8px), env(safe-area-inset-right));
  background: var(--color-bg);
}
.topbar__brand {
  display: flex; align-items: center; gap: var(--space-2);
  margin-right: auto; padding: 0 var(--space-2); min-height: var(--touch);
  font-weight: 700; font-size: var(--text-lg); color: var(--color-primary); text-decoration: none;
}
.topbar__brand img { width: 36px; height: 36px; }

main {
  flex: 1;
  width: 100%;
  padding-bottom: calc(var(--nav-height) + var(--space-6) + env(safe-area-inset-bottom));
}
main:focus { outline: none; }
/* Headings are focused after each screen change so screen readers start there; they are not controls, so no focus box. */
[tabindex="-1"]:focus, [tabindex="-1"]:focus-visible { outline: none; }
.app--bare main { padding-bottom: 0; }

.screen {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4) var(--gutter) var(--space-6);
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
  animation: screen-in var(--motion-base) var(--ease);
}
.screen--wide { max-width: 960px; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.screen__header { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-5); }
.screen__header > div { flex: 1; min-width: 0; }
.screen__header p { margin-top: var(--space-1); }
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-5); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.section-title { font-size: var(--text-lg); font-weight: 600; margin: var(--space-6) 0 var(--space-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch); padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-button); border: 2px solid transparent;
  font-weight: 600; font-size: var(--text-body); line-height: 1.2;
  text-decoration: none; text-align: center; cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}
.btn svg { width: 22px; height: 22px; flex: none; }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn--primary { min-height: var(--button-height); background: var(--color-primary); color: var(--color-on-primary); }
.btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn--secondary { min-height: var(--button-height); background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn--secondary:hover:not(:disabled) { background: var(--color-sage); }
.btn--quiet { background: transparent; color: var(--color-primary); padding: var(--space-2) var(--space-3); text-decoration: underline; text-underline-offset: 3px; }
.btn--small { min-height: var(--touch); padding: var(--space-2) var(--space-4); font-size: var(--text-body); }
.btn--danger { min-height: var(--button-height); background: var(--color-error); color: #fff; }
.btn--block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--color-border); color: var(--color-text-secondary); border-color: transparent; cursor: not-allowed; }
.btn.btn--secondary:disabled { background: transparent; border-color: var(--color-border); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--touch); height: var(--touch); flex: none;
  border-radius: var(--radius-pill); border: 0; background: transparent;
  color: var(--color-primary); cursor: pointer; position: relative; text-decoration: none;
}
.icon-btn:hover { background: var(--color-sage); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn__dot {
  position: absolute; top: 10px; right: 11px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--color-clay); border: 2px solid var(--color-bg);
}
.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-peach); font-weight: 700; font-size: 1rem;
}

.button-stack { display: grid; gap: var(--space-3); }

/* ---------- Icons ---------- */
.icon { width: 24px; height: 24px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
}
.card--sage { background: var(--color-sage); border-color: transparent; }
.card--peach { background: var(--color-peach); border-color: transparent; }
.card--sand { background: var(--color-sand); border-color: transparent; }
.card--quiet { background: var(--color-quiet); border-color: transparent; }

.home-card {
  display: flex; align-items: center; gap: var(--space-4);
  min-height: 112px; padding: var(--space-5);
  border-radius: var(--radius-card);
  color: var(--color-text); text-decoration: none;
  transition: transform var(--motion-fast) var(--ease), box-shadow var(--motion-fast) var(--ease);
}
.home-card:hover { box-shadow: var(--shadow-card); transform: translateY(-1px); }
.home-card__icon {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, 0.7); color: var(--color-primary);
}
.home-card__icon svg { width: 30px; height: 30px; }
.home-card__body { flex: 1; min-width: 0; }
.home-card__body h2 { font-size: var(--text-title); }
.home-card__body p { margin-top: var(--space-1); color: var(--color-text-secondary); }
.home-card > .icon { color: var(--color-primary); }
.home-grid { display: grid; gap: var(--space-4); }

.greeting { margin: var(--space-2) 0 var(--space-5); }
.greeting h1 { font-size: 1.75rem; }

.next-event {
  display: flex; gap: var(--space-4); align-items: center;
  padding: var(--space-4); border-radius: var(--radius-card);
  background: var(--color-surface); border: 1px solid var(--color-border);
  color: inherit; text-decoration: none;
}
.date-badge {
  flex: none; width: 64px; min-height: 68px; border-radius: 16px;
  background: var(--color-sand); display: grid; place-content: center; text-align: center;
  padding: var(--space-2) 0;
}
.date-badge__month { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-clay-text); }
.date-badge__day { font-size: 1.625rem; font-weight: 700; line-height: 1.1; }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--space-2); }
.field + .field { margin-top: var(--space-5); }
.field label, .field legend, .field__label { font-weight: 600; font-size: var(--text-body); }
.field__hint { font-size: var(--text-sm); color: var(--color-text-secondary); }
.input, .select, .textarea {
  width: 100%; min-height: var(--button-height);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-input);
  font-size: var(--text-body);
}
.textarea { min-height: 112px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23173E35' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 44px; }
.input:focus, .select:focus, .textarea:focus { outline: 3px solid var(--color-focus); outline-offset: 1px; border-color: var(--color-primary); }
.input[aria-invalid="true"] { border-color: var(--color-error); border-width: 2px; }
.field__error { display: flex; gap: var(--space-2); align-items: flex-start; color: var(--color-error); font-size: var(--text-sm); font-weight: 600; }
.field__error .icon { width: 20px; height: 20px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

/* Visibility note that sits beside each personal field */
.visibility {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3); border-radius: var(--radius-input);
  background: var(--color-sage);
}
.visibility > .icon { margin-top: 2px; }
.visibility__body { flex: 1; min-width: 0; display: grid; gap: var(--space-2); }
.visibility__body label { font-weight: 600; font-size: var(--text-sm); }
.visibility .select { min-height: var(--touch); padding-top: var(--space-2); padding-bottom: var(--space-2); font-size: var(--text-sm); }

/* Radio choices shown as large tappable rows */
.choices { display: grid; gap: var(--space-2); }
.choice {
  display: flex; gap: var(--space-3); align-items: flex-start;
  min-height: var(--touch); padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border-strong); border-radius: var(--radius-input);
  background: var(--color-surface); cursor: pointer;
}
.choice input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--color-primary); flex: none; }
.choice:has(input:checked) { border-color: var(--color-primary); border-width: 2px; background: var(--color-sage); }
.choice__text { display: grid; gap: 2px; }
.choice__text span:first-child { font-weight: 600; }

.checkbox { display: flex; gap: var(--space-3); align-items: flex-start; min-height: var(--touch); padding: var(--space-2) 0; cursor: pointer; }
.checkbox input { width: 24px; height: 24px; margin: 1px 0 0; accent-color: var(--color-primary); flex: none; }

/* Sign-up step indicator */
.steps { margin-bottom: var(--space-5); }
.steps__bar { display: flex; gap: var(--space-1); margin-top: var(--space-2); }
.steps__bar span { flex: 1; height: 6px; border-radius: var(--radius-pill); background: var(--color-border); }
.steps__bar span.is-done { background: var(--color-primary); }
.steps__bar span.is-current { background: var(--color-clay); }

/* Back / Continue stay reachable above the keyboard */
.form-footer {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; gap: var(--space-3);
  margin: var(--space-6) calc(-1 * var(--gutter)) 0;
  padding: var(--space-3) var(--gutter);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}
.form-footer .btn { flex: 1; }
.form-footer .btn--secondary { flex: 0 1 40%; }

.person-entry { padding: var(--space-4); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-surface); }
.person-entry + .person-entry { margin-top: var(--space-4); }
.person-entry h3 { margin-bottom: var(--space-3); }

/* ---------- Tabs and segmented controls ---------- */
.tabs {
  display: flex; padding: var(--space-1); gap: var(--space-1);
  background: var(--color-quiet); border-radius: var(--radius-button);
}
.tabs button {
  flex: 1; min-height: var(--touch); border: 0; border-radius: 12px;
  background: transparent; font-weight: 600; cursor: pointer; color: var(--color-text-secondary);
}
.tabs button[aria-selected="true"], .tabs button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-card); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-card); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--color-border); }
.list__item {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: 64px; padding: var(--space-3) var(--space-4);
  color: inherit; text-decoration: none; width: 100%; background: none; border: 0; text-align: left; cursor: pointer;
}
a.list__item:hover, button.list__item:hover { background: var(--color-bg); }
.list__body { flex: 1; min-width: 0; }
.list__body > span { display: block; }
.list__title { font-weight: 600; }
.list__meta { font-size: var(--text-sm); color: var(--color-text-secondary); }
.list__icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--color-sage); flex: none; }
.list__icon .icon { width: 22px; height: 22px; }

/* ---------- Avatars ---------- */
/* A person's photo, in a circle like their initials */
.avatar--photo { overflow: hidden; background: var(--color-sage); }
.avatar--photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 1rem;
  background: var(--color-peach); color: var(--color-primary);
}
.avatar--sage { background: var(--color-sage); }
.avatar--sand { background: var(--color-sand); }
.avatar--surface { background: var(--color-surface); box-shadow: inset 0 0 0 2px var(--color-border); }
.avatar--hidden { background: var(--color-quiet); color: var(--color-text-secondary); }
.avatar--lg { width: 88px; height: 88px; font-size: 1.75rem; }
.avatar .icon { width: 22px; height: 22px; }
.avatar--lg .icon { width: 40px; height: 40px; }

.tag {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-pill);
  font-size: 0.875rem; font-weight: 600; line-height: 1.5;
  background: var(--color-quiet); color: var(--color-text);
}
.tag--sage { background: var(--color-sage); }
.tag--peach { background: var(--color-peach); }
.tag--sand { background: var(--color-sand); }

/* ---------- Family tree ---------- */
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); font-size: var(--text-sm); }
.legend__item { display: flex; align-items: center; gap: var(--space-2); }
.legend__line { width: 36px; height: 0; border-top: 3px solid var(--color-primary); }

.tree-scroll {
  overflow: auto; border-radius: var(--radius-card);
  background: var(--color-surface); border: 1px solid var(--color-border);
  -webkit-overflow-scrolling: touch;
}
/* All tree positions are in rem so the whole tree grows with text size */
.tree-zoom { margin: 0 auto; }
.tree-zoom > .tree { margin: 0; transform-origin: 0 0; }
/* The tree box with its zoom buttons tucked into the bottom corner, out of the way. */
.tree-frame { position: relative; }
.tree-scroll { touch-action: pan-x pan-y; overscroll-behavior: contain; padding-bottom: calc(var(--touch) + 12px); }
.tree-zoom-controls {
  position: absolute; right: 8px; bottom: 6px; z-index: 2;
  display: flex; overflow: hidden;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
.tree-zoom-btn {
  display: grid; place-items: center; width: var(--touch); height: var(--touch);
  border: 0; background: transparent; color: var(--color-primary); cursor: pointer; padding: 0;
}
.tree-zoom-btn + .tree-zoom-btn { border-left: 1px solid var(--color-border); }
.tree-zoom-btn svg { width: 22px; height: 22px; }
@media (hover: hover) { .tree-zoom-btn:hover { background: var(--color-sage); } }
.tree-zoom-btn:focus-visible { outline: 3px solid var(--color-focus, var(--color-primary)); outline-offset: -3px; }
.tree-zoom-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.tree { position: relative; margin: 0 auto; }
.tree svg.tree__lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tree__line { stroke: var(--color-primary); stroke-width: 2.5px; fill: none; vector-effect: non-scaling-stroke; }
.tree__line--ex { stroke-dasharray: 7 5; }
/* "Other family" links (an aunty by her own words) are dotted, so they never look like a family line. */
.tree__line--other { stroke-dasharray: 1 6; stroke-linecap: round; stroke-width: 3px; }
/* A thin gap in the tree's background colour around each family's lines, so a line crossing
   another family's line clearly passes over it rather than looking joined to it. */
.tree__halo { stroke: var(--color-surface); stroke-width: 8px; fill: none; vector-effect: non-scaling-stroke; stroke-linecap: butt; }
.tree__line { stroke-linecap: square; stroke-linejoin: miter; }
.tree__label {
  position: absolute; transform: translate(-50%, -50%);
  padding: 0 6px; border-radius: var(--radius-pill);
  background: var(--color-sand); border: 0;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap; line-height: 1.6;
}
.person-card {
  position: absolute; transform: translate(-50%, -50%);
  width: 9.5rem; min-height: 5.5rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: var(--space-2); text-align: center;
  background: var(--color-surface); border: 1.5px solid var(--color-border-strong);
  border-radius: 16px; cursor: pointer; color: inherit;
  font-size: 0.875rem; line-height: 1.25;
}
.person-card:hover { border-color: var(--color-primary); }
.person-card .avatar { width: 32px; height: 32px; font-size: 0.8125rem; }
.person-card .avatar .icon { width: 18px; height: 18px; }
.person-card__name { font-weight: 600; }
.person-card__rel { color: var(--color-text-secondary); font-size: 0.8125rem; }
.person-card--me { background: var(--color-sage); border-color: var(--color-primary); border-width: 2px; }
.person-card--passed { background: var(--color-quiet); border-style: dashed; }
/* Phones: smaller cards and the tree runs edge to edge (sizes match TREE_SIZES.compact in family.js) */
.tree--compact .person-card { width: 7rem; min-height: 4.5rem; padding: 6px; gap: 1px; border-radius: 12px; font-size: 0.8125rem; }
.tree--compact .person-card .avatar { width: 26px; height: 26px; font-size: 0.6875rem; }
.tree--compact .person-card__rel { font-size: 0.75rem; }
@media (max-width: 599px) {
  .tree-scroll { margin-left: calc(-1 * var(--gutter)); margin-right: calc(-1 * var(--gutter)); border-radius: 0; border-left: 0; border-right: 0; }
}

.suggestion { border-left: 6px solid var(--color-gold); }

/* ---------- Events ---------- */
.event-card { display: grid; grid-template-columns: auto 1fr; gap: var(--space-4); align-items: start; }
.event-card__actions { grid-column: 1 / -1; }
.event-card__body { flex: 1; min-width: 0; display: grid; gap: var(--space-2); }
.event-card__meta { display: grid; gap: var(--space-1); color: var(--color-text-secondary); font-size: var(--text-body); }
.event-card__meta div { display: flex; gap: var(--space-2); align-items: flex-start; }
.event-card__meta .icon { width: 20px; height: 20px; margin-top: 2px; }
.rsvp { display: grid; grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.rsvp button {
  min-height: var(--touch); padding: var(--space-2); white-space: nowrap;
  border-radius: var(--radius-pill); border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface); font-weight: 600; cursor: pointer;
}
.rsvp button[aria-pressed="true"] { background: var(--color-primary); color: var(--color-on-primary); border-color: var(--color-primary); }
.event-card--sorry .date-badge { background: var(--color-surface); }
.event-card--sorry .date-badge__month { color: var(--color-text-secondary); }

/* ---------- Cousin Check ---------- */
.check-hero { text-align: center; padding: var(--space-6) var(--space-4); }
.check-pair { display: flex; align-items: center; justify-content: center; gap: var(--space-3); margin-bottom: var(--space-5); }
.check-pair__link { width: 48px; height: 0; border-top: 3px dashed var(--color-gold); }
.check-pair__link--done { border-top: 3px solid var(--color-primary); }
.check-steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); text-align: left; }
.check-steps li { display: flex; gap: var(--space-3); align-items: flex-start; }
.check-steps li::before {
  counter-increment: step; content: counter(step);
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: var(--color-surface); font-weight: 700;
}
.code-box {
  font-size: 2rem; font-weight: 700; letter-spacing: 0.2em; text-align: center;
  padding: var(--space-4); border-radius: var(--radius-card);
  background: var(--color-surface); border: 2px dashed var(--color-gold);
}
.pending-dots { display: inline-flex; gap: 6px; }
.pending-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); animation: pulse 1.2s infinite var(--ease); }
.pending-dots span:nth-child(2) { animation-delay: 0.2s; }
.pending-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
:root[data-reduce-motion="true"] .pending-dots span { animation: none; opacity: 0.6; }
@media (prefers-reduced-motion: reduce) { .pending-dots span { animation: none; opacity: 0.6; } }
.result-rel { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }

/* ---------- Notices, states ---------- */
.notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); border-radius: var(--radius-card); background: var(--color-sand); }
.notice .icon { margin-top: 1px; }
.notice--error { background: var(--color-error-bg); }
.notice--error .icon { color: var(--color-error); }
.state { text-align: center; padding: var(--space-6) var(--space-4); display: grid; justify-items: center; gap: var(--space-3); }
.state__icon { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--color-sage); }
.state__icon .icon { width: 34px; height: 34px; }
.state--error .state__icon { background: var(--color-error-bg); color: var(--color-error); }
.state p { max-width: 32ch; }

.skeleton { border-radius: var(--radius-card); background: linear-gradient(90deg, var(--color-quiet) 25%, #F6F3EC 50%, var(--color-quiet) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
:root[data-reduce-motion="true"] .skeleton { animation: none; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- Settings ---------- */
.settings-group + .settings-group { margin-top: var(--space-5); }
.settings-group > h2 { font-size: var(--text-body); color: var(--color-text-secondary); font-weight: 600; margin: 0 0 var(--space-2) var(--space-1); }
.switch-row { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-3) var(--space-4); cursor: pointer; }
.switch-row input {
  appearance: none; flex: none; width: 52px; height: 32px; border-radius: 999px; margin: 0;
  background: var(--color-border-strong); position: relative; cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease);
}
.switch-row input::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: transform var(--motion-fast) var(--ease);
}
.switch-row input:checked { background: var(--color-primary); }
.switch-row input:checked::after { transform: translateX(20px); }

/* ---------- Bottom navigation ---------- */
/* While typing on a phone, the tabs and top bar step aside so the form and keyboard have the room. */
@media (max-width: 899px) {
  .keyboard-open .bottom-nav { display: none; }
  .keyboard-open main { padding-bottom: var(--space-6); }
  .keyboard-open .topbar { position: static; }
}
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
}
.bottom-nav ul { display: flex; list-style: none; margin: 0; padding: 0; width: 100%; max-width: var(--content-max); }
.bottom-nav li { flex: 1; }
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--nav-height); padding: var(--space-1);
  color: var(--color-text-secondary); text-decoration: none; font-size: 0.8125rem; font-weight: 600;
  text-align: center; line-height: 1.2;
}
.bottom-nav a .nav-pill { display: grid; place-items: center; width: 56px; height: 30px; border-radius: var(--radius-pill); transition: background-color var(--motion-fast) var(--ease); }
.bottom-nav a[aria-current="page"] { color: var(--color-primary); }
.bottom-nav a[aria-current="page"] .nav-pill { background: var(--color-sage); }

/* ---------- Toast and dialogs ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-height) + var(--space-4) + env(safe-area-inset-bottom)); z-index: 50;
  transform: translateX(-50%); width: min(calc(100% - 2 * var(--gutter)), 480px);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-input);
  background: var(--color-primary); color: var(--color-on-primary); box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none; transition: opacity var(--motion-base) var(--ease);
}
.toast.is-visible { opacity: 1; }
.app--bare ~ .toast { bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); }

dialog.sheet {
  width: min(100% - 2 * var(--space-4), 520px); max-height: calc(100dvh - 2 * var(--space-4));
  border: 0; border-radius: var(--radius-card); padding: var(--space-5);
  background: var(--color-bg); color: var(--color-text); box-shadow: 0 12px 48px rgba(23, 62, 53, 0.25);
}
dialog.sheet::backdrop { background: rgba(23, 62, 53, 0.4); }
dialog.sheet[open] { animation: screen-in var(--motion-base) var(--ease); }
.sheet__header { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-4); }
.sheet__header h2 { flex: 1; font-size: 1.375rem; padding-top: 8px; }

/* ---------- Welcome ---------- */
.welcome {
  min-height: calc(100dvh - 40px);
  display: grid; align-content: center; gap: var(--space-5);
  max-width: var(--content-max); margin: 0 auto;
  padding: var(--space-5) var(--gutter) calc(var(--space-5) + env(safe-area-inset-bottom));
  text-align: center;
}
.welcome__brand { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.welcome__brand img { width: 56px; height: 56px; }
.welcome__brand span { font-size: 1.5rem; font-weight: 700; }
.welcome__tagline { color: var(--color-text-secondary); font-size: var(--text-sm); letter-spacing: 0.02em; margin-top: var(--space-1); }
.welcome__art { width: 100%; max-width: 340px; margin: 0 auto; }
.welcome h1 { font-size: var(--text-welcome); font-weight: 700; }
.welcome__notice { text-align: left; }
.welcome__notice p + p { margin-top: var(--space-1); }
.welcome__lead { font-size: var(--text-lg); color: var(--color-text-secondary); margin-top: var(--space-2); }

/* ---------- Larger screens ---------- */
@media (min-width: 700px) {
  .home-grid { grid-template-columns: repeat(2, 1fr); }   /* four cards: two by two */
  .home-grid .home-card { flex-direction: column; align-items: flex-start; }
  .home-grid .home-card > .icon { display: none; }
  .events-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
  .events-grid > * + * { margin-top: 0 !important; }
}

/* Side rail on tablets and desktop */
@media (min-width: 900px) {
  .app--nav { padding-left: 104px; }
  .bottom-nav {
    top: 0; right: auto; width: 104px; flex-direction: column; justify-content: flex-start;
    border-top: 0; border-right: 1px solid var(--color-border); padding-top: 120px;
  }
  .bottom-nav ul { flex-direction: column; gap: var(--space-2); }
  main { padding-bottom: var(--space-6); }
  .toast { bottom: var(--space-6); }
  .screen { max-width: 760px; }
  .screen--wide { max-width: 1040px; }
  .screen--wide > .stack-lg > .field, .screen--wide > .stack-lg > .btn--block, .screen--wide > .btn--block { max-width: 420px; }
  /* The family tree uses the whole width beside the side rail; words and buttons keep a readable width */
  .screen--tree { max-width: none; }
  .screen--tree .screen__header, .screen--tree p, .screen--tree .notice, .screen--tree .tabs { max-width: 760px; }
  .screen--tree .btn--block, .screen--tree .field { max-width: 420px; }
}

/* Phones turned sideways: use the width, keep content above the nav */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --nav-height: 56px; }
  .topbar { position: static; padding-top: 0; padding-bottom: 0; }
  .greeting { margin: 0 0 var(--space-4); }
  .greeting h1 { font-size: var(--text-heading); }
  .screen { padding-top: var(--space-2); }
  .home-card { min-height: 0; padding: var(--space-4); }
  .bottom-nav a { flex-direction: row; gap: var(--space-2); }
  .welcome { grid-template-columns: 1fr 1fr; align-items: center; text-align: left; min-height: auto; max-width: 900px; }
  .welcome__brand { justify-content: flex-start; }
  .welcome__art { grid-row: span 3; max-width: 300px; }
  .home-grid { grid-template-columns: repeat(3, 1fr); }
  .home-grid .home-card { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
  .home-grid .home-card > .icon { display: none; }
  .home-card__icon { width: 44px; height: 44px; }
  .screen { max-width: 860px; }
  .check-hero { padding: var(--space-4); }
}

/* Very small phones */
@media (max-width: 340px) {
  :root { --gutter: 16px; }
  .form-footer { flex-direction: column-reverse; }
  .form-footer .btn--secondary { flex: 1; }
}
/* Note above people in the tree who are not linked to anyone yet */
.tree__row-note { position: absolute; left: 0; right: 0; text-align: center; font-size: 0.8125rem; color: var(--color-text-secondary); }
/* The person whose close family the tree is showing (when not you) */
.person-card--focus { border-color: var(--color-primary); border-width: 2px; box-shadow: 0 0 0 3px var(--color-sage); }
.tree-focus { margin-bottom: var(--space-3); flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }

/* ---------- Family organiser: you at the top, family folding out ---------- */
.org { display: grid; gap: var(--space-3); }
.org-root { border: 2px solid var(--color-primary); border-radius: var(--radius-card); background: var(--color-sage); }
.org-section { border: 1px solid var(--color-border); border-radius: var(--radius-card); background: var(--color-surface); overflow: hidden; }
.org-section__head, .org-fold > summary { list-style: none; cursor: pointer; }
.org-section__head::-webkit-details-marker, .org-fold > summary::-webkit-details-marker { display: none; }
.org-section__head { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-3) var(--space-4); font-weight: 600; }
.org-section__head > span:first-child { flex: 1; }
.org-section > .org-list { border-top: 1px solid var(--color-border); }
.org-section__head > .icon:last-child, .org-fold > summary > .icon:last-child { transition: transform var(--motion-fast) var(--ease); }
.org-section[open] > .org-section__head > .icon:last-child, .org-fold[open] > summary > .icon:last-child { transform: rotate(180deg); }
.org-count {
  margin-left: auto; min-width: 1.75rem; padding: 0 8px; border-radius: var(--radius-pill);
  background: var(--color-sand); font-size: var(--text-sm); font-weight: 600; text-align: center; line-height: 1.6;
}
.org-list { margin: 0; }
.org-fold[open] > summary { background: var(--color-bg); }
.org-inner { margin: 0 0 var(--space-3) var(--space-5); padding-left: var(--space-3); border-left: 3px solid var(--color-sage); }
.org-heading { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-secondary); }
.org-details { margin-top: var(--space-2); }

/* "How are they family?" on the add-someone form, said back as a sentence */
.rel-pick__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-2); }
.rel-pick__say { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-card); background: var(--color-sage); font-weight: 600; }
/* Five tabs: keep each label on one line */
.bottom-nav a { white-space: nowrap; }
@media (max-width: 430px) { .bottom-nav a { font-size: 0.75rem; } }

/* A deceased relative shown in the living tree only because they link living family: faded */
.person-card--connector { opacity: 0.6; }

/* Phones that draw the app under the status bar (the Android and iPhone apps, iPhone home-screen
   web apps): keep everything below it, and keep a solid strip behind the status bar. */
.app { padding-top: env(safe-area-inset-top, 0px); }
.topbar { top: env(safe-area-inset-top, 0px); }
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: env(safe-area-inset-top, 0px); background: var(--color-bg);
}

/* ---------- Family messages ---------- */
.compose .pick__list { display: grid; gap: 0; margin-top: var(--space-2); max-height: 22rem; overflow-y: auto; }
.pick__item { align-items: center; border-bottom: 1px solid var(--color-border); }
.pick__item .avatar { width: 32px; height: 32px; font-size: 0.75rem; }
.messages { margin-top: var(--space-3); }
.message { display: grid; gap: var(--space-3); }
.message__head { display: flex; gap: var(--space-3); align-items: center; }
.message__who { min-width: 0; }
.message__author { font-size: var(--text-body); font-weight: 700; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.message__new { font-size: 0.75rem; }
.message__seen .tag { display: inline-flex; align-items: center; gap: 6px; }
.message__seen .tag .icon { width: 16px; height: 16px; }
.message__body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--text-body); }
.message__replies { list-style: none; margin: 0; padding: 0 0 0 var(--space-4); border-left: 3px solid var(--color-sage); display: grid; gap: var(--space-3); }
.message__reply-form { display: flex; gap: var(--space-2); }
.message__reply-form .input { flex: 1; min-width: 0; }
.message__actions { justify-content: flex-end; }

/* Plain bulleted lists in cards (the privacy summary) */
.bullets { margin: 0; padding-left: 1.25em; display: grid; gap: var(--space-2); }
.bullets li { list-style: disc; }
/* Date and time boxes shrink to share a row instead of running into each other */
.input[type="date"], .input[type="time"] { min-width: 0; width: 100%; }

/* The "something new" dot on Messages in the main menu */
.bottom-nav a .nav-pill { position: relative; }
.nav-dot { position: absolute; top: 1px; right: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--color-clay, #B86442); box-shadow: 0 0 0 2px var(--color-surface); }

/* Add or change a person's photo, in their details */
.photo-actions { gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
.photo-actions .btn svg { width: 20px; height: 20px; }
input[data-photo-input]:focus-visible + label { outline: 3px solid var(--color-focus); outline-offset: 2px; }
