:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3ede4;
  --border: #e7dccd;
  --text: #2a2118;
  --muted: #7a6b5c;
  --accent: #9a5b2e;
  --accent-2: #c07a43;
  --accent-soft: #f5e9dc;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --ok: #2f855a;
  --warn: #a16207;
  --warn-soft: #fdf3dc;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 7%);
  --radius: 14px;
  --g-m: #5b7fa6;
  --g-w: #b5687a;
  --g-x: #9b8f80;
  --tree-line: #b9a58f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15120f;
    --surface: #1e1a16;
    --surface-2: #28221c;
    --border: #3a3129;
    --text: #efe7dc;
    --muted: #a8998a;
    --accent: #e0a36b;
    --accent-2: #f0b47c;
    --accent-soft: #3a2a1c;
    --accent-text: #1a120b;
    --danger: #ef6b5b;
    --warn: #fbbf24;
    --warn-soft: #2d2412;
    --shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 6px 20px rgb(0 0 0 / 30%);
    --g-m: #7fa3cc;
    --g-w: #d48ba0;
    --g-x: #a89c8e;
    --tree-line: #6f6152;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 600 1.75rem/1.15 var(--serif); letter-spacing: -0.01em; }
h2 { font-size: 1.12rem; }
h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.pad { padding: 18px; }
.pad-s { padding: 10px; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
[hidden] { display: none !important; }
.row-gap { display: flex; align-items: center; gap: 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.error-text { color: var(--danger); font-size: 0.9rem; min-height: 1em; }
.danger-text { color: var(--danger) !important; }
.section { margin-top: 26px; }
.sec-title { margin-bottom: 10px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
svg { width: 20px; height: 20px; flex: none; }

/* ------------------------------ Layout ------------------------------ */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font: 600 1.05rem/1.2 var(--serif); color: var(--text); text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font: 500 0.78rem system-ui, sans-serif; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.upload-btn { margin: 14px 4px 0; justify-content: center; }
.spacer { flex: 1; }
.guest-box { padding: 12px; border-radius: 12px; background: var(--surface-2); display: grid; gap: 2px; }
.main { padding: 28px 32px 120px; min-width: 0; max-width: 1500px; width: 100%; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
    font-size: 0.7rem; color: var(--muted); text-decoration: none; font-weight: 500;
  }
  .tabbar a.active { color: var(--accent); }
  h1 { font-size: 1.45rem; }
  .hide-mobile { display: none; }
}

.page-head { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .muted { margin-top: 4px; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; font-size: 0.88rem; }
.crumbs svg { width: 14px; height: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* ------------------------------ Bausteine ------------------------------ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.empty, .empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.card.empty p { margin: 0 0 12px; }
a.card { color: inherit; text-decoration: none; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.form { display: grid; gap: 14px; align-content: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 0.86rem; gap: 6px; border-radius: 9px; }
.btn.sm svg { width: 17px; height: 17px; }
.btn .count { background: var(--accent); color: var(--accent-text); border-radius: 99px; padding: 0 7px; font-size: 0.75rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: none; background: transparent; color: var(--muted); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.link-btn { border: none; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 550; }
.link-btn:hover { text-decoration: underline; }
.pill { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; }

.field { display: grid; gap: 6px; font-weight: 550; font-size: 0.92rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; margin-top: -3px; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 400; min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
select { width: auto; }
.field select { width: 100%; }
.toggle { display: flex; align-items: center; gap: 9px; font-weight: 500; cursor: pointer; }
.toggle input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.toggle.small { font-size: 0.86rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface); font-size: 0.86rem; cursor: pointer; color: var(--text); text-decoration: none;
}
.chip svg { width: 15px; height: 15px; }
.chip.sm { padding: 3px 9px; font-size: 0.8rem; }
.chip small { color: var(--muted); font-size: 0.72rem; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip a { color: inherit; text-decoration: none; }
.chip.person { padding-left: 4px; }
.chip.person img, .chip.person .avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.chip.add { border-style: dashed; color: var(--muted); }
.chip-x { border: none; background: none; padding: 0; margin-right: -4px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.chip-x svg { width: 14px; height: 14px; }
.chip-in { width: 140px !important; padding: 4px 10px !important; border-radius: 99px !important; font-size: 0.86rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; display: grid; gap: 2px; }
.stat b { font: 600 1.6rem var(--serif); }
.stat span { color: var(--muted); font-size: 0.86rem; }

.hint-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: 14px; font-size: 0.9rem; }
.warn-box { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 0.9rem; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 16px; }
.toolbar-item { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--muted); }
.toolbar-item select { padding: 6px 9px; color: var(--text); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); flex: 1 1 260px; max-width: 520px; }
.search svg { color: var(--muted); width: 18px; }
.search input { border: none !important; outline: none !important; padding: 9px 0; background: transparent; }
.view-controls { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.view-controls input[type=range] { width: 110px; accent-color: var(--accent); }

/* ------------------------------ Popup & Dialoge ------------------------------ */
.popmenu {
  position: fixed; z-index: 120; min-width: 200px; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 40px rgb(0 0 0 / 22%);
  display: grid;
}
.popmenu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: none; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.popmenu button svg { width: 17px; height: 17px; color: var(--muted); }
.popmenu button:hover:not(:disabled) { background: var(--surface-2); }
.popmenu button:disabled { opacity: 0.45; cursor: default; }
.popmenu button.danger { color: var(--danger); }
.popmenu button.danger svg { color: var(--danger); }
.popmenu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.modal-back { position: fixed; inset: 0; z-index: 100; background: rgb(20 14 8 / 50%); display: grid; place-items: center; padding: 16px; animation: fade 0.12s; }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.modal-head h2 { flex: 1; }
.modal-body { padding: 4px 18px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 600px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
  .modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

.picker { display: grid; gap: 10px; }
.pick-list { display: grid; gap: 2px; max-height: 52vh; overflow-y: auto; }
.pick-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: none; background: none; border-radius: 9px; cursor: pointer; text-align: left; }
.pick-item:hover { background: var(--surface-2); }
.pick-item.on { background: var(--accent-soft); }
.pick-item img, .pick-dot { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); }
.pick-item span { flex: 1; display: grid; }
.pick-item small { color: var(--muted); font-size: 0.78rem; }
.pick-item svg { color: var(--accent); }
.pick-item.create { color: var(--accent); font-weight: 550; }

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 550; transition: 0.2s; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }
@media (max-width: 860px) { #toast { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* ------------------------------ Anmeldung ------------------------------ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 50%), var(--bg); }
.auth form { width: min(400px, 100%); padding: 26px; display: grid; gap: 14px; }
.auth .brand { padding: 0 0 6px; font-size: 1.3rem; }
.auth .brand img { width: 44px; height: 44px; }
.switch { text-align: center; font-size: 0.9rem; color: var(--muted); }
.switch button { border: none; background: none; color: var(--accent); font-weight: 600; cursor: pointer; }

/* ------------------------------ Alben ------------------------------ */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.album-card { display: grid; gap: 8px; color: inherit; text-decoration: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.album-cover {
  position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--surface-2);
  box-shadow: var(--shadow), 6px 6px 0 -1px var(--surface), 6px 6px 0 0 var(--border);
  transition: transform 0.15s;
}
.album-card:hover .album-cover { transform: translateY(-2px); }
.album-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-empty { display: grid; place-items: center; height: 100%; color: var(--muted); }
.album-empty svg { width: 40px; height: 40px; opacity: 0.5; }
.album-subs { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; background: rgb(0 0 0 / 55%); color: #fff; font-size: 0.78rem; }
.album-subs svg { width: 14px; height: 14px; }
.album-meta { display: grid; gap: 1px; padding: 0 2px; }
.album-meta b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-grid.arranging .album-card { cursor: grab; }
.album-card.dragging { opacity: 0.45; }
.album-desc { white-space: pre-line; color: var(--muted); max-width: 75ch; margin: -8px 0 18px; }

/* ------------------------------ Fotoraster ------------------------------ */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 180px), 1fr)); gap: 6px; }
.grid[data-fit=contain] { align-items: start; }
.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 8px; background: var(--surface-2); cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline-offset: 2px;
}
.grid[data-fit=contain] .tile { background: transparent; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.2s; }
.grid[data-fit=contain] .tile img { object-fit: contain; }
.tile:hover img { transform: scale(1.03); }
.tile-ph { display: grid; place-items: center; align-content: center; gap: 6px; height: 100%; color: var(--muted); padding: 8px; text-align: center; }
.tile-ph svg { width: 34px; height: 34px; }
.tile-ph small { font-size: 0.72rem; word-break: break-all; }
.tile-check {
  position: absolute; left: 6px; top: 6px; width: 26px; height: 26px; border-radius: 50%; padding: 0;
  border: 2px solid #fff; background: rgb(0 0 0 / 25%); color: transparent; display: grid; place-items: center;
  opacity: 0; transition: opacity 0.1s; cursor: pointer;
}
.tile-check svg { width: 16px; height: 16px; stroke-width: 3; }
.tile:hover .tile-check, .grid:has(.tile.sel) .tile-check, .arranging .tile-check { opacity: 1; }
@media (hover: none) { .tile-check { opacity: 0.85; } }
.tile.sel { outline: 3px solid var(--accent); }
.tile.sel .tile-check { background: var(--accent); border-color: var(--accent); color: #fff; opacity: 1; }
.tile.sel img { transform: scale(0.92); border-radius: 6px; }
.badges { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px; }
.badge { display: inline-flex; align-items: center; gap: 2px; padding: 2px 5px; border-radius: 6px; background: rgb(0 0 0 / 55%); color: #fff; font-size: 0.72rem; }
.badge svg { width: 13px; height: 13px; }
.badge.fav { color: #ff8fa3; }
.badge.fav svg { fill: currentColor; }
.tile-title { position: absolute; inset: auto 0 0 0; padding: 18px 8px 6px; background: linear-gradient(transparent, rgb(0 0 0 / 60%)); color: #fff; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.tile:has(.badges) .tile-title { padding-right: 70px; }
.tile-pos { position: absolute; right: 6px; top: 6px; min-width: 24px; padding: 1px 6px; border-radius: 99px; background: rgb(0 0 0 / 60%); color: #fff; font-size: 0.75rem; text-align: center; font-variant-numeric: tabular-nums; }
.arranging .tile { cursor: grab; touch-action: manipulation; }
.tile.dragging { opacity: 0.25; }
.tile.ghost { position: fixed; z-index: 150; pointer-events: none; box-shadow: 0 16px 40px rgb(0 0 0 / 35%); transform: rotate(2deg) scale(1.04); opacity: 0.95; }
.ghost-count { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--accent); color: var(--accent-text); border-radius: 99px; padding: 4px 12px; font-weight: 700; }
.sentinel { height: 1px; }

.selbar {
  position: fixed; left: 50%; bottom: 20px; z-index: 40; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 18px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 40px rgb(0 0 0 / 22%);
}
.selbar > b { white-space: nowrap; }
.selbar-actions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.selbar-end { display: flex; align-items: center; gap: 4px; border-left: 1px solid var(--border); padding-left: 8px; }
@media (min-width: 861px) { .selbar { margin-left: 120px; } }
@media (max-width: 860px) {
  .selbar { bottom: calc(76px + env(safe-area-inset-bottom)); left: 8px; right: 8px; transform: none; max-width: none; flex-wrap: wrap; padding: 10px; }
  .selbar-actions { order: 3; width: 100%; }
  .selbar-actions .btn span { display: none; }
  .selbar > b { flex: 1; }
}

/* ------------------------------ Filter ------------------------------ */
.filters { display: grid; gap: 12px; margin-bottom: 14px; }
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-label { width: 110px; flex: none; font-weight: 600; font-size: 0.86rem; color: var(--muted); }
.filter-row select { padding: 6px 9px; }
.year-strip { display: flex; align-items: flex-end; gap: 2px; height: 46px; flex: 1; min-width: 200px; overflow-x: auto; }
.year-bar { position: relative; flex: 1 0 14px; max-width: 30px; height: 100%; border: none; background: none; padding: 0; cursor: pointer; display: flex; align-items: flex-end; }
.year-bar::before { content: ""; position: absolute; inset: auto 0 14px 0; height: calc(var(--h) - 14px); min-height: 3px; border-radius: 3px 3px 0 0; background: var(--accent-2); opacity: 0.55; }
.year-bar:hover::before, .year-bar.on::before { opacity: 1; background: var(--accent); }
.year-bar span { width: 100%; font-size: 0.62rem; color: var(--muted); text-align: center; }
.active-filters { margin-bottom: 14px; }
@media (max-width: 600px) { .filter-label { width: 100%; } }

/* ------------------------------ Streifen (Übersicht) ------------------------------ */
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.strip-item { position: relative; flex: none; width: 150px; height: 150px; padding: 0; border: none; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; scroll-snap-align: start; }
.strip-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-item span { position: absolute; left: 6px; bottom: 6px; padding: 1px 7px; border-radius: 6px; background: rgb(0 0 0 / 55%); color: #fff; font-size: 0.75rem; }
.comment-row { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 14px; border: none; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; }
.comment-row:last-child { border-bottom: none; }
.comment-row:hover { background: var(--surface-2); }
.comment-row img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; }
.more-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; font-weight: 500; }
.more-row:last-child { border-bottom: none; }
.more-row svg:last-child { margin-left: auto; color: var(--muted); }
.act-row { display: flex; gap: 10px; align-items: baseline; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.act-row:last-child { border-bottom: none; }
.act-row .muted { margin-left: auto; }

/* ------------------------------ Viewer ------------------------------ */
.viewer { position: fixed; inset: 0; z-index: 90; background: #0d0b09; color: #f2ece4; display: grid; grid-template-columns: 1fr 0; grid-template-rows: auto 1fr; }
.viewer.panel-open { grid-template-columns: 1fr 380px; }
.v-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 4px; padding: 8px 10px; background: linear-gradient(rgb(0 0 0 / 50%), transparent); z-index: 2; }
.v-count { margin-left: 8px; font-size: 0.9rem; opacity: 0.75; font-variant-numeric: tabular-nums; }
.v-btn { display: grid; place-items: center; width: 40px; height: 40px; border: none; border-radius: 10px; background: transparent; color: inherit; cursor: pointer; }
.v-btn:hover { background: rgb(255 255 255 / 12%); }
.v-btn.on { color: #ff8fa3; }
.v-btn.on svg { fill: currentColor; }
.v-stage { grid-row: 2; grid-column: 1; display: grid; place-items: center; min-height: 0; min-width: 0; padding: 0 8px 12px; user-select: none; }
.v-stage img, .v-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.v-stage img { animation: fade 0.15s; }
.v-nav { position: absolute; top: 50%; z-index: 3; width: 48px; height: 64px; margin-top: -32px; border: none; border-radius: 12px; background: rgb(0 0 0 / 30%); color: #fff; cursor: pointer; display: grid; place-items: center; opacity: 0.7; }
.v-nav:hover { opacity: 1; background: rgb(0 0 0 / 55%); }
.v-nav svg { width: 28px; height: 28px; }
.v-nav.prev { left: 10px; }
.v-nav.next { right: 10px; }
.viewer.panel-open .v-nav.next { right: 390px; }
.v-nopreview { display: grid; justify-items: center; gap: 10px; text-align: center; color: #cbbfb1; }
.v-nopreview svg { width: 56px; height: 56px; }
.v-panel { grid-row: 2; grid-column: 2; overflow-y: auto; background: var(--surface); color: var(--text); border-left: 1px solid var(--border); display: none; }
.viewer.panel-open .v-panel { display: block; }
.v-panel-in { padding: 18px; display: grid; gap: 12px; }
.v-title-in { font: 600 1.2rem var(--serif) !important; border-color: transparent !important; padding: 6px 8px !important; margin-left: -8px; width: calc(100% + 8px) !important; background: transparent !important; }
.v-title-in:hover { border-color: var(--border) !important; }
.v-title { font: 600 1.25rem var(--serif); }
.v-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.92rem; }
.v-row > svg { color: var(--muted); width: 18px; height: 18px; }
.v-row a { color: var(--text); }
.inline-in { flex: 1; border-color: transparent !important; padding: 4px 6px !important; background: transparent !important; }
.inline-in:hover { border-color: var(--border) !important; }
.v-date-edit { display: grid; gap: 8px; width: 100%; }
.date-input { display: flex; gap: 6px; flex-wrap: wrap; }
.date-input select { flex: 1; min-width: 110px; }
.v-sec { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.v-note { min-height: 90px; }
.v-note-text { margin: 0; white-space: pre-line; }
.v-info { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 0.85rem; }
.v-info dt { color: var(--muted); }
.v-info dd { margin: 0; word-break: break-word; }
.v-sec > a { font-size: 0.88rem; display: inline-flex; align-items: center; gap: 4px; }
.v-sec > a svg { width: 16px; height: 16px; }
.comments { display: grid; gap: 10px; }
.comment { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.comment-head { display: flex; align-items: center; gap: 8px; }
.comment-head small { flex: 1; }
.comment p { margin: 4px 0 0; white-space: pre-line; }
.comment-form { display: grid; gap: 6px; justify-items: end; }
@media (max-width: 900px) {
  .viewer, .viewer.panel-open { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .viewer.panel-open .v-stage { max-height: 45vh; }
  .v-panel { grid-row: 3; grid-column: 1; max-height: 48vh; border-left: none; border-radius: 16px 16px 0 0; }
  .viewer.panel-open .v-nav.next { right: 10px; }
  .v-nav { top: 40%; width: 40px; height: 52px; }
  .v-top { overflow-x: auto; }
}

/* ------------------------------ Upload ------------------------------ */
.upload { display: grid; gap: 16px; }
.dropzone { display: grid; justify-items: center; gap: 8px; padding: 30px 16px; border: 2px dashed var(--border); border-radius: 14px; text-align: center; transition: 0.15s; }
.dropzone > svg { width: 36px; height: 36px; color: var(--accent); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.up-summary { display: grid; gap: 8px; }
.up-count { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.up-count .link-btn { margin-left: 8px; }
.up-options { display: grid; gap: 14px; }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface); text-align: left; }
.radio-card.on { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { accent-color: var(--accent); margin-top: 3px; }
.radio-card > svg { color: var(--accent); margin-top: 2px; }
button.radio-card:hover { border-color: var(--accent); }
.upload-dock {
  position: fixed; right: 20px; bottom: 20px; z-index: 80; width: min(360px, calc(100vw - 32px));
  padding: 14px; display: grid; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 40px rgb(0 0 0 / 22%);
}
.upload-dock svg { color: var(--accent); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.up-errors { max-height: 140px; overflow-y: auto; font-size: 0.78rem; color: var(--danger); display: grid; gap: 2px; }
@media (max-width: 860px) { .upload-dock { right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); } }
.page-drop { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgb(154 91 46 / 18%); backdrop-filter: blur(2px); pointer-events: none; }
.page-drop > div { display: grid; justify-items: center; gap: 8px; padding: 30px 40px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); border: 2px dashed var(--accent); }
.page-drop svg { width: 40px; height: 40px; color: var(--accent); }

/* ------------------------------ Personen ------------------------------ */
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.person-card { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: inherit; text-decoration: none; }
.person-card:hover { border-color: var(--accent); }
.person-card.deceased { background: var(--surface-2); }
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; font-weight: 700; color: #fff; background: var(--g-x); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.g-m { background: var(--g-m); }
.avatar.g-w { background: var(--g-w); }
.avatar.xs { width: 24px; height: 24px; font-size: 0.7rem; }
.avatar.md { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }
.avatar.xl { width: 120px; height: 120px; font-size: 2.6rem; }
.person-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.person-portrait { border: none; background: none; padding: 0; border-radius: 50%; cursor: pointer; }
.person-portrait:disabled { cursor: default; }
.person-portrait:not(:disabled):hover .avatar { outline: 3px solid var(--accent); outline-offset: 3px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 14px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.notes p { white-space: pre-line; margin: 10px 0 0; max-width: 80ch; }
.rels { display: grid; gap: 12px; }
.rel-group { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rel-label { width: 110px; color: var(--muted); font-weight: 600; font-size: 0.88rem; }

/* ------------------------------ Stammbaum ------------------------------ */
.tree-layout { display: grid; grid-template-columns: 1fr 300px; gap: 14px; height: calc(100vh - 210px); min-height: 460px; }
.tree-wrap {
  position: relative; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden;
  background: radial-gradient(circle, color-mix(in srgb, var(--border) 60%, transparent) 1px, transparent 1px) 0 0 / 22px 22px, var(--bg);
}
.tree-svg { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.tree-svg:active { cursor: grabbing; }
.tree-svg .tnode:hover rect:first-child { stroke: var(--accent); }
.tree-side { overflow-y: auto; display: grid; gap: 8px; align-content: start; }
.tree-side-head { display: flex; gap: 12px; align-items: center; }
.tree-add { display: grid; gap: 6px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 1000px) {
  .tree-layout { grid-template-columns: 1fr; height: auto; }
  .tree-wrap { height: 62vh; }
}

/* ------------------------------ Verwaltung ------------------------------ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.paused td { opacity: 0.6; }
.table select { padding: 5px 8px; }
.cred { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.cred code { font-size: 1.05rem; font-weight: 600; user-select: all; }
.share-row { display: flex; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.share-row:last-child { border-bottom: none; }
.share-row.inactive > .grow { opacity: 0.6; }
.share-row .muted.small { margin-top: 2px; }
.share-url { display: flex; gap: 8px; }
.album-checks { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.perm-list { display: grid; gap: 8px; }
