/* ============ Farger og grunnstil ============ */
:root {
  --bg: #fff6e5;
  --bg-2: #ffeccb;
  --card: #ffffff;
  --ink: #2a2340;
  --ink-2: #4f4768;
  --muted: #8a819e;
  --line: #f0e0c4;
  --line-2: #e2cfaa;

  --sun: #ffc23c;
  --sun-soft: #fff0c2;
  --sun-ink: #7a4f00;
  --far: #19a199;
  --far-soft: #d3f2ee;
  --far-ink: #0b6660;
  --mor: #ff6b57;
  --mor-soft: #ffe0d9;
  --mor-ink: #a8321f;
  --bonus: #8b76ef;
  --bonus-soft: #ece8ff;
  --bonus-ink: #4b37b5;
  --neutral: #a99fc0;
  --neutral-soft: #efeaf8;
  --neutral-ink: #4f4768;
  --leaf: #5bb85f;
  --danger: #e0484d;

  --shadow-sm: 0 2px 6px rgba(42, 35, 64, 0.08);
  --shadow: 0 8px 22px rgba(42, 35, 64, 0.1), 0 2px 5px rgba(42, 35, 64, 0.06);
  --shadow-lg: 0 18px 50px rgba(42, 35, 64, 0.2);
  --radius: 24px;
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --top-h: 64px;
  --bottom-h: 0px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(255, 194, 60, 0.16) 0 140px, transparent 141px),
    radial-gradient(circle at 92% 30%, rgba(25, 161, 153, 0.08) 0 180px, transparent 181px),
    radial-gradient(circle at 20% 90%, rgba(255, 107, 87, 0.08) 0 200px, transparent 201px);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: 0.005em; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--far-ink); }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* Fargene til hver side av familien */
.side-far { --c: var(--far); --c-soft: var(--far-soft); --c-ink: var(--far-ink); }
.side-mor { --c: var(--mor); --c-soft: var(--mor-soft); --c-ink: var(--mor-ink); }
.side-home { --c: var(--sun); --c-soft: var(--sun-soft); --c-ink: var(--sun-ink); }
.side-none, .side-barn, .side-partner { --c: var(--neutral); --c-soft: var(--neutral-soft); --c-ink: var(--neutral-ink); }
.is-bonus { --c: var(--bonus); --c-soft: var(--bonus-soft); --c-ink: var(--bonus-ink); }

/* ============ Oppstart og innlogging ============ */
.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 8px; color: var(--ink-2); padding: 24px; }
.boot-tree { font-size: 72px; animation: sway 2.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, #bfe8ff 0%, #e8f6ff 45%, var(--bg) 75%);
}
.login__sky { position: absolute; inset: 0; pointer-events: none; }
.sun { position: absolute; top: 7%; right: 12%; width: 110px; height: 110px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 18px rgba(255, 194, 60, 0.25), 0 0 0 40px rgba(255, 194, 60, 0.12); }
.cloud { position: absolute; background: #fff; border-radius: 99px; height: 38px; opacity: 0.95; animation: drift 40s linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 50px; height: 50px; top: -24px; left: 18px; }
.cloud::after { width: 64px; height: 64px; top: -34px; left: 52px; }
.c1 { width: 150px; top: 18%; left: -10%; }
.c2 { width: 120px; top: 34%; left: 40%; animation-duration: 55s; animation-delay: -20s; }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(120vw); } }
.login__card {
  position: relative; width: min(420px, 100%); background: var(--card); border-radius: 32px; padding: 28px 26px 24px;
  box-shadow: var(--shadow-lg); text-align: center; display: grid; gap: 12px;
}
.login__tree { font-size: 64px; margin-top: -70px; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.15)); animation: sway 3s ease-in-out infinite; transform-origin: 50% 90%; }
.login__card h1 { font-size: 2rem; }
.login__card p { margin: 0; color: var(--ink-2); }
.login__card .field { text-align: left; }
.login__demo { font-size: 0.85rem; color: var(--muted) !important; }

