/* ============================================================
   Charaktererstellung, dunkles Fantasy-Theme
   ============================================================ */
:root {
  --bg: #16120d;
  --bg-grad: radial-gradient(1200px 500px at 70% -10%, rgba(201, 162, 39, 0.07), transparent 60%),
             radial-gradient(900px 400px at 0% 110%, rgba(120, 80, 40, 0.10), transparent 55%);
  --panel: #1e1811;
  --card: #262017;
  --card-hover: #2d2519;
  --border: #4a3c28;
  --border-soft: #3a2f20;
  --gold: #c9a227;
  --gold-bright: #e6c14a;
  --text: #e8ddc7;
  --muted: #9a8b6f;
  --dim: #6d6049;
  --danger: #b0413e;
  --ok: #5d9e5d;
  --info: #4a7fa5;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-grad);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
  line-height: 1.45;
}

h1, h2, h3 {
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  letter-spacing: 0.3px;
}

.hidden { display: none !important; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #453826; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #5a4930; }

/* ---------- Charakter-Tabs (browser-artig, über der Topbar) ---------- */
#char-tabs { display: flex; align-items: flex-end; gap: 5px; padding: 8px 10px 0; background: #120e09; overflow-x: auto; scrollbar-width: none; }
#char-tabs::-webkit-scrollbar { display: none; }
.char-tab { display: flex; align-items: center; gap: 8px; max-width: 230px; min-width: 90px; height: 32px; padding: 0 8px 0 14px; background: #241c12; border: 1px solid var(--border-soft); border-bottom: none; border-radius: 9px 9px 0 0; color: var(--muted); font-size: 13.5px; cursor: pointer; white-space: nowrap; user-select: none; }
.char-tab:hover { background: #2c2317; color: var(--text); }
.char-tab.active { background: linear-gradient(180deg, #2e2517, #241c12); border-color: var(--gold); color: var(--gold-bright); font-weight: 600; }
.char-tab .tab-name { overflow: hidden; text-overflow: ellipsis; }
.char-tab .tab-lvl { flex: none; font-size: 11.5px; color: var(--dim); background: rgba(255,255,255,0.07); padding: 1px 6px; border-radius: 999px; }
.char-tab.active .tab-lvl { color: #221a08; background: var(--gold-bright); }
.char-tab .tab-close { flex: none; width: 18px; height: 18px; margin-left: auto; border: none; border-radius: 50%; background: transparent; color: inherit; font-size: 13px; line-height: 1; cursor: pointer; opacity: 0.55; }
.char-tab .tab-close:hover { background: rgba(224,123,120,0.25); color: #e07b78; opacity: 1; }
.char-tab-new { flex: none; width: 30px; height: 30px; margin-left: 4px; border-radius: 8px; border: 1px dashed var(--border); background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; }
.char-tab-new:hover { border-color: var(--gold); color: var(--gold-bright); }
/* Badge für Charaktere, deren Erstellung noch läuft (✏️). */
.char-tab .tab-creation { flex: none; font-size: 12px; }
/* Badge für an einen DM geteilte Charaktere (📤, R566); Hover-Text nennt den DM. */
.char-tab .tab-shared { flex: none; font-size: 12px; }

/* ---------- Topbar ---------- */
#topbar {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 14px 7px;
  background: linear-gradient(180deg, #241c12, #1b150e);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }

/* Zweite Topbar-Zeile: noch nicht vergebene Ressourcen (kompakte Chips).
   Ohne offene Posten wird die Zeile komplett ausgeblendet (.hidden). */
#pending-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; }
.pending-chip {
  background: rgba(201, 162, 39, 0.10);
  border: 1px solid rgba(201, 162, 39, 0.40);
  color: var(--gold-bright);
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pending-chip:hover { background: rgba(201, 162, 39, 0.22); }
/* Klickbare Chips springen zum Tab, in dem der offene Posten vergeben wird. */
.pending-chip.clickable { cursor: pointer; user-select: none; }
.pending-chip.clickable:hover {
  background: rgba(201, 162, 39, 0.30);
  border-color: var(--gold-bright);
}

/* Klickbare „Voraussetzung fehlt“-Badges bei Feats: springen zur Voraussetzung.
   Gestrichelte Unterstreichung signalisiert den Link-Charakter. */
.badge.prereq-link { cursor: pointer; text-decoration: underline dotted rgba(232, 201, 160, 0.7); }
.badge.prereq-link:hover { filter: brightness(1.3); border-color: var(--gold-bright); }

/* Kurzes goldenes Aufblinken des Ziel-Elements (Feat-Zeile / Level-Feld) nach dem Springen.
   background-image liegt als Overlay über der bestehenden Hintergrundfarbe. */
@keyframes prereq-flash {
  0%, 100% { box-shadow: none; background-image: none; }
  40% {
    box-shadow: 0 0 0 2px var(--gold-bright), 0 0 16px rgba(230, 193, 74, 0.5);
    background-image: linear-gradient(rgba(230, 193, 74, 0.14), rgba(230, 193, 74, 0.14));
  }
}
.flash-target { animation: prereq-flash 0.5s ease-in-out 3; border-radius: 8px; }

/* R325: Klickbarer Technik-Name in Effekt-Texten (Elemente, Klassen-Effektwahlen,
   Feats, Items, Rassen), springt zur Technik-Karte im Kampftechniken-Tab.
   Gleicher Link-Look wie .prereq-link. */
.tech-link { cursor: pointer; text-decoration: underline dotted rgba(232, 201, 160, 0.7); }
.tech-link:hover { filter: brightness(1.3); text-decoration: underline solid var(--gold-bright); }

/* R473: "Erhalten durch:"-Zeile auf Spezialtechnik-Karten, klickbare Quellen-Chips. */
.tech-grant-src { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tech-grant-src .gsrc-label { color: var(--muted); font-size: 0.85em; }
.grant-chip { cursor: pointer; background: rgba(232, 201, 160, 0.1); border: 1px solid rgba(232, 201, 160, 0.35); color: var(--gold-bright); border-radius: 999px; padding: 2px 10px; font-size: 0.8em; }
.grant-chip:hover { background: rgba(232, 201, 160, 0.22); border-color: var(--gold-bright); }

.statusbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.statusbar .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.7);
  flex: none;
}

.statusbar input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  padding: 4px 7px;
  border-radius: 6px;
}
.statusbar input:hover { background: rgba(255, 255, 255, 0.04); }
.statusbar input:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(0, 0, 0, 0.35);
}

#char-name { width: 190px; }
/* Name ist reine Anzeige (readonly), kein Feld-Look, auch nicht bei Hover/Fokus */
#char-name[readonly] {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
#char-name[readonly]:hover,
#char-name[readonly]:focus { background: transparent; border-color: transparent; }

#char-level { width: 58px; text-align: center; }
/* Level ist reine Anzeige (readonly), kein Feld-Look, auch nicht bei Hover/Fokus */
#char-level[readonly] {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
#char-level[readonly]:hover,
#char-level[readonly]:focus { background: transparent; border-color: transparent; }

#char-silver { width: 92px; text-align: right; color: var(--gold-bright); font-weight: 700; }

.money-btn {
  width: 20px; height: 20px; margin-left: 0; padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px; line-height: 1;
  cursor: pointer;
}
.money-btn:hover { background: rgba(255, 255, 255, 0.14); border-color: var(--gold); }

.statusbar .sep { color: var(--dim); font-size: 16px; }
.lvl-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.silver { display: inline-flex; align-items: center; gap: 5px; color: var(--gold-bright); font-size: 14.5px; white-space: nowrap; }
/* Negatives Guthaben (z. B. zurückgenommener Erstellungs-Feat), rot markiert,
   Abschluss der Charaktererstellung ist dann blockiert. */
#char-silver.negative { color: #e07b78; font-weight: 700; }

.char-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.save-state { font-size: 12px; color: var(--muted); min-width: 96px; text-align: right; }
.save-state.error { color: #e07b78; }
/* „✅ Fertigstellen“, beendet den Erstellungs-Modus (nur dann sichtbar). */
.finish-btn {
  color: #221a08;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border: 1px solid var(--gold);
  font-weight: 700;
  cursor: pointer;
}
.finish-btn:hover { filter: brightness(1.12); }
/* Pulsierender Glow, damit der Button im Erstellungs-Modus in der Topbar auffällt. */
.finish-btn:not(.hidden) { animation: finish-pulse 2s ease-in-out infinite; }
@keyframes finish-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(230, 193, 74, 0); }
  50%      { box-shadow: 0 0 16px 3px rgba(230, 193, 74, 0.45); }
}
/* „⬆️ Level Up“, nur nach Abschluss der Erstellung (syncTopbar). */
.levelup-btn {
  color: #0d2213;
  background: linear-gradient(180deg, #7fd99a, #4caf6e);
  border: 1px solid #4caf6e;
  font-weight: 700;
  cursor: pointer;
}
.levelup-btn:hover { filter: brightness(1.12); }
/* „✅ Level-Up bestätigen“, gold wie Fertigstellen; pulsiert, solange ein
   Level-Up auf die Bestätigung wartet. */
.confirm-lvl-btn {
  color: #221a08;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border: 1px solid var(--gold);
  font-weight: 700;
  cursor: pointer;
}
.confirm-lvl-btn:hover { filter: brightness(1.12); }
.confirm-lvl-btn:not(.hidden) { animation: finish-pulse 2s ease-in-out infinite; }

/* ---------- Layout ---------- */
#layout {
  display: grid;
  grid-template-columns: 234px 1fr;
  /* 96px = Topbar (~56px) + Charakter-Tab-Bar (8px Padding + 32px Tab-Höhe). */
  height: calc(100vh - 96px);
}

/* ---------- Sidebar ---------- */
#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  padding: 10px 8px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  color: var(--text);
  font-size: 14.5px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
}
.tab-btn .ico { font-size: 17px; width: 22px; text-align: center; flex: none; }
.tab-btn:hover { background: rgba(255, 255, 255, 0.04); }
.tab-btn.active {
  border-left-color: var(--gold);
  background: linear-gradient(90deg, rgba(201, 162, 39, 0.14), transparent 80%);
  color: var(--gold-bright);
}

.sidebar-footer {
  margin-top: 14px;
  padding: 10px 12px 4px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Content ---------- */
#content { overflow-y: auto; padding: 18px 22px 40px; }

/* ---------- Startseite (keine Charaktere vorhanden) ---------- */
/* Topbar & Sidebar ausblenden; die Tab-Bar mit dem ＋-Button bleibt oben. */
body.no-char #topbar, body.no-char #sidebar { display: none; }
body.no-char #layout { grid-template-columns: 1fr; height: calc(100vh - 40px); } /* nur noch Tab-Bar (~40px) oben */
.start-page {
  min-height: 75vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 40px 20px;
}
.start-icon { font-size: 58px; margin-bottom: 8px; }
.start-title { margin: 0; font-size: 25px; }
.start-sub { margin: 0 0 16px; color: var(--muted); font-size: 14.5px; }
.start-new-btn { font-size: 16px; padding: 12px 28px; border-radius: 10px; }

.subnav { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.subnav button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-soft);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  cursor: pointer;
}
.subnav button:hover { background: var(--card-hover); }
.subnav button.active {
  background: linear-gradient(180deg, var(--gold-bright), #a88420);
  border-color: var(--gold);
  color: #221a08;
  font-weight: 600;
}
/* Kampftechniken-Subnav: Reiter, deren Waffentyp der Charakter besitzt. */
.subnav button.has-gear { border-color: var(--gold); color: var(--gold-bright); }
.gear-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold-bright); margin-left: 7px; vertical-align: middle;
}
/* R312: Shop-Unterkategorien, zweite Reiter-Zeile unter den Topkategorien. */
.subnav .subnav-sub { flex-basis: 100%; margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.subnav .subnav-sub button { font-size: 12.5px; padding: 5px 11px; }

.tab-title { margin: 2px 0 4px; font-size: 22px; color: var(--gold-bright); }
.tab-subtitle { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; max-width: 780px; }

.section-title {
  margin: 22px 0 10px;
  font-size: 16.5px;
  color: var(--gold-bright);
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 5px;
}

/* ---------- Allgemein-Tab: Sektionen, Drag & Drop + Ein-/Ausblenden (R164) ---- */
.allg-section { position: relative; }
.allg-head { display: flex; align-items: center; gap: 8px; margin-top: 22px; position: relative; }
.allg-grip {
  flex: 0 0 auto; cursor: grab; color: var(--dim); font-size: 13px; line-height: 1;
  padding: 2px 0; user-select: none;
}
.allg-grip:hover { color: var(--muted); }
.allg-grip:active { cursor: grabbing; }
.allg-head .section-title { margin: 0; flex: 1 1 auto; min-width: 0; }
.allg-toggle {
  flex: 0 0 auto; width: 26px; height: 24px; padding: 0; line-height: 1;
  font-size: 13px; border-radius: 6px;
}
.allg-section-body { margin-top: 10px; }
.allg-section-body.collapsed { display: none; }
/* Drop-Markierung: goldene Linie über/unter der Ziel-Sektion */
.allg-section.drop-above { box-shadow: 0 -3px 0 0 var(--gold); }
.allg-section.drop-below { box-shadow: 0 3px 0 0 var(--gold); }
.allg-section.allg-dragging { opacity: .5; }
/* R182: Element-Gruppen im Zauber-Tab („Vollständige Liste“), Farbpunkt am
   Gruppentitel + Zauber-Anzahl rechts neben dem Titel. */
.zauber-elem-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 7px; vertical-align: baseline;
}
.zauber-count { flex: 0 0 auto; font-size: 12px; color: var(--dim); }
/* R183: Inline AP/RP-Icons in Regeltexten (Zauber-Kosten/-Beschreibungen, Klassen-Level-Ups,
   Kampftechniken), Hover über das Icon zeigt das Wort als Label. */
.aprp-inline { display:inline-block; vertical-align:-2px; margin:0 2px; }
.aprp-inline img { width:14px; height:14px; display:block; pointer-events:none; }
/* ---------- Cards & grids ---------- */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
/* R210: Abstand der Nachteil-Auswahl-/Würfel-Panels = Grid-Gap (12px). */
.roll-panel { margin-top: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 13px 14px;
}
.card:hover { background: var(--card-hover); }
.card h3 { margin: 0 0 6px; font-size: 16.5px; color: var(--gold-bright); }
.card .meta-line { font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }
.card p.desc { margin: 6px 0 0; font-size: 13px; color: #cfc2a8; overflow-wrap: break-word; }
/* Einheitliche Standard-Kartenhöhe (wird von equalizeCardGrid() pro Grid gesetzt):
   min-height statt height, Karten wachsen bei Bedarf (z. B. manuell ausgeklappter
   Text) und die Grid-Reihe dehnt sich mit, sodass nichts überläuft. */
.grid-cards .card { min-height: var(--uniform-card-h, auto); }

.card.selectable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 0 14px rgba(201, 162, 39, 0.18);
}
/* Charakter-Erstellungs-Modus: nach Abschluss gesperrte Karten (Rasse/Subrasse/Klasse). */
.card.selectable.locked-card { opacity: 0.5; cursor: not-allowed; }
.card.selectable.locked-card:hover { background: var(--card); }
/* „Elementar Feat“-Wahl: andere Farbe als normale Auswahl (Epic = lila). */
.card.elem-feat-card {
  border-color: #a06ad4;
  box-shadow: 0 0 0 1px #a06ad4, 0 0 14px rgba(160, 106, 212, 0.20);
}

/* ---------- Rows (Feats/Techniken/Items) ---------- */
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 10px 13px;
}
.row-item:hover { background: var(--card-hover); }
.row-item.selected { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.55); }
.row-item.locked { opacity: 0.5; }
/* R338: Tooltip-Lesbarkeit, die ausgegraute Zeile setzt opacity auf den ganzen
   .row-item, und der ::after-Tooltip (data-tip) erbt sie: halbtransparent, Text
   darunter durchsichtig. Beim Hover wird die Karte wieder voll opak, damit das
   Hover-Fenster lesbar ist; beim Verlassen greift die Ausgrauung erneut. */
.row-item.locked:hover { opacity: 1; }
/* R174: Zauber-Kacheln farbcodiert nach Element, gedämpfte Töne, die zum dunklen
   Theme passen; pro Karte werden --se-bg/--se-bg-hover/--se-border aus app.js gesetzt.
   (Im Reiter „alle“ gibt es kein .locked mehr, nicht lernbare Zauber bleiben voll sichtbar.) */
.tech-grid .row-item.spell-elem { background: var(--se-bg); border-color: var(--se-border); }
.tech-grid .row-item.spell-elem:hover { background: var(--se-bg-hover); }
/* Gelernte Zauber behalten den goldenen „selected“-Rahmen. */
.tech-grid .row-item.spell-elem.selected { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.55); }
/* R184: Helle Element-Kacheln (Nebel = weiß), dunkler Text/Badges/Buttons für Lesbarkeit.
    --se-fg wird pro Karte aus dem 4. Wert von SPELL_ELEM_COLORS gesetzt. */
