/* KaGae styles. The family navigator is ported from the Kinfolk prototype (MLK.Family/index.html);
   app chrome (sign-in, forms, group list) follows the same tokens. Theme: Auto follows the system; Light/Dark set data-theme on <html>. */
:root {
  --ink: #183a32;
  --muted: #5f7169;
  --paper: #f7f2e8;
  --card: #fffdf8;
  --stage: #fcf9f2;
  --line: #d8ded4;
  --pine: #215747;
  --leaf: #9aae73;
  --gold: #e6bd68;
  --family-tag: #8a5a12;
  --soft: #e6f0e9;
  --radius: 24px;
  --danger: #9b2c2c;
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --stroke: rgb(var(--accent-rgb) / .42);

  /* Surfaces + tints (themeable) */
  --surface: #ffffff;
  --surface-rgb: 255 255 255;
  --accent-rgb: 33 87 71;
  --shadow-rgb: 24 58 50;
  --pine-bg: #215747;
  --on-accent: #ffffff;
  --tile: #f5f2e9;
  --hero-2: #f6f1d9;
  --toast-bg: #183a32;
  --glow-1: rgba(230,189,104,.24);
  --glow-2: rgba(154,174,115,.18);
  --photo-1a: #fff9e9; --photo-1b: #e6f0e9;
  --photo-2a: #f8ebe5; --photo-2b: #f5d9bd;
  --photo-3a: #e6eef2; --photo-3b: #d1dfca;
  color-scheme: light;

  /* Family sides (relative to "you") */
  --side-core: linear-gradient(135deg, #215747, #8fa868);
  --side-paternal: linear-gradient(135deg, #9c4f2b, #dcad62);
  --side-maternal: linear-gradient(135deg, #2c5876, #85adc0);
  --side-inlaw: linear-gradient(135deg, #7a465a, #d3a2b0);

  /* Relationship-type palette (shape + colour, never colour alone) */
  --t-biological: #215747;
  --t-adoptive: #74508a;
  --t-step: #8f5c12;
  --t-guardian: #3b5d78;
  --t-spouse: #8a4357;
  --t-partner: #8a4357;
}
/* Dark theme: follows the system unless the viewer picks Light or Dark in Preview settings */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e4ece7;
    --muted: #9db0a7;
    --paper: #111714;
    --card: #19211d;
    --stage: #151c19;
    --line: #2b3732;
    --pine: #8fd0b1;
    --family-tag: #e6bd68;
    --soft: #213029;
    --gold: #d9b064;
    --surface: #222c27;
    --surface-rgb: 34 44 39;
    --accent-rgb: 143 208 177;
    --shadow-rgb: 0 0 0;
    --pine-bg: #2b6955;
    --tile: #1f2824;
    --hero-2: #26271c;
    --toast-bg: #2b6955;
    --glow-1: rgba(217,176,100,.07);
    --glow-2: rgba(143,208,177,.05);
    --photo-1a: #2a2c22; --photo-1b: #1f2d27;
    --photo-2a: #2f2523; --photo-2b: #33291f;
    --photo-3a: #1f2a30; --photo-3b: #232d22;
    --t-biological: #8fd0b1;
    --t-adoptive: #c6a6dc;
    --t-step: #e0b26a;
    --t-guardian: #9fc3de;
    --t-spouse: #e7a3b5;
    --t-partner: #e7a3b5;
    --danger: #f1a3a3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e4ece7;
  --muted: #9db0a7;
  --paper: #111714;
  --card: #19211d;
  --stage: #151c19;
  --line: #2b3732;
  --pine: #8fd0b1;
  --family-tag: #e6bd68;
  --soft: #213029;
  --gold: #d9b064;
  --surface: #222c27;
  --surface-rgb: 34 44 39;
  --accent-rgb: 143 208 177;
  --shadow-rgb: 0 0 0;
  --pine-bg: #2b6955;
  --tile: #1f2824;
  --hero-2: #26271c;
  --toast-bg: #2b6955;
  --glow-1: rgba(217,176,100,.07);
  --glow-2: rgba(143,208,177,.05);
  --photo-1a: #2a2c22; --photo-1b: #1f2d27;
  --photo-2a: #2f2523; --photo-2b: #33291f;
  --photo-3a: #1f2a30; --photo-3b: #232d22;
  --t-biological: #8fd0b1;
  --t-adoptive: #c6a6dc;
  --t-step: #e0b26a;
  --t-guardian: #9fc3de;
  --t-spouse: #e7a3b5;
  --t-partner: #e7a3b5;
  --danger: #f1a3a3;
  color-scheme: dark;
}
:root { --t-foster: var(--t-guardian); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; margin: 0; color: var(--ink); font: 16px/1.5 var(--sans);
  background:
    radial-gradient(circle at 6% 3%, var(--glow-1), transparent 24rem),
    radial-gradient(circle at 93% 96%, var(--glow-2), transparent 29rem),
    var(--paper);
}
button { font: inherit; }
a { color: var(--pine); }
h1 { margin: 0 0 8px; font: 600 clamp(1.6rem, 4.4vw, 2.5rem)/1.08 var(--serif); letter-spacing: -.025em; }
h2 { margin: 0 0 8px; font: 600 1.4rem/1.15 var(--serif); }
h3 { margin: 0; font: 600 1.1rem var(--serif); }
.quiet { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.eyebrow { margin: 0 0 .5rem; color: var(--pine); font: 700 .72rem var(--sans); letter-spacing: .13em; text-transform: uppercase; }
.eyebrow a { color: inherit; text-decoration: none; }

/* ---------- Header ---------- */
.header {
  width: min(1040px, calc(100% - 32px)); margin: auto; padding: 22px 0 10px;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font: 600 1.2rem var(--serif); text-decoration: none; }
.brand-large { font-size: 1.8rem; justify-content: center; margin-bottom: 18px; }
.mark { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--pine-bg) url("../icons/icon.svg") center / cover; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.head-button {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 12px 7px 8px; border: 1px solid rgb(var(--accent-rgb) / .18);
  border-radius: 999px; color: var(--pine); background: rgb(var(--surface-rgb) / .55); cursor: pointer; font: 700 .76rem var(--sans); text-decoration: none;
}
.head-button:hover, .head-button:focus-visible { outline: none; background: var(--surface); border-color: rgb(var(--accent-rgb) / .38); }
.head-button i {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  color: var(--on-accent); background: var(--pine-bg); font: italic 700 .78rem var(--serif);
}
.head-button svg { width: 18px; height: 18px; }
.head-button .avatar { width: 22px; font-size: .55rem; }
.head-button kbd { margin-left: 4px; }
kbd { padding: 1px 6px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface); font: 500 .68rem var(--sans); }
main { width: min(1040px, calc(100% - 32px)); margin: auto; padding: 4px 0 54px; }
main:focus { outline: none; }
.page { max-width: 640px; margin: 0 auto; }
.intro { margin: 12px 0 20px; }
.auth-shell { width: min(440px, calc(100% - 32px)); padding-top: 9vh; }

/* ---------- Avatars (one shape everywhere, tinted by family side) ---------- */
.avatar {
  flex: none; display: grid; place-items: center; aspect-ratio: 1; border-radius: 50%;
  color: var(--on-accent); background: var(--side-core); font: 700 1rem var(--sans); letter-spacing: .02em;
}
.side-core { background: var(--side-core); }
.side-paternal { background: var(--side-paternal); }
.side-maternal { background: var(--side-maternal); }
.side-inlaw { background: var(--side-inlaw); }
/* Illustrated placeholder portraits (faceless on purpose: no uncanny stand-ins for real relatives) */
.avatar.photo { overflow: hidden; }
.avatar.photo svg { display: block; width: 100%; height: 100%; }
.avatar.private { background: linear-gradient(135deg, #aab3ab, #d9ddd5); }
/* Remembered (deceased): softened, never greyed out entirely */
.avatar.passed { filter: saturate(.35) brightness(1.05); }
.portrait.passed { box-shadow: 0 10px 24px rgb(var(--accent-rgb) / .18); }
.memoriam {
  display: inline-flex; align-items: center; gap: 5px; margin-left: 8px; padding: 2px 8px; border-radius: 999px;
  color: var(--muted); background: rgb(var(--surface-rgb) / .7); border: 1px solid var(--line);
  font: 700 .62rem var(--sans); letter-spacing: .08em; text-transform: uppercase; vertical-align: 2px;
}

/* ---------- Generation cues ---------- */
.gen-cue {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--pine); font: 700 .68rem var(--sans); letter-spacing: .13em; text-transform: uppercase;
}
.gen-cue::before, .gen-cue::after { content: ""; flex: 0 1 46px; height: 1px; background: rgb(var(--accent-rgb) / .22); }
.gen-cue span { padding: 2px 8px; background: var(--stage); }
.gen-cue small { color: var(--muted); font: 500 .72rem var(--sans); letter-spacing: 0; text-transform: none; }
.gen-tag { color: var(--muted); font: .74rem var(--sans); }

/* ---------- Relationship labels + type glyphs ---------- */
.rel-label {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
  color: var(--t-biological); font: 700 .64rem var(--sans); letter-spacing: .08em; text-transform: uppercase;
  line-height: 1.25;
}
.rel-label.t-adoptive { color: var(--t-adoptive); }
.rel-label.t-step { color: var(--t-step); }
.rel-label.t-guardian { color: var(--t-guardian); }
.rel-label.t-spouse { color: var(--t-spouse); }
.rel-label.t-partner { color: var(--t-partner); }
.glyph { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.glyph.half { width: 9px; height: 5px; border-radius: 9px 9px 0 0; margin-top: 3px; }
.glyph.adoptive { background: transparent; border: 1.5px solid currentColor; }
.glyph.step { background: linear-gradient(90deg, currentColor 50%, transparent 50%); border: 1.5px solid currentColor; }
.glyph.guardian { border-radius: 2px; background: transparent; border: 1.5px solid currentColor; }
.glyph.spouse { width: 10px; height: 10px; background: transparent; border: 3px double currentColor; }
.glyph.partner { width: 9px; height: 9px; background: transparent; border: 1.5px dashed currentColor; }

.card-text { display: grid; gap: 3px; min-width: 0; }
.card-text strong { display: -webkit-box; overflow: hidden; font: 600 .95rem/1.2 var(--serif); -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.card-text .sub { color: var(--muted); font: .74rem var(--sans); }

/* ---------- Kin card: shared by parents, partner and children ---------- */
.kin-card {
  position: relative; z-index: 2; width: 100%;
  display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 11px; padding: 10px;
  border: 1px solid rgb(var(--accent-rgb) / .08); border-radius: 16px; color: var(--ink); background: var(--surface); cursor: pointer;
  text-align: left; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.kin-card .avatar { width: 48px; font-size: .92rem; }
.kin-card:hover, .kin-card:focus-visible, .person-card:hover, .person-card:focus-visible {
  outline: none; transform: translateY(-2px); border-color: rgb(var(--accent-rgb) / .25); background: var(--surface); box-shadow: 0 9px 18px rgb(var(--shadow-rgb) / .11);
}

/* Depth hint: a tag on the card edge showing the next generation beyond (up for parents, down for children) */
.depth {
  position: absolute; right: 10px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 3px;
  border: 1px solid rgb(var(--accent-rgb) / .14); border-radius: 999px; color: var(--pine); background: var(--card);
  font: 700 .62rem var(--sans); box-shadow: 0 2px 6px rgb(var(--shadow-rgb) / .08);
}
.depth.up { top: -10px; }
.depth.down { bottom: -10px; }
.kin-card .depth .avatar { width: 16px; border: 1.5px solid var(--card); font-size: .42rem; }
.kin-card .depth .avatar + .avatar { margin-left: -7px; }

/* Former partners: a quiet line under the current partner, never hidden, never centre stage */
.former {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: center; gap: 8px; width: 100%; margin-top: 8px; padding: 6px 8px;
  border: 0; border-radius: 12px; color: var(--muted); background: transparent; cursor: pointer; text-align: left; font: .74rem/1.3 var(--sans);
}
.former:hover, .former:focus-visible { outline: none; background: rgb(var(--surface-rgb) / .75); }
.former .avatar { width: 26px; font-size: .55rem; opacity: .85; }
.former b { color: var(--ink); font-weight: 700; }

/* Empty slots are invitations, not gaps */
.ghost { border: 1.5px dashed rgb(var(--accent-rgb) / .28) !important; background: rgb(var(--surface-rgb) / .45) !important; color: var(--pine); }
.ghost .avatar { color: var(--pine); background: transparent; border: 1.5px dashed rgb(var(--accent-rgb) / .35); font: 400 1.3rem var(--sans); }
.ghost strong { font: 700 .86rem var(--sans) !important; }
.ghost:hover, .ghost:focus-visible { background: var(--surface) !important; border-color: rgb(var(--accent-rgb) / .5) !important; }

/* ---------- Parents ---------- */
.parent-stage {
  position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  max-width: 570px; margin: 0 auto; padding: 38px 18px 18px; border: 1px solid rgb(var(--accent-rgb) / .14);
  border-radius: 22px; background: var(--stage);
}
.parent-stage > .gen-cue { position: absolute; top: 12px; left: 0; right: 0; }

/* Lines from parents converging on the focused person */
.lineage { position: relative; z-index: 2; max-width: 570px; height: 62px; margin: 0 auto -15px; pointer-events: none; }
.lineage svg { position: absolute; top: 0; left: 0; width: 100%; height: 40px; overflow: visible; }
.lineage path, .spine path {
  fill: none; stroke: var(--stroke); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke;
}
.lineage path.dashed, .spine path.dashed { stroke-dasharray: 2 5; stroke: rgb(var(--accent-rgb) / .32); }
.spine circle { fill: var(--pine); stroke: var(--card); stroke-width: 2; }
.focus-pill {
  position: absolute; top: 36px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 13px; border-radius: 999px;
  color: var(--on-accent); background: var(--pine-bg); box-shadow: 0 6px 14px rgb(var(--accent-rgb) / .25);
  font: 700 .68rem var(--sans); letter-spacing: .13em; text-transform: uppercase; white-space: nowrap;
}

/* ---------- Focused profile ---------- */
.profile {
  position: relative; overflow: hidden; border: 1px solid rgb(var(--accent-rgb) / .13); border-radius: var(--radius);
  background: var(--card); box-shadow: 0 24px 58px rgb(var(--shadow-rgb) / .11);
}
.profile-top {
  display: grid; grid-template-columns: 116px minmax(0, 1fr) 230px; align-items: center; gap: 23px;
  padding: 38px 28px 28px; background: linear-gradient(135deg, var(--soft), var(--hero-2));
}
.portrait {
  width: 116px; border: 5px solid rgb(var(--surface-rgb) / .85); box-shadow: 0 10px 24px rgb(var(--accent-rgb) / .22);
  font-size: 2.6rem;
}
.back-button {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 10px; padding: 6px 11px 6px 8px;
  border: 1px solid rgb(var(--accent-rgb) / .18); border-radius: 999px; color: var(--pine);
  background: rgb(var(--surface-rgb) / .7); cursor: pointer; font: 700 .76rem var(--sans);
}
.back-button:hover, .back-button:focus-visible { outline: none; background: var(--surface); border-color: rgb(var(--accent-rgb) / .38); }
.back-button[hidden] { display: none; }
.profile-top h2 { margin: 0; font: 600 clamp(2rem, 5vw, 3rem)/1.05 var(--serif); letter-spacing: -.03em; overflow-wrap: anywhere; }
.detail { margin: .45rem 0 0; color: var(--muted); }
.bio { max-width: 580px; margin: .8rem 0 0; line-height: 1.55; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.action-button {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border: 1px solid rgb(var(--accent-rgb) / .18); border-radius: 999px; color: var(--pine);
  background: rgb(var(--surface-rgb) / .62); cursor: pointer; font: 700 .76rem var(--sans);
}
.action-button:hover, .action-button:focus-visible { outline: none; background: var(--surface); border-color: rgb(var(--accent-rgb) / .38); }
.path-panel {
  margin-top: 12px; padding: 12px 14px; border: 1px dashed rgb(var(--accent-rgb) / .32); border-radius: 14px;
  background: rgb(var(--surface-rgb) / .65);
}
.path-panel[hidden] { display: none; }
.path-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.path-node { padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font: 700 .76rem var(--sans); }
.path-node.is-you { border-color: transparent; color: var(--on-accent); background: var(--pine-bg); }
.path-link { color: var(--muted); font: .72rem var(--sans); }
.path-panel p { margin: 9px 0 0; color: var(--muted); font: .76rem/1.4 var(--sans); }

.partner-slot { align-self: stretch; display: grid; align-content: center; border-left: 1px solid rgb(var(--accent-rgb) / .16); padding-left: 18px; }
.partner-slot[hidden] { display: none; }
.partner-slot .kin-card { background: rgb(var(--surface-rgb) / .82); }

/* ---------- Children: hang directly off the focused person ---------- */
.child-band { position: relative; padding: 22px 22px 24px; border-top: 1px solid rgb(var(--accent-rgb) / .1); }
.child-band[hidden] { display: none; }
.child-band > .gen-cue { position: relative; z-index: 2; margin-bottom: 16px; }
.child-band > .gen-cue span { background: var(--card); }
.spine { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.child-grid {
  position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 34px;
  max-width: 570px; margin: 0 auto;
}
.child-grid.single { grid-template-columns: minmax(0, 1fr); max-width: 268px; }

/* ---------- Siblings (same generation) ---------- */
.relation { min-width: 0; padding: 20px 0 18px 22px; border-top: 1px solid var(--line); }
.relation-head { display: flex; align-items: center; gap: .6rem; margin: 0 22px .8rem 0; }
.relation-head .count { margin-left: auto; }
.count {
  display: grid; place-items: center; min-width: 25px; height: 25px; padding: 0 .45rem;
  border-radius: 999px; color: var(--pine); background: var(--soft); font: 700 .76rem var(--sans);
}
.memory-strip, .family-rail {
  display: flex; gap: 10px; overflow-x: auto; padding: 3px 22px 7px 1px;
  scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--leaf) transparent;
}
.family-rail::-webkit-scrollbar, .memory-strip::-webkit-scrollbar { height: 6px; }
.family-rail::-webkit-scrollbar-thumb, .memory-strip::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--leaf); }
.person-card {
  flex: 0 0 132px; display: grid; justify-items: start; align-content: start; gap: 9px; padding: 12px; scroll-snap-align: start;
  border: 1px solid transparent; border-radius: 17px; color: var(--ink); background: var(--tile);
  cursor: pointer; text-align: left; transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.person-card .avatar { width: 54px; }
.person-card .card-text { width: 100%; }

/* ---------- Family memories ---------- */
.memories { padding: 16px 0 18px 22px; border-top: 1px solid var(--line); background: rgb(var(--surface-rgb) / .45); }
.memories-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin: 0 22px 10px 0; }
.memories-head h3 { white-space: nowrap; }
.memory-card {
  flex: 0 0 168px; display: grid; grid-template-rows: 62px auto; gap: 8px; padding: 8px 8px 11px;
  border-radius: 15px; color: var(--ink); background: var(--surface); border: 1px solid rgb(var(--accent-rgb) / .1);
  scroll-snap-align: start;
}
.memory-photo { display: grid; place-items: center; border-radius: 10px; color: rgb(var(--accent-rgb) / .55); background: linear-gradient(145deg, var(--photo-1a), var(--photo-1b)); }
.memory-card:nth-child(3n+2) .memory-photo { background: linear-gradient(145deg, var(--photo-2a), var(--photo-2b)); color: rgba(138,67,87,.5); }
.memory-card:nth-child(3n+3) .memory-photo { background: linear-gradient(145deg, var(--photo-3a), var(--photo-3b)); color: rgba(59,93,120,.5); }
.memory-photo svg { width: 26px; height: 26px; }
.memory-text { display: grid; gap: 3px; padding: 0 4px; }
.memory-text > span:first-child { color: var(--pine); font: 700 .62rem var(--sans); letter-spacing: .1em; text-transform: uppercase; }
.memory-text strong { font: 600 .92rem/1.2 var(--serif); }
.memory-text small { color: var(--muted); font: .72rem var(--sans); }
.memory-card.add {
  place-content: center; justify-items: center; grid-template-rows: auto; gap: 4px; border: 1.5px dashed rgb(var(--accent-rgb) / .28);
  background: transparent; color: var(--pine); cursor: pointer; font: 700 .76rem var(--sans);
}
.memory-card.add b { font-size: 1.4rem; line-height: 1; }

/* Life timeline: a dated line runs through the strip; each card hangs from its year */
.memories .memory-strip {
  gap: 12px; padding-top: 30px;
  background: linear-gradient(rgb(var(--accent-rgb) / .2), rgb(var(--accent-rgb) / .2)) 0 10px / 100% 1px no-repeat local;
}
.memory-card { position: relative; font: inherit; text-align: left; }
button.memory-card { cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
button.memory-card:not(.add):hover, button.memory-card:not(.add):focus-visible { outline: none; transform: translateY(-2px); box-shadow: 0 9px 18px rgb(var(--shadow-rgb) / .11); }
.tl-year {
  position: absolute; top: -28px; left: 8px; display: flex; align-items: center; gap: 6px;
  color: var(--pine); font: 700 .72rem var(--sans); white-space: nowrap;
}
.tl-year::before { content: ""; width: 9px; height: 9px; border: 2px solid var(--card); border-radius: 50%; background: var(--pine-bg); box-shadow: 0 0 0 1px rgb(var(--accent-rgb) / .3); }
.memory-card.event { grid-template-rows: auto; align-content: start; gap: 10px; padding: 12px; background: rgb(var(--surface-rgb) / .55); border-style: dashed; }
.event-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--pine); background: var(--soft); }
.event-icon svg { width: 18px; height: 18px; }
.memory-card.event.remembered .event-icon { color: var(--muted); background: var(--tile); }
.with { display: flex; align-items: center; gap: 6px; margin-top: 4px; color: var(--muted); font: .7rem var(--sans); }
.with .avatar { width: 20px; border: 1.5px solid var(--surface); font-size: .45rem; }
.with .avatar + .avatar { margin-left: -9px; }

/* Memory detail */
.memory-dialog .memory-photo { height: 170px; margin-bottom: 16px; border-radius: 16px; }
.memory-dialog .memory-photo svg { width: 44px; height: 44px; }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px 6px; margin-top: 12px; }
.face {
  display: grid; justify-items: center; align-content: start; gap: 3px; padding: 6px 2px; border: 0; border-radius: 12px;
  color: var(--ink); background: transparent; cursor: pointer; text-align: center; font: inherit;
}
.face:hover, .face:focus-visible { outline: none; background: var(--soft); }
.face .avatar { width: 48px; margin-bottom: 3px; font-size: .8rem; }
.face b { font: 700 .78rem var(--sans); }
.face small { color: var(--muted); font: .66rem/1.25 var(--sans); }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

/* Children grouped by their other parent */
.group-label { grid-column: 1 / -1; position: relative; z-index: 2; display: flex; justify-content: center; margin: 4px 0 -8px; }
.group-label span { padding: 2px 10px; border-radius: 999px; background: var(--card); color: var(--muted); font: .74rem var(--sans); }
.group-label b { color: var(--pine); }

/* ---------- Side key ---------- */
.side-key { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 16px; margin: 24px 0 0; padding: 0; list-style: none; color: var(--muted); font: .76rem var(--sans); }
.side-key li { display: inline-flex; align-items: center; gap: 6px; }
.side-key i { width: 12px; height: 12px; border-radius: 50%; }

.close-button {
  display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%;
  color: var(--pine); background: var(--surface); cursor: pointer; font-size: 1.1rem;
}

/* ---------- Family map (generations) ---------- */
.map-row { padding: 12px 0 10px; border-top: 1px solid var(--line); }
.map-row:first-child { border-top: 0; }
.map-row h4 { margin: 0 0 8px; color: var(--muted); font: 700 .64rem var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.map-row.is-you h4 { color: var(--pine); }
.map-faces { display: flex; flex-wrap: wrap; gap: 6px 4px; }
.map-face {
  display: grid; justify-items: center; gap: 5px; width: 60px; padding: 5px 0; border: 0; border-radius: 12px;
  color: var(--ink); background: transparent; cursor: pointer; font: .7rem var(--sans);
}
.map-face:hover, .map-face:focus-visible { outline: none; background: var(--soft); }
.map-face .avatar { width: 40px; font-size: .7rem; }
.map-face span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-face.on-path .avatar { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--leaf); }
.map-face.is-current .avatar { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--pine); }
.map-face.is-current span { color: var(--pine); font-weight: 700; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font: .74rem var(--sans); }
.map-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 50%; vertical-align: -2px; }
/* ---------- Search ---------- */
.search {
  width: min(600px, calc(100% - 24px)); margin: 7vh auto auto; padding: 0; border: 0; border-radius: 20px;
  color: var(--ink); background: var(--card); box-shadow: 0 30px 80px rgb(var(--shadow-rgb) / .3);
}
.search::backdrop { background: rgb(var(--shadow-rgb) / .35); backdrop-filter: blur(2px); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.search-box svg { flex: none; width: 18px; height: 18px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: none; color: var(--ink); background: transparent; font: 1rem var(--sans); }
.search-hint { margin: 12px 16px 4px; color: var(--pine); font: 700 .64rem var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.find-map { max-height: min(64vh, 540px); padding: 0 16px 14px; overflow: auto; }
.find-map[hidden], .search-results[hidden] { display: none; }
.search-results { max-height: min(60vh, 440px); margin: 0; padding: 2px 8px 10px; overflow: auto; list-style: none; }
.result { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; }
.result[aria-selected="true"] { background: var(--soft); }
.result .avatar { width: 38px; font-size: .75rem; }
.result strong { display: block; font: 600 .95rem/1.2 var(--serif); }
.result small, .result .when { color: var(--muted); font: .74rem var(--sans); }
.search-empty { padding: 14px 16px 20px; color: var(--muted); font: .86rem var(--sans); }
/* ---------- Navigation transition ---------- */
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2,.75,.15,1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.fallback-swap .profile, .fallback-swap .parent-stage { animation: rise .35s ease both; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .fallback-swap .profile, .fallback-swap .parent-stage { animation: none; }
  .toast { transition: none; }
}

/* ---------- Additions for the real app ---------- */
.kin-card, .person-card, .former, .back-button, .action-button, .map-face { text-decoration: none; }
.rel-label.t-foster { color: var(--t-foster); }
.glyph.foster { border-radius: 2px; background: transparent; border: 1.5px solid currentColor; }
.avatar.private { color: transparent; }
.avatar svg { display: block; width: 100%; height: 100%; }
.detail .memoriam { margin-left: 8px; }
.child-grid > .group-label .action-button { margin-top: 4px; }
.map-row.unconnected h4 { color: var(--muted); }
.side-key i.side-core { background: var(--side-core); }
.side-key i.side-paternal { background: var(--side-paternal); }
.side-key i.side-maternal { background: var(--side-maternal); }
.side-key i.side-inlaw { background: var(--side-inlaw); }
.loading-veil { opacity: .55; transition: opacity .2s ease; }

/* Dialogs (Find, Settings) share the prototype's dialog look */
.about {
  width: min(640px, calc(100% - 24px)); max-height: calc(100% - 48px); padding: 0; border: 0; border-radius: 22px;
  color: var(--ink); background: var(--card); box-shadow: 0 30px 80px rgb(var(--shadow-rgb) / .3);
}
.about::backdrop { background: rgb(var(--shadow-rgb) / .35); backdrop-filter: blur(2px); }
.about-inner { padding: 24px 24px 22px; }
.about-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.about h2 { font-size: 1.6rem; }
.about h3 { margin-top: 22px; font-size: 1rem; }
.about p:not(.eyebrow) { margin: .4rem 0 0; color: var(--muted); font: .86rem/1.5 var(--sans); }
.about .side-key { justify-content: flex-start; margin-top: 10px; }
.about-links { display: grid; gap: 8px; margin-top: 18px; }
.close-button {
  display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%;
  color: var(--pine); background: var(--surface); cursor: pointer; font-size: 1.1rem;
}
.tabs { display: flex; gap: 4px; margin: 16px 0 4px; padding: 4px; border-radius: 999px; background: var(--soft); }
.tabs button { flex: 1; padding: 8px 10px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; font: 700 .8rem var(--sans); }
.tabs button[aria-pressed="true"], .tabs button[aria-checked="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 2px 6px rgb(var(--shadow-rgb) / .1); }

/* ---------- Cards, forms, buttons (sign-in, groups, add and edit) ---------- */
.card { display: block; padding: 20px; margin-bottom: 14px; border: 1px solid rgb(var(--accent-rgb) / .13); border-radius: var(--radius); background: var(--card); box-shadow: 0 12px 30px rgb(var(--shadow-rgb) / .06); }
.auth-card h1 { font-size: 1.8rem; }
.stack { display: grid; gap: 12px; margin-top: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span, .field > legend { color: var(--muted); font: 700 .78rem var(--sans); }
.stack .field { margin-bottom: 0; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); background: var(--surface); font: 16px var(--sans);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
.date-field { display: grid; gap: 8px; }
.date-row { display: grid; grid-template-columns: 1.2fr 1.4fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 19px; height: 19px; margin: 0; accent-color: var(--pine-bg); }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 72px !important; }
.password-field .link-button { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.link-button { border: 0; background: none; color: var(--pine); font: 700 .86rem var(--sans); cursor: pointer; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid rgb(var(--accent-rgb) / .22); border-radius: 999px; background: var(--surface); color: var(--pine);
  font: 700 .9rem var(--sans); text-decoration: none; cursor: pointer;
}
.button-primary { border-color: var(--pine-bg); background: var(--pine-bg); color: var(--on-accent); }
.button-full { width: 100%; margin-top: 4px; }
.button:disabled { opacity: .6; cursor: progress; }
.form-error { margin: 0; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.form-success { padding: 10px 14px; border-radius: 12px; background: var(--soft); color: var(--pine); }
.form-note { margin: 0; padding: 10px 12px; border-radius: 12px; color: var(--muted); background: var(--soft); font: .8rem/1.45 var(--sans); }
details > summary { cursor: pointer; }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--soft); }
.segmented button { flex: 1; padding: 8px 6px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; cursor: pointer; font: 700 .8rem var(--sans); }
.segmented button.on { color: var(--ink); background: var(--surface); box-shadow: 0 2px 6px rgb(var(--shadow-rgb) / .1); }
.crumbs { display: flex; gap: 8px; margin: 0 0 12px; font-size: .9rem; }
.rel-edit { padding: 12px 0; border-top: 1px solid var(--line); }
.rel-edit-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; }
.rel-edit-row select { width: auto; flex: 1 1 180px; }
.danger { color: var(--danger); }
.danger-button { border-color: var(--danger); color: var(--danger); }
.danger-zone h2 { font-size: 1.15rem; }

/* Family groups */
.group-list { display: grid; gap: 12px; margin: 0 0 18px; padding: 0; list-style: none; }
.group-card { display: grid; gap: 4px; margin: 0; color: var(--ink); text-decoration: none; }
.group-card:hover { border-color: rgb(var(--accent-rgb) / .4); }
.group-name { font: 600 1.2rem var(--serif); }
.profile-placeholder { display: flex; align-items: center; gap: 18px; }
.profile-placeholder .avatar { width: 84px; font-size: 1.6rem; }

/* ---------- Accessibility ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link {
  position: absolute; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; border-radius: 12px;
  color: var(--on-accent); background: var(--pine-bg); font: 700 .86rem var(--sans); transform: translateY(-160%);
}
.skip-link:focus { transform: none; }
:is(button, a, input, select, textarea, summary, [tabindex]:not(#name)):focus-visible { outline: 2px solid var(--pine) !important; outline-offset: 2px; }
#name:focus { outline: none; }
#name:focus-visible { outline: none; }

@media (max-width: 680px) {
  .header { padding-top: 16px; }
  .head-button .wide, .head-button kbd { display: none; }
  .head-button { padding: 7px; }
  .head-button.home { padding-right: 11px; }
  .header-actions { gap: 6px; }
  .result { grid-template-columns: 38px minmax(0, 1fr); }
  .result .when { display: none; }
  main { width: min(100% - 24px, 680px); }
  .profile-top { grid-template-columns: 78px 1fr; align-items: start; gap: 16px; padding: 32px 20px 22px; }
  .portrait { width: 78px; font-size: 1.8rem; border-width: 4px; }
  .partner-slot { grid-column: 1 / -1; padding: 14px 0 0; border-top: 1px solid rgb(var(--accent-rgb) / .16); border-left: 0; }
  .parent-stage { gap: 8px; padding: 36px 10px 10px; }
  .kin-card { grid-template-columns: 40px minmax(0, 1fr); gap: 8px; padding: 8px; }
  .kin-card .avatar { width: 40px; font-size: .82rem; }
  .card-text strong { font-size: .86rem; }
  .rel-label { letter-spacing: .05em; }
  .parent-stage .kin-card { padding-top: 14px; }
  .child-band { padding: 20px 10px 18px; }
  .child-grid { gap: 8px 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Members, activity, notice ---------- */
.link-box { display: flex; gap: 8px; }
.link-box input { flex: 1; min-width: 0; font: 600 1.1rem ui-monospace, Menlo, Consolas, monospace !important; letter-spacing: .06em; }
.invite-result h2 { font-size: 1.2rem; }
.member-list { margin: 0 0 12px; padding: 6px 16px; list-style: none; }
.member { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: 0; }
.member .avatar { width: 40px; font-size: .78rem; }
.member-text { display: grid; min-width: 0; }
.member-text strong { font: 600 1rem var(--serif); overflow-wrap: anywhere; }
.member-text small { color: var(--muted); font-size: .8rem; }
.member-actions { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.member-actions:empty { display: none; }
.member-actions select { width: auto; padding: 6px 10px; font-size: .9rem; }
@media (min-width: 560px) { .member { grid-template-columns: 40px minmax(0, 1fr) auto; } .member-actions { grid-column: 3; } }
.activity-day h2 { margin: 18px 0 8px; font: 700 .72rem var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.activity { margin: 0; padding: 4px 16px; list-style: none; }
.activity li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.activity li:first-child { border-top: 0; }
.activity-icon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: var(--pine); background: var(--soft); font: 700 .8rem var(--sans); }
.activity-icon.removed { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.notice h2 { margin-top: 18px; font-size: 1.1rem; }
.notice h2:first-child { margin-top: 0; }
.notice p, .notice li { color: var(--muted); font-size: .92rem; line-height: 1.55; }
.notice ul { padding-left: 1.2rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.nowrap { white-space: nowrap; }

/* ---------- Which family you're in, under the app name ---------- */
.header .brand { flex: 1 1 auto; min-width: 0; }
.header-actions { flex: none; }
.brand-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.brand-name { display: block; line-height: 1.1; }
.brand-family {
  display: block; max-width: 100%; margin-top: 2px; overflow: hidden; color: var(--family-tag);
  font: 600 .78rem/1.2 var(--sans); letter-spacing: .01em; text-overflow: ellipsis; white-space: nowrap;
}
@media (min-width: 560px) { .brand-family { max-width: 360px; font-size: .82rem; } }
/* Phones: "Back to you" becomes your avatar alone, so the family name fits */
@media (max-width: 479px) {
  .head-button.home.has-avatar { padding: 3px; }
  .head-button.home.has-avatar > span:not(.avatar) { display: none; }
  .header .brand { gap: .5rem; }
}
.activity li .button { align-self: center; min-height: 34px; padding: 6px 12px; font-size: .82rem; }
