/* Ahnenforschung: ruhiges Layout. Farben als Variablen, mit dunklem Modus.
   Palette: Muted Teal #7c9885, Charcoal Brown #484538, White #fbfbfb,
   Sapphire #0353a4, Cornflower Ocean #006daa. Dazu ein neutrales Grau für Verstorbene.
   Der hervorgehobene Verwandtschaftsweg leuchtet in Sapphire. */

:root {
  --teal: #7c9885;
  --charcoal: #484538;
  --white: #fbfbfb;
  --sapphire: #0353a4;
  --cornflower: #006daa;

  --bg: #eff1ee;
  --paper: var(--white);
  --ink: var(--charcoal);
  --muted: #77735f;
  --line: #d9ddd6;
  --accent: var(--cornflower);
  --accent-ink: var(--white);
  --accent-soft: #e0edf5;
  --danger: #a33b2b;
  --warn: #8a6400;
  --hl: var(--sapphire);
  --hl-soft: #cfe2f7;
  --hl-glow: rgba(3, 83, 164, .55);

  /* Karten im Stammbaum */
  --alive: #dcebf4;           /* lebend: helles Cornflower */
  --alive-line: var(--cornflower);
  --dead: #e4e4e4;            /* verstorben: neutrales Grau */
  --dead-line: #a6a6a6;
  --dead-ink: #6b6b6b;
  --line-efferoth: var(--sapphire);
  --efferoth-soft: #d9e5f3;
  --line-inlaw: var(--teal);
  --inlaw-soft: #dce7df;

  --shadow: 0 1px 2px rgba(72, 69, 56, .08), 0 4px 14px rgba(72, 69, 56, .06);
  --radius: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #23221b;
    --paper: #2e2d25;
    --ink: var(--white);
    --muted: #b5b1a0;
    --line: #48463a;
    --accent: #4fa3d6;
    --accent-ink: #0d1d28;
    --accent-soft: #1f3442;
    --danger: #ef8a78;
    --warn: #e8b84f;
    --hl: #6db3ff;
    --hl-soft: #1b3150;
    --hl-glow: rgba(109, 179, 255, .6);
    --alive: #1d3a4f;
    --alive-line: #4fa3d6;
    --dead: #3a3a38;
    --dead-line: #6e6e6a;
    --dead-ink: #b3b3ae;
    --line-efferoth: #5c9be0;
    --efferoth-soft: #1b3150;
    --line-inlaw: #9cb8a5;
    --inlaw-soft: #2d3d33;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.3rem; margin-top: .3em; }
h3 { font-size: 1.05rem; margin-top: 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--danger); }
.warn { color: var(--warn); }
.ok { color: var(--accent); font-weight: 600; }
.loading { padding: 2rem; color: var(--muted); }
code { background: var(--accent-soft); padding: 0 .3em; border-radius: 4px; }

/* Kopfzeile */
/* Das Logo ist für dunklen Grund gemacht (weißer Schriftzug), die Leiste bleibt darum in beiden Modi Charcoal */
.topbar {
  display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap;
  padding: .3rem 1.2rem; background: var(--charcoal); box-shadow: 0 2px 8px rgba(72, 69, 56, .28);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: block; flex: none; }
