/* Radici — interfaccia. Token su :root (chiaro), ridefiniti per il tema scuro. */
:root {
  color-scheme: light;
  --font: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #fffdf9; --surface: #ffffff; --surface-2: #f6f1e9; --surface-3: #ece5d9;
  --ink: #1f1c18; --ink-2: #4f483f; --muted: #8a8174; --faint: #b9b0a2;
  --line: rgba(74, 56, 30, .09); --line-2: rgba(74, 56, 30, .16); --wire: #d4cabb;
  --accent: #16a35a; --accent-hover: #11914f; --accent-ink: #ffffff; --accent-soft: #e3f6eb; --accent-text: #0e8546;
  --ring-m: #5c90dc; --ring-f: #e0789c; --ring-u: #cfc6b8; --tint-m: #e6eefb; --tint-f: #fce8ef;
  --danger: #d0453a; --danger-soft: #fdecea;
  --shadow-sm: 0 1px 2px rgba(60, 40, 10, .06), 0 2px 8px -2px rgba(60, 40, 10, .07);
  --shadow: 0 2px 6px rgba(60, 40, 10, .05), 0 18px 40px -14px rgba(60, 40, 10, .2);
  --shadow-lg: 0 6px 20px rgba(40, 28, 8, .07), 0 40px 90px -24px rgba(40, 28, 8, .3);
  --scrim: rgba(28, 22, 12, .3);
  --ini-l: 91%; --ini-s: 42%; --ini-tl: 32%; --ini-ts: 32%;
  --art-1: #e4f5ea; --art-2: #b3e0c3; --art-line: rgba(16, 84, 46, .32); --art-a: #f8d9c4; --art-b: #d3e2f6; --art-c: #fff7ea; --art-face: rgba(24, 66, 42, .32); --art-quote: #123824;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --gap: var(--bg);
  --pf-w: min(600px, 46vw);
  --top-h: 64px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #151412; --surface: #1f1d1a; --surface-2: #282521; --surface-3: #34302a;
  --ink: #f4efe7; --ink-2: #d3cbbf; --muted: #9a9184; --faint: #6b645a;
  --line: rgba(255, 240, 220, .07); --line-2: rgba(255, 240, 220, .14); --wire: #4b453d;
  --accent: #2fbf72; --accent-hover: #43cf85; --accent-ink: #04190c; --accent-soft: rgba(47, 191, 114, .15); --accent-text: #5fd897;
  --ring-m: #7eaaee; --ring-f: #f097b5; --ring-u: #5f584e; --tint-m: #1e2836; --tint-f: #352026;
  --danger: #f06b5f; --danger-soft: rgba(240, 107, 95, .15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px -2px rgba(0, 0, 0, .35);
  --shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 18px 40px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, .3), 0 40px 90px -24px rgba(0, 0, 0, .75);
  --scrim: rgba(0, 0, 0, .5);
  --ini-l: 25%; --ini-s: 20%; --ini-tl: 82%; --ini-ts: 40%;
  --art-1: #173323; --art-2: #0d2216; --art-line: rgba(150, 225, 180, .3); --art-a: #4a3a31; --art-b: #2e3c50; --art-c: #3a3a2f; --art-face: rgba(220, 245, 230, .28); --art-quote: #e3f4e9;
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151412; --surface: #1f1d1a; --surface-2: #282521; --surface-3: #34302a;
  --ink: #f4efe7; --ink-2: #d3cbbf; --muted: #9a9184; --faint: #6b645a;
  --line: rgba(255, 240, 220, .07); --line-2: rgba(255, 240, 220, .14); --wire: #4b453d;
  --accent: #2fbf72; --accent-hover: #43cf85; --accent-ink: #04190c; --accent-soft: rgba(47, 191, 114, .15); --accent-text: #5fd897;
  --ring-m: #7eaaee; --ring-f: #f097b5; --ring-u: #5f584e; --tint-m: #1e2836; --tint-f: #352026;
  --danger: #f06b5f; --danger-soft: rgba(240, 107, 95, .15);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 8px -2px rgba(0, 0, 0, .35);
  --shadow: 0 2px 6px rgba(0, 0, 0, .25), 0 18px 40px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, .3), 0 40px 90px -24px rgba(0, 0, 0, .75);
  --scrim: rgba(0, 0, 0, .5);
  --ini-l: 25%; --ini-s: 20%; --ini-tl: 82%; --ini-ts: 40%;
  --art-1: #173323; --art-2: #0d2216; --art-line: rgba(150, 225, 180, .3); --art-a: #4a3a31; --art-b: #2e3c50; --art-c: #3a3a2f; --art-face: rgba(220, 245, 230, .28); --art-quote: #e3f4e9;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow: hidden; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { flex: none; display: block; }
.muted { color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.45; }
.pad { padding: 12px; }
::selection { background: var(--accent-soft); }

.app { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }

