/* ====== D&D Dashboard – „Kriegstisch": Seitenleiste, Seiten, Übersicht ====== */
@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #0d1115;
  --bg2: #10161b;
  --panel: #141a20;
  --panel2: #182027;
  --ink: #d5dde4;
  --ink-dim: #7d8a96;
  --gold: #f2a541;          /* Bernstein als Akzent */
  --gold-bright: #ffc56b;
  --bronze: #7a5a2b;
  --line: #24303a;
  --red: #c2413a;
  --red2: #ef6a5f;
  --green: #4caf7a;
  --blue: #3d5a7a;
  --shadow: none;
  --radius: 6px;
  --field: #0f1419;
  --card: #1b242c;
  --font-head: 'Rajdhani', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --page-bg:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  --header-bg: #10161b;
  --btn-bg: #1e2831;
  --panel-bg: var(--panel);
  --head-tint: transparent;
  --hover-tint: rgba(242,165,65,.08);
  --sel-tint: rgba(242,165,65,.16);
  --narr-bg: #1a1f2e;
  --narr-line: #2f3a55;
  --narr-accent: #7aa2ff;
  --narr-ink: #dbe4ff;
  --nav-w: 210px;
  --head-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  min-height: 100vh;
}

h1, h2, h3, .cinzel { font-family: var(--font-head); letter-spacing: .04em; }

a { color: var(--gold); }