.brand img { display: block; width: 72px; height: 72px; }
.topbar nav { display: flex; gap: .3rem; flex-wrap: wrap; }
.topbar nav a, .me a { padding: .4rem .85rem; border-radius: 8px; text-decoration: none; color: var(--white); font-weight: 500; }
.topbar nav a.active, .me a.active { background: var(--cornflower); font-weight: 600; }
.topbar nav a:not(.active):hover, .me a:not(.active):not(.me-avatar):hover { background: rgba(251, 251, 251, .14); }
.me { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.me a.me-avatar {
  width: 46px; height: 46px; padding: 0; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; background: var(--teal); border: 2px solid var(--white);
  font: 700 1rem var(--serif);
}
.me-avatar:hover { box-shadow: 0 0 0 3px rgba(251, 251, 251, .35); }
.me-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

main { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
main.full { max-width: none; padding: 0; }

/* Karten und Formulare */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem 1.4rem; margin-bottom: 1rem;
}
.card.narrow { max-width: 440px; margin: 8vh auto; }
.card-sub { border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem; margin: .8rem 0; }
.form-card { max-width: 820px; margin-inline: auto; }
.plain-wrap { padding: 1rem; }
body.plain { padding: 1rem; }

.form { display: grid; gap: .9rem; }
.form label, .grid2 label, .grid3 label { display: grid; gap: .25rem; font-size: .9rem; font-weight: 600; }
.form label[hidden] { display: none; }
.form label.btn { display: inline-flex; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem 1rem; }
.grid2 .wide { grid-column: 1 / -1; }
label.check { display: flex !important; align-items: center; gap: .5rem; font-weight: 400 !important; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0;
}
input[type=checkbox] { width: auto; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }
.inline-form > * { flex: 1 1 140px; width: auto; }
.inline-form .btn { flex: 0 0 auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  font: inherit; font-size: .95rem; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { font-size: .85rem; padding: .25rem .6rem; }
.btn.icon { width: 2.2rem; padding: .35rem 0; font-size: 1.1rem; }
.btn.link { border: none; background: none; padding: 0 .2rem; color: var(--accent); font-weight: 400; }
.btn.link.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .8rem; }
.btn-row input { flex: 1 1 220px; width: auto; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.section-head h1, .section-head h2 { margin: 0; }
.tag { font: 600 .75rem var(--sans); background: var(--accent-soft); color: var(--accent); padding: .1rem .5rem; border-radius: 99px; vertical-align: middle; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
ul.plain li:last-child { border-bottom: none; }

/* Personenauswahl */
.picker { position: relative; flex: 1 1 220px; }
.picker-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: .25rem;
  list-style: none; background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 300px; overflow: auto; font-weight: 400;
}
.picker-list li { padding: .4rem .6rem; border-radius: 6px; cursor: pointer; }
.picker-list li.active, .picker-list li:hover { background: var(--accent-soft); }

/* Stammbaum */
body.tree-mode { overflow: hidden; }
body.tree-mode #app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.tree-mode main.full { flex: 1; min-height: 0; width: 100%; }
.legend[hidden], .side[hidden] { display: none; }
.tree-page { position: relative; height: 100%; display: flex; flex-direction: column; }
.tree-toolbar {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  padding: .6rem 1rem; background: var(--paper); border-bottom: 1px solid var(--line);
}
.tree-toolbar #find { max-width: 280px; }
.root-select { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.root-select select { max-width: 300px; }
.root-select .picker { flex: none; width: 250px; }
.zoom { display: flex; gap: .3rem; }
.tree-area { flex: 1; position: relative; overflow: hidden; background:
  radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 1px) 0 0 / 22px 22px, var(--bg); }
.tree-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; user-select: none; }
.tree-svg:active { cursor: grabbing; }
.hint { position: absolute; left: 1rem; bottom: .3rem; margin: 0; font-size: .78rem; pointer-events: none; }

.edge { fill: none; stroke: var(--dead-line); stroke-width: 1.8; }
.edge.spouse { stroke-dasharray: 5 4; }
.edge.hl { stroke: var(--hl); stroke-width: 6; stroke-dasharray: none; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 5px var(--hl-glow)); }