/* ---------- pulsanti ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--ink); font-size: 14.5px; font-weight: 550; white-space: nowrap; text-decoration: none; transition: background .15s, box-shadow .15s, transform .1s, color .15s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 6px 16px -8px var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; gap: 6px; }
.btn.lg { height: 50px; font-size: 16px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.busy { opacity: .7; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; flex: none; display: inline-grid; place-items: center; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2); transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.danger.solid { width: auto; padding: 0 12px; background: var(--danger); color: #fff; font-size: 13.5px; font-weight: 600; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent-text); font-weight: 600; }
.linkish:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; vertical-align: 2px; }
.badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
kbd { font: 500 11.5px var(--font); color: var(--muted); border-radius: 6px; padding: 1px 6px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); }

/* ---------- avatar con anello ---------- */
.ava { --ring: var(--ring-u); width: var(--s); height: var(--s); flex: none; position: relative; display: inline-grid; place-items: center; border-radius: 50%; background: var(--surface-2); box-shadow: 0 0 0 2px var(--gap), 0 0 0 3.75px var(--ring); }
.ava img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.ava.ini { background: hsl(var(--h) var(--ini-s) var(--ini-l)); color: hsl(var(--h) var(--ini-ts) var(--ini-tl)); font-weight: 600; font-size: calc(var(--s) * .36); letter-spacing: .02em; line-height: 1; user-select: none; }
.r-m { --ring: var(--ring-m); }
.r-f { --ring: var(--ring-f); }
.r-u { --ring: var(--ring-u); }
.r-none { --ring: transparent; box-shadow: none; }