/* ============ Ramme: toppmeny og faner ============ */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: rgba(255, 246, 229, 0.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px; }
.brand__logo { font-size: 30px; transition: transform 0.3s var(--bounce); }
.brand:hover .brand__logo { transform: rotate(-12deg) scale(1.1); }
.brand__text { font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; white-space: nowrap; }
.topbar__right { margin-left: auto; display: flex; gap: 6px; position: relative; }
.tabs { display: flex; gap: 4px; }
.tabs--top { margin-left: 12px; }
.tab {
  display: flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 8px 14px; border-radius: 99px;
  font-weight: 800; color: var(--ink-2); transition: background 0.15s, transform 0.2s var(--bounce);
}
.tab span { font-size: 1.15em; }
.tab:hover { background: var(--bg-2); }
.tab.is-on { background: var(--ink); color: #fff; }
.tabs--bottom { display: none; }
.menu {
  position: absolute; right: 0; top: 48px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 6px; display: grid; min-width: 210px; z-index: 40; animation: pop 0.18s var(--bounce);
}
.menu button { text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 12px; font-weight: 700; }
.menu button:hover { background: var(--bg); }
.demo-bar { text-align: center; font-size: 0.82rem; font-weight: 700; padding: 5px 12px; background: var(--sun-soft); color: var(--sun-ink); }
.main { padding: 20px 16px 48px; }
/* Treet og kartet fyller resten av skjermen under toppmenyen. */
.view-tre, .view-kart { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.view-tre .main, .view-kart .main { padding: 0; flex: 1; min-height: 0; position: relative; }
.view-tre .tree, .view-kart .mapview { height: 100%; }

/* ============ Knapper og småting ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid var(--line-2); background: var(--card);
  border-radius: 99px; padding: 9px 16px; font-weight: 800; font-size: 0.95rem; transition: transform 0.18s var(--bounce), box-shadow 0.15s, background 0.15s;
  text-decoration: none; color: var(--ink); white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--sun); border-color: #f2ad18; color: var(--ink); }
.btn--soft { background: var(--card); }
.btn--big { padding: 13px 22px; font-size: 1.05rem; }
.btn--tiny { padding: 5px 12px; font-size: 0.82rem; border-width: 2px; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-link { border: 0; background: none; color: var(--danger); font-weight: 700; padding: 6px 8px; }
.btn--rec { border-color: var(--mor); color: var(--mor-ink); }
.btn--rec.is-on { background: var(--mor); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 107, 87, 0.2); } }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: transparent; display: grid; place-items: center; font-size: 1.15rem;
  transition: background 0.15s, transform 0.2s var(--bounce);
}
.icon-btn:hover { background: var(--bg-2); transform: scale(1.06); }
.icon-btn--raised { background: var(--card); box-shadow: var(--shadow); font-weight: 800; font-size: 1.3rem; }
.chip {
  border: 2px solid var(--line-2); background: var(--card); border-radius: 99px; padding: 6px 14px; font-weight: 800; font-size: 0.9rem;
}
.chip.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip--back { margin-bottom: 4px; }
.link { border: 0; background: none; padding: 0; color: var(--far-ink); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.badge { display: inline-flex; gap: 4px; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 0.8rem; font-weight: 800; }
.badge--usikker { background: #fff0d6; color: #8a5300; }
.badge--sannsynlig { background: #e6f4ff; color: #1f5f8b; }
.empty { text-align: center; padding: 48px 16px; color: var(--ink-2); }
.empty__emoji { font-size: 56px; display: block; }
.notice { background: var(--sun-soft); border-radius: 14px; padding: 10px 14px; margin: 0; }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============ Avatar og personkort ============ */
.avatar {
  flex: none; display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden;
  background: var(--c-soft); color: var(--c-ink); font-family: var(--font-head); font-weight: 600;
  border: 4px solid #fff; box-shadow: 0 0 0 3px var(--c), var(--shadow-sm);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar__ini { letter-spacing: 0.02em; }

.pcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
  background: var(--card); border: 3px solid var(--c-soft); border-radius: var(--radius); padding: 14px 10px 12px;
  box-shadow: var(--shadow); transition: transform 0.22s var(--bounce), box-shadow 0.2s, border-color 0.2s;
}
.pcard:hover { transform: translateY(-4px) rotate(-0.6deg); box-shadow: var(--shadow-lg); border-color: var(--c); }
.pcard:active { transform: scale(0.97); }
.pcard--xl { width: 230px; padding: 18px 14px 16px; border-color: var(--c); background: linear-gradient(180deg, var(--c-soft) 0%, #fff 62%); }
.pcard--lg { width: 180px; }
.pcard--md { width: 150px; }
.pcard--sm { width: 124px; padding: 12px 8px 10px; }
.pcard__label {
  margin-top: -14px; z-index: 1; background: var(--c); color: #fff; font-family: var(--font-head); font-weight: 600; font-size: 0.8rem;
  padding: 3px 11px; border-radius: 99px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.side-home .pcard__label, .pcard.side-home .pcard__label { color: var(--sun-ink); }
.pcard--xl .pcard__label { font-size: 0.95rem; padding: 4px 14px; }
.pcard__name { font-weight: 800; line-height: 1.15; font-size: 0.98rem; margin-top: 4px; }
.pcard--xl .pcard__name { font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; }
.pcard--sm .pcard__name { font-size: 0.88rem; }
.pcard__years { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.pcard__note { font-size: 0.75rem; font-weight: 800; color: var(--c-ink); background: var(--c-soft); padding: 2px 9px; border-radius: 99px; margin-top: 2px; }
.pcard.is-bonus { border-style: dashed; border-color: var(--bonus); }
.pcard.is-uncertain::after {
  content: '?'; position: absolute; top: 8px; right: 10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: #fff0d6; color: #8a5300; font-weight: 800; font-size: 0.8rem;
}

/* ============ Familievisningen ============ */
.focus { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; animation: rise 0.35s var(--bounce); }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.frow { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0; }
.frow__title { font-size: 1.15rem; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.frow__title::before, .frow__title::after { content: ''; width: 34px; height: 3px; border-radius: 3px; background: var(--line-2); }
.parents { display: flex; align-items: flex-start; justify-content: center; gap: 0; flex-wrap: nowrap; }
.parent-col { display: flex; flex-direction: column; align-items: center; }
.couple-link { align-self: flex-start; margin-top: 66px; display: flex; align-items: center; min-width: 56px; position: relative; }
.couple-link::before { content: ''; position: absolute; left: -6px; right: -6px; top: 50%; height: 4px; border-radius: 4px; background: var(--line-2); }
.couple-link span { position: relative; margin: 0 auto; background: var(--card); border-radius: 99px; padding: 2px 9px; color: var(--mor); font-weight: 800; box-shadow: var(--shadow-sm); font-size: 0.95rem; }
.couple-link.is-former::before { background: repeating-linear-gradient(90deg, var(--line-2) 0 8px, transparent 8px 14px); }
.couple-link.is-former span { color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.bonus-attach { display: flex; flex-direction: column; align-items: center; margin-top: 2px; }
.bonus-attach__line { width: 0; height: 18px; border-left: 3px dashed var(--bonus); }
.stem { width: 4px; height: 30px; border-radius: 4px; background: linear-gradient(var(--line-2), var(--sun)); }
.center { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.partner { display: flex; align-items: center; gap: 4px; }
.partner__link { font-weight: 800; color: var(--mor); background: var(--card); border: 2px solid var(--mor-soft); border-radius: 99px; padding: 3px 10px; font-size: 0.82rem; white-space: nowrap; }
.partner.is-former .partner__link { color: var(--muted); border-style: dashed; border-color: var(--line-2); }
.center-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.kid-group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.kid-group__with { margin: 0; font-weight: 800; color: var(--muted); font-size: 0.9rem; }
.ghost-card {
  width: 150px; min-height: 140px; border: 3px dashed var(--line-2); border-radius: var(--radius); background: rgba(255, 255, 255, 0.5);
  display: grid; place-content: center; gap: 4px; color: var(--muted); font-weight: 800;
}
.ghost-card span { font-size: 2rem; line-height: 1; }
.ghost-card--sm { min-height: 90px; width: 120px; margin-top: 8px; }
.ghost-card:hover { border-color: var(--sun); color: var(--ink); }

/* ============ Hele treet ============ */
.tree { position: relative; height: calc(100vh - var(--top-h) - var(--bottom-h)); height: calc(100dvh - var(--top-h) - var(--bottom-h)); overflow: hidden; }
.tree__viewport {
  position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  background-image: radial-gradient(rgba(42, 35, 64, 0.09) 1.5px, transparent 1.5px); background-size: 26px 26px;
}
.tree__viewport:active { cursor: grabbing; }
.tree__canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.tree__edges { position: absolute; left: 0; top: 0; overflow: visible; }
.edge { fill: none; stroke: #cdb894; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.edge--partner { stroke: #e7a5b4; }
.edge.is-former { stroke-dasharray: 9 8; stroke: #c9bfd8; }
.edge.is-uncertain { stroke-dasharray: 1 9; stroke-width: 4.5; }
.union { position: absolute; width: 14px; height: 14px; display: grid; place-items: center; font-size: 13px; line-height: 1; color: var(--mor); transform: scale(1.5); }
.union.is-former { color: var(--muted); }
.tree__loading { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-head); font-size: 1.3rem; color: var(--ink-2); }
.tnode {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 12px 8px 8px;
  background: var(--card); border: 3px solid var(--c-soft); border-radius: 22px; box-shadow: var(--shadow); text-align: center;
  transition: transform 0.2s var(--bounce), border-color 0.2s;
}
.tnode:hover { transform: translateY(-3px); border-color: var(--c); }
.tnode.is-bonus { border-style: dashed; border-color: var(--bonus); }
.tnode.is-home { border-color: var(--sun); box-shadow: 0 0 0 8px rgba(255, 194, 60, 0.3), var(--shadow-lg); }
.tnode.is-uncertain::after { content: '?'; position: absolute; top: 6px; right: 8px; width: 20px; height: 20px; border-radius: 50%; background: #fff0d6; color: #8a5300; font-weight: 800; font-size: 0.75rem; display: grid; place-items: center; }
.tnode__label { margin-top: -12px; z-index: 1; background: var(--c); color: #fff; font-family: var(--font-head); font-weight: 600; font-size: 0.72rem; padding: 2px 8px; border-radius: 99px; max-width: 136px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-home .tnode__label, .tnode.side-home .tnode__label { color: var(--sun-ink); }
.tnode__name { font-weight: 800; font-size: 0.85rem; line-height: 1.15; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tnode__years { font-size: 0.75rem; color: var(--muted); font-weight: 700; }
.tree__controls { position: absolute; right: 14px; bottom: 16px; display: grid; gap: 8px; }
.legend {
  position: absolute; left: 12px; top: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: calc(100% - 24px);
  background: rgba(255, 255, 255, 0.92); border-radius: 16px; padding: 8px 12px; box-shadow: var(--shadow-sm); font-size: 0.78rem; font-weight: 700; color: var(--ink-2);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); display: inline-block; }
.dot--bonus { background: #fff; border: 2px dashed var(--bonus); }
.line { width: 22px; height: 0; border-top: 3px solid #cdb894; display: inline-block; }
.line--former { border-top: 3px dashed #c9bfd8; }
.line--uncertain { border-top: 4px dotted #cdb894; }

/* ============ Personkortet (ark) ============ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(42, 35, 64, 0.38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; justify-content: flex-end; animation: fade 0.2s;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative; width: min(560px, 100%); height: 100%; overflow-y: auto; background: var(--bg); box-shadow: var(--shadow-lg);
  animation: slide 0.32s var(--bounce); overscroll-behavior: contain;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.sheet__close { position: absolute; top: 12px; right: 12px; z-index: 2; background: rgba(255, 255, 255, 0.8); }
.sheet__hero {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 34px 20px 22px;
  background: radial-gradient(circle at 50% 0%, var(--c-soft) 0 60%, transparent 61%), linear-gradient(180deg, var(--c-soft), var(--bg));
  border-bottom-left-radius: 40px; border-bottom-right-radius: 40px;
}
.sheet__label { margin-top: -18px; z-index: 1; background: var(--c); color: #fff; font-family: var(--font-head); font-weight: 600; padding: 5px 16px; border-radius: 99px; font-size: 1.05rem; }
.side-home .sheet__label { color: var(--sun-ink); }
.sheet__name { font-size: 1.85rem; margin-top: 6px; }
.sheet__years { margin: 0; font-weight: 800; color: var(--ink-2); }
.sheet__sub { margin: 0; color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.sheet__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 14px 16px 4px; }
.sheet__section { padding: 14px 20px; }
.sheet__section h3 { font-size: 1.2rem; margin-bottom: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.section-head h3 { margin: 0; }
.sheet__foot { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 40px; font-size: 0.85rem; }
.facts { list-style: none; margin: 0; padding: 6px; display: grid; gap: 2px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-sm); }
.facts li { display: grid; grid-template-columns: 32px 92px 1fr; gap: 8px; align-items: baseline; padding: 9px 10px; border-radius: 14px; }
.facts li:nth-child(odd) { background: #fffaf0; }
.facts__icon { font-size: 1.15rem; }
.facts__k { font-weight: 800; color: var(--muted); font-size: 0.88rem; }
.facts__v { font-weight: 700; }
.bio { margin: 0; font-size: 1.05rem; background: var(--card); padding: 14px 16px; border-radius: 18px; border-left: 6px solid var(--c); }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 16px; overflow: hidden; background: var(--bg-2); box-shadow: var(--shadow-sm); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.thumb:hover img { transform: scale(1.06); }
.thumb__ph { display: grid; place-items: center; height: 100%; font-size: 1.6rem; }
.thumb.is-profile { box-shadow: 0 0 0 3px var(--sun); }
.thumb__star { position: absolute; top: 6px; left: 6px; background: var(--sun); color: var(--ink); border-radius: 50%; width: 24px; height: 24px; display: grid; place-items: center; font-size: 0.8rem; }
.fam-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.fam-chip { display: flex; align-items: center; gap: 8px; border: 2px solid var(--line); background: var(--card); border-radius: 99px; padding: 4px 14px 4px 4px; text-align: left; transition: transform 0.18s var(--bounce); }
.fam-chip:hover { transform: translateY(-2px); border-color: var(--line-2); }
.fam-chip span { display: flex; flex-direction: column; line-height: 1.15; font-weight: 800; font-size: 0.9rem; }
.fam-chip small { color: var(--muted); font-weight: 700; font-size: 0.72rem; }
.fam-chip.is-uncertain { border-style: dashed; }
.fam-chip .avatar { border-width: 2px; box-shadow: 0 0 0 2px var(--c); }
.sources { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.sources a { font-weight: 700; word-break: break-word; }

.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(20, 16, 32, 0.92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 12px 12px; gap: 12px; }
.viewer img { max-height: calc(100vh - 170px); max-width: 100%; border-radius: 12px; object-fit: contain; }
.viewer__close { position: absolute; top: 10px; right: 10px; background: rgba(255, 255, 255, 0.9); }
.viewer__bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: min(640px, 100%); }
.viewer__bar .input { flex: 1 1 260px; }
.viewer .btn--danger-link { color: #ff9a9a; }

/* ============ Modaler og skjemaer ============ */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(42, 35, 64, 0.42); display: grid; place-items: center; padding: 12px; animation: fade 0.15s; }
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); background: var(--bg); border-radius: 28px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop 0.22s var(--bounce);
}
.modal--wide { width: min(720px, 100%); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 18px 8px 22px; }
.modal__head h2 { font-size: 1.4rem; }
.modal__body { padding: 6px 22px 18px; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px 18px; border-top: 2px solid var(--line); }
.modal__foot .btn--danger-link { margin-right: auto; }
.form { display: grid; gap: 12px; }
.form__h { font-size: 1.05rem; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 5px; }
.field__label { font-weight: 800; font-size: 0.9rem; color: var(--ink-2); }
.field__hint { font-size: 0.8rem; color: var(--muted); }
.field__error { font-size: 0.82rem; color: var(--danger); font-weight: 700; }
.input {
  width: 100%; border: 2px solid var(--line-2); border-radius: 14px; background: var(--card); padding: 10px 12px; font: inherit; color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--sun); box-shadow: 0 0 0 4px rgba(255, 194, 60, 0.3); }
.input--big { font-size: 1.1rem; padding: 13px 15px; }
textarea.input { resize: vertical; min-height: 80px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.check input { width: 20px; height: 20px; accent-color: var(--far); }
.check--field { align-self: end; padding-bottom: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg__opt { border: 2px solid var(--line-2); background: var(--card); border-radius: 99px; padding: 7px 14px; font-weight: 800; font-size: 0.9rem; cursor: pointer; }
.seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg__opt.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.type-btn {
  display: grid; justify-items: center; gap: 4px; padding: 20px 10px; border-radius: 22px; border: 3px solid var(--line); background: var(--card);
  font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; transition: transform 0.2s var(--bounce), border-color 0.15s;
}
.type-btn span { font-size: 2.4rem; }
.type-btn:hover { transform: translateY(-3px) rotate(-1deg); border-color: var(--sun); }
.picker { display: grid; gap: 8px; margin-top: 10px; }
.picker__list { display: grid; gap: 4px; max-height: 280px; overflow-y: auto; margin-top: 8px; }
.picker__list--tall { max-height: 60vh; }
.picker__item { display: flex; align-items: center; gap: 10px; border: 2px solid transparent; background: var(--card); border-radius: 16px; padding: 6px 10px; text-align: left; }
.picker__item span { display: flex; flex-direction: column; font-weight: 800; line-height: 1.2; }
.picker__item small { color: var(--muted); font-weight: 700; }
.picker__item:hover { border-color: var(--line-2); }
.picker__item.is-on { border-color: var(--sun); background: var(--sun-soft); }
.picker__item .avatar { border-width: 2px; box-shadow: 0 0 0 2px var(--c); }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick { width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-size: 1.3rem; }
.emoji-pick.is-on { border-color: var(--sun); background: var(--sun-soft); transform: scale(1.08); }
.recorder { display: grid; gap: 8px; background: var(--card); border-radius: 18px; padding: 12px; }
.recorder audio { width: 100%; }

/* ============ Sider: historier, endringer ============ */
.page { max-width: 1060px; margin: 0 auto; }
.page__head { margin-bottom: 18px; }
.page__head h1 { font-size: 2rem; margin-bottom: 4px; }
.page__head p { margin: 0 0 8px; color: var(--ink-2); max-width: 60ch; }
.story-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.story { background: var(--card); border-radius: 22px; padding: 16px 18px 12px; box-shadow: var(--shadow-sm); border-top: 6px solid var(--c); margin-bottom: 12px; }
.story-list .story { margin: 0; }
.story__who { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; margin-bottom: 10px; text-align: left; }
.story__who span { display: flex; flex-direction: column; line-height: 1.2; }
.story__who small { color: var(--c-ink); font-weight: 800; }
.story__title { font-size: 1.2rem; display: flex; gap: 8px; align-items: baseline; }
.story__emoji { font-size: 1.4rem; }
.story__body p { margin: 8px 0 0; }
.story audio { width: 100%; margin-top: 10px; }
.story__foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: 0.82rem; color: var(--muted); font-weight: 700; }
.changes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.change { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow-sm); }

/* ============ Kart ============ */
.mapview { position: relative; height: calc(100vh - var(--top-h) - var(--bottom-h)); height: calc(100dvh - var(--top-h) - var(--bottom-h)); }
.mapview__map { position: absolute; inset: 0; background: #dfeef3; }
.mapview__filters { position: absolute; z-index: 500; top: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100% - 24px); }
.mapview__filters .chip { box-shadow: var(--shadow-sm); }
.mapview__note { position: absolute; z-index: 500; left: 12px; bottom: 6px; margin: 0; font-size: 0.75rem; background: rgba(255, 255, 255, 0.85); padding: 2px 8px; border-radius: 8px; }
.map-pin {
  width: 38px; height: 38px; border-radius: 50% 50% 50% 8px; transform: rotate(-45deg); display: grid; place-items: center;
  background: var(--c); color: #fff; font-family: var(--font-head); font-weight: 700; border: 3px solid #fff; box-shadow: var(--shadow);
}
.map-pin.side-home { color: var(--sun-ink); }
.map-pin b { transform: rotate(45deg); line-height: 1; }
.map-card {
  position: absolute; z-index: 600; left: 12px; right: 12px; bottom: 16px; max-width: 420px; margin: 0 auto; background: var(--card);
  border-radius: 22px; box-shadow: var(--shadow-lg); padding: 12px 16px 14px; animation: pop 0.2s var(--bounce); max-height: 45%; overflow: auto;
}
.map-card header { display: flex; align-items: center; justify-content: space-between; }
.map-card h3 { font-size: 1.15rem; }
.map-card ul { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.leaflet-container { font-family: var(--font); }

/* ============ Tidslinje ============ */
.page--timeline { max-width: none; }
.tl { overflow-x: auto; background: var(--card); border-radius: 22px; box-shadow: var(--shadow-sm); padding-bottom: 8px; }
.tl__inner { position: relative; }
.tl__axis { position: sticky; top: 0; height: 30px; border-bottom: 2px solid var(--line); z-index: 3; background: var(--card); }
.tl__tick { position: absolute; top: 6px; transform: translateX(-50%); font-weight: 800; font-size: 0.78rem; color: var(--muted); }
.tl__body { position: relative; padding-top: 134px; }
.tl__grid { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.tl__gridline { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--line); }
.tl__event { position: absolute; top: 0; bottom: 0; border-left: 2px dotted rgba(139, 118, 239, 0.45); }
.tl__event-label {
  position: absolute; left: 4px; white-space: nowrap; font-size: 0.74rem; background: var(--bonus-soft); color: var(--bonus-ink);
  padding: 2px 8px; border-radius: 99px; font-weight: 700; pointer-events: auto;
}
.tl__row { display: flex; align-items: center; height: 46px; position: relative; }
.tl__row:hover { background: rgba(255, 194, 60, 0.07); }
.tl__who {
  position: sticky; left: 0; z-index: 2; width: 200px; flex: none; display: flex; align-items: center; gap: 8px; border: 0; padding: 4px 10px;
  background: linear-gradient(90deg, var(--card) 85%, transparent); text-align: left;
}
.tl__who .avatar { border-width: 2px; box-shadow: 0 0 0 2px var(--c); }
.tl__who span { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.tl__who b { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl__who small { font-size: 0.7rem; color: var(--c-ink); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl__track { position: relative; height: 100%; flex: none; }
.tl__bar {
  position: absolute; top: 11px; height: 24px; border-radius: 99px; border: 0; background: var(--c); color: #fff; font-size: 0.72rem; font-weight: 800;
  display: flex; align-items: center; padding: 0 10px; white-space: nowrap; overflow: hidden; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.2s var(--bounce);
}
.tl__bar:hover { transform: scaleY(1.15); }
.side-home .tl__bar { color: var(--sun-ink); }
.tl__bar.is-living { background: linear-gradient(90deg, var(--c) 80%, var(--c-soft)); }
.tl__bar.is-open { background: linear-gradient(90deg, var(--c), transparent); }
.is-bonus .tl__bar { background: repeating-linear-gradient(135deg, var(--bonus) 0 8px, #9f8ef3 8px 16px); }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--bottom-h)); transform: translateX(-50%); z-index: 90; background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 99px; font-weight: 800; box-shadow: var(--shadow-lg); animation: toast 0.3s var(--bounce); max-width: calc(100% - 32px);
}
.toast--error { background: var(--danger); }
@keyframes toast { from { transform: translate(-50%, 20px); opacity: 0; } }

/* ============ Mobil ============ */
@media (max-width: 860px) {
  :root { --top-h: 56px; --bottom-h: calc(68px + env(safe-area-inset-bottom)); }
  .tabs--top { display: none; }
  .brand__text { font-size: 1.15rem; }
  .tabs--bottom {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; justify-content: space-around; gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 2px solid var(--line);
  }
  .tabs--bottom .tab { flex-direction: column; gap: 0; padding: 4px 6px; font-size: 0.72rem; border-radius: 14px; flex: 1; }
  .tabs--bottom .tab span { font-size: 1.45rem; }
  .tabs--bottom .tab.is-on { background: var(--sun-soft); color: var(--ink); }
  .main { padding: 14px 10px calc(var(--bottom-h) + 30px); }
  .view-tre .main, .view-kart .main { padding-bottom: 0; margin-bottom: var(--bottom-h); }
  .pcard--xl { width: 172px; padding: 14px 10px 12px; }
  .pcard--xl .avatar { width: 108px !important; height: 108px !important; font-size: 38px !important; }
  .pcard--xl .pcard__name { font-size: 1.15rem; }
  .pcard--md { width: 132px; }
  .pcard--sm { width: 112px; }
  .pcard--sm .pcard__label { font-size: 0.7rem; padding: 3px 7px; white-space: normal; line-height: 1.1; }
  .center { gap: 10px; flex-wrap: nowrap; }
  .partner { position: relative; }
  .partner__link { position: absolute; left: -16px; top: 46px; z-index: 2; padding: 2px 7px; font-size: 0.7rem; }
  .partner .pcard--md { width: 124px; }
  .center:has(.partner ~ .partner) { flex-wrap: wrap; }
  .couple-link { min-width: 40px; }
  .couple-link.is-former span { font-size: 0.62rem; padding: 2px 5px; }
  .cards { gap: 10px; }
  .sheet-backdrop { align-items: flex-end; }
  .sheet { height: 94vh; height: 94dvh; border-radius: 30px 30px 0 0; animation: up 0.34s var(--bounce); }
  @keyframes up { from { transform: translateY(60px); opacity: 0; } }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 28px 28px 0 0; max-height: 92vh; max-height: 92dvh; }
  .grid2 { grid-template-columns: 1fr; }
  .facts li { grid-template-columns: 28px 80px 1fr; }
  .legend { font-size: 0.7rem; top: 8px; left: 8px; padding: 6px 10px; gap: 4px 10px; }
  .tree__controls { bottom: 14px; right: 10px; }
  .page__head h1 { font-size: 1.6rem; }
  .tl__who { width: 150px; }
  .toast { bottom: calc(var(--bottom-h) + 14px); }
}
@media (max-width: 380px) {
  .pcard--md { width: 118px; }
  .pcard--md .avatar { width: 64px !important; height: 64px !important; }
}

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