/* ---------- Header ---------- */
header {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px;
  border-bottom: 2px solid var(--line);
  background: var(--header-bg);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand .title {
  font-family: var(--font-head); font-weight: 700; font-size: 26px;
  color: var(--gold-bright); text-shadow: 0 2px 6px #000;
  background: transparent; border: 0; outline: none; width: 100%;
}
.brand .subtitle {
  color: var(--ink-dim); font-style: italic; font-size: 14px;
  background: transparent; border: 0; outline: none;
}
.header-spacer { flex: 1; }
.header-tools { display: flex; align-items: center; gap: 10px; }

.conn { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-dim); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot.ok { background: var(--green); box-shadow: 0 0 6px #8ec24a; }

/* ---------- Buttons ---------- */
button, .btn {
  font-family: var(--font-head); font-size: 13px;
  color: var(--ink); cursor: pointer;
  background: var(--btn-bg);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 12px; transition: .15s;
}
button:hover, .btn:hover { border-color: var(--gold); color: var(--gold-bright); }
button:active { transform: translateY(1px); }
.btn-gold { border-color: var(--gold); color: var(--gold-bright); }
.btn-sm { padding: 2px 8px; font-size: 12px; }
.btn-danger:hover { border-color: var(--red2); color: var(--red2); }
.icon-btn { padding: 2px 7px; line-height: 1; }

/* ---------- Panel ---------- */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(216,176,102,.06);
  position: relative;
}
.panel > h2 {
  margin: 0; padding: 10px 14px;
  font-size: 15px; color: var(--gold);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px;
  background: var(--head-tint);
}
.panel > h2 .ttl { flex: 1; }
.panel-body { padding: 12px 14px; }
.panel.dm-only > h2 { color: var(--red2); }
.dm-badge { font-size: 10px; color: var(--red2); border: 1px solid var(--red); border-radius: 4px; padding: 1px 5px; font-family: var(--font-head); }

/* ---------- Inputs ---------- */
input[type=text], input[type=number], textarea, select {
  font-family: var(--font-body); font-size: 15px; color: var(--ink);
  background: var(--field); border: 1px solid var(--line); border-radius: 4px;
  padding: 5px 8px; width: 100%;
}
input:focus, textarea:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; min-height: 70px; line-height: 1.4; }
label.fld { display: block; font-size: 12px; color: var(--ink-dim); margin: 6px 0 2px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.muted { color: var(--ink-dim); }
.right { margin-left: auto; }
[hidden] { display: none !important; }

/* ---------- Ressourcen ---------- */
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.res {
  border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px;
  background: var(--card); text-align: center;
}
.res .ico { font-size: 20px; }
.res .nm { font-size: 12px; color: var(--ink-dim); }
.res .val { font-family: var(--font-head); font-size: 18px; color: var(--gold-bright); }
.res .ctl { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }

/* ---------- Fraktionen ---------- */
.faction { margin-bottom: 9px; }
.faction .top { display: flex; justify-content: space-between; font-size: 14px; }
.repbar { height: 10px; border-radius: 5px; background: var(--field); border: 1px solid var(--line);
  position: relative; overflow: hidden; margin-top: 3px; }
.repbar .mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--ink-dim); }
.repbar .fill { position: absolute; top: 0; bottom: 0; }
.repbar .fill.pos { left: 50%; background: linear-gradient(90deg, #6c8a3e, #9ec45a); }
.repbar .fill.neg { right: 50%; background: linear-gradient(270deg, #8a3a32, #d6584a); }
.rep-ctl { display: flex; gap: 4px; }

/* ---------- NPC ---------- */
.npc, .pc, .sess, .secret { border: 1px solid var(--line); border-radius: 5px;
  padding: 8px 10px; background: var(--card); margin-bottom: 10px; }
.npc .nm, .pc .nm, .sess .nm { font-family: var(--font-head); color: var(--gold-bright); font-size: 15px; }
.sess-head { cursor: pointer; gap: 6px; }
.sess-head input { cursor: text; }
.sess-head .nm { flex: 1; }
.npc .role { color: var(--ink-dim); font-style: italic; font-size: 13px; }
.npc-img { width: 128px; height: 128px; object-fit: cover; border-radius: 5px; border: 1px solid var(--line); margin: 6px 0; display: block; }
.secret-note { color: var(--red2); font-size: 13px; border-left: 2px solid var(--red); padding-left: 8px; margin-top: 6px; }
.tag-hidden { font-size: 10px; color: var(--red2); }

/* ---------- Spielercharaktere ---------- */
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.pc .cls { color: var(--ink-dim); font-style: italic; font-size: 13px; }
.hpbar { height: 16px; border-radius: 8px; background: var(--field); border: 1px solid var(--line);
  position: relative; overflow: hidden; margin: 6px 0; }
.hpbar .fill { position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #7a241c, var(--red2)); transition: width .25s; }
.hpbar .txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000; }
.ac { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-size: 13px; }

/* ---------- Initiative ---------- */
.init-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.init-head .round { font-family: var(--font-head); color: var(--gold-bright); font-size: 16px; }
.init-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 5px;
  border: 1px solid transparent; }
.init-row + .init-row { margin-top: 2px; }
.init-row.active { border-color: var(--gold); background: rgba(216,176,102,.10); }
.init-row.enemy .init-name { color: var(--red2); }
.init-init { font-family: var(--font-head); width: 28px; text-align: center; color: var(--gold); }
.init-name { flex: 1; }
.init-hp { width: 110px; }

/* ---------- Boss ---------- */
.boss-name { font-family: var(--font-head); font-size: 22px; color: var(--red2); text-shadow: 0 2px 6px #000; }
.boss-sub { color: var(--ink-dim); font-style: italic; }
.phase-pips { display: flex; gap: 6px; margin: 8px 0; }
.pip { width: 22px; height: 8px; border-radius: 4px; background: #2a1d10; border: 1px solid var(--line); }
.pip.on { background: linear-gradient(90deg,#8a3a32,#d6584a); }
.actions-list li { margin: 2px 0; }

/* ---------- Tracker ---------- */
.track-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.track-item input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--gold); }
.track-item.done .track-text { text-decoration: line-through; color: var(--ink-dim); }
.track-text { flex: 1; }

/* ---------- Karte ---------- */
.map-wrap { position: relative; border: 1px solid var(--line); border-radius: 5px; overflow: hidden;
  background: var(--field); min-height: 120px; }
.map-wrap img { width: 100%; display: block; }
.map-empty { padding: 30px; text-align: center; color: var(--ink-dim); }
.marker { position: absolute; transform: translate(-50%, -100%); cursor: pointer; font-size: 22px;
  filter: drop-shadow(0 2px 3px #000); }
.marker .lbl { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%);
  white-space: nowrap; background: var(--card); border: 1px solid var(--gold); border-radius: 4px;
  padding: 2px 6px; font-size: 12px; color: var(--gold-bright); display: none; }
.marker:hover .lbl { display: block; }

/* ---------- Add row ---------- */
.add-row { display: flex; gap: 6px; margin-top: 8px; }
.list-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }

/* ---------- Markdown-Vorschau & Galerie ---------- */
.md-preview { background:var(--field); border:1px solid var(--line); border-radius:5px;
  padding:8px 10px; min-height:40px; line-height:1.45; }
.md-preview img { max-width:100%; border-radius:5px; border:1px solid var(--line); margin:6px 0; display:block; }
.md-preview h2 { font-family: var(--font-head); font-size:18px; color:var(--gold); margin:8px 0 4px; }
.md-preview h3 { font-family: var(--font-head); font-size:16px; color:var(--gold); margin:6px 0 3px; }
.md-preview h4 { font-family: var(--font-head); font-size:14px; color:var(--gold-bright); margin:4px 0; }
.md-preview code { background:var(--panel2); padding:1px 4px; border-radius:3px; }
.md-preview ul { margin:4px 0; padding-left:20px; }

/* Erzähler-/Vorlesetext-Box: für Spieler laut vorzulesende Beschreibungen */
.md-preview .narrator-box {
  margin: 10px 0; padding: 14px 18px 14px 42px;
  background: var(--narr-bg);
  border: 1px solid var(--narr-line); border-left: 4px solid var(--narr-accent);
  border-radius: 6px;
  font-family: var(--font-body); font-style: normal;
  font-size: 15.5px; line-height: 1.6; color: var(--narr-ink);
  position: relative;
  box-shadow: inset 0 0 18px rgba(150, 100, 220, 0.12);
}
.md-preview .narrator-box::before {
  content: "\201C"; position: absolute; left: 10px; top: 0px;
  font-family: var(--font-head); font-style: normal;
  font-size: 38px; line-height: 1; color: var(--narr-accent); opacity: .75;
}
.gallery { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; margin-top:6px; }
.gal-item { border:1px solid var(--line); border-radius:5px; padding:6px; background:var(--card);
  display:flex; flex-direction:column; gap:5px; }
.gal-item img { width:100%; height:90px; object-fit:cover; border-radius:4px; border:1px solid var(--line); }
.gal-item .cap { font-size:13px; color:var(--ink); }

img[data-full] { cursor: zoom-in; }

/* ---------- Lightbox (Bild groß) ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 300;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 6px;
  border: 1px solid var(--gold); box-shadow: 0 8px 40px #000; }
.lightbox .lb-cap { font-family: var(--font-head); color: var(--gold-bright); font-size: 18px;
  text-shadow: 0 2px 4px #000; text-align: center; max-width: 90vw; }
.lightbox .lb-hint { position: absolute; top: 16px; right: 22px; color: var(--ink-dim); font-size: 13px; }
.lightbox .map-stage { position: relative; display: inline-block; cursor: default; }
.lightbox .map-stage img { display: block; max-width: 94vw; max-height: 86vh; }

/* ---------- Was bisher geschah ---------- */
.recap-panel > h2 .ttl { color: var(--gold-bright); }
.recap-text { white-space: pre-wrap; line-height: 1.65; font-size: 15px;
  max-height: 460px; overflow: auto; margin-top: 10px; padding-right: 8px; }
#p-recap textarea { min-height: 320px; line-height: 1.55; }

/* ---------- Quests ---------- */
.quest-text { white-space: pre-wrap; line-height: 1.45; margin-bottom: 6px; }

/* ---------- Bibliothek (Baum + Seiten-Editor) ---------- */
.tree { border: 1px solid var(--line); border-radius: 5px; background: var(--field); padding: 4px; margin: 8px 0; }
.tree-row { display: flex; align-items: center; gap: 4px; padding: 3px 4px; border-radius: 4px; }
.tree-row:hover { background: var(--hover-tint); }
.tree-row.sel { background: var(--sel-tint); outline: 1px solid var(--line); }
.tree-row .tw { width: 14px; text-align: center; color: var(--ink-dim); cursor: pointer; user-select: none; }
.tree-row .tname { flex: 1; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-row .tname.tfolder { color: var(--gold); font-family: var(--font-head); font-size: 14px; }
.tree-row .tree-acts { display: none; gap: 2px; }
.tree-row:hover .tree-acts { display: flex; }
.tree-acts .icon-btn { padding: 1px 5px; font-size: 12px; }
.page-editor { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 4px; }

/* ---------- Spieler-Journal ---------- */
.journal-entry { border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 5px; background: var(--card); padding: 8px 10px; margin-bottom: 10px; }
.je-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.je-title { font-family: var(--font-head); color: var(--gold-bright); font-size: 15px; flex: 1; }
.journal-entry .md-preview { background: transparent; border: 0; padding: 0; }
.journal-entry .cap { font-size: 13px; color: var(--ink-dim); font-style: italic; }

/* DM-Login Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex;
  align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--panel2); border: 1px solid var(--gold); border-radius: 8px;
  padding: 22px; width: 320px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 12px; color: var(--gold-bright); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--gold); color: var(--gold-bright);
  padding: 8px 16px; border-radius: 6px; z-index: 200; opacity: 0; transition: .3s; pointer-events: none; }
.toast.show { opacity: 1; }

/* ---------- Selbstgehostet: Ergänzungen ---------- */
.npc.npc-hidden { opacity: .6; border-style: dashed; }
.npc textarea + textarea { margin-top: 6px; border-color: var(--red); }



/* =====================================================================
   Kriegstisch-Layout: Kopfzeile, Seitenleiste, Seiten
   ===================================================================== */
header { height: var(--head-h); padding: 0 18px; border-bottom: 1px solid var(--line); box-shadow: none; }
.brand .title { font-size: 22px; letter-spacing: .12em; text-transform: uppercase; color: #fff; text-shadow: none; }
.brand .subtitle { font-style: normal; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }

.sidenav {
  position: fixed; top: var(--head-h); left: 0; bottom: 0; width: var(--nav-w); z-index: 40;
  display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
  background: var(--bg2); border-right: 1px solid var(--line); overflow-y: auto;
}
.sidenav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 0 6px 6px 0;
  border-left: 2px solid transparent; color: var(--ink-dim); text-decoration: none; font-weight: 500;
}
.sidenav a .ico { width: 20px; text-align: center; }
.sidenav a:hover { color: var(--ink); background: var(--hover-tint); }
.sidenav a.active { color: var(--gold-bright); background: var(--sel-tint); border-left-color: var(--gold); }
.nav-sep { margin: 14px 12px 4px; font-family: var(--font-head); font-size: 11px; font-weight: 700;
  letter-spacing: .18em; color: var(--red2); border-top: 1px solid var(--line); padding-top: 12px; }

.wrap { margin-left: var(--nav-w); max-width: none; padding: 18px 22px 40px; }
.page-title { font-family: var(--font-head); font-size: 26px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: #fff; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; }
.page-title .dm-badge { font-size: 11px; letter-spacing: .05em; }

.page-grid { display: grid; gap: 14px; align-items: start; }
.page-grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.page-grid.map-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.page-grid.narrow { max-width: 760px; }

/* Panels: flach, mit Bernstein-Statuszeile oben */
.panel { border: 1px solid var(--line); border-top: 2px solid var(--gold); box-shadow: none; }
.panel.dm-only { border-top-color: var(--red2); }
.panel > h2 { font-size: 14px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: #fff; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 12px 14px; }

button, .btn { font-family: var(--font-body); font-size: 12px; font-weight: 500; border-radius: 4px; }
.btn-gold { background: var(--gold); color: #1a1206; border-color: var(--gold); }
.btn-gold:hover { background: var(--gold-bright); color: #1a1206; }
input[type=text], input[type=number], input[type=search], textarea, select {
  font-family: var(--font-body); font-size: 14px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 4px; padding: 6px 9px; width: 100%; }
input[type=search]:focus { outline: none; border-color: var(--gold); }
label.fld { text-transform: uppercase; letter-spacing: .1em; font-size: 10px; font-weight: 600; }
.dot.ok { box-shadow: 0 0 8px var(--green); }

/* Inhalte */
.res-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.res { background: var(--card); border-color: var(--line); }
.res .val { font-family: var(--font-head); font-size: 26px; font-weight: 700; color: var(--gold-bright); }
.npc, .pc, .sess, .secret, .journal-entry, .gal-item { background: var(--card); border-color: var(--line); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; }
.npc .nm, .sess .nm, .je-title { font-family: var(--font-head); font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .04em; }
.repbar { height: 8px; border: 0; background: #0a0e12; }
.track-item { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.md-preview { line-height: 1.55; }
.md-preview h2, .md-preview h3, .md-preview h4 { text-transform: uppercase; letter-spacing: .06em; }
.recap-text { font-size: 15px; line-height: 1.7; max-height: none; }
#p-recap textarea { min-height: 60vh; }
.sess-head .nm { font-size: 15px; }

/* NPC-Seite: Suche + Raster */
.npc-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.npc-search { flex: 1 1 260px; max-width: 420px; }
.npc-add { flex: 2 1 380px; }
.npc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.npc-grid .npc { margin: 0; border-top: 2px solid var(--gold); padding: 10px 12px; }
.npc-grid .npc.npc-hidden { border-top-color: var(--red2); }
.npc-img { width: 84px; height: 84px; float: right; margin: 0 0 6px 10px; border-radius: 4px; }
.npc::after { content: ""; display: block; clear: both; }
.npc .row + * { margin-top: 4px; }
.npc textarea { margin-top: 6px; min-height: 60px; }
.npc.npc-hidden { opacity: .65; border-style: dashed; }
.npc textarea + textarea { border-color: var(--red); }

/* Bibliothek: Baum links, Editor rechts */
#p-library { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0 18px; align-items: start; }
#p-library > .list-actions, #p-library > .tree { grid-column: 1; }
#p-library > .tree { margin-top: 8px; max-height: calc(100vh - 230px); overflow-y: auto; }
#p-library > .page-editor { grid-column: 2; grid-row: 1 / span 2; border-top: 0; margin-top: 0; padding-top: 0; }
#p-library .page-editor > input:first-child { margin-top: 0 !important; font-size: 20px; font-weight: 700; }
#lib-body-ta { min-height: 320px !important; }

/* =====================================================================
   Übersicht
   ===================================================================== */
.dash { display: grid; gap: 14px; }
.dash-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.dash-card.wide { grid-column: 1 / -1; }
.dash-card > h2 { display: flex; align-items: center; }
.dash-card .more { margin-left: auto; font-family: var(--font-body); font-size: 11px; font-weight: 500;
  letter-spacing: .04em; text-transform: none; color: var(--ink-dim); text-decoration: none; }
.dash-card .more:hover { color: var(--gold-bright); }
.dash-card p { margin: 4px 0 0; line-height: 1.6; }
.dash-recap { white-space: pre-line; font-size: 15px; }
.dash-label { font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); margin: 6px 0 3px; }
.dash-card .md-preview { background: transparent; border: 0; padding: 0; min-height: 0; }
.md-preview.clamp { max-height: 7.8em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.dash-title { font-weight: 600; color: #fff; }
.dash-boss-img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.dash-faces { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 6px; }
.face { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--ink); min-width: 0; }
.face img, .face .initial { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); }
.face .initial { display: grid; place-items: center; background: var(--card); font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--gold); }
.face:hover img, .face:hover .initial { border-color: var(--gold); }
.face-name { font-size: 11px; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-fac { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.dash-fac .rep { font-family: var(--font-head); font-weight: 700; font-size: 16px; }
.dash-fac .rep.pos { color: var(--green); }
.dash-fac .rep.neg { color: var(--red2); }
.dash-map { display: block; text-decoration: none; }
.dash-map img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); display: block; margin-bottom: 4px; }
.dash-list { margin: 0; padding-left: 18px; }
.dash-list li { margin: 3px 0; }

/* =====================================================================
   Kleinere Bildschirme
   ===================================================================== */
@media (max-width: 1100px) {
  .page-grid.two, .page-grid.map-side { grid-template-columns: minmax(0, 1fr); }
  #p-library { grid-template-columns: minmax(0, 1fr); }
  #p-library > .page-editor { grid-column: 1; grid-row: auto; border-top: 1px dashed var(--line); padding-top: 8px; }
  #p-library > .tree { max-height: 320px; }
}
@media (max-width: 860px) {
  header { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 8px; position: relative; }
  .header-tools { flex-wrap: wrap; }
  .sidenav { position: sticky; top: 0; bottom: auto; width: auto; flex-direction: row; overflow-x: auto;
    padding: 6px 8px; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .sidenav a { border-left: 0; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; white-space: nowrap; padding: 8px 10px; }
  .sidenav a.active { border-bottom-color: var(--gold); }
  .nav-sep { display: none !important; }
  .wrap { margin-left: 0; padding: 14px 12px 40px; }
  .page-title { font-size: 20px; }
  .dash-cards, .npc-grid { grid-template-columns: minmax(0, 1fr); }
}
.goals-card .track-item { cursor: pointer; }
.goals-card .track-item:last-of-type { border-bottom: 0; }