/* Karten: lebend farbig, verstorben grau */
.card { cursor: pointer; }
.card rect { fill: var(--alive); stroke: var(--alive-line); stroke-width: 1.4; transition: stroke-width .15s; }
.card.deceased rect { fill: var(--dead); stroke: var(--dead-line); }
.card text { fill: var(--ink); font-family: var(--sans); pointer-events: none; }
.card.deceased text { fill: var(--dead-ink); }
.card .given { font-size: 16px; font-weight: 650; }
.card .surname { font-size: 14px; }
.card .years { font-size: 12.5px; fill: var(--muted); }
.card .card-line { stroke: var(--alive-line); stroke-opacity: .45; stroke-width: 1.2; fill: none; }
.card.deceased .card-line { stroke: var(--dead-line); }
.card .photo-ring { fill: var(--paper); }
.card .photo-ph { fill: var(--accent-soft); }
.card.deceased .photo-ph { fill: #cfcfcf; }
.card .initials { font: 700 18px var(--serif); fill: var(--accent) !important; }
.card.deceased .initials { fill: var(--dead-ink) !important; }
.card.deceased image { filter: grayscale(1); }
.more-kids { font: 600 12px var(--sans); fill: var(--muted); }
.card:hover rect, .card:focus rect { stroke: var(--accent); stroke-width: 2.6; }
.card:focus { outline: none; }
.card.selected rect { stroke: var(--accent); stroke-width: 4; }

/* Efferoth-Linie hervorheben: Linie dick in Sapphire umrandet, Angeheiratete in Teal gefüllt */
.mode-line .card.line-blood rect { stroke: var(--line-efferoth); stroke-width: 4; }
.mode-line .card.line-blood.alive rect { fill: var(--efferoth-soft); }
.mode-line .card.line-inlaw rect { stroke: var(--line-inlaw); stroke-width: 1.6; }
.mode-line .card.line-inlaw.alive rect { fill: var(--inlaw-soft); }
.mode-line .card.line-inlaw .photo-ph { fill: var(--inlaw-soft); }
.mode-line .card.line-inlaw .initials { fill: var(--line-inlaw) !important; }

.has-path .card { opacity: .3; }
.has-path .edge:not(.hl) { opacity: .3; }
.has-path .card.hl { opacity: 1; }
.card.hl rect { stroke: var(--hl) !important; stroke-width: 4 !important; }
.card.hl-end rect { fill: var(--hl-soft) !important; stroke-width: 5 !important; }

/* Baumkrone: illustrierter Hintergrund, Äste in Holzfarbe, runde Knoten, Wachstums-Animation */
:root { --wood: #6f6450; --sky-top: #dbe8f1; --sky-bottom: #f4f6f1; --leaf: #7c9885; }
@media (prefers-color-scheme: dark) { :root { --wood: #a8977a; --sky-top: #172634; --sky-bottom: #23221b; --leaf: #6f8a77; } }
.tree-area.radial {
  background:
    radial-gradient(circle at 82% 12%, rgba(255, 236, 170, .55) 0, rgba(255, 236, 170, 0) 16%),
    linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-bottom) 70%);
}
.radial .r-crown { fill: var(--leaf); opacity: .16; }
.radial .r-crown.inner { fill: var(--cornflower); opacity: .07; }
.radial .r-ring { fill: none; stroke: var(--leaf); stroke-opacity: .45; stroke-width: 1.5; stroke-dasharray: 3 7; }
.radial .r-ring-label { font: 600 13px var(--sans); fill: var(--muted); opacity: .8; }
.radial .r-ground { fill: var(--leaf); opacity: .5; }
.radial .r-trunk { fill: var(--wood); }
.radial .r-leaf { fill: var(--leaf); opacity: .55; }
.radial .edge.branch { stroke: var(--wood); stroke-width: var(--w); stroke-linecap: round; opacity: .9; }
.radial .edge.spouse { stroke: var(--leaf); stroke-width: 2.5; stroke-dasharray: 4 4; }
.radial .edge.hl { stroke: var(--hl); stroke-width: 8; opacity: 1; }

.rnode .disc { fill: var(--paper); stroke: var(--alive-line); stroke-width: 3; }
.rnode.deceased .disc { stroke: var(--dead-line); }
.rnode .photo-ph { fill: var(--alive); }
.rnode.deceased .photo-ph { fill: var(--dead); }
.rnode .r-name, .rnode .r-years, .radial .more-kids {
  paint-order: stroke; stroke: var(--sky-bottom); stroke-width: 4px; stroke-linejoin: round;
}
.rnode .r-name { font: 650 15px var(--sans); fill: var(--ink); }
.rnode .r-years { font: 12.5px var(--sans); fill: var(--muted); }
.rnode.deceased .r-name { fill: var(--dead-ink); }
.rnode-inner { transform-origin: 0 0; transition: transform .2s; }
.rnode:hover .rnode-inner, .rnode:focus .rnode-inner { transform: scale(1.08); }
.rnode.selected .disc { stroke: var(--accent); stroke-width: 5; }
.mode-line .rnode.line-blood .disc { stroke: var(--line-efferoth); stroke-width: 5.5; }
.mode-line .rnode.line-inlaw .disc { stroke: var(--line-inlaw); fill: var(--inlaw-soft); }
.mode-line .rnode.line-inlaw .photo-ph { fill: var(--inlaw-soft); }
.rnode.hl .disc { stroke: var(--hl) !important; stroke-width: 6 !important; }
.rnode.hl-end .disc { fill: var(--hl-soft) !important; }

/* Wachsen: erst die Äste, dann die Knoten, Generation für Generation */
.radial .tree-svg .edge { stroke-dasharray: calc(var(--len, 0) * 1px); stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s ease-out calc(var(--g, 0) * .22s); }
.radial .tree-svg .edge.spouse { stroke-dasharray: 4 4; transition: opacity .6s calc(var(--g, 0) * .22s + .5s); }
.radial .tree-svg .edge.hl { stroke-dasharray: none; }
.radial .tree-svg:not(.grown) .edge.branch { stroke-dashoffset: calc(var(--len, 0) * 1px); transition: none; }
.radial .tree-svg:not(.grown) .edge.spouse { opacity: 0; transition: none; }
.radial .tree-svg .rnode .rnode-inner { transition: transform .5s cubic-bezier(.3, 1.5, .5, 1) calc(var(--g, 0) * .22s + .35s); }
.radial .tree-svg:not(.grown) .rnode .rnode-inner { transform: scale(0); transition: none; }
.radial .tree-svg .r-leaf { transition: opacity .8s calc(var(--g, 0) * .22s + .6s); }
.radial .tree-svg:not(.grown) .r-leaf { opacity: 0; transition: none; }
@media (prefers-reduced-motion: reduce) {
  .radial .tree-svg *, .radial .tree-svg:not(.grown) * { transition: none !important; }
  .radial .tree-svg:not(.grown) .rnode .rnode-inner { transform: none; }
  .radial .tree-svg:not(.grown) .edge.branch { stroke-dashoffset: 0; }
}

.legend {
  position: absolute; left: 12px; bottom: 28px; display: flex; gap: .9rem; flex-wrap: wrap;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .4rem .7rem;
  font-size: .82rem; box-shadow: var(--shadow); z-index: 5;
}
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend i { width: 18px; height: 12px; border-radius: 4px; display: inline-block; }
.legend .l-blood { background: var(--efferoth-soft); border: 3px solid var(--line-efferoth); }
.legend .l-inlaw { background: var(--inlaw-soft); border: 1.5px solid var(--line-inlaw); }
.legend .l-dead { background: var(--dead); border: 1.5px solid var(--dead-line); }
.btn.toggle[aria-pressed="true"] { background: var(--sapphire); border-color: var(--sapphire); color: var(--white); }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; }
.seg .btn:first-child { border-radius: 8px 0 0 8px; }
.seg .btn:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.seg .btn.on { background: var(--sapphire); border-color: var(--sapphire); color: var(--white); }
.tree-options { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.tree-options select { width: auto; }

/* Seitenleiste im Stammbaum */
.side {
  position: absolute; top: 64px; right: 12px; width: 340px; max-height: calc(100% - 80px); overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; z-index: 10;
}
.side .close { position: absolute; top: .4rem; right: .6rem; border: none; background: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }
.side-head { display: flex; gap: .8rem; align-items: center; margin-bottom: .5rem; padding-right: 1.5rem; }
.side-head h2 { margin: 0; font-size: 1.2rem; }
.side h3 { font-size: .95rem; margin: 1rem 0 .4rem; }
.avatar-wrap { position: relative; cursor: pointer; flex: none; }
.avatar-btn {
  position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center;
  font-weight: 700; font-size: .9rem; border: 2px solid var(--paper);
}
.avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; flex: none; }
.ph { display: grid; place-items: center; font: 700 1.4rem var(--serif); background: var(--accent-soft); color: var(--accent); }
dl.mini { display: grid; grid-template-columns: auto 1fr; gap: .2rem .7rem; margin: .5rem 0; font-size: .9rem; }
dl.mini dt { color: var(--muted); }
dl.mini dd { margin: 0; }
.relation { margin-top: .8rem; padding: .8rem; border-radius: 10px; background: var(--hl-soft); border: 1px solid var(--hl); }
.rel-sentence { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; margin: 0 0 .4rem; }
ol.path { margin: .4rem 0 .6rem; padding-left: 1.3rem; font-size: .9rem; }

/* Profil */
/* Profilkopf wie bei LinkedIn: Titelbild, darüber ragt das runde Profilbild */
.profile-head { padding: 0; overflow: hidden; }
.cover {
  position: relative; height: 220px; background-size: cover; background-position: center;
  background-color: var(--teal);
  background-image: linear-gradient(135deg, var(--sapphire), var(--cornflower) 55%, var(--teal));
}
.cover-actions { position: absolute; right: 12px; top: 12px; display: flex; gap: .4rem; }
.cover-actions .btn { background: rgba(251, 251, 251, .92); }
.head-body { display: flex; gap: 1.4rem; align-items: flex-end; padding: 0 1.4rem 1.2rem; }
.portrait-wrap { position: relative; margin-top: -84px; flex: none; }
.portrait {
  width: 168px; height: 168px; border-radius: 50%; object-fit: cover; display: grid; place-items: center;
  border: 5px solid var(--paper); background: var(--accent-soft); font-size: 3.4rem; box-shadow: var(--shadow);
}
.portrait.deceased-img { filter: grayscale(1); }
.portrait-btn {
  position: absolute; right: 6px; bottom: 6px; width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--paper); background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer; font-size: 1.1rem;
}
.head-body .grow { padding-top: .8rem; }
.head-body h1 { margin-bottom: .2rem; }
.about { white-space: pre-wrap; }
.about-empty { display: block; width: 100%; text-align: left; font: inherit; cursor: pointer; background: none; border: 2px dashed var(--line); border-radius: 10px; padding: 1rem; color: var(--muted); }
.about-empty:hover { border-color: var(--accent); color: var(--accent); }
.story { background: var(--accent-soft); border-radius: 10px; padding: .8rem 1rem; margin-top: .5rem; }
.story h4 { margin: 0 0 .3rem; font: 600 .9rem var(--sans); color: var(--accent); }
.story p { margin: 0 0 .5em; }
.grow { flex: 1; min-width: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.cols .card { margin-bottom: 0; }
.cols + * { margin-top: 1rem; }
dl.family { display: grid; grid-template-columns: 110px 1fr; gap: .5rem .8rem; margin: 0; }
dl.family dt { color: var(--muted); font-size: .9rem; }
dl.family dd { margin: 0; }
dl.family .kids { margin: .3rem 0 0 .8rem; padding-left: .7rem; border-left: 2px solid var(--line); }
.prose { line-height: 1.65; }
.prose p { margin: 0 0 1em; }
.article { max-width: 760px; margin-inline: auto; }
a.tag { text-decoration: none; }
.article-hero { display: block; width: 100%; max-height: 460px; object-fit: cover; border-radius: 10px; margin: 0 0 1rem; }

/* Artikel: Filter nach Kategorie und Kacheln mit Bild */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.chips .btn.on { background: var(--sapphire); border-color: var(--sapphire); color: var(--white); }
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.article-tile {
  display: flex; flex-direction: column; overflow: hidden; color: inherit; text-decoration: none;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.article-tile:hover { border-color: var(--accent); }
.article-tile img, .tile-ph { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--accent-soft); }
.tile-body { padding: .7rem .8rem .8rem; }
.tile-body h2 { font-size: 1.1rem; margin: .4rem 0 .3rem; }
.tile-body p { margin: 0 0 .4rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; display: block; background: var(--dead); }
.gallery figcaption { font-size: .85rem; margin-top: .3rem; }
.fig-actions { display: block; }

.place-list, .article-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.place-list li, .article-list li { padding: .6rem 0; border-bottom: 1px solid var(--line); }

.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 1rem; }
.tbl th, .tbl td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl select { width: auto; padding: .2rem .4rem; }
.copy { display: flex; gap: .5rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: 10px; z-index: 100;
  transition: all .25s; max-width: calc(100% - 2rem);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }

@media (max-width: 760px) {
  h1 { font-size: 1.45rem; }
  .grid2, .cols { grid-template-columns: 1fr; }
  .cover { height: 140px; }
  .head-body { flex-direction: column; align-items: flex-start; gap: .4rem; padding: 0 1rem 1rem; }
  .portrait-wrap { margin-top: -64px; }
  .portrait { width: 124px; height: 124px; }
  .legend { bottom: 8px; }
  .topbar { gap: .2rem .4rem; padding: .25rem .5rem; }
  .brand img { width: 52px; height: 52px; }
  .topbar nav { order: 3; width: 100%; flex-wrap: nowrap; justify-content: space-between; }
  .topbar nav a, .me a { padding: .25rem .5rem; font-size: .92rem; }
  .me a.me-avatar { width: 40px; height: 40px; }
  .me { margin-left: auto; }
  .tree-toolbar { padding: .5rem; gap: .4rem; }
  .tree-toolbar #find { max-width: none; flex: 1 1 100%; }
  .root-select select { max-width: 60vw; }
  .root-select .picker { width: 60vw; }
  .side { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; max-height: 58%; }
  .hint { display: none; }
  dl.family { grid-template-columns: 1fr; }
  .tbl { display: block; overflow-x: auto; }
}
.trash-thumb { width: 2.5rem; height: 2.5rem; object-fit: cover; border-radius: 6px; vertical-align: middle; margin-right: .4rem; }