/* ---------- scheletri di caricamento ---------- */
.skel { display: block; height: 12px; width: 96px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel.round { border-radius: 50%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- header ---------- */
.top { position: relative; z-index: 20; height: var(--top-h); display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); box-shadow: 0 1px 0 var(--line); }
.top-l { display: flex; align-items: center; gap: 6px; min-width: 0; }
.brand { display: grid; flex: none; margin-right: 4px; }
.logo { display: block; border-radius: 9px; }
.tree-btn { display: flex; align-items: center; gap: 6px; min-width: 0; height: 40px; padding: 0 10px; border: 0; border-radius: 12px; background: none; font-size: 17px; font-weight: 650; letter-spacing: -.01em; transition: background .15s; }
.tree-btn:hover, .tree-btn[aria-expanded="true"] { background: var(--surface-2); }
.tree-btn .ico { color: var(--muted); }
#treeName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#treeName.skel { width: 150px; height: 18px; }
.top-r { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px; background: var(--surface-2); }
.views-seg button { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-size: 14.5px; font-weight: 550; transition: background .18s, color .18s, box-shadow .18s; }
.views-seg button:hover { color: var(--ink); }
.views-seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.views-seg button.on .ico { color: var(--accent); }
.seg label { position: relative; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px; color: var(--ink-2); font-size: 14px; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background .18s, color .18s, box-shadow .18s; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg.sm label span { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.seg.wide { display: flex; }
.seg.wide label { flex: 1; }
.seg.wide label span { width: 100%; height: 40px; }

.search { position: relative; display: flex; align-items: center; width: 280px; }
.top .search input { width: 100%; height: 40px; padding: 0 40px 0 40px; border: 0; border-radius: 12px; background: var(--surface-2); outline: none; transition: background .15s, box-shadow .15s; -webkit-appearance: none; appearance: none; }
.top .search input::-webkit-search-cancel-button { display: none; }
.search input::placeholder { color: var(--muted); }
.top .search input:focus { background: var(--surface); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
.search-ico { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search kbd { position: absolute; right: 10px; pointer-events: none; }
.search input:focus ~ kbd { display: none; }
.search-back { display: none; }
.search-res { position: absolute; top: calc(100% + 8px); right: 0; width: max(100%, 360px); max-height: min(480px, 70vh); overflow-y: auto; padding: 6px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); --gap: var(--surface); animation: pop .16s var(--ease); }
.sr { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: none; text-align: left; }
.sr.on, .sr:hover { background: var(--surface-2); }
.sr-t { min-width: 0; }
.sr-t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-t small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-none { padding: 14px; color: var(--muted); font-size: 14px; }
.btn-search { display: none; }
.invite { margin-left: 4px; }
.more { position: relative; }
.more.dot::after { content: ""; position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.acct { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; margin-left: 2px; border: 0; border-radius: 50%; background: none; }
.acct .ava { --gap: var(--bg); transition: transform .15s; }
.acct:hover .ava { transform: scale(1.05); }

.banner { position: absolute; z-index: 25; top: calc(var(--top-h) + 12px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 16px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-sm); }

/* ---------- viste ---------- */
.views { position: relative; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
body[data-view="tree"] .views { overflow: hidden; }
.view.enter { animation: fadeIn .22s var(--ease); }
.view-list.enter { animation: viewIn .24s var(--ease); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

.view-list { max-width: 1180px; margin: 0 auto; padding: 32px 32px 120px; }
.vh { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.vh h1 { font-size: 34px; font-weight: 700; letter-spacing: -.025em; line-height: 1.1; }
.vh p { margin-top: 6px; color: var(--muted); font-size: 15px; }

.empty-in { max-width: 420px; margin: 0 auto; text-align: center; }
.empty-in h2 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 18px 0 8px; }
.empty-in p { color: var(--ink-2); font-size: 15.5px; line-height: 1.55; text-wrap: pretty; }
.empty-in.soft { padding: 48px 0 24px; }
.empty-ico { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 24px; background: var(--surface-2); color: var(--ink-2); }
.empty-art { display: block; margin: 0 auto; }
.empty-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }

/* ---------- albero ---------- */
.view-tree { position: absolute; inset: 0; overflow: hidden; }
.canvas { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.canvas.drag { cursor: grabbing; }
.stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.stage.glide { transition: transform .26s var(--ease); }
.lines { position: absolute; left: 0; top: 0; overflow: visible; transition: opacity .25s; }
.lines.enter { opacity: 0; transition: none; }
.lines path { fill: none; stroke: var(--wire); stroke-width: 1.6; stroke-linecap: round; }
.lines .dash { stroke-dasharray: 2 6; }
.lines circle.wed { fill: var(--bg); stroke: var(--wire); stroke-width: 1.6; }
.lines circle.wed.dash { stroke-dasharray: 2 3; }
.node { position: absolute; width: 148px; display: flex; flex-direction: column; align-items: center; padding: 0; border: 0; background: none; text-align: center; color: inherit; transition: opacity .24s var(--ease), transform .24s var(--ease); }
.nodes.enter .node:not(.focus) { opacity: 0; transform: scale(.94); transition: none; }
.node .ava { transition: transform .18s var(--ease), box-shadow .18s; }
.node:hover .ava { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--gap), 0 0 0 3.75px var(--ring), var(--shadow); }
.node:focus-visible { outline: none; }
.node:focus-visible .ava { box-shadow: 0 0 0 3px var(--gap), 0 0 0 6px var(--accent); }
.node .nm { max-width: 100%; margin-top: 12px; font-size: 15px; font-weight: 650; line-height: 1.2; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .sn { max-width: 100%; font-size: 15px; font-weight: 450; line-height: 1.25; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .yr { margin-top: 4px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.node .more { margin-top: 6px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.node.focus .nm { margin-top: 14px; font-size: 19px; font-weight: 700; letter-spacing: -.015em; }
.node.focus .sn { font-size: 19px; }
.node.focus .yr { font-size: 13.5px; }
.node.focus .ava { box-shadow: 0 0 0 3px var(--gap), 0 0 0 5.5px var(--ring), var(--shadow); }
.node.sel .ava, .node.sel:hover .ava { box-shadow: 0 0 0 3px var(--gap), 0 0 0 6px var(--accent), var(--shadow); }
.node.sel .nm { color: var(--accent-text); }
.node.add .add-c { width: 76px; height: 76px; display: grid; place-items: center; border-radius: 50%; border: 1.75px dashed var(--faint); color: var(--muted); transition: border-color .18s, color .18s, background .18s, transform .18s var(--ease); }
.node.add:hover .add-c { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); transform: translateY(-3px); }
.node.add .nm { font-size: 13px; font-weight: 500; color: var(--muted); }
.node.add:hover .nm { color: var(--accent-text); }

.tree-ctl { position: absolute; z-index: 5; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; padding: 5px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); transition: left .26s var(--ease); }
.tree-ctl button { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 12px; background: none; color: var(--ink-2); transition: background .15s, color .15s; }
.tree-ctl button:hover { background: var(--surface-2); color: var(--ink); }
.ctl-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line-2); }
.ctl-gen { position: relative; display: flex; align-items: center; gap: 2px; height: 38px; padding-left: 10px; border-radius: 12px; color: var(--ink-2); }
.ctl-gen:hover { background: var(--surface-2); }
.tree-ctl .ctl-gen select { width: auto; height: 38px; padding: 0 12px 0 6px; border: 0; border-radius: 0; background: none; box-shadow: none; font-size: 13.5px; font-weight: 550; appearance: none; -webkit-appearance: none; cursor: pointer; outline: none; }
.ctl-gen:focus-within { outline: 2px solid var(--accent); }
.tree-skel { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 70px; pointer-events: none; }
.sk-row { display: flex; gap: 56px; }
.sk-n { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.sk-n .skel.round { width: 76px; height: 76px; }
.sk-n.big .skel.round { width: 112px; height: 112px; }
.sk-n .skel.short { width: 56px; }
.tree-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; overflow-y: auto; }
.tree-empty .empty-in { animation: viewIn .3s var(--ease); }

/* ---------- persone ---------- */
.p-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.chips { display: flex; gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); padding-right: 32px; }
.chips::-webkit-scrollbar { display: none; }
.chip { position: relative; flex: none; display: flex; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 550; white-space: nowrap; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.chip span:hover { background: var(--surface-3); }
.chip small { color: var(--muted); font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.chip input:checked + span { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.chip input:checked + span small { color: inherit; opacity: .75; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.p-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 6px 10px; }
.p-card { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding: 22px 10px 18px; border: 0; border-radius: 24px; background: none; text-align: center; transition: background .18s; }
.p-card:hover { background: var(--surface-2); --gap: var(--surface-2); }
.p-card.sel { background: var(--accent-soft); }
.p-card .ava { margin-bottom: 12px; transition: transform .22s var(--ease); }
.p-card:hover .ava { transform: scale(1.03); }
.p-name { max-width: 100%; font-size: 15.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.p-name b { font-weight: 650; }
.p-yr { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-pl { display: flex; align-items: center; gap: 4px; max-width: 100%; font-size: 12.5px; color: var(--muted); }
.p-pl .ico { opacity: .8; }
.p-pl { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- foto ---------- */
.g-sec { margin-bottom: 36px; }
.g-who { display: inline-flex; align-items: center; gap: 12px; max-width: 100%; margin: 0 0 14px -8px; padding: 6px 14px 6px 6px; border: 0; border-radius: 99px; background: none; text-align: left; transition: background .15s; }
.g-who:hover { background: var(--surface-2); --gap: var(--surface-2); }
.g-who b { display: block; font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; }
.g-who small { display: block; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.g-who .count { margin-left: 6px; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; }
.g-tile { position: relative; aspect-ratio: 1; display: block; overflow: hidden; padding: 0; border: 0; border-radius: 18px; background: var(--surface-2); cursor: zoom-in; }
.g-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease), filter .2s; }
.g-tile:hover img { transform: scale(1.045); }
.g-tile.doc { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; color: var(--ink-2); cursor: pointer; transition: background .15s; }
.g-tile.doc:hover { background: var(--surface-3); }
.g-tile.doc span { font-size: 13px; font-weight: 550; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.g-tile.doc small { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
span.g-tile { cursor: default; }

/* ---------- profilo ---------- */
.scrim { position: fixed; inset: 0; z-index: 29; background: var(--scrim); opacity: 0; transition: opacity .22s; }
.scrim.open { opacity: 1; }
.profile { position: fixed; z-index: 30; top: calc(var(--top-h) + 10px); right: 12px; bottom: 12px; width: var(--pf-w); display: flex; flex-direction: column; overflow: hidden; border-radius: 30px; background: var(--surface); box-shadow: var(--shadow-lg); --gap: var(--surface); opacity: 0; transform: translateX(28px); transition: transform .24s var(--ease), opacity .2s; }
.profile.open { opacity: 1; transform: none; }
.pf-bar { position: absolute; z-index: 2; top: 0; left: 0; right: 0; height: 60px; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 24px; pointer-events: none; transition: background .2s, box-shadow .2s; }
.pf-bar > * { pointer-events: auto; }
.pf-bar-name { flex: 1; min-width: 0; font-size: 16px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0; transform: translateY(4px); transition: opacity .2s, transform .2s; }
.pf-close { order: 2; background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.profile.scrolled .pf-bar { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 1px 0 var(--line); }
.profile.scrolled .pf-bar-name { opacity: 1; transform: none; }
.pf-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 28px; }
.pf-hero { --tint: var(--surface-2); display: flex; flex-direction: column; align-items: center; padding: 52px 32px 30px; text-align: center; background: radial-gradient(120% 70% at 50% 0%, var(--tint) 0%, transparent 72%); }
.pf-hero.m { --tint: var(--tint-m); }
.pf-hero.f { --tint: var(--tint-f); }
.pf-photo { position: relative; padding: 0; border: 0; border-radius: 50%; background: none; }
.pf-photo .ava { box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--ring), var(--shadow); transition: transform .2s var(--ease); }
button.pf-photo:hover .ava { transform: scale(1.025); }
.pf-cam { position: absolute; right: 2px; bottom: 6px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.pf-name { margin: 20px 0 6px; font-size: 30px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; text-wrap: balance; }
.pf-life { color: var(--ink-2); font-size: 16px; }
.pf-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 10px; color: var(--muted); font-size: 14px; }
.pf-facts span { display: inline-flex; align-items: center; gap: 6px; }
.pf-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.pf-sec { padding: 26px 32px 6px; }
.pf-sec h2 { margin-bottom: 16px; font-size: 20px; font-weight: 700; letter-spacing: -.015em; }
.pf-sec h2 .count { margin-left: 4px; }
.pf-sec > .muted { font-size: 14.5px; }
.fam-g + .fam-g { margin-top: 14px; }
.fam-g h3 { margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 550; }
.fam-row { display: flex; gap: 4px; margin: 0 -32px; padding: 6px 32px 4px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding: 0 32px; }
.fam-row::-webkit-scrollbar { display: none; }
.fam-p { flex: none; width: 88px; display: flex; flex-direction: column; align-items: center; padding: 8px 2px 8px; border: 0; border-radius: 18px; background: none; scroll-snap-align: start; transition: background .15s; }
.fam-p:hover { background: var(--surface-2); --gap: var(--surface-2); }
.fam-p .ava { margin-bottom: 10px; }
.fam-n, .fam-s { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fam-n { font-size: 13.5px; font-weight: 600; }
.fam-s { font-size: 12px; color: var(--muted); }
.fam-add .add-c { width: 60px; height: 60px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; border: 1.75px dashed var(--faint); color: var(--muted); transition: border-color .15s, color .15s, background .15s; }
.fam-add .fam-n { font-weight: 500; color: var(--muted); white-space: normal; line-height: 1.25; }
.fam-add:hover { background: none; }
.fam-add:hover .add-c { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.fam-add:hover .fam-n { color: var(--accent-text); }

.tl { list-style: none; margin: 0; padding: 0; }
.tl-i { position: relative; display: grid; grid-template-columns: 48px 32px minmax(0, 1fr); column-gap: 12px; padding-bottom: 20px; }
.tl-i::before { content: ""; position: absolute; left: calc(48px + 12px + 15.25px); top: 36px; bottom: 4px; width: 1.5px; border-radius: 1px; background: var(--line-2); }
.tl-i:last-child { padding-bottom: 4px; }
.tl-i:last-child::before { display: none; }
.tl-y { padding-top: 6px; text-align: right; color: var(--ink-2); font-size: 14.5px; font-weight: 650; }
.tl-dot { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); }
.tl-i.birth .tl-dot { background: var(--accent-soft); color: var(--accent-text); }
.tl-c { padding-top: 5px; }
.tl-t { font-size: 15.5px; font-weight: 500; line-height: 1.35; }
.tl-d { margin-top: 2px; color: var(--muted); font-size: 13.5px; }
.tl-link { padding: 0; border: 0; background: none; color: var(--accent-text); font-weight: 650; }
.tl-link:hover { text-decoration: underline; text-underline-offset: 2px; }

.m-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border-radius: 18px; transition: outline-color .15s; outline: 2px dashed transparent; outline-offset: 6px; }
.m-tile { position: relative; aspect-ratio: 1; overflow: hidden; padding: 0; border: 0; border-radius: 16px; background: var(--surface-2); }
.m-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s var(--ease); }
.m-tile:hover img { transform: scale(1.05); }
.m-tile.doc { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; color: var(--ink-2); }
.m-tile.doc span, .m-drop span { font-size: 12.5px; font-weight: 550; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; text-align: center; }
.m-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1.75px dashed var(--line-2); background: transparent; color: var(--muted); transition: border-color .15s, background .15s, color .15s; }
.m-drop:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.m-grid > .m-drop:only-child { grid-column: 1 / -1; aspect-ratio: auto; height: 140px; }
.pf-media.over .m-grid { outline-color: var(--accent); }
.pf-media.over .m-drop { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.pf-note p { font-size: 16.5px; line-height: 1.65; text-wrap: pretty; }
.pf-note p + p { margin-top: 12px; }
.pf-meta { padding: 22px 32px 0; color: var(--faint); font-size: 12.5px; }

/* ---------- fogli modali ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: var(--scrim); opacity: 0; transition: opacity .2s; }
.sheet-wrap.open { opacity: 1; }
.sheet { width: min(560px, 100%); max-height: min(880px, calc(100dvh - 48px)); display: flex; flex-direction: column; overflow: hidden; border-radius: 28px; background: var(--surface); box-shadow: var(--shadow-lg); --gap: var(--surface); transform: translateY(14px) scale(.98); transition: transform .24s var(--ease); }
.sheet.wide { width: min(780px, 100%); }
.sheet-wrap.open .sheet { transform: none; }
.sheet > form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sheet-h { display: flex; align-items: flex-start; gap: 12px; padding: 22px 18px 4px 28px; }
.sheet-ht { flex: 1; min-width: 0; padding-top: 6px; }
.sheet-h h2 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.sheet-h p { margin-top: 4px; color: var(--muted); font-size: 14.5px; overflow-wrap: anywhere; }
.sheet-b { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 20px; padding: 16px 28px 26px; }
.sheet-b > p { color: var(--ink-2); line-height: 1.55; }
.sheet-f { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); box-shadow: 0 -1px 0 var(--line); }
.sheet-f .sp { flex: 1; }
.lead { color: var(--ink-2); font-size: 15px; line-height: 1.55; }
.sub-h { margin-bottom: 8px; color: var(--muted); font-size: 13.5px; font-weight: 600; }

/* ---------- campi ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .lbl { color: var(--ink-2); font-size: 13.5px; font-weight: 550; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea { width: 100%; height: 44px; padding: 0 14px; border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); color: var(--ink); outline: none; transition: background .15s, border-color .15s, box-shadow .15s; }
textarea { height: auto; min-height: 108px; padding: 11px 14px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.top .search input:focus { border-color: transparent; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
#fNew { display: flex; flex-direction: column; gap: 26px; }
#fLink { display: flex; flex-direction: column; gap: 10px; }
.f-sec { min-width: 0; display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; border: 0; }
.f-sec legend { padding: 0; margin-bottom: 14px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.select { position: relative; }
.select select { padding-right: 40px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.select .ico { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.select.sm select { height: 36px; font-size: 13.5px; padding: 0 34px 0 12px; border-radius: 10px; }
.select.sm .ico { right: 10px; }
.input-ico { position: relative; }
.input-ico .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-ico input { padding-left: 40px; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.sw { position: relative; flex: none; width: 46px; height: 28px; border-radius: 99px; background: var(--surface-3); transition: background .2s; }
.sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .22s var(--ease); }
.switch input:checked + .sw { background: var(--accent); }
.switch input:checked + .sw::after { transform: translateX(18px); }
.switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; margin: 0 -8px; }
.pick { display: flex; align-items: center; gap: 12px; padding: 8px; border: 0; border-radius: 14px; background: none; text-align: left; }
.pick:hover { background: var(--surface-2); --gap: var(--surface-2); }
.pick.on { background: var(--accent-soft); }
.pick.on > .ico { color: var(--accent-text); }
.pick-t { flex: 1; min-width: 0; }
.pick-t b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-t small { display: block; color: var(--muted); font-size: 13px; }
.pw { position: relative; }
.pw input { padding-right: 48px; }
.pw-eye { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--muted); }
.pw-eye:hover, .pw-eye.on { color: var(--accent-text); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }

/* righe (membri, alberi, inviti) */
.rows { display: flex; flex-direction: column; gap: 2px; }
.row-i { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0; }
.row-t { flex: 1; min-width: 0; }
.row-t b { display: block; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-t small { display: block; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); }
.btnrow { width: 100%; padding: 8px 10px; margin: 0 -10px; width: calc(100% + 20px); border: 0; border-radius: 16px; background: none; text-align: left; }
.btnrow:hover { background: var(--surface-2); }
.btnrow.on .row-ico { background: var(--accent-soft); color: var(--accent-text); }
.btnrow > .ico { color: var(--accent-text); }
.row-t .you { display: inline; margin-left: 4px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 550; vertical-align: 1px; }
.inv-card { display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: 22px; background: var(--surface-2); }
.inv-card h3 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.inv-card .seg { background: var(--surface-3); }
.inv-card input[type="text"] { background: var(--surface); }
.inv-link { display: flex; flex-wrap: wrap; gap: 8px; animation: viewIn .2s var(--ease); }
.inv-link input { flex: 1 1 220px; font-size: 13.5px; }
.stat-row { display: flex; gap: 12px; }
.stat-row > div { flex: 1; padding: 14px 18px; border-radius: 18px; background: var(--surface-2); }
.stat-row b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-row span { color: var(--muted); font-size: 13.5px; }
.progress { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-2); }
.progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s var(--ease); }

/* duplicati */
.dup { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 24px; background: var(--surface-2); }
.dup-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; }
.dup-p { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding: 18px 12px 14px; border-radius: 18px; background: var(--surface); text-align: center; color: var(--muted); font-size: 13px; --gap: var(--surface); }
.dup-p b { margin-top: 10px; color: var(--ink); font-size: 15.5px; font-weight: 650; }
.dup-p .btn { margin-top: 12px; }
.dup-mid { align-self: center; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-sm); }
.dup-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; padding: 0 4px; }
.dup-why { color: var(--ink-2); font-size: 13.5px; }

/* ---------- menu ---------- */
.menu { position: fixed; z-index: 60; min-width: 248px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 90px); overflow-y: auto; padding: 6px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg), 0 0 0 1px var(--line); opacity: 0; transform: translateY(-4px) scale(.97); transition: opacity .15s, transform .15s var(--ease); }
.menu.open { opacity: 1; transform: none; }
.menu-i { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; border-radius: 12px; background: none; font-size: 14.5px; font-weight: 500; text-align: left; outline: none; }
.menu-i:hover, .menu-i:focus-visible { background: var(--surface-2); }
.menu-i > .ico:first-child { color: var(--ink-2); }
.menu-i.danger, .menu-i.danger > .ico:first-child { color: var(--danger); }
.menu-i.on { font-weight: 600; }
.menu-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu-l small { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.menu-ck { color: var(--accent-text); }
.menu-head { padding: 10px 12px 4px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.menu-head b { display: block; color: var(--ink); font-size: 15px; font-weight: 650; }
.menu-head small { display: block; font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.menu-sep { height: 1px; margin: 6px 10px; background: var(--line-2); }
.ico-sp { width: 18px; flex: none; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 95; left: 50%; bottom: 28px; display: flex; align-items: center; gap: 10px; max-width: min(520px, calc(100vw - 32px)); padding: 8px 18px 8px 8px; border-radius: 22px; background: var(--ink); color: var(--bg); font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translate(-50%, 16px) scale(.98); transition: opacity .2s, transform .24s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-i { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; }
.toast-i > * { display: none; }
.toast[data-kind="ok"] .t-ok, .toast[data-kind="err"] .t-err, .toast[data-kind="busy"] .t-busy { display: block; }
.toast[data-kind="err"] .toast-i { background: var(--danger); }
.toast[data-kind="busy"] .toast-i { background: transparent; }
.toast-t { line-height: 1.35; padding: 3px 0; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--bg) 30%, transparent); border-top-color: var(--bg); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- visualizzatore ---------- */
.viewer { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: rgba(12, 11, 9, .95); color: #f4efe7; --gap: #0c0b09; opacity: 0; transition: opacity .2s; }
.viewer.open { opacity: 1; }
.vw-top { display: flex; align-items: center; gap: 10px; padding: 12px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left)); }
.vw-who { flex: 1; min-width: 0; }
.vw-person { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; padding: 6px 14px 6px 6px; border: 0; border-radius: 99px; background: none; color: inherit; text-align: left; }
.vw-person:hover { background: rgba(255, 255, 255, .08); }
.vw-person > span { min-width: 0; }
.vw-person b { display: block; font-size: 15px; font-weight: 600; }
.vw-person small { display: block; font-size: 13px; opacity: .6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vw-acts { display: flex; gap: 6px; }
.vw-btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .1); color: inherit; font-size: 14px; font-weight: 500; text-decoration: none; transition: background .15s; }
.vw-btn:hover { background: rgba(255, 255, 255, .18); }
.vw-btn.danger.solid { background: var(--danger); color: #fff; }
.vw-x, .vw-nav { display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .1); color: inherit; transition: background .15s; }
.vw-x { width: 44px; height: 44px; margin-left: 4px; }
.vw-x:hover, .vw-nav:hover { background: rgba(255, 255, 255, .2); }
.vw-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 8px 84px; overflow: hidden; touch-action: pan-y; }
.vw-stage img { max-width: 100%; max-height: calc(100dvh - 150px); object-fit: contain; border-radius: 6px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); user-select: none; -webkit-user-drag: none; }
.vw-stage.in > * { animation: vwIn .24s var(--ease); }
.vw-stage.in[data-dir="next"] > * { animation-name: vwNext; }
.vw-stage.in[data-dir="prev"] > * { animation-name: vwPrev; }
@keyframes vwIn { from { opacity: 0; transform: scale(.97); } }
@keyframes vwNext { from { opacity: 0; transform: translateX(28px); } }
@keyframes vwPrev { from { opacity: 0; transform: translateX(-28px); } }
.vw-nav { position: absolute; top: 50%; width: 52px; height: 52px; margin-top: -26px; }
.vw-prev { left: 18px; }
.vw-next { right: 18px; }
.viewer.single .vw-nav { display: none; }
.vw-count { padding: 10px 0 calc(18px + env(safe-area-inset-bottom)); text-align: center; font-size: 13.5px; opacity: .65; font-variant-numeric: tabular-nums; min-height: 20px; }
.vw-doc { display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 420px; padding: 40px 44px; border-radius: 28px; background: #23201c; text-align: center; }
.vw-doc b { margin-top: 8px; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.vw-doc span { opacity: .6; font-size: 14px; }
.vw-doc .btn { margin-top: 16px; }

/* ---------- accesso ---------- */
.auth { position: fixed; inset: 0; z-index: 90; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); opacity: 0; transition: opacity .25s; }
.auth.open { opacity: 1; }
.auth-art { position: relative; overflow: hidden; margin: 16px; border-radius: 34px; background: var(--art-2); }
.auth-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-quote { position: absolute; left: 44px; right: 44px; top: 44px; margin: 0; color: var(--art-quote); font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.auth-main { display: grid; place-items: center; padding: 32px; overflow-y: auto; }
.auth-box { width: min(400px, 100%); animation: viewIn .35s var(--ease); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 44px; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.auth-box h1 { margin-bottom: 10px; font-size: 32px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; text-wrap: balance; }
.auth-sub { margin-bottom: 30px; color: var(--ink-2); font-size: 16px; line-height: 1.5; }
.auth-box form { display: flex; flex-direction: column; gap: 16px; }
.auth-box .btn.lg { margin-top: 8px; }
.auth-err { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); font-size: 14px; line-height: 1.4; }
.auth-switch { margin-top: 26px; text-align: center; color: var(--muted); font-size: 14.5px; }

/* ---------- barra delle schede (telefono) ---------- */
.tabs { display: none; }

/* ---------- schermi medi ---------- */
@media (max-width: 1180px) {
  .search { width: 220px; }
}
@media (max-width: 1060px) {
  .search { display: none; }
  .btn-search { display: inline-grid; }
  body.searching .top { grid-template-columns: 1fr; }
  body.searching .top-l, body.searching .views-seg, body.searching .top-r > :not(.search) { display: none !important; }
  body.searching .search { display: flex; width: 100%; }
  body.searching .search-back { display: inline-grid; flex: none; margin-right: 6px; }
  body.searching .search-ico { left: 58px; }
  body.searching .search-res { left: 0; right: 0; width: auto; }
}
@media (max-width: 899px) {
  .profile { top: 10px; right: 10px; bottom: 10px; width: min(560px, calc(100vw - 20px)); }
}
@media (min-width: 900px) {
  .scrim { display: none; }
  body.pf-on .view-list { max-width: none; margin: 0; padding-right: calc(var(--pf-w) + 44px); padding-left: 40px; }
  body.pf-on .tree-ctl { left: calc((100% - var(--pf-w) - 12px) / 2); }
}

/* ---------- telefono ---------- */
@media (max-width: 760px) {
  :root { --top-h: 56px; }
  body { font-size: 15px; }
  .top { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); }
  .views-seg { display: none; }
  .brand .logo { width: 28px; height: 28px; }
  .tree-btn { padding: 0 6px; font-size: 16px; }
  #rolePill { width: 26px; padding: 0; justify-content: center; font-size: 0; gap: 0; }
  .invite { width: 40px; padding: 0; margin-left: 0; }
  .invite span { display: none; }
  .top-r { gap: 2px; }
  body.searching .search-ico { left: 54px; }
  .tabs { position: relative; z-index: 20; display: grid; grid-template-columns: repeat(3, 1fr); height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px); box-shadow: 0 -1px 0 var(--line); }
  .tabs button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font-size: 11.5px; font-weight: 600; transition: color .15s; }
  .tabs button.on { color: var(--accent-text); }
  .toast { bottom: calc(78px + env(safe-area-inset-bottom)); }
  .tree-ctl { bottom: 14px; padding: 4px; border-radius: 16px; }
  .tree-ctl button, .ctl-gen, .tree-ctl .ctl-gen select { height: 36px; }
  .tree-ctl button { width: 36px; }
  .view-list { padding: 22px 16px 40px; }
  .vh { margin-bottom: 16px; }
  .vh h1 { font-size: 28px; }
  .vh .btn span { display: none; }
  .vh .btn { width: 44px; padding: 0; border-radius: 14px; }
  #viewPhotos .vh { flex-direction: column; align-items: flex-start; gap: 14px; }
  .pf-acts { gap: 6px; flex-wrap: nowrap; }
  .pf-acts .btn { padding: 0 13px; }
  .p-tools { flex-direction: column; align-items: stretch; gap: 12px; }
  .p-tools .seg { align-self: flex-start; }
  .chips { margin: 0 -16px; padding: 2px 32px 2px 16px; }
  .p-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .p-card { padding: 16px 6px 14px; border-radius: 20px; }
  .p-card .ava { --s: 96px !important; }
  .g-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .g-tile { border-radius: 10px; }
  .g-sec { margin-bottom: 26px; }
  .g-sec .g-grid { margin: 0 -10px; }
  /* profilo a tutto schermo che sale dal basso */
  .profile { inset: 0; width: auto; border-radius: 0; opacity: 1; transform: translateY(100%); transition: transform .3s var(--ease); padding-top: env(safe-area-inset-top); }
  .profile.open { transform: none; }
  .scrim { display: none; }
  .pf-bar { top: env(safe-area-inset-top); height: 56px; padding: 0 8px 0 18px; }
  .pf-hero { padding: 48px 20px 26px; }
  .pf-name { font-size: 27px; }
  .pf-sec { padding: 24px 20px 4px; }
  .fam-row { margin: 0 -20px; padding: 6px 20px 4px; scroll-padding: 0 20px; }
  .pf-meta { padding: 22px 20px 0; }
  .pf-scroll { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
  /* fogli dal basso */
  .sheet-wrap { padding: 0; align-items: end; justify-items: stretch; }
  .sheet, .sheet.wide { width: 100%; max-height: calc(100dvh - 16px); border-radius: 26px 26px 0 0; transform: translateY(100%); transition: transform .3s var(--ease); }
  .sheet.form-sheet { height: calc(100dvh - 16px); }
  .sheet-h { padding: 18px 12px 2px 20px; }
  .sheet-h h2 { font-size: 20px; }
  .sheet-b { padding: 14px 20px 22px; }
  .sheet-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .sheet-f .btn { flex: 1; }
  .sheet-f .sp { display: none; }
  .sheet-f #fDel { flex: none; width: 44px; padding: 0; }
  .hide-xs { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .dup-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dup-mid { display: none; }
  .dup-p { padding: 14px 8px 12px; }
  .dup-p .btn { width: 100%; padding: 0 8px; }
  .inline { flex-wrap: wrap; }
  .menu { min-width: min(280px, calc(100vw - 16px)); }
  .vw-stage { padding: 4px 0; }
  .vw-nav { display: none; }
  .vw-btn span { display: none; }
  .vw-btn { width: 40px; padding: 0; justify-content: center; }
  .vw-acts a.vw-btn:first-child:not([download]) span { display: inline; }
  .auth { grid-template-columns: 1fr; grid-template-rows: 210px auto; overflow-y: auto; }
  .auth-art { margin: 10px 10px 0; border-radius: 26px; }
  .auth-quote { display: none; }
  .auth-main { padding: 28px 20px calc(28px + env(safe-area-inset-bottom)); place-items: start center; overflow: visible; }
  .auth-brand { margin-bottom: 26px; }
  .auth-box h1 { font-size: 27px; }
}
@media (max-width: 400px) {
  .tree-btn { font-size: 15px; }
  .ctl-gen svg { display: none; }
  .ctl-gen { padding-left: 4px; }
}

/* ---------- movimento ridotto ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skel { animation: none; }
}