.tech-grid .row-item.spell-elem.elem-light { color: var(--se-fg); }
.tech-grid .row-item.spell-elem.elem-light .row-meta,
.tech-grid .row-item.spell-elem.elem-light .tech-spec .lbl { color: #6f6a5e; }
.tech-grid .row-item.spell-elem.elem-light .row-text,
.tech-grid .row-item.spell-elem.elem-light .tech-spec { color: var(--se-fg); }
.tech-grid .row-item.spell-elem.elem-light .badge { color: #4a4a52; background: rgba(0, 0, 0, 0.07); border-color: #b9b9c1; }
.tech-grid .row-item.spell-elem.elem-light .btn.ghost { color: #3a3a42; border-color: #9a9aa2; }
.tech-grid .row-item.spell-elem.elem-light .btn.ghost:hover { background: rgba(0, 0, 0, 0.06); }
/* R198: Summon-Zauber auf einen Blick erkennbar, Drachen-Wasserzeichen im Karten-Hintergrund
    (static/icons/SummonDragon.png, transparentes PNG). ::before mit z-index:-1 +
    isolation:isolate → wird zwischen dem Karten-Background und dem Text gemalt.
    Dunkle Kacheln: invertiert = weißes Wasserzeichen; helle Nebel-Kacheln (.elem-light): schwarz. */
.row-item.summon-spell { position: relative; isolation: isolate; }
.row-item.summon-spell::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: url("/icons/SummonDragon.png") center / contain no-repeat;
  opacity: .16; filter: invert(1); pointer-events: none;
}
.row-item.summon-spell.elem-light::before { filter: none; opacity: .2; }
/* R185: Element-Karten im Elemente-Tab farbcodiert wie die Zauber-Kacheln -
   dieselben --se-* Variablen, pro Karte aus SPELL_ELEM_COLORS gesetzt (app.js). */
.card.el-elem { background: var(--se-bg); border-color: var(--se-border); }
.card.el-elem:hover { background: var(--se-bg-hover); }
/* Gewählte Elemente behalten den goldenen Rahmen, Zustands-Signal schlägt Elementfarbe. */
.card.el-elem.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), 0 0 14px rgba(201, 162, 39, 0.18); }
/* „Elementar Feat“-Karten behalten den lila Rahmen (wie .card.elem-feat-card). */
.card.el-elem.elem-feat-card { border-color: #a06ad4; box-shadow: 0 0 0 1px #a06ad4, 0 0 14px rgba(160, 106, 212, 0.20); }
/* Helle Element-Karten (Nebel = weiß), dunkler Text/Badges/Buttons für Lesbarkeit. */
.card.el-elem.elem-light { color: var(--se-fg); }
.card.el-elem.elem-light h3 { color: var(--se-fg); }
.card.el-elem.elem-light .meta-line { color: #6f6a5e; }
.card.el-elem.elem-light p.desc { color: var(--se-fg); }
.card.el-elem.elem-light .feat-list { color: var(--se-fg); }
.card.el-elem.elem-light .feat-list li.reached { color: #2f6d2f; }
.card.el-elem.elem-light .feat-list li.feat-granted { color: #6b3fa0; }
.card.el-elem.elem-light .lv-tag { color: #7a5c14; background: rgba(201, 162, 39, 0.15); border-color: rgba(201, 162, 39, 0.5); }
.card.el-elem.elem-light .feat-list li.reached .lv-tag { color: #2f6d2f; background: rgba(93, 158, 93, 0.15); border-color: rgba(93, 158, 93, 0.5); }
.card.el-elem.elem-light .feat-list li.feat-granted .lv-tag { color: #7d4fb5; background: rgba(160, 106, 212, 0.15); border-color: rgba(160, 106, 212, 0.5); }
.card.el-elem.elem-light .badge { color: #4a4a52; background: rgba(0, 0, 0, 0.07); border-color: #b9b9c1; }
.card.el-elem.elem-light .badge.ok { color: #2f6d2f; background: rgba(93, 158, 93, 0.14); border-color: rgba(93, 158, 93, 0.5); }
.card.el-elem.elem-light .badge.elem-feat { color: #f5ecff; background: linear-gradient(180deg, #a06ad4, #6b3fa0); border-color: #7d4fb5; font-weight: 600; }
.card.el-elem.elem-light .btn.ghost { color: #3a3a42; border-color: #9a9aa2; }
.card.el-elem.elem-light .btn.ghost:hover { background: rgba(0, 0, 0, 0.06); }
.card.el-elem.elem-light .gear-btn { color: #4a4a52; border-color: #b9b9c1; }

.row-main { min-width: 0; flex: 1; }
.row-name { font-weight: 600; font-size: 14.5px; }
.row-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row-text { font-size: 13px; color: #cfc2a8; margin-top: 5px; white-space: pre-line; }

/* Kampftechniken: Statliste (Kosten/Cooldown/Reichweite/…) als kompakte Zwei-Spalten-Zeilen */
.tech-specs { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.tech-spec { display: flex; align-items: baseline; gap: 10px; font-size: 12.5px; color: #cfc2a8; min-width: 0; }
.tech-spec .lbl { flex: none; width: 92px; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; }
.tech-spec .val { overflow-wrap: anywhere; }

/* Kampftechniken: Karten-Grid statt Zeilenliste, mehr auf einen Blick */
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.tech-grid .row-item { flex-direction: column; align-items: stretch; justify-content: flex-start; min-height: var(--uniform-card-h, auto); }
.tech-grid .row-side { margin-top: auto; padding-top: 8px; width: 100%; justify-content: space-between; }
/* R161: Technik ohne passende getragene Waffe wird ausgegraut (nur im Allgemein-Tab) */
.tech-grid .row-item.tech-no-weapon { opacity: .45; }
/* R338: Wie bei .locked, Tooltips auf ausgegrauten Technik-Karten wieder lesbar. */
.tech-grid .row-item.tech-no-weapon:hover { opacity: 1; }

.row-side { display: flex; align-items: center; gap: 8px; flex: none; }
.feat-count { min-width: 26px; text-align: center; font-size: 14px; font-weight: 700; color: var(--gold-bright); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.25);
  white-space: nowrap;
}
.badge.gold { color: #221a08; background: linear-gradient(180deg, var(--gold-bright), #a88420); border-color: var(--gold); font-weight: 600; }
/* Geschenkte Feats (🎁), belegen keine Featslots. */
.badge.gift { color: #e3d5a3; background: rgba(201, 162, 39, 0.14); border-color: var(--gold); }
/* Seltenheits-Farben: gewöhnlich grau · selten blau · episch lila · legendär gold */
.badge.rar-gewoehnlich { color: #b9b4a8; background: rgba(150, 145, 130, 0.12); border-color: #6d675c; }
.badge.rar-selten { color: #eaf2ff; background: linear-gradient(180deg, #4a7fd4, #2c4f96); border-color: #35589e; font-weight: 600; }
.badge.rar-episch { color: #f5ecff; background: linear-gradient(180deg, #a06ad4, #6b3fa0); border-color: #7d4fb5; font-weight: 600; }
.badge.rar-legendaer { color: #221a08; background: linear-gradient(180deg, var(--gold-bright), #a88420); border-color: var(--gold); font-weight: 600; }
/* Item-Tags (z. B. „Zwillingswaffe“), gestrichelte Umrandung zur Unterscheidung von Seltenheits-Badges. */
.badge.tag-badge { font-size: 10.5px; padding: 1px 7px; border-style: dashed; }
/* R549: Klickbares Tag „Lebendige Waffe“ im Inventar (springt zum Nachteil),
   eigene goldene Farbe, damit es von den normalen Tags abhebt und klickbar wirkt. */
.badge.tag-badge[data-disadvantageId] {
  cursor: pointer;
  color: #221a08; background: linear-gradient(180deg, var(--gold-bright), #a88420);
  border-color: var(--gold); font-weight: 600;
}
.badge.tag-badge[data-disadvantageId]:hover { filter: brightness(1.3); }
.badge.ok { color: #bfe3bf; border-color: #3f6b3f; }
.badge.elem-feat { color: #f5ecff; background: linear-gradient(180deg, #a06ad4, #6b3fa0); border-color: #7d4fb5; font-weight: 600; }
.badge.warn { color: #e8c9a0; border-color: #7a5a2a; }
.badge.danger { color: #eeb1af; border-color: #7a3a37; }
/* R237: Technik-Cooldown-Badge im Kampf-Tab (orange, klar abgesetzt). */
.badge.cd { color: #f0c987; background: rgba(150, 96, 32, 0.2); border-color: #a06a24; font-weight: 600; }
/* R420: "Gelegenheitsangriff"-Tag auf Technik-Karten (blau-teal, abgesetzt von Waffentags). */
.badge.ga { color: #bfe3e8; background: rgba(56, 120, 140, 0.18); border-color: #3f7a8c; font-weight: 600; }
/* R434: "Kombo"-Tag auf Technik-Karten (violett, abgesetzt von GA und Waffentags). */
.badge.kombo { color: #d9c2f0; background: rgba(110, 70, 150, 0.18); border-color: #6e4a96; font-weight: 600; }
/* R438: Magiestein-Stufen-Badge an den Elementstufen (cyan-blau, abgesetzt von Seltenheits-Badges). */
.badge.spellcap { color: #bfe3f5; background: rgba(52, 110, 160, 0.18); border-color: #3a7ca5; font-weight: 600; }
/* Metal L1 Tech-Gegenstand, silberne Umrandung + Badge (virtuelles Tag, nicht in items.yaml). */
.inv-row.tech-item { border-color: #b9c2cc; box-shadow: 0 0 0 1px rgba(185, 194, 204, 0.6), 0 0 12px rgba(185, 194, 204, 0.18); }
.badge.tech-badge { color: #eef2f7; background: linear-gradient(180deg, #cfd6de, #8d99a6); border-color: #b9c2cc; font-weight: 600; }
/* Metal L1 Tech-Wahl-Buttons: Text-Buttons direkt am Item-Namen (links im
   Zeilenkopf), metallisch für „machen“, warnend für „aufheben“. */
.tech-make-btn {
  margin-left: 8px; padding: 3px 9px; font-size: 12px; font-weight: 600; line-height: 1.4;
  color: #eef2f7; background: linear-gradient(180deg, #5a6470, #3c434d);
  border: 1px solid #b9c2cc; border-radius: 6px; cursor: pointer; white-space: nowrap; vertical-align: middle;
}
.tech-make-btn:hover { background: linear-gradient(180deg, #6d7885, #4a525e); box-shadow: 0 0 8px rgba(185, 194, 204, 0.35); }
.tech-undo-btn {
  margin-left: 8px; padding: 3px 9px; font-size: 12px; font-weight: 600; line-height: 1.4;
  color: #eeb1af; background: rgba(122, 58, 55, 0.25);
  border: 1px solid #7a3a37; border-radius: 6px; cursor: pointer; white-space: nowrap; vertical-align: middle;
}
.tech-undo-btn:hover { background: rgba(122, 58, 55, 0.45); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
/* R169: AP/RP-Zeile, Aktions- & Reaktionspunkte immer nebeneinander in einer eigenen Zeile. */
.ap-rp-row { flex-wrap: nowrap; }
.stat-chip {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 13px;
}
.stat-chip b { color: var(--gold-bright); }
/* R177: Chip-Icons (Herz = HP, Blitz gelb/blau = Aktions-/Reaktionspunkte). */
.stat-chip .chip-icon { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }
/* Resistenz blau / Schwäche rot, auf einen Blick unterscheidbar (Kampfwerte-Chips). */
.stat-chip.resist-chip { border-color: var(--info); }
.stat-chip.resist-chip b { color: #b9cfe0; }
.stat-chip.weak-chip { border-color: var(--danger); }
.stat-chip.weak-chip b { color: #e8b0ae; }
.chip-sub { margin-left: 6px; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.hp-input { width: 62px; padding: 3px 6px; font-size: 13px; text-align: center; border-radius: 6px; }
/* Blutig: aktuelle HP unter der Hälfte des Maximums → rot markiert. */
.hp-input.low { border-color: var(--danger); background: rgba(214, 69, 56, 0.18); color: #ff9d97; font-weight: 700; }
.stat-chip.hp-low { border-color: var(--danger); }
/* Traglast überschritten: Chip rot markiert. */
.stat-chip.carry-over { border-color: var(--danger); }
.stat-chip.carry-over b { color: #e07b78; }
/* R262: Status-Chips im Kampf-Tab, direkt unter den großen HP (z. B. „Brennen“). */
.combat-status-row { margin-top: -4px; }
.stat-chip.status-chip { border-color: rgba(255, 138, 60, 0.55); background: rgba(255, 94, 40, 0.10); }
/* R268: Status-Emoji als Text (statt <img src="Emoji"> → kaputtes Bild). */
.stat-chip .status-emoji { font-size: 13px; line-height: 1; vertical-align: -2px; margin-right: 4px; }
/* R463: X am Status-/Versteckt-Chip im Kampf-Tab, Effekt jederzeit manuell entfernen. */
.stat-chip .status-chip-x { margin-left: 7px; padding: 0 5px; font-size: 12px; line-height: 16px; border-radius: 8px; color: var(--muted); cursor: pointer; user-select: none; }
.stat-chip .status-chip-x:hover { background: rgba(255, 94, 40, 0.25); color: #ffb3a7; }
/* R484: Seelenmarker-Counter-Chip im Kampf-Tab (Untoten-Element Stufe 3), +/− Buttons. */
.stat-chip.seelen-chip { border-color: rgba(160, 120, 255, 0.55); background: rgba(120, 80, 220, 0.12); }
.stat-chip .seelen-chip-btn { margin-left: 7px; padding: 0 6px; font-size: 13px; line-height: 16px; border-radius: 8px; color: #cbb8ff; cursor: pointer; user-select: none; }
.stat-chip .seelen-chip-btn:hover { background: rgba(120, 80, 220, 0.30); color: #e6dcff; }
.stat-chip .seelen-chip-btn.seelen-chip-off { opacity: 0.35; cursor: default; }
.stat-chip .seelen-chip-btn.seelen-chip-off:hover { background: none; color: #cbb8ff; }
/* R484: Seelenmarker-Info-Box im „Zauber wirken“-Modal (Untoten-Zauber). */
.spelllvl-smbox { margin-top: 10px; padding: 8px 10px; border: 1px solid rgba(160, 120, 255, 0.4); border-radius: 8px; background: rgba(120, 80, 220, 0.08); }
.spelllvl-smbox div { margin-top: 3px; }
/* R263: Waffenbuff-Chips im Kampf-Tab, grün (Buff) statt orange (Status). */
.combat-buff-row { margin-top: -4px; }
.stat-chip.buff-chip { border-color: rgba(90, 190, 120, 0.55); background: rgba(60, 170, 90, 0.10); }
.stat-chip .btn.small { margin-left: 8px; padding: 3px 9px; font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  background: linear-gradient(180deg, #d4ab35, #a88420);
  border: 1px solid #8f6f1c;
  color: #221a08;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 15px;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
/* R279: Hellerer Rot-Ton (nur „Schaden nehmen“/„Schaden anwenden“ nutzen .btn.danger). */
.btn.danger { background: linear-gradient(180deg, #ea6a5f, #bf4237); border-color: #96352e; color: #ffe9e8; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); filter: none; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover { background: var(--card-hover); }
.icon-btn.danger:hover { border-color: var(--danger); color: #eeb1af; }
/* R551: Deaktivierter Icon-Button (z. B. Verkauf der lebendigen Waffe) sichtbar absetzen. */
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Inventar: Tragen-Toggle (alle ausrüstbaren Items) */
.equip-btn.on {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(201, 162, 39, 0.12);
}
.dim-note { color: var(--dim); font-size: 12px; }

/* ---------- Inventar: Lagerorte & Drag & Drop ---------- */
.inv-section {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
/* Inventar-Hauptzeile (zweispaltig): links Equipment-Layout, rechts „Am Körper“. */
.inv-main { display: flex; gap: 16px; align-items: flex-start; }
.inv-equip-col { flex: none; width: min(460px, 45%); }
.inv-body-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.inv-main .inv-section { margin-bottom: 0; }
/* Container-Sektionen (Rucksack/Gürtel) nebeneinander unter der Hauptzeile. */
.inv-containers { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.inv-containers .inv-section { flex: 1 1 300px; min-width: 0; margin-bottom: 0; }
.inv-loc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.loc-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 400; }
.inv-dropzone { min-height: 34px; border-radius: 8px; transition: background .15s ease, box-shadow .15s ease; }
.drop-hint {
  padding: 10px;
  text-align: center;
  color: var(--dim);
  font-size: 12.5px;
  border: 1px dashed var(--border-soft);
  border-radius: 8px;
}
.inv-dropzone.drag-over { background: rgba(201, 162, 39, 0.07); box-shadow: inset 0 0 0 1px var(--gold); }
.row-item.dragging { opacity: 0.45; cursor: grabbing; }
.drag-grip { flex: none; margin-right: 8px; color: var(--dim); font-size: 13px; cursor: grab; user-select: none; }
.inv-weight { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Shop: Kategorie- & Seltenheits-Umbrüche */
.shop-cat-header {
  margin: 18px 0 6px;
  font-size: 15.5px; font-weight: 700; color: var(--gold-bright);
  border-bottom: 1px solid var(--border-soft); padding-bottom: 5px;
}
.shop-cat-header:first-child { margin-top: 2px; }
.shop-rarity-header {
  margin: 12px 0 3px 4px;
  font-size: 12.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase;
  color: var(--gold); opacity: .8;
}
.shop-rarity-header.rar-gewoehnlich { color: #b9b4a8; }
.shop-rarity-header.rar-selten { color: #7fb0f0; }
.shop-rarity-header.rar-episch { color: #c39ae6; }
.shop-rarity-header.rar-legendaer { color: var(--gold-bright); }

/* Feats: Attribut-Wahl für „Attributspunkte“ / „Große Attributssteigerung“ */
.attr-feat-choices { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; }
.afc-item { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.afc-item select { font-size: 12.5px; padding: 4px 8px; border-radius: 7px; max-width: 190px; }

/* Klassen-Level-Ups mit Effektwahl (z. B. Schütze Lv3): Radio-Optionen */
.lu-wahl { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.lu-wahl-opt { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 7px 9px; border: 1px solid var(--border-soft); border-radius: 8px; cursor: pointer; }
.lu-wahl-opt input { margin-top: 2px; accent-color: var(--gold); flex-shrink: 0; }
.lu-wahl-opt.picked { border-color: var(--gold); background: rgba(201, 162, 39, 0.08); color: var(--text); }
/* Festgelegte Effektwahl (nach Bestätigung des Level-Ups / der Erstellung):
   Read-only-Karte mit Schloss, nicht mehr änderbar. */
.lu-wahl-locked .lu-wahl-opt { cursor: default; border-style: dashed; }
.lu-wahl-locked .lu-wahl-opt.picked { background: rgba(201, 162, 39, 0.05); color: var(--muted); }
/* R435: Noch nicht erreichte Elementstufe → Effektwahl als ausgegraute Vorschau
   (nicht wählbar, wird aktiv wenn die Stufe erreicht ist). */
.lu-wahl-dim { opacity: 0.65; }
.lu-wahl-dim .lu-wahl-opt { cursor: default; border-style: dashed; }
/* R486: Ausgegraute Effektwahl-Vorschau (noch nicht erreichte Stufe) wird beim
   Hover temporär voll lesbar, damit man sie vor dem Skillen lesen kann;
   beim Verlassen greift die Ausgrauung wieder. */
.lu-wahl-dim:hover { opacity: 1; }

/* R507: Ausgegraute Metal-Vorschau einklappbar (<details>/<summary>), damit Wahlstufen
   mit vielen Optionen (Stufe 5/9) die Karte nicht zu lang machen. */
.lu-wahl-fold { margin-top: 6px; }
.lu-wahl-fold > summary { list-style: none; cursor: pointer; user-select: none; font-size: 12px; color: var(--muted); border: 1px dashed var(--border-soft); border-radius: 8px; padding: 5px 9px; width: fit-content; display: flex; align-items: center; gap: 6px; }
.lu-wahl-fold > summary::-webkit-details-marker { display: none; }
.lu-wahl-fold > summary::before { content: "▸"; display: inline-block; font-size: 10px; transition: transform 0.15s ease; }
.lu-wahl-fold[open] > summary::before { transform: rotate(90deg); }
.lu-wahl-fold > summary::after { content: "anzeigen"; opacity: 0.7; }
.lu-wahl-fold[open] > summary::after { content: "ausblenden"; }
.lu-wahl-body { margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }

/* R431: Zauberer Lv10 Option 3, Lieblingszauber-Dropdown in der Effektwahl. */
.lu-wahl-spell-pick { margin-top: 6px; padding-left: 26px; font-size: 12.5px; color: var(--muted); }
.lu-wahl-spell-pick select { font-size: 12.5px; padding: 4px 8px; border-radius: 7px; max-width: 230px; margin-left: 6px; }

/* R431: Zauberer Lv10 Option 1, Highcast-Hakenfeld im Stufe-Wahl-Modal. */
.spell-lvl-highcast { display: block; margin-top: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.spell-lvl-highcast input { accent-color: var(--gold); margin-right: 6px; vertical-align: middle; }

/* ---------- Forms ---------- */
input[type="text"], input[type="number"], select, textarea {
  background: #191409;
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 8px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.15);
}
textarea { resize: vertical; min-height: 74px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; }
/* Read-only Felder im Allgemein-Tab (z. B. Rasse): DIV statt <input>, Replaced-
   Elements rendern keine ::after-Pseudo-Elemente, der Hover-Tooltip bräuchte sie.
   Sieht wie ein Input aus, ohne Editier-Look (kein Fokus-Ring). */
.field .readonly-field {
  background: rgba(201, 162, 39, 0.07);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 8px;
  width: 100%;
}

/* ---------- Attribute-Editor ---------- */
/* Zeilen-Karte pro Attribut: Name+Beschreibung | Punkte-Kauf | manueller Bonus | Ergebnis (Gleichung).
   Beide Control-Groups haben in jeder Zeile identische Breite -> alles bleibt ausgerichtet. */
.attr-row {
  display: grid;
  grid-template-columns: 210px auto auto minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 9px 13px;
  margin-bottom: 8px;
}
/* R568: Shop-Item durch Rasse-Gate gesperrt (z. B. Elfenbogen für Nicht-Elfen) */
.shop-item.shop-locked { opacity: 0.55; filter: grayscale(0.75); }
.shop-lock-note { margin-top: 6px; font-size: 12px; color: var(--danger); font-weight: 600; }

/* R567: Ohne Bonus-Feld (Spieler) -> 3 Spalten, Ergebnis rückt auf */
.attr-row.no-bonus { grid-template-columns: 210px auto minmax(0, 1fr); }
.attr-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attr-row .attr-name { font-weight: 600; line-height: 1.3; }
/* Beschreibung bricht um (statt Ellipsis-Abbruch) */
.attr-row .attr-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
/* Manueller Bonus (Buffs/Nerfs) neben dem Punkte-Kauf */
.bonus-group { display: flex; align-items: center; gap: 4px; }
.bonus-group input {
  width: 52px; padding: 4px 6px; font-size: 13px;
  text-align: center; border-radius: 6px;
}
.bonus-group .icon-btn { width: 26px; height: 26px; font-size: 13px; }
/* Punkte-Kauf −/+ direkt um das Basiswert-Feld (wie die Bonus-Punkte daneben) */
.base-group { display: flex; align-items: center; gap: 4px; }
.base-group input {
  width: 52px; padding: 4px 6px; font-size: 13px;
  text-align: center; border-radius: 6px;
}
.base-group .icon-btn { width: 26px; height: 26px; font-size: 13px; }
/* Ergebnis-Block: wörtliche Gleichung „14 + 1 = 15“ mit Modifier-Chip und Quellen-Zeile */
.attr-result { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.attr-eq { font-size: 14px; color: var(--muted); white-space: nowrap; }
.attr-eq .eq-base { color: var(--text); font-weight: 600; }
.attr-eq .eq-inc, .attr-eq .eq-bonus { font-weight: 700; padding: 0 3px; border-radius: 4px; margin: 0 1px; }
.attr-eq .pos { color: #9fd39f; background: rgba(159, 211, 159, 0.10); }
.attr-eq .neg { color: #e07b78; background: rgba(224, 123, 120, 0.10); }
.attr-eq b { font-size: 16px; color: var(--gold-bright); margin-left: 3px; }
.attr-mod-chip {
  margin-left: 9px; padding: 1px 8px; font-size: 12px; font-weight: 700;
  color: var(--gold-bright); background: rgba(201, 162, 39, 0.10);
  border: 1px solid var(--border-soft); border-radius: 999px;
}
.attr-src { font-size: 11px; color: var(--muted); white-space: nowrap; }
.attr-src .src-inc { color: #9fd39f; font-weight: 600; }
.attr-src .src-bonus { color: #cfc2a8; font-weight: 600; }
.attr-src .neg { color: #e07b78; }

.pool-bar {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pool-bar .pool-num { font-size: 18px; font-weight: 700; color: var(--gold-bright); }
.pool-bar.over { border-color: var(--danger); }
.pool-bar.over .pool-num { color: #e07b78; }

/* ---------- Level-Up-Tabelle ---------- */
table.lu-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lu-table th, table.lu-table td { border: 1px solid var(--border-soft); padding: 7px 10px; text-align: left; vertical-align: top; }
table.lu-table th { background: #2b2314; color: var(--gold-bright); font-size: 12.5px; }
table.lu-table tr.reached td { background: rgba(93, 158, 93, 0.07); }
table.lu-table tr.future td { opacity: 0.45; }
/* R486: Noch nicht erreichte Level-Up-Zeilen werden beim Hover temporär lesbar
   (lesen vor dem Skillen); beim Verlassen greift die Ausgrauung wieder. */
table.lu-table tr.future:hover td { opacity: 1; }

/* ---------- Elemente-Features (alle Level als Übersicht) ---------- */
.feat-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: #cfc2a8; }
.feat-list li { margin-bottom: 7px; overflow-wrap: break-word; }
.feat-list li.locked { opacity: 0.45; }
.feat-list li.reached { color: #cfe3cf; }
.feat-list li.future { opacity: 0.45; }
/* R486: Ausgegraute Element-Level-Zeilen (locked/future) werden beim Hover
   temporär lesbar; beim Verlassen greift die Ausgrauung wieder. */
.feat-list li.locked:hover, .feat-list li.future:hover { opacity: 1; }
.lv-tag {
  display: inline-block; min-width: 56px; text-align: center;
  margin-right: 7px; padding: 1px 5px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .3px;
  color: var(--gold-bright); background: rgba(201, 162, 39, 0.10);
  border: 1px solid var(--border-soft); border-radius: 4px;
}
.feat-list li.reached .lv-tag { color: #9fd39f; background: rgba(93, 158, 93, 0.12); border-color: rgba(93, 158, 93, 0.4); }
/* „Elementar Feat“: gewährte Stufen (1 & 3) in lila statt grün. */
.feat-list li.feat-granted { color: #e2ccff; }
.feat-list li.feat-granted .lv-tag { color: #c9a3f0; background: rgba(160, 106, 212, 0.14); border-color: rgba(160, 106, 212, 0.5); }
.el-level-btns { display: flex; gap: 8px; margin-top: 6px; margin-bottom: 2px; }
.card.mix-locked { opacity: .55; border-style: dashed; }
.note.over { background: rgba(224, 123, 120, 0.10); border-color: rgba(224, 123, 120, 0.45); color: #e8a5a3; }

/* ---------- Aufklappbare lange Texte („Mehr/Weniger“) ---------- */
.clp-body { display: block; overflow-wrap: break-word; white-space: pre-wrap; }
.clp-body.clp-clamped {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.clp-toggle {
  margin-top: 4px; padding: 2px 10px;
  font-size: 11.5px; cursor: pointer;
  background: rgba(201, 162, 39, 0.10); color: var(--gold-bright);
  border: 1px solid var(--border-soft); border-radius: 6px;
}
.clp-toggle:hover { border-color: var(--gold); }

/* Rassen-Bild: immer sichtbar, ganz oben in der Karte (nach Name + Movespeed/Schwimmen),
   dann erst Beschreibung. Max. 200px hoch, zentriert, kompakt genug für das Grid;
   dezenter Rahmen fügt das Bild optisch in die Karte ein. */
.race-img-wrap { display: block; margin: 10px 0 8px; text-align: center; }
.race-img-wrap img { max-height: 200px; max-width: 100%; border-radius: 6px; border: 1px solid var(--border-soft); }

/* Inventar: besessene Menge (×N) */
.qty-badge { font-weight: 700; }

/* ---------- Rassen-Effekte ---------- */
/* Jeder Effekt als eigene Zeile (statt nowrap-Badge, das lange Texte überlappt). */
.race-effects { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: #cfc2a8; }
.race-effects li { margin-bottom: 4px; overflow-wrap: break-word; }
/* Echsenmensch-Karte: Resistenz-Dropdown direkt in der Rassenkarte (unten). */
.race-resist-pick { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--border-soft); }
.race-resist-pick label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.race-resist-pick .note { font-size: 11.5px; color: var(--dim); margin: 0 0 6px; }

/* Backstory-Textarea deutlich größer, in alle Richtungen per Maus ziehbar */
textarea.backstory { width: 100%; resize: both; overflow: auto; min-height: 340px; line-height: 1.5; }

/* Rassen-Karte: Hinweis auf verfügbare Subrassen (unter der Beschreibung) */
.subrace-hint { margin-top: 8px; font-size: 12.5px; color: var(--gold-bright); }

/* Inventar/Shop: Item-Beschreibung, magische Effekte & Verfluchungen */
.inv-desc { font-size: 12px; color: #cfc2a8; margin-top: 4px; max-width: 56ch; overflow-wrap: break-word; }
.magic-effect {
  font-size: 12.5px; color: #d9b8f0;
  background: rgba(120, 80, 160, 0.14);
  border-left: 3px solid #8a5fb0;
  border-radius: 5px;
  padding: 5px 9px; margin-top: 6px;
  max-width: 72ch; overflow-wrap: break-word;
}
.curse-note {
  font-size: 12.5px; color: #e8b0ae;
  background: rgba(176, 65, 62, 0.14);
  border-left: 3px solid var(--danger);
  border-radius: 5px;
  padding: 5px 9px; margin-top: 6px;
  max-width: 72ch; overflow-wrap: break-word;
}
/* Traglast-Überschreitung im Allgemein-Tab: rote Warnbox mit Penalty-Auflistung. */
.carry-note {
  font-size: 12.5px; color: #e8b0ae;
  background: rgba(176, 65, 62, 0.14);
  border: 1px solid var(--danger);
  border-left: 3px solid var(--danger);
  border-radius: 6px;
  padding: 8px 12px; margin-top: 8px;
  max-width: 72ch; overflow-wrap: break-word;
}
.carry-note ul { margin: 6px 0 2px; padding-left: 18px; }
.carry-note li { margin: 2px 0; }

/* Allgemein-Tab: „Boni & Fähigkeiten“ / „Nachteile“ / „Magische Ausrüstung“ als Kachel-Grid */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 4px; }
.tile {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tile .tile-src { font-size: 12.5px; color: var(--gold-bright); font-weight: 600; }
.tile .tile-text { font-size: 13px; color: #d9cfb8; overflow-wrap: break-word; }
.tile.disadvantage-tile { border-left: 3px solid rgba(224, 123, 120, 0.5); }

/* Talente-Tab: kompakte Kacheln statt Zeilen, alle Talente passen auf eine Seite */
.talent-groups { display: flex; flex-direction: column; gap: 10px; }
.talent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 8px; }
.talent-tile {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.talent-tile.selected { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.45); }
.talent-tile .tt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.talent-tile .tt-name { font-size: 13.5px; font-weight: 600; color: #e9dcb8; overflow-wrap: anywhere; }
.talent-tile .tt-formula { font-size: 12px; color: var(--muted); }
.talent-tile .tt-mod { font-size: 12px; color: var(--text); }
.talent-tile .tt-mod b { color: var(--gold-bright); font-weight: 700; }
.talent-tile .tt-grants { font-size: 11.5px; color: var(--gold-bright); }
.talent-tile .tt-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.talent-tile .tt-btns { display: inline-flex; gap: 4px; align-items: center; }
.talent-tile .tt-manual {
  width: 52px; padding: 3px 5px; font-size: 12.5px;
  text-align: center; border-radius: 6px;
}
.talent-tile .tt-manual-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.talent-tile .tt-manual-label { font-size: 10.5px; color: var(--muted); letter-spacing: 0.3px; }

/* ---------- Shop / Inventar ---------- */
.shop-item .price { font-weight: 700; color: var(--gold-bright); white-space: nowrap; }
table.inv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 8px; }
table.inv-table th, table.inv-table td { border: 1px solid var(--border-soft); padding: 7px 10px; text-align: left; }
table.inv-table th { background: #2b2314; color: var(--gold-bright); font-size: 12.5px; }
table.inv-table tr.total td { font-weight: 700; background: rgba(201, 162, 39, 0.08); }

/* ---------- Zusammenfassung ---------- */
.summary-block { margin-bottom: 18px; }
.summary-block h3 { margin: 0 0 8px; font-size: 15.5px; color: var(--gold-bright); border-bottom: 1px solid var(--border-soft); padding-bottom: 4px; }
.kv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv-table td { padding: 5px 8px; border-bottom: 1px dashed var(--border-soft); vertical-align: top; }
.kv-table td:first-child { color: var(--muted); width: 200px; white-space: nowrap; }

/* ---------- Dev-Modus: ⚙️-Gears & Objekt-Modal ---------- */
.gear-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-left: 6px; padding: 0; flex: none;
  font-size: 13px; line-height: 1; cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-soft); border-radius: 6px;
  color: var(--muted); vertical-align: middle;
}
.gear-btn:hover { background: rgba(201, 162, 39, 0.15); border-color: var(--gold); }
.feat-list .gear-btn { margin-left: 8px; }
table.lu-table th.gear-col, table.lu-table td.gear-col { width: 40px; text-align: center; padding: 6px 4px; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 8, 5, 0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  width: min(760px, 100%); max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}
.modal-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0 0 4px; font-size: 17px; color: var(--gold-bright); overflow-wrap: anywhere; }
.modal-body { padding: 12px 16px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border-soft); flex-wrap: wrap;
}
.modal-foot .save-state { margin-right: auto; text-align: left; min-width: 0; }
.managed-warn { font-size: 11.5px; color: #e8c9a0; }

/* Bestätigungs-Modal (Erstellung abschließen / Level-Up bestätigen) */
.confirm-modal { width: min(560px, 100%); }

/* R317: Inskriptions-Dropdown für Schriftrollen (Shop-Kauf & Herstellung). */
.scroll-select {
  width: 100%; max-width: 480px; padding: 9px 12px; font-size: 14px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px;
}

/* R373: Shop-Kauf-Popup, Mengenauswahl + Projektionspreis + Bestätigung. */
.buy-popup { width: min(460px, 100%); }
.buy-qty-row .buy-qty-ctrl { display: flex; align-items: center; gap: 8px; }
.buy-qty-btn { padding: 7px 13px; font-size: 15px; line-height: 1; min-width: 40px; }
.buy-qty-input {
  width: 92px; text-align: center; padding: 8px 10px; font-size: 14px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
}
.buy-price-line { margin-top: 2px; font-size: 14.5px; }
.buy-price-line .buy-total { color: var(--gold-bright); font-size: 16px; }
.buy-money-note { margin-top: 8px; }
.buy-money-warn {
  border-color: #b3574d;
  background: rgba(179, 87, 77, 0.12);
  color: #e8a49c;
}
.confirm-pane .confirm-warn { font-size: 13.5px; color: #e8c9a0; margin-bottom: 8px; }
.open-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.open-list li {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 7px 10px; font-size: 13.5px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.open-list .ol-icon { font-size: 14px; }
.confirm-blocked {
  background: rgba(224, 123, 120, 0.1); border: 1px solid #e07b78; color: #f0a9a6;
  border-radius: 8px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere;
}

/* Warnungs-Modal vor Würfelauswahl (Roulette / Dragonborn / Ungebildet). */
.rollwarn-modal { width: min(520px, 100%); border-color: var(--gold); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(201, 162, 39, 0.25); }
.rollwarn-head-icon { font-size: 24px; margin-right: 8px; vertical-align: -3px; }
.rollwarn-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.rollwarn-list li { background: var(--card); border: 1px solid var(--border-soft); border-left: 3px solid var(--gold); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; line-height: 1.45; display: flex; gap: 8px; align-items: baseline; }
.rollwarn-list .rw-icon { font-size: 15px; }
/* Hinweis in Würfelpanels, sobald das Ergebnis festgeschrieben ist. */
.roll-locked-note { color: #e8c9a0; border-left: 3px solid var(--gold); padding-left: 10px; }

/* generischer rekursiver Editor (Objekt-Modal) */
.re-node { margin-bottom: 6px; }
.re-dict-row, .re-list-item {
  display: grid;
  grid-template-columns: minmax(130px, 240px) 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 6px 8px;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  margin-bottom: 5px;
  background: rgba(0, 0, 0, 0.14);
}
.re-list-item { grid-template-columns: 34px 1fr auto; }
.re-key { width: 100%; font-family: Consolas, monospace; font-size: 12.5px; padding: 5px 8px; }
.re-idx { color: var(--dim); font-size: 12px; text-align: center; padding-top: 7px; font-family: Consolas, monospace; }
.re-del { margin-top: 3px; }
.re-add { width: 100%; margin-top: 4px; }
.re-scalar { width: 100%; font-size: 12.5px; padding: 5px 8px; }
.re-scalar.long { min-height: 132px; resize: vertical; }
.re-typehint { font-size: 10.5px; color: var(--dim); margin-top: 3px; }

/* ---------- Shop: Seltenheits-Filter-Zeile & Item-Anlage-Formular ---------- */
.rarity-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.rarity-row button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border-soft);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
}
.rarity-row button:hover { background: var(--card-hover); }
.rarity-row button.active {
  background: linear-gradient(180deg, var(--gold-bright), #a88420);
  border-color: var(--gold);
  color: #221a08;
  font-weight: 600;
}
.rarity-row .rarity-add { margin-left: auto; }

.ai-form { display: flex; flex-direction: column; gap: 10px; }
.ai-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 8px; align-items: start; }
.ai-label { font-size: 13px; color: var(--muted); padding-top: 9px; }
.ai-block { padding-top: 0; margin-bottom: -4px; }
.ai-row input[type="text"], .ai-row input[type="number"], .ai-row select, .ai-row textarea { width: 100%; }
.ai-long { min-height: 74px; resize: vertical; }
.ai-eff-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.ai-eff-add { align-self: flex-start; margin-top: 2px; }
.ai-extra { border-top: 1px solid var(--border-soft); padding-top: 4px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Dev-Modus: „➕ neu"-Buttons & Subrassen-Blöcke ---------- */
.dev-add-row { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.ai-sub {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(0, 0, 0, 0.12);
  margin-bottom: 6px;
}
.ai-sub-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }

/* ---------- Platzhalter (Zauber) ---------- */
.placeholder-box {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 34px 26px;
  text-align: center;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.15);
}
.placeholder-box .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- Hinweis-Boxen ---------- */
.note {
  background: rgba(74, 127, 165, 0.10);
  border: 1px solid rgba(74, 127, 165, 0.35);
  color: #b9cfe0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  margin: 10px 0;
}

/* ---------- Versionsanzeige + Account-Tags (unten links) ---------- */
#app-version {
  position: fixed; left: 8px; bottom: 6px; z-index: 40;
  font-size: 11px; color: var(--dim); pointer-events: none;
  display: flex; align-items: center; gap: 5px;
}
/* R561: Account-Tags als kleine Chips direkt neben der Versionsnummer */
.ver-tag {
  font-size: 10px; font-weight: 600; letter-spacing: .02em;
  padding: 1px 7px; border-radius: 999px; border: 1px solid transparent;
}
.ver-tag-admin   { color: #ffd97a; background: rgba(255, 190, 60, .13);  border-color: rgba(255, 190, 60, .45); }
.ver-tag-dm      { color: #d9b8ff; background: rgba(160, 100, 255, .13); border-color: rgba(160, 100, 255, .45); }
.ver-tag-spieler { color: #a9d9a9; background: rgba(90, 180, 90, .13);   border-color: rgba(90, 180, 90, .45); }

/* ---------- Attribute & Talente Übersicht (Allgemein-Tab) ---------- */
.attr-talent-wrap { display: grid; grid-template-columns: minmax(230px, 330px) 1fr; gap: 18px; align-items: start; margin-top: 6px; }
.at-attr-row, .at-talent-row {
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 7px 10px; margin-bottom: 6px;
}
.at-attr-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.at-name { font-size: 13px; font-weight: 600; color: #e9dcb8; }
.at-val { text-align: right; font-size: 14px; white-space: nowrap; }
.at-talent-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.at-talent-row .at-name { overflow-wrap: anywhere; }
.at-talent-row .at-sub { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }

/* Talente im Allgemein-Tab: eine Spalte pro Kategorie (Kategorien nebeneinander),
   Talente als kompakte Zeilen darunter, noch flacher als die Attribut-Zeilen. */
.at-talents { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; align-items: start; }
.at-talent-col .shop-cat-header { margin: 0 0 3px; font-size: 12px; }
.at-talent-row {
  background: transparent; border: none;
  padding: 1px 3px; margin-bottom: 0;
}
.at-talent-row:hover { background: var(--card); }
.at-talent-row .at-name { font-size: 11px; }
.at-talent-row .at-val { font-size: 12px; }
.at-talent-row .at-sub { font-size: 9.5px; margin-top: -2px; line-height: 1.3; }

@media (max-width: 900px) {
  #layout { grid-template-columns: 190px 1fr; }
  /* Attribute-Zeilen auf schmalen Screens: Name oben, Controls nebeneinander, Ergebnis unten */
  .attr-row { grid-template-columns: 1fr auto; }
  .attr-row .attr-id { grid-column: 1 / -1; }
  .attr-row .base-group { justify-self: start; }
  .attr-row .bonus-group { justify-self: end; }
  .attr-row .attr-result { grid-column: 1 / -1; margin-top: 2px; }
  .attr-talent-wrap { grid-template-columns: 1fr; }
}

/* Talente-Spalten auf schmalen Screens zusammenfalten */
@media (max-width: 1200px) {
  .at-talents { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .at-talents { grid-template-columns: 1fr; }
}

/* ---------- Portrait (Allgemein-Tab) ---------- */
/* R165: Das Portrait steht im normalen Flow der Info-Sektion (rechts neben den
   Feldern) und dehnt sich per align-items: stretch auf die volle Höhe der Zeile -
   es ragt damit nie in Kampfwerte oder andere Sektionen hinein. Der frühere
   Linien-Schlenker-Mechanismus (absolutes Portrait + ::after-Linie) ist entfallen. */
.info-portrait-wrap { display: flex; gap: 18px; align-items: stretch; }
.info-portrait-wrap > .form-grid { flex: 1 1 auto; min-width: 0; }
.portrait-box { flex: 0 0 210px; width: 210px; display: flex; flex-direction: column; gap: 6px; }
/* R562: Die Magiestein-Info-Box im Allgemein-Tab wurde auf User-Wunsch entfernt.
   .magistein-title bleibt bestehen: es nutzt noch das Kampf-Log (R239). */
.magistein-title { font-weight: 600; padding-top: 4px; }

/* ---------- Kampf-Tab (R235) ---------- */
/* Leiste mit Rundenzähler + Starten/Nächste Runde/Beenden. */
.combat-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 6px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
}
.combat-round {
  font-weight: 700; color: var(--gold-bright);
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}
.combat-note { color: var(--muted); font-size: 12.5px; }
/* R343: Tag/Nacht-Toggle als animierter Button (GIF-Frames aus /icons/dn/) -
   rechtsbündig in der Kampf-Leiste (margin-left: auto) damit die Buttons links bleiben. */
.dn-switch { appearance: none; -webkit-appearance: none; margin-left: auto; border: 1px solid var(--border); border-radius: 999px; background: rgba(0, 0, 0, 0.25); padding: 3px 6px; cursor: pointer; line-height: 0; transition: border-color 0.15s ease, transform 0.1s ease; }
.dn-switch:hover { border-color: var(--gold-bright); }
.dn-switch:active { transform: scale(0.97); }
.dn-switch:disabled { cursor: default; opacity: 0.85; }
.dn-img { display: block; height: 34px; width: auto; border-radius: 999px; }
/* R238: Große HP-Anzeige im Kampf-Tab, prominent über der Runde-Leiste.
   Blutig (unter Hälfte des Maximums) → rot. */
.combat-hp-big { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 19px; }
.combat-hp-big .hp-big-icon { width: 26px; height: 26px; image-rendering: pixelated; }
.combat-hp-big b { font-size: 24px; color: var(--gold-bright); }
.combat-hp-big .hp-big-sep { color: var(--muted); }
.combat-hp-big .hp-big-max { color: var(--muted); font-weight: 700; font-size: 21px; }
.combat-hp-big.hp-low, .combat-hp-big.hp-low b { color: #e05555; }
/* R274/R276: HP-Steuerung im Kampf-Tab, „Schaden nehmen“/„Heilen“ direkt unter den
   großen HP; der Betrag wird per Modal abgefragt (R276). Schaden = rote .btn.danger,
   Heilung = grüne .btn.heal. */
.combat-hp-ctrl { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }
.btn.heal { background: linear-gradient(180deg, #5d9c5a, #3f7240); border-color: #33592f; color: #eaffea; }
/* R276: HP-Betrag-Modal, Betrag eingeben und bestätigen. */
.hpamt-modal { width: 340px; max-width: calc(100vw - 32px); }
.hpamt-input { width: 100%; padding: 8px 10px; font-size: 15px; text-align: center; border-radius: 8px; }
/* R275: „➕ Status Effekt“-Button im Kampf-Tab, violetter Akzent, abgesetzt von
   Schaden (rot) und Heilung (grün). */
.btn.status { background: linear-gradient(180deg, #6d5a9c, #4e3f75); border-color: #3d3260; color: #efeaff; }
.btn.status:disabled { opacity: .45; cursor: not-allowed; }
/* R275: Status-Effekt-Modal, Dropdown + optionale Kampfrunden-Auswahl. */
.statusadd-modal { width: 460px; max-width: calc(100vw - 32px); }
.statusadd-field { margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.statusadd-lbl { font-size: 12.5px; color: var(--muted); min-width: 96px; text-transform: uppercase; letter-spacing: .04em; }
.statusadd-sel { flex: 1; width: auto; }
.statusadd-rounds { width: 84px; padding: 4px 6px; font-size: 13px; text-align: center; border-radius: 6px; }
.statusadd-note { margin-top: 2px; font-size: 12.5px; color: var(--text); line-height: 1.45; min-height: 18px; }
/* R241: Magiestein-Bestände horizontal im Kopf der Zauber-Sektion (Kampf-Tab) -
   platzsparend und nah an den Zaubern. Read-only („verwenden“ bleibt im Allgemein-Tab).
   Die Chips nutzen das bestehende .stat-chip-Design; die Titel-Linie läuft unter
   Titel + Chips durch. */
.combat-spell-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 22px; padding-bottom: 5px; border-bottom: 1px solid var(--border-soft);
}
.combat-spell-head .section-title { margin: 0; border-bottom: none; padding-bottom: 0; }
/* Log der Verwendungen dieser Runde. */
.combat-log {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.02); border: 1px solid var(--border); border-radius: 10px;
}
.combat-log-entry { font-size: 13px; color: var(--muted); }
/* „Verwenden“/„Wirken“-Buttons in den Technik-/Zauber-Karten. */
.tech-grid .row-item .combat-use-btn {
  margin-top: auto; padding-top: 8px; width: 100%; justify-content: center;
}
.combat-use-btn:disabled { opacity: 0.45; cursor: not-allowed; }
/* R236: Level-Wahl-Modal beim Wirken von Zaubern im Kampf-Tab. */
.spelllvl-modal { width: min(480px, 100%); }
.spell-lvl-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.spell-lvl-btn.selected { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
.spelllvl-err { margin-top: 4px; }
.portrait-frame {
  position: relative; width: 100%; min-height: 230px; flex: 1 1 auto; overflow: hidden; cursor: pointer;
  background: var(--card); border: 1.5px dashed var(--border); border-radius: 10px;
}
.portrait-frame:hover { border-color: var(--gold); }
.portrait-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.portrait-del { position: absolute; top: 6px; right: 6px; padding: 2px 8px; font-size: 12px; background: rgba(20, 14, 8, 0.75); }
.portrait-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; text-align: center; padding: 10px; }
.portrait-ico { font-size: 34px; }
.portrait-caption { font-size: 11.5px; color: var(--dim); text-align: center; }
.portrait-file { display: none; }

/* ---------- Kampfwerte + Nachteile nebeneinander (Allgemein-Tab) ---------- */
.kw-wrap { display: flex; gap: 28px; align-items: flex-start; margin-top: 4px; }
.kw-chips { flex: 0 1 auto; min-width: 0; max-width: 640px; }
.kw-disadvantages { flex: 1 1 300px; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; align-content: start; }
.kw-dis-label { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); letter-spacing: 0.4px; margin-bottom: -2px; }

@media (max-width: 980px) {
  .info-portrait-wrap { flex-direction: column-reverse; }
  /* Mobil: Portrait über den Feldern, begrenzte Breite. */
  .portrait-box { flex: none; width: auto; max-width: 260px; }
  .token-box { flex: none; width: auto; max-width: 260px; }
  .token-body { flex-direction: column; }
  .token-preview-wrap { align-self: center; }
  .kw-wrap { flex-direction: column; gap: 14px; }
}

/* ---------- Toast (Erfolgs-Bestätigung) ---------- */
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 60;
  background: var(--panel); border: 1px solid var(--gold);
  color: var(--text); font-size: 13.5px;
  padding: 10px 16px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Hover-Breakdowns („woher kommen die Punkte?“) ----------
   Generischer Tooltip: Element bekommt .tip-hover + data-tip (per JS-Eigenschaft).
   R219: Erscheint sofort beim Hover, RECHTS neben dem Wert (vertikal zentriert) -
   so kann kein Tooltip mehr hinter die linke App-Sidebar laufen. Elemente am
   Viewport-Rechtsrand werden per .tip-flip-left (globaler mouseover-Listener in
   app.js) auf die linke Seite umgeklappt. */
.tip-hover { position: relative; cursor: help; }
.tip-hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 7px); top: 50%; transform: translateY(-50%);
  /* R152: min-width:max-content entfernt! Es ist die Einzeilen-Breite des Texts und
     hat Vorrang vor max-width, lange Tooltips (z.B. Rassen-Beschreibung) wurden
     dadurch als eine Zeile über die ganze Seite gerendert. width:max-content allein
     reicht: kurze Tooltips bleiben eng, lange brechen an max-width um. */
  width: max-content; max-width: 340px;
  white-space: pre-line; text-align: left; line-height: 1.5;
  background: #120e08; color: var(--text);
  border: 1px solid rgba(201, 162, 39, 0.45); border-radius: 8px;
  padding: 8px 11px; font-size: 12.5px; font-weight: 400;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  opacity: 0; visibility: hidden; transition: opacity .1s ease;
  z-index: 80; pointer-events: none;
}
.tip-hover:hover::after { opacity: 1; visibility: visible; }
/* R219: Flip an den Viewport-Rechtsrand, der globale mouseover-Listener in app.js
   setzt .tip-flip-left, wenn der Tooltip (geschätzte Breite) rechts aus dem Fenster
   laufen würde. Dann wächst er nach LINKS vom Element (vertikal weiterhin zentriert). */
.tip-hover.tip-flip-left::after { left: auto; right: calc(100% + 7px); }
/* Rassen-Tooltip (Allgemein): breiter als der Standard, die Rasse steht links im
   Info-Grid, und der Tooltip soll in den linken Seitenbereich passen (Zielbreite aus
   User-Skizze ~585px). Lange Beschreibungen brechen hier um statt eine Zeile über
   die ganze Seite zu bilden. */
/* R219: Die Rasse steht oben im Info-Grid, der hohe Tooltip wächst nach UNTEN
   (Top-Kante bündig), statt vertikal zentriert am Viewport-Oberrand zu klemmen. */
.tip-hover.tip-race::after { max-width: 560px; top: 0; transform: none; }
/* R239: Breite Elemente (z.B. die große HP-Leiste im Kampf-Tab) haben auf keiner
   Seite genug Platz für einen seitlichen Tooltip, der globale mouseover-Listener
   in app.js setzt dann .tip-below: Tooltip steht UNTER dem Element, links bündig.
   Steht nach tip-race, damit es bei Kombination Vorrang hat. */
.tip-hover.tip-below::after { left: 0; top: calc(100% + 7px); transform: none; }
/* R190: Kreatur-Tooltip auf Zauber-Karten, echtes HTML-Div (.creature-tip, per JS
   an die Karte angehängt) statt ::after/attr(data-tip), das keine Formatierung
   erlaubt. Aufbau: Name als Kopfzeile, HP/AC/MV als Stat-Chips, Stats/Angriff/
   Zauber/Fähigkeiten als Label-Wert-Zeilen; mehrere Kreaturen = Blöcke mit Trenner.
   Position wie R180: RECHTS neben der Karte (oben bündig); .tip-below (per JS in
   letzter Spalte, wenn rechts < ~500px Platz sind) → unten, zentriert. */
.has-ctip { position: relative; cursor: help; }
.creature-tip {
  position: absolute; left: calc(100% + 7px); top: 0; z-index: 85;
  width: max-content; min-width: 230px; max-width: 360px;
  background: #120e08; color: var(--text);
  border: 1px solid rgba(201, 162, 39, 0.45); border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; line-height: 1.5; text-align: left;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  opacity: 0; visibility: hidden; transition: opacity .1s ease; pointer-events: none;
}
/* R489: Beim Hover interaktiv, damit Status-Namen im Tooltip hovern koennen und der
   Tip beim Darueberfahren zum Lesen offen bleibt (Basisregel hat pointer-events:none). */
.has-ctip:hover > .creature-tip { opacity: 1; visibility: visible; pointer-events: auto; }
.tip-below .creature-tip { left: 50%; top: calc(100% + 7px); transform: translateX(-50%); }
/* R206: Das Kreatur-Tooltip muss ueber benachbarten Kacheln und Element-Sektionen
   gezeichnet werden, .summon-spell erzeugt per isolation:isolate einen eigenen
   Stacking-Kontext, daher wirkt z-index 85 nur innerhalb der Karte. Beim Hover wird
   die ganze Karte (inkl. isoliertem Kontext) ueber alle anderen z-auto-Positionierten
   gehoben (gleiches Muster wie R181 .equip-slot.tip-hover:hover). */
.tech-grid .row-item.has-ctip:hover { position: relative; z-index: 30; }
/* R329: Tooltips in Karten (.row-item), ausgegraute Karten (.locked opacity<1,
   .tech-no-weapon) und Summon-Karten (isolation:isolate) erzeugen eigene
   Stacking-Kontexte, die den z-index 80 des ::after-Tooltips einfangen; benachbarte
   Kacheln deckten das Hover-Fenster ab. Der globale mouseover/mouseout-Listener in
   app.js hebt beim Hover über einen .tip-hover die ganze Karte an (Muster R206/R181).
   R450: Element-Karten (.card.el-elem) sind keine .row-item, aber ihre ausgegrauten
   Level-Zeilen (li.future opacity<1) erzeugen eigene Stacking-Kontexte -> .card wird
   als Fallback mit angehoben. */
.row-item.tip-lift, .card.tip-lift { position: relative; z-index: 30; }
.ct-creature + .ct-creature { margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(201, 162, 39, 0.25); }
.ct-name { font-weight: 700; font-size: 13px; color: #c9a227; margin-bottom: 5px; overflow-wrap: anywhere; }
.ct-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 7px; }
.ct-stat {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: rgba(201, 162, 39, 0.1); border: 1px solid rgba(201, 162, 39, 0.28);
  border-radius: 6px; padding: 2px 7px;
}
.ct-stat i { font-style: normal; font-size: 10.5px; letter-spacing: .4px; text-transform: uppercase; color: rgba(233, 220, 190, 0.6); }
.ct-stat b { font-weight: 700; overflow-wrap: anywhere; }
.ct-rows { display: grid; grid-template-columns: 84px 1fr; gap: 3px 8px; }
.ct-label { color: rgba(233, 220, 190, 0.6); font-size: 11px; text-transform: uppercase; letter-spacing: .4px; align-self: start; padding-top: 1px; }
.ct-val { overflow-wrap: anywhere; }
/* R219: Die alten per-Chip-Messregeln (tip-left / tip-right-edge) sind entfernt -
   der neue Standard „rechts neben dem Element“ läuft nie hinter die Sidebar, und den
   Viewport-Rechtsrand deckt der globale .tip-flip-left-Flip in app.js ab. */

/* ---------- Roulette-Würfel (Feat „Roulette“) ---------- */
.roulette-modal { width: min(460px, 100%); }
.roulette-pane { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 16px; }
.dice-row { display: flex; gap: 28px; justify-content: center; }
.die-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.die-caption {
  font-size: 13px; color: var(--muted); min-height: 18px;
  text-align: center; max-width: 160px; line-height: 1.35;
}
.die-caption b { color: var(--gold-bright, #e6c14a); }
.dice {
  width: 92px; height: 92px;
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 700; color: #2a2115;
  background: linear-gradient(160deg, #f3e8cf, #d9c9a3);
  border: 2px solid #b39b6b; border-radius: 16px;
  box-shadow: inset 0 -4px 10px rgba(90, 70, 35, 0.28), 0 8px 18px rgba(0, 0, 0, 0.4);
  user-select: none;
}
.dice.rolling { animation: dice-shake .16s linear infinite; }
@keyframes dice-shake {
  0%   { transform: rotate(-7deg) translateY(0); }
  25%  { transform: rotate(4deg) translateY(-5px); }
  50%  { transform: rotate(8deg) translateY(1px); }
  75%  { transform: rotate(-3deg) translateY(-3px); }
  100% { transform: rotate(-7deg) translateY(0); }
}
.dice.settled { animation: dice-pop .28s ease; border-color: var(--gold-bright); }
@keyframes dice-pop {
  0%   { transform: scale(1.18); box-shadow: 0 0 26px rgba(230, 193, 74, 0.55), inset 0 -4px 10px rgba(90, 70, 35, 0.28); }
  100% { transform: scale(1); }
}
/* R291: Crafting-Modal, Total-Tile (grün/rot je nach Erfolg). */
.dice.total-die.ok { border-color: #86b56d; box-shadow: inset 0 -4px 10px rgba(70, 100, 45, 0.3), 0 8px 18px rgba(0, 0, 0, 0.4); }
.dice.total-die.fail { border-color: #b56d5c; box-shadow: inset 0 -4px 10px rgba(120, 55, 40, 0.3), 0 8px 18px rgba(0, 0, 0, 0.4); }
/* R292: Crafting-Modal, vertikaler Stapel (d20, Modifier-Zeile, Total). */
.craft-dice-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.craft-mod-line { font-size: 20px; font-weight: 700; color: var(--gold-bright); min-height: 24px; user-select: none; }
.roulette-status { font-size: 14px; color: var(--muted); min-height: 20px; text-align: center; }
.roulette-results {
  width: 100%; display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 10px 14px; font-size: 13.5px;
}
.roulette-confirm { font-weight: 700; color: var(--gold-bright, #e6c14a); }
.roulette-results b { color: var(--gold-bright); }
.roulette-info { margin-top: 10px; }

/* Stufe-8-Bonuspunkte (Elemente-Tab): Zeile mit Quelle, Ziel-Dropdown + Button. */
.bonus-point-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 8px 12px; margin: 6px 0;
}
.bonus-point-row .meta-line { flex: 1 1 auto; }
.bonus-point-row select { max-width: 340px; }

/* ---------- Neues Charakter-Fenster (Name + Startlevel) ---------- */
.newchar-modal { width: min(460px, 100%); }
.nc-money-note {
  margin-top: 2px;
  padding: 9px 12px;
  background: rgba(201, 162, 39, 0.10);
  border: 1px dashed var(--gold);
  border-radius: 8px;
  color: var(--gold-bright);
  font-size: 14px;
}

/* ---------- Equipment-Layout (Charakter-Silhouette + Ausrüstungs-Slots) ----
   Diablo-3-artig: SVG-Silhouette als Hintergrund, Slots absolut positioniert
   (Prozentwerte aus SLOT_POS in app.js). Belegte Slots zeigen Itemname in der
   Seltenheitsfarbe; Drag & Drop = anlegen/verschieben, Klick = ablegen. */
/* Füllt die linke Inventar-Spalte (.inv-equip-col), Zentrierung/Margen übernimmt das
   zweispaltige Layout, damit rechts „Am Körper“ Platz hat. */
.equip-layout { position: relative; width: 100%; aspect-ratio: 2 / 3; margin: 0; }
/* Silhouette-Bild (silhouette.svg, Wikimedia Commons CC0): object-fit:contain
   behält das Seitenverhältnis der Figur, sie füllt die volle Höhe und belegt
   x≈15-85% der Box-Breite. SLOT_POS in app.js ist an diese Landmarken
   ausgerichtet; Deckkraft bewusst hoch, damit die Figur klar hinter den Slots
   steht. */
.silhouette { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: center; opacity: .92; pointer-events: none; }
.equip-slot {
  position: absolute; transform: translate(-50%, -50%);
  width: 92px; min-height: 46px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: rgba(30, 24, 17, .82);
  border: 1.5px dashed var(--border); cursor: pointer;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.equip-slot.empty { color: var(--dim); }
.slot-empty { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 15px; line-height: 1.1; pointer-events: none; }
.slot-empty i { font-style: normal; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.equip-slot.filled { border-style: solid; cursor: grab; }
.equip-slot.filled:hover { box-shadow: 0 0 8px rgba(230, 193, 74, .25); transform: translate(-50%, -50%) scale(1.04); }
.slot-item {
  font-size: 11.5px; text-align: center; line-height: 1.15; max-width: 100%;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  pointer-events: none; padding: 3px 6px;
}
/* Seltenheits-Farben, abgestimmt auf die .badge.rar-* im Shop/Inventar. */
.equip-slot.rar-gewoehnlich { border-color: #8d8574; }
.equip-slot.rar-selten    { border-color: #4a7fd4; box-shadow: 0 0 6px rgba(74,127,212,.35); }
.equip-slot.rar-episch    { border-color: #a06ad4; box-shadow: 0 0 6px rgba(160,106,212,.35); }
.equip-slot.rar-legendaer { border-color: var(--gold-bright); box-shadow: 0 0 8px rgba(230,193,74,.4); }
/* Drag-Feedback zuletzt → gewinnt gegen die Seltenheits-Borders. */
.equip-slot.drag-over { border-color: var(--gold-bright) !important; box-shadow: 0 0 10px rgba(230, 193, 74, .45); }
.equip-slot.dragging { opacity: .5; }
/* Kompakte Slots (Ringe): etwas kleiner als die Standard-Slots. */
.equip-slot.slot-sm { width: 76px; min-height: 40px; border-radius: 8px; }
.equip-slot.slot-sm .slot-empty { font-size: 13px; }
.equip-slot.slot-sm .slot-item { font-size: 10.5px; padding: 2px 4px; }
/* Extra-kleiner Slot (Laterne). */
.equip-slot.slot-xs { width: 62px; min-height: 34px; border-radius: 7px; }
.equip-slot.slot-xs .slot-empty { font-size: 12px; }
.equip-slot.slot-xs .slot-item { font-size: 9.5px; padding: 2px 3px; }
/* Große Slots (Rüstung, Hose, Hände/Waffen). */
.equip-slot.slot-lg { width: 135px; min-height: 68px; border-radius: 12px; }
.equip-slot.slot-lg .slot-empty { font-size: 17px; }
.equip-slot.slot-lg .slot-item { font-size: 13.5px; padding: 4px 8px; }
/* Schwertscheide-Deko an der Hüfte (kein Slot): erscheint nur, wenn eine Scheide
   getragen wird. Liegt unter den Slots; Hover zeigt die Item-Infos der Scheide.
   Durchgehende Linie (SVG in app.js, viewBox −30/−75 105×305, Anker = Box-Mitte
   22.5/77.5 = Gürtelposition an der Hüftaußenkante): Knauf ragt nach oben über
   die Taille, Scabbard hängt 16° geneigt entlang des Oberschenkels bis zum Knie.
   Position = Box-Mitte in Layout-% (Test-Layout 460×690: Anker bei 275/260 →
   Mitte 59.8% / 37.7%, Breite 105px = 22.8%). */
.sheath-deco {
  position: absolute; left: 59.8%; top: 37.7%; width: 22.8%;
  transform: translate(-50%, -50%); cursor: default;
  /* Die Box ist groß und deckt viel Figur ab, nur die gezeichneten
     Scheide-Teile sind hoverbar, damit der unsichtbare Rest nicht als
     Tooltip-Zone über der Silhouette liegt. */
  pointer-events: none;
}
.sheath-deco svg circle, .sheath-deco svg rect, .sheath-deco svg path { pointer-events: visiblePainted; }
/* R219: Die alten Scheide-Overrides (top:10% / left:0) sind überflüssig, der neue
   Standard „rechts neben dem Element“ wächst von selbst nach rechts, so dass die
   Tooltips nie hinter die linke App-Sidebar ragen. */
.sheath-deco svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
/* Zweite Schwertscheide auf der anderen Hüfte (rechte Seite der Figur = unsere
   linke): dieselbe SVG, per CSS gespiegelt. */
.sheath-deco.mirrored { left: 40.2%; transform: translate(-50%, -50%) scaleX(-1); }
/* Hover-Tooltips auf belegten Slots & Scheide-Deko (data-tip via JS):
   R219: Die Ausrichtung übernimmt der neue Standard „rechts neben dem Element“ -
   die alten tip-left/tip-right/tip-up-Regeln sind entfernt, die Klassen im DOM
   bleiben harmlos. Gefüllte Slots behalten ihren Grab-Cursor statt cursor:help. */
.equip-slot.tip-hover { cursor: grab; }
/* Jeder Slot/Scheide ist ein eigenes Stacking-Context (transform), beim Hover
   heben wir ihn an, damit der Tooltip nicht von späteren Slots oder den
   Inventar-Sektionen rechts/unten überdeckt wird. */
.equip-slot.tip-hover:hover { z-index: 30; }
.sheath-deco.tip-hover:hover { z-index: 30; }
/* Teil-Mengen-Tragen-Stepper in Inventar-Zeilen (− n/qty +). */
.eq-qty { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.eq-qty .icon-btn { width: 26px; height: 26px; font-size: 13px; }
.eq-qty-label {
  font-size: 12px; color: var(--muted); min-width: 28px;
  text-align: center; white-space: nowrap;
}
@media (max-width: 560px) {
  .equip-slot { width: 74px; min-height: 38px; }
  .slot-item { font-size: 10.5px; }
  .equip-slot.slot-sm { width: 62px; min-height: 34px; }
  .equip-slot.slot-xs { width: 50px; min-height: 28px; }
  .equip-slot.slot-lg { width: 108px; min-height: 54px; }
}

/* ---------- Slot-Picker (Klick auf Equipment-Slot) --------------------------
   Stilvolles Auswahl-Menü statt natives <select>: dunkle Karte mit goldenem
   Rahmen, Itemnamen + Seltenheits-Badge, „Ablegen“ bei belegtem Slot. */
.slot-picker {
  position: fixed; z-index: 90; min-width: 230px; max-width: 300px;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0,0,0,.5), 0 0 12px rgba(201,162,39,.18);
  padding: 7px; display: flex; flex-direction: column; gap: 3px;
}
.sp-head {
  font-size: 13.5px; color: var(--gold-bright); font-weight: 600;
  padding: 4px 8px 7px; border-bottom: 1px solid var(--border-soft); margin-bottom: 3px;
}
.sp-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--text); font-size: 13px; padding: 6px 9px; cursor: pointer; text-align: left;
}
.sp-opt:hover { background: var(--card-hover); border-color: var(--border-soft); }
.sp-opt.cur { border-color: var(--gold); background: rgba(201,162,39,.10); }
.sp-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-unequip { color: #e07b78; border-style: dashed; border-color: rgba(224,123,120,.5); margin-top: 3px; }

/* ---------- R222: Chaos-Tabs (Elementliste + Wild Magic) ------------------ */
.chaos-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chaos-tile {
  background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: 9px;
  padding: 12px 8px 10px; text-align: center; transition: background .15s ease, transform .15s ease;
}
.chaos-tile:hover { background: var(--ct-bg-hi); transform: translateY(-1px); }
.ct-roll { font-size: 26px; font-weight: 700; color: var(--gold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.ct-name { margin-top: 5px; font-size: 13px; color: var(--text); word-break: break-word; line-height: 1.25; }
.chaos-tile.elem-light .ct-roll, .chaos-tile.elem-light .ct-name { color: #3a3a42; }

.wildmagic-list { display: flex; flex-direction: column; gap: 4px; max-width: 980px; }
.wildmagic-row {
  display: flex; align-items: baseline; gap: 10px; background: var(--panel);
  border: 1px solid var(--border-soft); border-radius: 6px; padding: 6px 10px; font-size: 13.5px;
}
.wildmagic-row:hover { border-color: rgba(201, 162, 39, .45); }
.wm-num { flex: 0 0 auto; min-width: 30px; text-align: right; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.wm-text { color: var(--text); line-height: 1.45; }
.wm-roll-bar { display: flex; justify-content: flex-end; margin-bottom: 12px; } /* R346: Wild-Magic-Würfel-Button */

/* R246: Statuszustände & Bodeneffekte, hoverbare Markierung im Regeltext */
.status-tip { border-bottom: 1px dashed rgba(255,255,255,.35); cursor: help; }

/* ---------- R283: Herstellung-Tab (Rezept-Kacheln + Ergebnis-Modal) -------- */
.craft-ing-list { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.craft-ing { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.craft-ing b { color: var(--text); font-variant-numeric: tabular-nums; }
.craft-tools {
  margin-top: 4px; padding-top: 4px; border-top: 1px dashed var(--border-soft);
  font-size: 12.5px; color: var(--muted); line-height: 1.35;
}
.craft-desc { margin-top: 4px; font-size: 12.5px; color: var(--muted); line-height: 1.35; } /* R485: Rezept-Beschreibung (z.B. benötigte Werkzeuge ohne Inventar-Check) */
.craft-result { margin-top: 10px; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; line-height: 1.45; }
.craft-result.ok {
  background: rgba(93, 158, 93, .12); border: 1px solid rgba(93, 158, 93, .5);
  color: #bfe0bf;
}
.craft-result.fail {
  background: rgba(176, 65, 62, .12); border: 1px solid rgba(176, 65, 62, .5);
  color: #e8b3b1;
}
/* R374: DC-Stufen im Wurf-Modal, erreichte Stufe grün markiert, nicht
   erreichte dim. Steht zwischen Breakdown und Erfolgszeile. */
.craft-dc-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.craft-dc-steps span {
  font-size: 12.5px; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  background: var(--card); border: 1px solid var(--border-soft); color: var(--muted);
}
.craft-dc-steps span.hit {
  font-weight: 600; color: #bfe0bf;
  border-color: rgba(93, 158, 93, .6); background: rgba(93, 158, 93, .12);
}


/* ---- Login-Overlay (Accounts) ---- */
#login-overlay { position: fixed; inset: 0; z-index: 9999; background: #14100d; display: flex; align-items: center; justify-content: center; }
#login-overlay.hidden { display: none; }
.login-box { width: min(360px, 90vw); background: #221b15; border: 1px solid #4a3b2a; border-radius: 10px; padding: 28px 26px; color: #e8dcc8; box-shadow: 0 8px 40px rgba(0,0,0,.6); text-align: center; }
.login-title { margin: 0 0 4px; font-size: 1.35rem; color: #d9b36c; }
.login-sub { margin: 0 0 18px; font-size: .85rem; color: #a89878; }
.login-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.login-tab { flex: 1; padding: 8px 6px; background: #1a1410; color: #c8b898; border: 1px solid #4a3b2a; border-radius: 6px; cursor: pointer; font-size: .85rem; }
.login-tab.active { background: #3a2d1d; color: #f0e2c0; border-color: #d9b36c; }
#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input { padding: 9px 11px; background: #1a1410; border: 1px solid #4a3b2a; border-radius: 6px; color: #f0e2c0; font-size: .95rem; }
#login-form input:focus { outline: none; border-color: #d9b36c; }
#login-submit { padding: 9px; background: #d9b36c; color: #221b15; border: none; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: .95rem; }
#login-submit:disabled { opacity: .6; cursor: default; }
.login-error { min-height: 1.2em; color: #e0705a; font-size: .82rem; }
#logout-btn { position: fixed; right: 10px; bottom: 8px; z-index: 500; padding: 4px 10px; background: #221b15; color: #a89878; border: 1px solid #4a3b2a; border-radius: 6px; cursor: pointer; font-size: .75rem; }
#logout-btn:hover { color: #f0e2c0; border-color: #d9b36c; }

/* ---------- R564: Token Maker ---------- */
.token-box { flex: 0 0 150px; width: 150px; display: flex; flex-direction: column; gap: 6px; }
.token-frame {
  aspect-ratio: 1; border-radius: 50%; cursor: pointer; position: relative;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  /* R571: Kein Schachbrett mehr - Transparenz bleibt komplett transparent */
  background: transparent;
  border: 2px dashed var(--border); transition: border-color .15s, transform .15s;
}
.token-frame:hover { border-color: var(--gold); transform: scale(1.02); }
.token-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.token-empty { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; padding: 10px; color: var(--muted); font-size: 11px; }
.token-empty b { color: var(--text); font-size: 12px; }
.token-ico { font-size: 26px; }
.token-caption { font-size: 11px; color: var(--muted); text-align: center; }

.token-modal { max-width: 680px; width: 94vw; }
.token-body { display: flex; gap: 18px; padding: 16px; align-items: flex-start; }
.token-preview-wrap {
  flex: 0 0 256px; width: 256px; height: 256px; border-radius: 14px; overflow: hidden;
  /* R571: Kein Schachbrett mehr - die Transparenz ist komplett transparent */
  background: transparent;
  border: 1px solid var(--border-soft);
}
.token-preview { width: 256px; height: 256px; display: block; cursor: grab; touch-action: none; }
.token-preview.dragging { cursor: grabbing; }
.token-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.token-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }
.token-src-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.token-file { display: none; }
.token-src-row .btn.active { border-color: var(--gold); color: var(--gold-bright); background: rgba(201, 162, 39, .12); }
.token-zoom-row { display: flex; align-items: center; gap: 8px; }
.token-zoom { flex: 1; min-width: 0; accent-color: var(--gold); }
.token-zoom-lbl { font-size: 12px; color: var(--text); min-width: 44px; text-align: right; font-family: Consolas, monospace; }
.token-hint { font-size: 11px; color: var(--muted); }
.token-border-row { display: flex; gap: 8px; flex-wrap: wrap; }
.token-border-thumb {
  width: 54px; height: 54px; border-radius: 50%; padding: 2px; cursor: pointer;
  border: 2px solid var(--border); background: var(--card); transition: border-color .12s;
}
/* R571: ＋-Button für eigene Border-Uploads in der Border-Reihe */
.token-border-add {
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; color: var(--muted); background: transparent;
  border-style: dashed;
}
.token-border-add:hover { color: var(--gold); border-color: var(--gold); }
.token-border-thumb:hover { border-color: var(--gold-bright); }
.token-border-thumb.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201, 162, 39, .35); }
.token-border-thumb img { width: 100%; height: 100%; display: block; }

.cp-root { display: flex; flex-direction: column; gap: 8px; }
.cp-col { display: flex; gap: 10px; align-items: flex-start; }
.cp-wheel { width: 170px; height: 170px; cursor: crosshair; touch-action: none; border-radius: 50%; }
.cp-bar { width: 24px; height: 170px; cursor: pointer; touch-action: none; border-radius: 7px; border: 1px solid var(--border-soft); }
.cp-color-row { display: flex; align-items: center; gap: 8px; }
.cp-swatch { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--border); }
.cp-hex { font-family: Consolas, monospace; font-size: 12.5px; color: var(--text); }

/* ============================================================
   R572: Spielbereich (VTT-Grundgerüst)
   Dunkle, aufgeräumte Oberfläche im Stil moderner Virtual
   Tabletops (Owlbear Rodeo): viel Platz für die Battlemap,
   schlanke Werkzeugleiste, dezente Seitenleisten.
   ============================================================ */
#vtt-view { position: fixed; inset: 0; z-index: 900; display: flex; flex-direction: column; background: #141210; color: var(--text); }

/* ---------- Obere Werkzeugleiste ---------- */
#vtt-topbar { flex: none; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 10px; background: var(--panel); border-bottom: 1px solid var(--border-soft); }
.vtt-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.vtt-btn:hover { background: var(--card-hover); color: var(--text); }
.vtt-btn svg { width: 17px; height: 17px; flex: none; }
.vtt-title { font-family: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif; font-size: 15px; letter-spacing: .4px; color: var(--gold-bright); padding: 0 6px; user-select: none; }
.vtt-tools { flex: 1; display: flex; justify-content: center; gap: 6px; min-width: 0; }
.vtt-tool { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.vtt-tool:hover { background: var(--card-hover); color: var(--gold-bright); border-color: var(--border-soft); }
.vtt-tool svg { width: 19px; height: 19px; }
.vtt-topbar-right { display: flex; align-items: center; gap: 8px; }
.vtt-icon { width: 36px; padding: 0; justify-content: center; }
.vtt-icon.active { color: var(--gold-bright); background: var(--card); border-color: var(--border); }

/* ---------- Sync-Anzeige (rechts in der Topbar) ---------- */
.vtt-sync { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: rgba(93, 158, 93, .12); border: 1px solid rgba(93, 158, 93, .35); color: #9fcf9f; font-size: 12px; user-select: none; white-space: nowrap; }
.vtt-sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.vtt-sync.off { background: rgba(176, 65, 62, .12); border-color: rgba(176, 65, 62, .4); color: #d99a98; }
.vtt-sync.off .vtt-sync-dot { background: var(--danger); }
.vtt-sync.pulse .vtt-sync-dot { animation: vtt-pulse .35s ease; }
@keyframes vtt-pulse { 0% { transform: scale(1); } 50% { transform: scale(1.9); box-shadow: 0 0 8px rgba(93, 158, 93, .8); } 100% { transform: scale(1); } }

/* ---------- Hauptbereich: Battlemap + rechte Seitenleiste ---------- */
#vtt-main { flex: 1; display: flex; min-height: 0; position: relative; }
#vtt-map { flex: 1; position: relative; overflow: hidden; background-color: #17140f; background-image: radial-gradient(rgba(232, 221, 199, .055) 1px, transparent 1.5px); background-size: 26px 26px; }
#vtt-map-hint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--dim); font-size: 15px; letter-spacing: .5px; pointer-events: none; user-select: none; }
#vtt-map-hint span { font-size: 12.5px; color: #55493a; }

/* Rechte Seitenleiste (Karten & Token) */
#vtt-side { flex: none; width: 280px; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border-soft); }
#vtt-view.side-collapsed #vtt-side { display: none; }
#vtt-side-rail { display: none; }
#vtt-view.side-collapsed #vtt-side-rail { display: flex; align-items: flex-start; justify-content: center; flex: none; width: 26px; padding-top: 10px; background: var(--panel); border: none; border-left: 1px solid var(--border-soft); color: var(--muted); font-size: 15px; cursor: pointer; }
#vtt-side-rail:hover { color: var(--gold-bright); }

/* ---------- R573: Linke Seitenleiste (Kartenverwaltung) + Kartenebene ---------- */
#vtt-cards-side { flex: none; width: 260px; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--border-soft); }
#vtt-view.cards-collapsed #vtt-cards-side { display: none; }
#vtt-cards-rail { display: none; }
#vtt-view.cards-collapsed #vtt-cards-rail { display: flex; align-items: flex-start; justify-content: center; flex: none; width: 26px; padding-top: 10px; background: var(--panel); border: none; border-right: 1px solid var(--border-soft); color: var(--muted); font-size: 15px; cursor: pointer; }
#vtt-cards-rail:hover { color: var(--gold-bright); }

/* Die Karte ist eine eigenständige Ebene: eigener <img>-Layer in #vtt-map
   (z-index 1, unter künftigen Grid-/Token-Elementen). Lage/Zoom per CSS-
   transform aus state.board -> immer proportional (ein gemeinsamer Faktor). */
#vtt-map-img { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; cursor: grab; user-select: none; -webkit-user-drag: none; z-index: 1; will-change: transform; }
#vtt-map-img.dragging { cursor: grabbing; }
#vtt-map-img.hidden { display: none; }

/* Karten-Info + Verwaltung in der linken Seitenleiste */
.vtt-map-card { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
#vtt-map-thumb { width: 100%; height: 108px; object-fit: cover; border-radius: 9px; border: 1px solid var(--border-soft); background: #0d0b08; }
.vtt-map-name { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vtt-map-dims { font-size: 11.5px; color: var(--dim); }
.vtt-map-actions { display: flex; gap: 6px; }
.vtt-mini-btn { flex: 1; height: 28px; border: 1px solid var(--border-soft); border-radius: 7px; background: rgba(255, 255, 255, .03); color: var(--muted); font-size: 12px; cursor: pointer; }
.vtt-mini-btn:hover { color: var(--text); border-color: var(--border); background: var(--card-hover); }
.vtt-mini-btn.danger:hover { color: #e08987; border-color: rgba(176, 65, 62, .55); }
.vtt-mini-btn.sq { flex: none; width: 30px; font-size: 15px; line-height: 1; }
.vtt-upload-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; height: 34px; border: 1px dashed var(--border-soft); border-radius: 9px; background: rgba(255, 255, 255, .02); color: var(--text); font-size: 12.5px; cursor: pointer; }
.vtt-upload-btn svg { width: 15px; height: 15px; }
.vtt-upload-btn:hover { border-color: var(--gold); color: var(--gold-bright); background: var(--card-hover); }
.vtt-zoom-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
#vtt-zoom-label { flex: 1; text-align: center; font-size: 12.5px; color: var(--muted); font-family: Consolas, monospace; }
.vtt-hint { padding: 9px 10px; font-size: 11.5px; }

.vtt-side-head { flex: none; display: flex; align-items: center; justify-content: space-between; height: 42px; padding: 0 12px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; font-weight: 600; color: var(--gold-bright); letter-spacing: .3px; }
.vtt-mini { width: 24px; height: 24px; border: none; border-radius: 6px; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.vtt-mini:hover { background: var(--card-hover); color: var(--text); }
.vtt-side-body { flex: 1; overflow-y: auto; padding: 10px; }
.vtt-side-sec { margin-bottom: 16px; }
.vtt-side-sec h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.vtt-side-empty { padding: 14px 12px; border: 1px dashed var(--border-soft); border-radius: 10px; background: rgba(255, 255, 255, .02); color: var(--dim); font-size: 12.5px; text-align: center; line-height: 1.5; }

/* ---------- Einstell-Seitenleiste (Zahnrad) ---------- */
#vtt-settings { position: absolute; top: 0; right: 0; bottom: 0; width: 300px; z-index: 6; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border); box-shadow: -10px 0 26px rgba(0, 0, 0, .45); }

/* ---------- Navigationspunkt „Spielbereich“ in der App-Sidebar ---------- */
.tab-sep { height: 1px; margin: 8px 10px 6px; background: var(--border-soft); flex: none; }
.vtt-nav { margin-top: 2px; }
.vtt-nav .ico { filter: saturate(.9); }
