:root {
  --bg: #1a1614;
  --panel: #241f1b;
  --panel-2: #2e2823;
  --ink: #ece3d4;
  --muted: #9a8f7d;
  --accent: #b5452f;       /* dragon red */
  --accent-2: #c9a14a;     /* worn gold */
  --border: #3a322b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Georgia", "Iowan Old Style", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

/* Top bar + tabs */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
}

.brand {
  font-weight: bold;
  font-size: 1.25rem;
  color: var(--accent-2);
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.4rem 0.9rem;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s;
}

.tab:hover { color: var(--ink); background: var(--panel-2); }

.tab.active {
  color: var(--ink);
  background: var(--panel-2);
  border-color: var(--border);
  border-bottom-color: var(--panel-2);
}

/* Nav notification badge (e.g. pending trade offers on the Character tab) */
.tab-badge {
  display: inline-block; min-width: 1.1rem; margin-left: 0.3rem;
  padding: 0 0.3rem; font-family: sans-serif; font-size: 0.7rem; font-weight: 700;
  line-height: 1.1rem; text-align: center; color: #fff;
  background: #c0563f; border-radius: 999px; vertical-align: middle;
}

/* Assist / Track mode toggle */
.mode-toggle {
  margin: 0 0 0 auto;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.mode-btn {
  font: inherit;
  font-family: sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.3rem 0.85rem;
  background: transparent;
  border: none;
  color: var(--muted);
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.active { background: var(--accent); color: #fff; }

/* Layout: sidebar + content */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 120px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 1.05rem;
  color: var(--accent-2);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.content {
  padding: 1.75rem 2rem;
}

.content h1 {
  margin-top: 0;
  color: var(--accent-2);
}

/* Helpers */
.muted { color: var(--muted); }

.placeholder-note {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  color: var(--accent-2);
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}

/* --- Phase 1: characters --- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; }
.head-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Buttons */
.btn, .btn-ghost, .btn-danger {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
}
.btn { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; }

/* Flash messages */
.flashes { margin-bottom: 1.25rem; }
.flash {
  padding: 0.5rem 0.9rem;
  background: var(--panel-2);
  border-left: 3px solid var(--accent-2);
  border-radius: 4px;
  margin-bottom: 0.4rem;
}

/* Badges */
.badge-dm {
  font-size: 0.7rem;
  font-family: sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent-2);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
}

/* Kind badge (PC / NPC) */
.badge-kind {
  font-size: 0.7rem;
  font-family: sans-serif;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
}

.badge-kind-pc { color: #8fd0a0; border-color: #3f6b4c; }
.badge-kind-npc { color: #9ab8e8; border-color: #3f5070; }
.badge-kind-monster { color: #e0a0a0; border-color: #7a4040; }

/* Roster search + kind filter */
.roster-filter {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
#roster-search {
  flex: 1; min-width: 12rem; font: inherit;
  padding: 0.5rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
#roster-search:focus { outline: none; border-color: var(--accent-2); }
.roster-kinds { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.kind-btn {
  font: inherit; font-family: sans-serif; font-size: 0.82rem; cursor: pointer;
  padding: 0.4rem 0.9rem; background: transparent; border: none; color: var(--muted);
}
.kind-btn:hover { color: var(--ink); }
.kind-btn.active { background: var(--accent); color: #fff; }
.roster-empty { margin-top: 1rem; }

/* Disposition pills (read-only, e.g. on cards) */
.char-meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; flex-wrap: wrap; }
.disp {
  font-family: sans-serif;
  font-size: 0.72rem;
  text-transform: capitalize;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid;
}
.disp-hostile    { color: #e8918f; border-color: #7a3838; }
.disp-unfriendly { color: #e8b58f; border-color: #7a5a38; }
.disp-neutral    { color: #d9c98f; border-color: #6b5f3f; }
.disp-friendly   { color: #b5d68f; border-color: #5a7b3f; }
.disp-allied     { color: #8fd0a0; border-color: #3f6b4c; }

/* Disposition toggle (DM live control on the detail page) */
.disp-toggle { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem; flex-wrap: wrap; }
.disp-toggle-label { font-family: sans-serif; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.disp-btn {
  font: inherit;
  font-family: sans-serif;
  font-size: 0.8rem;
  text-transform: capitalize;
  cursor: pointer;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  opacity: 0.65;
}
.disp-btn:hover { opacity: 1; }
.disp-btn.active { opacity: 1; font-weight: bold; }
.disp-btn.disp-hostile.active    { color: #e8918f; border-color: #7a3838; background: rgba(122,56,56,0.18); }
.disp-btn.disp-unfriendly.active { color: #e8b58f; border-color: #7a5a38; background: rgba(122,90,56,0.18); }
.disp-btn.disp-neutral.active    { color: #d9c98f; border-color: #6b5f3f; background: rgba(107,95,63,0.18); }
.disp-btn.disp-friendly.active   { color: #b5d68f; border-color: #5a7b3f; background: rgba(90,123,63,0.18); }
.disp-btn.disp-allied.active     { color: #8fd0a0; border-color: #3f6b4c; background: rgba(63,107,76,0.18); }

/* Character cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.char-card {
  display: block;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.12s, transform 0.12s;
}
.char-card:hover { border-color: var(--accent-2); transform: translateY(-2px); }

/* Maps (Phase 10) */
.map-card { padding: 0; overflow: hidden; }
.map-card .char-card-head,
.map-card .char-loc { padding: 0 1rem; }
.map-card .char-card-head { padding-top: 0.7rem; }
.map-card .char-loc { padding-bottom: 0.8rem; }
.map-thumb {
  width: 100%;
  height: 130px;
  background-size: cover;
  background-position: center;
  background-color: var(--bg);
  border-bottom: 1px solid var(--border);
}
.map-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; opacity: 0.4;
}
.map-stage {
  position: relative;
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;            /* the canvas clips the zoom/pan transform */
}
.map-toolbar { display: flex; align-items: center; gap: 1rem; margin: 0.6rem 0; flex-wrap: wrap; }
/* The canvas is a fixed window; the viewport inside it is transformed (zoom/pan).
   The image fills the width so every map renders at the same on-screen scale
   regardless of its source resolution. */
.map-canvas { position: relative; max-width: 100%; overflow: hidden; line-height: 0; touch-action: none;
  user-select: none; -webkit-user-select: none; }
.map-canvas.pannable { cursor: grab; }
.map-canvas.panning { cursor: grabbing; }
.map-canvas.placing { cursor: crosshair; }
.map-canvas.placing .map-markers { pointer-events: none; }
.map-viewport { position: relative; transform-origin: 0 0; will-change: transform; }
/* pointer-events:none + no native drag so panning never grabs/selects the image */
.map-image { display: block; width: 100%; height: auto; pointer-events: none;
  -webkit-user-drag: none; user-select: none; }
/* Grid overlay: a <canvas> sized to the image's source pixels, stretched to the
   image box, so cells stay square + content-aligned at any display size/zoom. */
.map-grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.map-markers { position: absolute; inset: 0; }

/* Zoom controls float over the stage (outside the clipped/transformed canvas). */
.map-zoom { position: absolute; top: 0.5rem; right: 0.5rem; z-index: 6;
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.map-zoom .btn-zoom {
  width: 34px; height: 30px; line-height: 1; font-size: 1.1rem; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.map-zoom .btn-zoom:hover { border-color: var(--accent-2); }
.map-zoom-level { text-align: center; font-size: 0.62rem; color: var(--muted);
  background: rgba(0, 0, 0, 0.5); border-radius: 4px; padding: 1px 0; user-select: none; }
.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  cursor: pointer; text-decoration: none; color: var(--ink);
  touch-action: none; user-select: none;
}
.map-marker .marker-pin {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); border: 2px solid var(--accent-2);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  font-size: 1.1rem; line-height: 1; overflow: hidden;
}
.map-marker .marker-pin .avatar-img { width: 100%; height: 100%; object-fit: cover; }
.map-marker .marker-label {
  font-size: 0.72rem; line-height: 1.3;
  background: rgba(0, 0, 0, 0.65); color: #fff;
  padding: 0 4px; border-radius: 3px;
  white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis;
}
.map-marker.dragging { opacity: 0.7; z-index: 5; }
.map-marker.marker-hidden .marker-pin { border-style: dashed; opacity: 0.55; }

.marker-form { margin-top: 1rem; max-width: 480px; }
.marker-form-title { margin-top: 0; }
.marker-manage { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.marker-manage li { display: flex; align-items: center; gap: 0.6rem; }
.marker-manage-icon { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; flex: none; }
.marker-manage-icon .avatar-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.marker-manage-name { flex: 1; min-width: 0; }
.marker-manage-actions { display: flex; gap: 0.5rem; align-items: center; flex: none; }
.btn-text.danger { color: #d66; }

/* Companions / summons (Phase 12) */
.companion-card { padding: 0; display: flex; flex-direction: column; }
.companion-link { display: block; padding: 1rem; color: var(--ink); text-decoration: none; }
.companion-dismiss { padding: 0 1rem 0.6rem; text-align: right; }
.summon-form { display: flex; align-items: flex-end; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.summon-form .field { max-width: 320px; }

/* Roll result toast (app-wide AJAX dice) */
.roll-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  max-width: 22rem;
  padding: 0.7rem 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 5px solid var(--accent-2);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  font-family: sans-serif;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.roll-toast.show { opacity: 1; transform: translateY(0); }
.roll-toast .rt-label { font-size: 0.8rem; color: var(--muted); flex: 1; min-width: 0; }
.roll-toast .rt-total { font-size: 1.6rem; font-weight: bold; color: var(--accent-2); }
.roll-toast .rt-detail { font-size: 0.82rem; color: var(--muted); }
.char-card-head { display: flex; align-items: center; gap: 0.5rem; justify-content: space-between; }
.char-name { font-size: 1.15rem; font-weight: bold; color: var(--accent-2); }
.char-card-stats { margin-top: 0.6rem; display: flex; gap: 1rem; font-family: sans-serif; font-size: 0.9rem; }
.char-loc { margin-top: 0.45rem; font-family: sans-serif; font-size: 0.85rem; }

/* Sheet: vitals + ability grid */
.sheet-name { display: flex; align-items: center; gap: 0.6rem; }
.vitals { display: flex; gap: 1rem; margin: 1rem 0 1.5rem; }
.vital {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  text-align: center;
}
.vital-label { display: block; font-size: 0.75rem; font-family: sans-serif; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.vital-value { display: block; font-size: 1.6rem; font-weight: bold; }
.xp-value { font-size: 1.3rem; }
.inspiration .vital-value { font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; justify-content: center; }
.inspiration.has-inspiration { border-color: color-mix(in srgb, var(--accent-2) 55%, transparent); background: color-mix(in srgb, var(--accent-2) 10%, var(--panel)); }
.insp-on { color: var(--accent-2); }

/* Shared adv/dis roll-mode selector (applies to the next sheet d20 roll) */
.roll-mode { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.9rem;
  margin: 0.25rem 0 0.75rem; padding: 0.4rem 0.7rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; font-family: sans-serif; font-size: 0.85rem; }
.roll-mode-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.rm-opt { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }
.rm-opt input { accent-color: var(--accent-2); }
.rm-adv:has(input:checked) { color: #7fc99a; font-weight: bold; }
.rm-dis:has(input:checked) { color: #e08a8a; font-weight: bold; }
.rm-insp { color: var(--accent-2); font-size: 0.8rem; }
.rm-hint { font-size: 0.78rem; }
.purse { text-align: left; }
.coins { display: flex; gap: 0.5rem; margin-top: 0.3rem; }
.coin { font-family: sans-serif; font-weight: bold; font-size: 1rem; padding: 0.1rem 0.4rem; border-radius: 4px; }
.coin-gp { color: #e8c860; }
.coin-sp { color: #cdd2d8; }
.coin-cp { color: #cf9b6b; }
.levelup {
  display: inline-block;
  color: #b5d68f;
  background: rgba(90, 123, 63, 0.18);
  border: 1px solid #5a7b3f;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-family: sans-serif;
  font-size: 0.85rem;
  margin: 0 0 1rem;
}
.xp-progress { font-size: 0.85rem; margin: -0.5rem 0 1rem; }

/* Centered section break between major character-sheet sections (gear, spells,
   actions, notes). A soft gold gradient line with a gold diamond ornament in the
   middle, so it reads as an intentional divider rather than another card edge. */
.sheet-divider {
  position: relative;
  height: 1px; width: 65%;
  margin: 2rem auto;
  background: linear-gradient(to right, transparent, rgba(201, 161, 74, 0.8) 50%, transparent);
}
.sheet-divider::after {
  content: "◆";
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent-2);
  font-size: 0.7rem; line-height: 1;
  background: var(--bg); padding: 0 0.6rem;
}

/* Level-up control */
.levelup-box {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.8rem; border-radius: 6px; margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  font-family: sans-serif; font-size: 0.85rem;
}
.levelup-box.ready { color: #b5d68f; border-color: #5a7b3f; background: rgba(90,123,63,0.18); }
.levelup-form { display: flex; align-items: center; gap: 0.6rem; }
.hp-gain-label { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); }
.hp-gain-input {
  width: 4rem; font: inherit; padding: 0.3rem 0.45rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.levelup-btn { white-space: nowrap; }
.levelup-hint { font-size: 0.78rem; }
.class-kit { align-self: flex-end; }
.spell-help { font-size: 0.82rem; margin: -0.3rem 0 0.8rem; }

.ability-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.ability {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 0.5rem;
  text-align: center;
}
.ability-short { display: block; font-size: 0.75rem; font-family: sans-serif; letter-spacing: 0.08em; color: var(--muted); }
.ability-mod { display: block; font-size: 1.8rem; font-weight: bold; color: var(--accent-2); }
.ability-score { display: block; font-size: 0.85rem; color: var(--muted); }

/* Defenses + chips */
.defenses { margin-bottom: 1.5rem; }
.defense-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.defense-label { width: 7rem; font-family: sans-serif; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.chip {
  font-family: sans-serif;
  font-size: 0.8rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.chip-res { color: #8fd0a0; border-color: #3f6b4c; }
.chip-imm { color: #9ab8e8; border-color: #3f5070; }
.chip-vul { color: #e8a08f; border-color: #7a4338; }

/* Forms */
.sheet-form { max-width: 720px; }
.sheet-form fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem 1rem;
}
.sheet-form legend { color: var(--accent-2); padding: 0 0.4rem; font-family: sans-serif; font-size: 0.85rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.75rem; }
.field > span { font-size: 0.8rem; font-family: sans-serif; color: var(--muted); }
.field input, .field textarea, .field select {
  font: inherit;
  padding: 0.4rem 0.55rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent-2); }
.field-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.field.grow { flex: 1 1 12rem; }
.field.narrow { width: 5.5rem; }
.ability-inputs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.checkbox { display: flex; align-items: center; gap: 0.5rem; font-family: sans-serif; font-size: 0.9rem; margin-bottom: 1rem; }
.form-actions { display: flex; gap: 0.75rem; }
.notes h2 { color: var(--accent-2); font-size: 1.1rem; }

/* --- Phase 2: dice --- */
form.inline { display: inline; margin: 0; }

.dice-quick { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 1.5rem; }
.die-btn {
  font: inherit;
  font-family: sans-serif;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.55rem 0.9rem;
  min-width: 3.4rem;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.12s, transform 0.1s;
}
.die-btn:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.die-adv { color: #b5d68f; }
.die-dis { color: #e8918f; }

.dice-expr { display: flex; gap: 0.5rem; max-width: 420px; margin-bottom: 2rem; }
.dice-expr input {
  flex: 1;
  font: inherit;
  padding: 0.5rem 0.7rem;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.dice-expr input:focus { outline: none; border-color: var(--accent-2); }

.roll-log-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.roll-log-head h2 { color: var(--accent-2); font-size: 1.1rem; margin: 0; }
.roll-list { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.roll-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.5rem 0.2rem 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;  /* tinted with the roller's colour */
}
.roll-roller { font-weight: bold; margin-right: 0.4rem; }

/* Roll-colour pickers (Dice page + Users admin) */
.roll-log-tools { display: flex; align-items: center; gap: 1rem; }
.color-form { display: flex; align-items: center; gap: 0.4rem; }
.color-form input[type="color"] {
  width: 2rem; height: 1.6rem; padding: 0; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); border-radius: 5px;
}
.roll-total {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--accent-2);
  min-width: 2.4rem;
  text-align: center;
}
.roll-detail { flex: 1; font-family: sans-serif; font-size: 0.9rem; color: var(--ink); }
.roll-label { color: var(--muted); margin-right: 0.4rem; }
.roll-time {
  font-family: sans-serif;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}
.roll-del {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.3rem;
  background: transparent;
  border: none;
  color: var(--muted);
  opacity: 0.5;
}
.roll-del:hover { color: var(--accent); opacity: 1; }

/* Per-row Hide / Show toggle (spells, actions, inventory) + dimmed hidden rows */
.hide-toggle {
  font: inherit; font-size: 0.72rem; line-height: 1; cursor: pointer;
  padding: 0.1rem 0.4rem; background: transparent; border: 1px solid var(--border);
  border-radius: 999px; color: var(--muted); opacity: 0.75; white-space: nowrap;
}
.hide-toggle:hover { color: var(--ink); opacity: 1; }
.is-hidden { opacity: 0.45; }
.is-hidden:hover { opacity: 0.7; }
/* "Show hidden" filter-bar toggle reads as a count chip until activated */
.show-hidden-btn { margin-left: auto; }

/* Gap divider between bursts of rolls separated by a long pause */
.roll-break {
  list-style: none;
  display: flex;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  margin: 0.5rem 0;
  color: var(--muted);
  font-family: sans-serif;
  font-size: 0.72rem;
}
.roll-break::before, .roll-break::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--border);
}

/* Per-ability check button on the sheet */
.check-btn {
  margin-top: 0.4rem;
  font: inherit;
  font-family: sans-serif;
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.15rem 0.6rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.check-btn:hover { color: var(--ink); border-color: var(--accent-2); }
.check-btn.is-prof { color: var(--accent-2); border-color: var(--accent-2); }
.check-hint { font-size: 0.8rem; margin-top: -0.75rem; }

/* Saving throws (under each ability) + the two roll buttons */
.ability-save { display: block; margin-top: 0.35rem; font-family: sans-serif; font-size: 0.72rem; color: var(--muted); }
.ability-save.is-prof { color: var(--accent-2); font-weight: bold; }
.prof-dot { color: var(--accent-2); }
.ability-rolls { display: flex; gap: 0.3rem; justify-content: center; flex-wrap: wrap; }

/* Skills */
.skills { margin-bottom: 1.5rem; }
.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.4rem;
  margin-top: 0.75rem;
}
.skill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}
.skill.is-prof { border-color: var(--accent-2); }
.skill-dot { color: var(--muted); font-size: 0.7rem; width: 0.9rem; text-align: center; }
.skill.is-prof .skill-dot { color: var(--accent-2); }
/* Expertise reads brighter/bolder than plain proficiency; half-prof a dim accent. */
.skill.is-exp { border-color: #d9b441; }
.skill.is-exp .skill-dot, .prof-dot.exp { color: #e8c75a; }
.skill.is-half .skill-dot { color: color-mix(in srgb, var(--accent-2) 60%, var(--muted)); }
.skill-flag { font-family: sans-serif; font-size: 0.6rem; text-transform: uppercase;
              letter-spacing: 0.05em; padding: 0.02rem 0.4rem; border-radius: 999px;
              margin-left: 0.3rem; vertical-align: middle; }
.skill-flag.exp { color: #e8c75a; border: 1px solid color-mix(in srgb, #e8c75a 45%, transparent); }
/* Expertise picker on the edit form */
.skill-opt { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.skill-opt .checkbox { margin-bottom: 0; }
.exp-check { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.exp-check input:disabled + .exp-label { opacity: 0.35; }
.exp-label { color: #c9a93f; }
.skill-name { flex: 1; font-size: 0.9rem; }
.skill-ability { font-family: sans-serif; font-size: 0.7rem; letter-spacing: 0.05em; }
.skill-mod { font-weight: bold; color: var(--accent-2); min-width: 1.8rem; text-align: right; }
.skill .check-btn { margin-top: 0; }
.skills .check-hint { margin-top: 0.75rem; }

/* Spellcasting panel: casting stats + slot tracker */
.spellcasting {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.cast-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; align-items: center; }
.cast-stat { font-family: sans-serif; font-size: 0.85rem; color: var(--muted); }
.cast-stat strong { color: var(--accent-2); font-size: 1.05rem; margin-left: 0.15rem; }
.spell-limits { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; width: 100%; }
.limit { font-family: sans-serif; font-size: 0.85rem; color: var(--muted); }
.limit strong { color: var(--accent-2); font-size: 1.05rem; margin-left: 0.15rem; }
.limit.over strong { color: var(--warn, #e0a33d); }
.limit-warn { font-family: sans-serif; font-size: 0.66rem; text-transform: uppercase;
              letter-spacing: 0.05em; padding: 0.1rem 0.5rem; border-radius: 999px;
              color: var(--warn, #e0a33d);
              border: 1px solid color-mix(in srgb, var(--warn, #e0a33d) 45%, transparent); }
.slot-tracker { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; min-width: 16rem; }
.slot-row { display: flex; align-items: center; gap: 0.5rem; }
.slot-label { font-family: sans-serif; font-size: 0.75rem; color: var(--muted); width: 4.5rem; }
.slot-pips { display: inline-flex; gap: 0.2rem; }
.pip { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 1px solid var(--accent-2); background: var(--accent-2); }
.pip.spent { background: transparent; opacity: 0.5; }
.slot-count { font-family: sans-serif; font-size: 0.8rem; color: var(--muted); min-width: 2.2rem; }
.slot-btn {
  font: inherit; font-family: sans-serif; font-size: 0.8rem; line-height: 1;
  cursor: pointer; width: 1.4rem; height: 1.4rem; padding: 0;
  color: var(--muted); background: transparent;
  border: 1px solid var(--border); border-radius: 999px;
}
.slot-btn:hover:not(:disabled) { color: var(--ink); border-color: var(--accent-2); }
.slot-btn:disabled { opacity: 0.35; cursor: default; }
.slot-rests { display: flex; gap: 0.4rem; margin-top: 0.35rem; }
.cast-slot { color: var(--accent-2); border-color: var(--accent-2); }
.cast-slot:disabled { opacity: 0.35; cursor: default; color: var(--muted); border-color: var(--border); }

/* Class-resources panel — reuses the slot tracker's pip + button look. */
.char-resources .resource-tracker { display: flex; flex-direction: column; gap: 0.4rem; max-width: 34rem; }
.resource-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0; }
.resource-name { font-weight: 600; min-width: 9.5rem; }
.recharge-tag { font-family: sans-serif; font-size: 0.6rem; text-transform: uppercase;
                letter-spacing: 0.05em; margin-left: 0.35rem; padding: 0.05rem 0.4rem;
                border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.recharge-tag.short { color: var(--accent-2);
                      border-color: color-mix(in srgb, var(--accent-2) 45%, transparent); }
.resource-count { font-family: sans-serif; font-size: 0.82rem; color: var(--muted);
                  min-width: 2.6rem; text-align: center; }
.resource-count strong { color: var(--accent-2); font-size: 1.05rem; }
.res-amount { width: 3.4rem; }
.res-textbtn { width: auto; padding: 0 0.5rem; }
.resource-rests { margin-top: 0.5rem; }

/* Ability Score Improvement allocator on the character sheet */
.char-asi { max-width: 34rem; }
/* Collapsible ASI panel: summary doubles as the section head (title + budget). */
.asi-panel > summary {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  cursor: pointer; list-style: none; padding: 0.15rem 0;
}
.asi-panel > summary::-webkit-details-marker { display: none; }
.asi-summary-title { color: var(--accent-2); font-size: 1.2rem; font-weight: 700; }
.asi-summary-title::before {
  content: "▸"; display: inline-block; margin-right: 0.4rem;
  color: var(--muted); font-size: 0.85em; transition: transform 0.12s;
}
.asi-panel[open] > summary .asi-summary-title::before { transform: rotate(90deg); }
.asi-budget { font-family: sans-serif; font-size: 0.82rem; color: var(--muted); }
.asi-budget strong { color: var(--accent-2); font-size: 1.05rem; }
.asi-budget.full strong { color: var(--muted); }
.asi-budget.over { color: var(--warn, #e0a33d); }
.asi-budget.over strong { color: var(--warn, #e0a33d); }
.asi-grid { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.5rem; }
.asi-row { display: flex; align-items: center; gap: 0.6rem; }
.asi-ability { font-weight: 600; min-width: 3rem; letter-spacing: 0.03em; }
.asi-value { min-width: 4.2rem; font-variant-numeric: tabular-nums; }
.asi-mod { margin-left: 0.35rem; font-size: 0.82rem; }
.asi-tag { color: var(--accent-2); font-size: 0.82rem; min-width: 1.6rem; }
.asi-tag-blank { min-width: 1.6rem; }
.asi-row.has-asi .asi-value { color: var(--accent-2); }
.asi-controls { display: inline-flex; gap: 0.3rem; margin: 0; }

/* Skill-proficiency picker on the edit form */
.skill-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.25rem 1rem; }
.skill-budget { margin: 0 0 0.6rem; font-size: 0.9rem; }
.skill-budget.over { color: var(--warn, #e0a33d); }
.skill-opt { border-radius: 4px; padding: 0.05rem 0.3rem; }
.skill-opt.is-class-skill { background: color-mix(in srgb, var(--accent-2) 14%, transparent); }
.skill-tag { color: var(--muted); font-size: 0.78rem; }
.skill-opt.is-class-skill .skill-tag { color: var(--accent-2); }
code { background: var(--panel-2); padding: 0.05rem 0.35rem; border-radius: 4px; }

/* Class features section on the character sheet (computed from class + level) */
.class-blurb { margin: 0 0 0.9rem; max-width: 60ch; }
.feature-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.feature { display: flex; gap: 0.7rem; align-items: baseline; }
.feature-lvl { flex: 0 0 auto; min-width: 2.1rem; text-align: center; font-size: 0.78rem;
               font-weight: 600; color: var(--accent-2); background: var(--panel-2);
               border-radius: 4px; padding: 0.1rem 0.3rem; }
.feature-asi .feature-lvl { color: var(--muted); }
.feature-body { display: flex; flex-direction: column; gap: 0.1rem; }
.feature-name { font-weight: 600; }
.feature-desc { color: var(--muted); font-size: 0.92rem; line-height: 1.35; }
.feature-next { margin-top: 1rem; }
.feature-next > summary { cursor: pointer; color: var(--accent-2); font-size: 0.92rem; }
.feature-next .feature-list { margin-top: 0.7rem; }
.feature-list.dim .feature-name { font-weight: 500; color: var(--ink); }
.feature-list.dim .feature-lvl { color: var(--muted); }
/* Subclass features: a small pill + a tinted level chip to set them apart. */
.feature-tag { font-family: sans-serif; font-size: 0.62rem; text-transform: uppercase;
               letter-spacing: 0.05em; vertical-align: middle; margin-left: 0.3rem;
               color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
               border-radius: 999px; padding: 0.05rem 0.4rem; }
.feature-sub .feature-lvl { color: var(--accent);
                            background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); }

/* Info icon + hover/focus tooltip (reusable glossary component) */
.info {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 0.2rem;
  font-family: sans-serif;
  font-size: 0.8em;
  color: var(--accent-2);
  cursor: help;
  outline: none;
}
.info .tip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: max-content;
  max-width: 240px;
  padding: 0.5rem 0.65rem;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--accent-2);
  border-radius: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: opacity 0.12s;
  pointer-events: none;
}
.info:hover .tip, .info:focus .tip { visibility: visible; opacity: 1; }

/* --- Phase 3: spells --- */
.mode-hint { font-size: 0.85rem; }
.spell-search { display: flex; gap: 0.5rem; max-width: 460px; margin-bottom: 1.5rem; }
.spell-search input {
  flex: 1; font: inherit; padding: 0.5rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
.spell-search input:focus { outline: none; border-color: var(--accent-2); }

.spell-filter { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.25rem; }
.spell-select-wrap { display: inline-flex; align-items: center; gap: 0.35rem; font-family: sans-serif; font-size: 0.8rem; color: var(--muted); }
.spell-select {
  font: inherit; padding: 0.32rem 0.5rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
#spell-search {
  flex: 1; min-width: 12rem; font: inherit;
  padding: 0.5rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
#spell-search:focus { outline: none; border-color: var(--accent-2); }
.book-filter { margin-top: 0; }
.bookfilt-search, .actfilt-search {
  flex: 1; min-width: 12rem; font: inherit;
  padding: 0.5rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
.bookfilt-search:focus, .actfilt-search:focus { outline: none; border-color: var(--accent-2); }
.filter-group { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.filt-btn {
  font: inherit; font-family: sans-serif; font-size: 0.8rem; cursor: pointer;
  padding: 0.4rem 0.85rem; background: transparent; border: none; color: var(--muted);
}
.filt-btn:hover { color: var(--ink); }
.filt-btn.active { background: var(--accent); color: #fff; }

.spell-list { list-style: none; padding: 0; margin: 0; }
.spell-item { list-style: none; }
.spell-row {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.6rem 0.4rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--ink);
}
.spell-row:hover { background: var(--panel); }
.spell-name { font-weight: bold; color: var(--accent-2); min-width: 9rem; }
.known-badge {
  font-family: sans-serif; font-size: 0.7rem; white-space: nowrap;
  color: #b5d68f; border: 1px solid #5a7b3f; background: rgba(90,123,63,0.18);
  padding: 0.05rem 0.45rem; border-radius: 999px;
}
/* Known-but-unprepared reads in worn gold, distinct from the green "prepared". */
.known-badge.known-only { color: var(--accent-2); border-color: #6b5f3f; background: rgba(107,95,63,0.18); }

/* "Viewing as" character scope selector on the spells library */
.view-as {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 1rem; font-family: sans-serif; font-size: 0.85rem;
}
.view-as label { color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.72rem; }
.view-as select {
  font: inherit; padding: 0.35rem 0.5rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.spell-meta { flex: 1; font-family: sans-serif; font-size: 0.85rem; }

/* Dice rendered in text */
.die-text {
  font-family: sans-serif; font-size: 0.85em;
  color: var(--accent-2);
  background: var(--panel-2);
  padding: 0.02rem 0.4rem; border-radius: 4px;
  white-space: nowrap;
}
.rollable {
  font: inherit; font-family: sans-serif; font-size: 0.85em; cursor: pointer;
  color: var(--accent-2);
  background: var(--panel-2);
  border: 1px solid var(--accent-2);
  padding: 0.02rem 0.45rem; border-radius: 4px;
  white-space: nowrap;
}
.rollable:hover { background: var(--accent-2); color: var(--bg); }

/* Spell detail */
.spell-title { margin: 0; }
.spell-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem 1.5rem; margin: 1rem 0 1.5rem;
}
.spell-stats div { border-left: 2px solid var(--border); padding-left: 0.7rem; }
.spell-stats dt { font-family: sans-serif; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.spell-stats dd { margin: 0.1rem 0 0; }
.spell-desc { max-width: 680px; line-height: 1.7; }
.cast-box { margin-top: 1.5rem; }
.cast-btn { font-size: 0.95rem; }

/* Spellbook on the character sheet */
.char-spells, .add-to-char { margin-top: 1.75rem; }
.char-spells h2, .add-to-char h2 { color: var(--accent-2); font-size: 1.1rem; }
.spellbook { list-style: none; padding: 0; margin: 0 0 1rem; }
.spell-line {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.45rem 0.2rem;
  border-bottom: 1px solid var(--border);
}
.spell-line.unprepared { opacity: 0.6; }
.spell-line-name { color: var(--accent-2); text-decoration: none; font-weight: bold; }
.spell-line-name:hover { text-decoration: underline; }
.spell-line-meta { flex: 1; font-size: 0.85rem; }
.prep-toggle {
  font: inherit; font-family: sans-serif; font-size: 0.7rem; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 0.15rem 0.6rem; border-radius: 999px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); min-width: 5.5rem;
}
.prep-toggle.on { color: #b5d68f; border-color: #5a7b3f; background: rgba(90,123,63,0.18); }
/* Unprepared *leveled* spells can't be cast right now — flag the badge red so it's
   obviously "off", not just muted. Cantrips are always castable, so they stay
   neutral (a cantrip is never wrongly shown as unusable). */
.spell-line[data-cantrip="0"] .prep-toggle:not(.on) {
  color: #e0796b; border-color: #8a3f33; background: rgba(138,63,51,0.18);
}
.spell-line[data-cantrip="0"] button.prep-toggle:not(.on):hover { border-color: #b5503f; color: #f0a08f; }

/* Weapon & armor proficiencies (from the class) + the non-proficient-armor flag */
.proficiencies { margin-top: 1.25rem; }
.prof-rows { display: flex; flex-direction: column; gap: 0.4rem; }
.prof-row { display: flex; gap: 0.6rem; align-items: baseline; }
.prof-key { min-width: 5rem; font-weight: 600; color: var(--muted); font-family: sans-serif;
            font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.prof-vals { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.prof-chip { font-family: sans-serif; font-size: 0.78rem; padding: 0.1rem 0.5rem;
             border-radius: 999px; border: 1px solid var(--border); color: var(--ink); }
.armor-warn { display: inline-block; margin-top: 0.2rem; font-family: sans-serif;
              font-size: 0.7rem; color: #e0796b; border: 1px solid #8a3f33;
              background: rgba(138,63,51,0.16); padding: 0.05rem 0.45rem;
              border-radius: 999px; cursor: help; white-space: nowrap; }
.cast-block { width: 100%; font-family: sans-serif; font-size: 0.82rem; color: #e0796b;
              border: 1px solid #8a3f33; background: rgba(138,63,51,0.14);
              border-radius: 6px; padding: 0.4rem 0.6rem; }

.add-spell { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.add-spell select {
  font: inherit; padding: 0.4rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}

/* Actions & abilities on the character/monster sheet (free-form, distinct from
   spells). */
.char-actions { margin-top: 1.75rem; }
.char-actions h2 { color: var(--accent-2); font-size: 1.1rem; }
.action-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.action-line { padding: 0.55rem 0.2rem; border-bottom: 1px solid var(--border); }
.action-head { display: flex; align-items: center; gap: 0.7rem; }
.action-name { font-weight: bold; flex: 1; }
.action-cat {
  font-family: sans-serif; font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.1rem 0.5rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.action-cat-trait     { color: #c9b88f; border-color: #6b5f3f; }
.action-cat-action    { color: #b5d68f; border-color: #5a7b3f; }
.action-cat-bonus     { color: #8fc6e8; border-color: #38607a; }
.action-cat-reaction  { color: #e8b58f; border-color: #7a5a38; }
.action-cat-legendary { color: #d59ae0; border-color: #6b3f7a; }
.action-src { font-family: sans-serif; font-size: 0.62rem; text-transform: uppercase;
              letter-spacing: 0.05em; color: var(--accent-2);
              border: 1px solid color-mix(in srgb, var(--accent-2) 45%, transparent);
              border-radius: 999px; padding: 0.05rem 0.4rem; }
.action-desc { margin: 0.4rem 0 0; max-width: 680px; line-height: 1.6; color: var(--ink); }

/* Exhaustion (loose 0–6 tracker; effects shown, never auto-applied) */
.exhaustion { margin-top: 1rem; }
.exhaustion-row { display: flex; align-items: center; gap: 0.5rem; }
.exhaustion-pips { display: inline-flex; gap: 0.25rem; }
.ex-pip { width: 1.4rem; height: 1.4rem; line-height: 1.4rem; text-align: center;
  font-family: sans-serif; font-size: 0.78rem; border-radius: 4px;
  border: 1px solid var(--border); color: var(--muted); }
.ex-pip.on { color: #e0a33d; border-color: #8a6a2f; background: rgba(138,106,47,0.18); }
.ex-pip.on.death { color: #e0796b; border-color: #8a3f33; background: rgba(138,63,51,0.22); }
.exhaustion-effects { list-style: none; margin: 0.5rem 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.88rem; }
.ex-lvl { display: inline-block; min-width: 1.4rem; text-align: center; font-family: sans-serif;
  font-size: 0.72rem; color: #e0a33d; border: 1px solid #8a6a2f; border-radius: 4px;
  margin-right: 0.4rem; }

/* Concentration (the one concentration spell a caster is holding) */
.concentration-banner { width: 100%; display: flex; align-items: center; gap: 0.5rem;
  font-family: sans-serif; font-size: 0.85rem; color: #c9a9e0;
  border: 1px solid color-mix(in srgb, #9a6fb0 45%, transparent);
  background: rgba(120,80,150,0.14); border-radius: 6px; padding: 0.3rem 0.6rem; }
.conc-tag { font-family: sans-serif; font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.05rem 0.45rem; border-radius: 999px; white-space: nowrap;
  color: #c9a9e0; border: 1px solid color-mix(in srgb, #9a6fb0 45%, transparent); }

/* Damage defenses (resist/immune/vulnerable) on a combatant + the damage-type picker */
.def-tag { font-family: sans-serif; font-size: 0.64rem; padding: 0.05rem 0.4rem;
  border-radius: 999px; white-space: nowrap; border: 1px solid var(--border); }
.def-immune { color: #8fc6e8; border-color: color-mix(in srgb, #8fc6e8 45%, transparent); }
.def-resist { color: #7fc99a; border-color: color-mix(in srgb, #7fc99a 45%, transparent); }
.def-vuln   { color: #e08a8a; border-color: color-mix(in srgb, #e08a8a 45%, transparent); }
.dmg-type { font-size: 0.78rem; padding: 0.1rem 0.2rem; max-width: 6.5rem; }

/* Attacks (equipped weapons → to-hit + damage rolls) */
.char-attacks h2 { color: var(--accent-2); font-size: 1.1rem; }
.attack-list { list-style: none; padding: 0; margin: 0; }
.attack-line { display: flex; align-items: center; justify-content: space-between;
               gap: 0.7rem; flex-wrap: wrap; padding: 0.5rem 0.2rem;
               border-bottom: 1px solid var(--border); }
.attack-name { font-weight: bold; }
.attack-type { font-family: sans-serif; font-size: 0.78rem; text-transform: capitalize; }
.attack-abil { font-family: sans-serif; font-size: 0.72rem; }
.attack-rolls { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.crit-btn { border-color: color-mix(in srgb, #e0a84a 55%, transparent) !important; color: #e0a84a !important; }
.crit-btn:hover { background: color-mix(in srgb, #e0a84a 16%, transparent) !important; }
.attack-stat { font-family: sans-serif; font-size: 0.85rem; color: var(--muted); }
.attack-stat + .attack-stat { color: var(--accent-2); }
.attack-warn { font-family: sans-serif; font-size: 0.6rem; text-transform: uppercase;
               letter-spacing: 0.05em; padding: 0.05rem 0.45rem; border-radius: 999px;
               color: #e0796b; border: 1px solid #8a3f33; white-space: nowrap; }

/* Feats list on the character sheet (tracked; no mechanics yet) */
.char-feats h2 { color: var(--accent-2); font-size: 1.1rem; }
.feat-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.feat-line { padding: 0.55rem 0.2rem; border-bottom: 1px solid var(--border); }
.feat-head { display: flex; align-items: center; gap: 0.7rem; }
.feat-name { font-weight: bold; }
.feat-prereq { font-family: sans-serif; font-size: 0.66rem; text-transform: uppercase;
               letter-spacing: 0.05em; padding: 0.1rem 0.5rem; border-radius: 999px;
               border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.feat-line .roll-del { margin-left: auto; }
.feat-desc { margin: 0.4rem 0 0; max-width: 680px; line-height: 1.6; color: var(--ink); }

.add-action { display: flex; flex-direction: column; gap: 0.5rem; max-width: 680px; }
.add-action .field-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.add-action input, .add-action select, .add-action textarea {
  font: inherit; padding: 0.4rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.add-action input[name="name"] { flex: 1 1 12rem; }
.add-action .dice-input { flex: 0 1 12rem; }
.add-action textarea { width: 100%; resize: vertical; }
.add-action .btn { align-self: flex-start; }

/* Primary "add from action book" picker + secondary custom <details> */
.add-from-book select {
  flex: 1 1 16rem; font: inherit; padding: 0.4rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.add-from-book { margin-bottom: 0.75rem; }
.add-custom-action > summary {
  cursor: pointer; color: var(--muted); font-family: sans-serif;
  font-size: 0.85rem; padding: 0.3rem 0;
}
.add-custom-action[open] > summary { color: var(--ink); margin-bottom: 0.5rem; }

/* Library pane toggle (Spells / Action Book) */
.library-toggle {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; margin-bottom: 1.25rem;
}
.lib-btn {
  font: inherit; font-family: sans-serif; font-size: 0.85rem; cursor: pointer;
  padding: 0.45rem 1.1rem; background: transparent; border: none; color: var(--muted);
}
.lib-btn:hover { color: var(--ink); }
.lib-btn.active { background: var(--accent); color: #fff; }

/* Action book list (Spells & Actions tab) */
#action-search {
  width: 100%; max-width: 460px; font: inherit; padding: 0.5rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.75rem;
}
#action-search:focus { outline: none; border-color: var(--accent-2); }
.actionbook-list { list-style: none; padding: 0; margin: 0; }
.actionbook-item { padding: 0.6rem 0.4rem; border-bottom: 1px solid var(--border); }
.actionbook-head { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.actionbook-add { margin-left: auto; display: flex; gap: 0.4rem; }
.actionbook-add select {
  font: inherit; padding: 0.25rem 0.45rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.btn-small {
  font: inherit; font-family: sans-serif; font-size: 0.8rem; cursor: pointer;
  padding: 0.25rem 0.7rem; border-radius: 5px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
}
.btn-small:hover { opacity: 0.9; }

/* Inventory */
.inventory { margin-top: 1.75rem; }
.inventory h2 { color: var(--accent-2); font-size: 1.1rem; }
.item-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.item-line {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.45rem 0.2rem;
  border-bottom: 1px solid var(--border);
}
.item-main { flex: 1; display: flex; flex-direction: column; }
.item-name { font-weight: bold; }
.item-line.equipped .item-name { color: var(--accent-2); }
.item-desc { font-size: 0.8rem; }
.equip-toggle {
  font: inherit; font-family: sans-serif; font-size: 0.72rem;
  cursor: pointer; min-width: 4.4rem; padding: 0.2rem 0.5rem; border-radius: 999px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.equip-toggle:hover { color: var(--ink); border-color: var(--accent-2); }
.equip-toggle.on { color: var(--accent-2); border-color: var(--accent-2); background: rgba(201,161,74,0.15); }
.equip-spacer { display: inline-block; min-width: 4.4rem; }
.tag-2h {
  font-family: sans-serif; font-size: 0.62rem; font-weight: bold;
  color: var(--bg); background: var(--accent-2);
  padding: 0.02rem 0.3rem; border-radius: 3px; vertical-align: middle;
}

/* Equipment slot panel (Baldur's Gate-style) */
.equipment { margin-top: 1.75rem; }
.equipment h2 { color: var(--accent-2); font-size: 1.1rem; }
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.6rem;
}

/* Equipment + inventory side by side for short drag distances */
.gear-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 1.75rem;
  align-items: flex-start;
  margin-top: 1.75rem;
}
.gear-layout .equipment { flex: 2 1 460px; margin-top: 0; }
.gear-layout .inventory { flex: 1 1 280px; margin-top: 0; display: flex; flex-direction: column; }

/* Inventory as a fixed-height scrollable nested panel (height synced to the
   equipment panel via JS); list scrolls, search/filter + footer stay put. */
.inv-filter { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.inv-search {
  flex: 1; min-width: 8rem; font: inherit;
  padding: 0.35rem 0.6rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
.inv-search:focus { outline: none; border-color: var(--accent-2); }
.inv-kinds { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.invk-btn {
  font: inherit; font-family: sans-serif; font-size: 0.75rem; cursor: pointer;
  padding: 0.3rem 0.65rem; background: transparent; border: none; color: var(--muted);
}
.invk-btn:hover { color: var(--ink); }
.invk-btn.active { background: var(--accent); color: #fff; }
.inv-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.6rem;
}
.inv-scroll .item-list { margin: 0; }
.inv-empty { padding: 0.6rem 0.2rem; }

/* Baldur's Gate-style paper doll: armor left, figure middle, weapons/jewelry right */
.equip-doll {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  max-width: 100%;
}
.equip-col { display: flex; flex-direction: column; gap: 0.6rem; }
.equip-figure { align-self: stretch; display: flex; }
.figure-frame {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem;
  text-align: center;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--accent-2);
  border-radius: 10px;
}
.figure-icon { font-size: 3.5rem; line-height: 1; }
.figure-name { font-weight: bold; font-size: 1.1rem; color: var(--accent-2); }
.figure-meta { font-size: 0.8rem; }

/* Character portrait (avatar): emoji or uploaded image, shared by the sheet
   figure and reused for map markers later. The figure shows a large square. */
.avatar-img {
  width: 96px; height: 96px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--accent-2); display: block;
}
.figure-icon .avatar-emoji { font-size: 3.5rem; line-height: 1; }

/* Portrait editor on the character form */
.avatar-edit { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.avatar-preview {
  display: flex; align-items: center; justify-content: center;
  width: 110px; height: 110px; flex: none;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
}
.avatar-preview .avatar-lg { font-size: 4rem; line-height: 1; }
.avatar-preview .avatar-img { width: 108px; height: 108px; border: none; }
.avatar-fields { flex: 1; min-width: 14rem; display: flex; flex-direction: column; gap: 0.6rem; }
.avatar-fields input[type="file"] { font: inherit; color: var(--ink); }
.avatar-hint { margin: 0; font-size: 0.8rem; }

/* Avatar size variants (cards, inspector). */
.avatar-img.avatar-sm { width: 38px; height: 38px; border-radius: 8px; }
.avatar-emoji.avatar-sm { font-size: 1.7rem; line-height: 1; }
.avatar-img.avatar-md { width: 64px; height: 64px; }
.avatar-emoji.avatar-md { font-size: 2.6rem; line-height: 1; }

/* Roster/bestiary card title: portrait beside the name. */
.char-card-title { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.char-card-title .char-name { overflow: hidden; text-overflow: ellipsis; }
/* Inspector title: portrait beside the name block. */
.inspect-title { display: flex; align-items: center; gap: 1rem; }

/* Quick "change portrait" editor on the sheet figure. */
.portrait-edit { width: 100%; margin-top: 0.4rem; }
.portrait-edit > summary {
  cursor: pointer; color: var(--muted); font-family: sans-serif; font-size: 0.78rem;
  text-align: center; list-style: none;
}
.portrait-edit[open] > summary { color: var(--ink); margin-bottom: 0.5rem; }
.portrait-form { display: flex; flex-direction: column; gap: 0.45rem; align-items: stretch; }
.portrait-form input[type="text"], .portrait-form input[type="file"] {
  font: inherit; font-size: 0.8rem; padding: 0.3rem 0.45rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px; max-width: 100%;
}
.checkbox-inline { font-family: sans-serif; font-size: 0.78rem; color: var(--muted); display: flex; align-items: center; gap: 0.35rem; }

@media (max-width: 720px) {
  .equip-doll { grid-template-columns: 1fr; }
  .equip-figure { order: -1; }
}
.slot-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  min-height: 3.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.slot-box.filled { border-color: var(--accent-2); }
.slot-box.drop-ok {
  border-color: var(--accent-2);
  border-style: dashed;
  background: rgba(201, 161, 74, 0.18);
}
.item-line.draggable { cursor: grab; }
.item-line.draggable:active { cursor: grabbing; }
.item-line.dragging { opacity: 0.45; }

/* Compact chip used as the drag image (positioned off-screen until grabbed) */
.drag-ghost {
  position: absolute;
  top: -1000px;
  left: -1000px;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--accent-2);
  font-family: sans-serif;
  font-size: 0.82rem;
  font-weight: bold;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}
.slot-label {
  font-family: sans-serif; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
}
.slot-item { font-weight: bold; color: var(--accent-2); }
.slot-empty { color: var(--muted); font-style: italic; font-size: 0.85rem; }
.slot-filled-row { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.slot-unequip {
  font: inherit; font-size: 0.95rem; line-height: 1; cursor: pointer;
  padding: 0 0.25rem; background: transparent; border: none;
  color: var(--muted); opacity: 0.6;
}
.slot-unequip:hover { color: var(--accent); opacity: 1; }
.two-handed-check {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: sans-serif; font-size: 0.8rem; color: var(--muted);
}
.loot-note { margin-top: 0.5rem; font-size: 0.85rem; }
.loot-note a { color: var(--accent-2); }

/* --- Phase 4c: loot tab --- */
.area-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.area-switch { display: flex; align-items: center; gap: 0.5rem; }
.area-switch select, .add-area input, .add-area + * {
  font: inherit;
}
.area-switch select {
  font-size: 1.05rem; padding: 0.4rem 0.6rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--accent-2); border-radius: 6px;
}
.area-actions { display: flex; gap: 0.5rem; }
.add-area { display: flex; gap: 0.5rem; margin-bottom: 1.75rem; }
.add-area input {
  padding: 0.4rem 0.6rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}

.loot-heading { color: var(--accent-2); font-size: 1.15rem; }
.loot-list { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.loot-row {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.55rem 0.2rem;
  border-bottom: 1px solid var(--border);
}
.loot-main { flex: 1; display: flex; flex-direction: column; }
.loot-name { font-weight: bold; }
.loot-sub { font-size: 0.82rem; }
.give-form { display: flex; gap: 0.35rem; }
.give-form select {
  font: inherit; padding: 0.3rem 0.5rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}

.loot-add-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.loot-add { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.1rem; }
.loot-add h3 { margin-top: 0; color: var(--accent-2); font-size: 0.95rem; }
.qty { display: flex; align-items: center; gap: 0.4rem; }
.qty-btn {
  font: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
  width: 1.5rem; height: 1.5rem;
  background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 4px;
}
.qty-btn:hover { border-color: var(--accent-2); }
.qty-num { min-width: 1.5rem; text-align: center; font-family: sans-serif; }
.add-item { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.add-item input {
  font: inherit; padding: 0.4rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.add-item .qty-input { width: 4rem; }
.add-item .desc-input { flex: 1; min-width: 8rem; }

/* --- Phase 5: bestiary + monster inspector --- */
.revealed { color: #b5d68f; }

/* Bestiary card: a main link plus a separate Inspect link below it. */
.monster-card { display: flex; flex-direction: column; }
.char-card-link { display: block; color: var(--ink); text-decoration: none; }
.inspect-link {
  font-family: sans-serif; font-size: 0.85rem;
  color: var(--accent-2); text-decoration: none;
}
.inspect-link:hover { text-decoration: underline; }
.monster-card-foot {
  margin-top: 0.7rem; display: flex; align-items: center; gap: 0.6rem;
  justify-content: space-between; flex-wrap: wrap;
}

/* Inspector reveal banner (DM control). */
.reveal-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.9rem; border-radius: 8px; margin: 0 0 1.5rem;
  font-family: sans-serif; font-size: 0.9rem;
  border: 1px solid var(--border);
}
.reveal-banner.revealed { border-color: #5a7b3f; background: rgba(90,123,63,0.12); }
.reveal-banner.hidden { border-color: #6b5f3f; background: rgba(107,95,63,0.12); }

.inspect-vitals { margin-top: 0; }
.inspect-h { color: var(--accent-2); font-size: 1.1rem; margin-top: 1.75rem; }
.inspect-note { margin-top: 1rem; }
/* Masked (unrevealed) stat block reads as a dim silhouette. */
.inspect-block.masked .vital-value,
.inspect-block.masked .ability-mod,
.inspect-block.masked .ability-score { color: var(--muted); opacity: 0.7; }

/* Encounters (Bestiary tab + detail page) */
.encounters { margin-top: 2.5rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head h2 { color: var(--accent-2); font-size: 1.2rem; margin: 0; }
.encounter-new input, .add-encounter-member select, .add-encounter-member input,
.encounter-tools input {
  font: inherit; padding: 0.4rem 0.55rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.encounter-new { display: flex; gap: 0.5rem; }
.encounter-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.encounter-row {
  display: flex; align-items: baseline; gap: 0.8rem;
  padding: 0.55rem 0.2rem; border-bottom: 1px solid var(--border);
}
.encounter-name { color: var(--accent-2); text-decoration: none; font-weight: bold; }
.encounter-name:hover { text-decoration: underline; }

.encounter-members { list-style: none; padding: 0; margin: 0 0 1rem; }
.encounter-member {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--border);
}
.encounter-member-name { color: var(--accent-2); text-decoration: none; font-weight: bold; flex: 1; }
.encounter-member-name:hover { text-decoration: underline; }
.encounter-member-stats { font-family: sans-serif; font-size: 0.85rem; }
.encounter-qty { font-family: sans-serif; min-width: 2.2rem; text-align: center; }

/* Encounter difficulty (XP-budget) panel */
.enc-difficulty { display: flex; align-items: center; flex-wrap: wrap; gap: 0.6rem 1rem;
  margin: 0 0 1.25rem; padding: 0.6rem 0.9rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; font-family: sans-serif; font-size: 0.9rem; }
.enc-rating { font-weight: bold; text-transform: uppercase; letter-spacing: 0.05em;
  font-size: 0.8rem; padding: 0.2rem 0.7rem; border-radius: 999px; color: var(--bg); }
.enc-rating-trivial { background: #6c8f6c; }
.enc-rating-easy    { background: #7fc99a; }
.enc-rating-medium  { background: #e0c04a; }
.enc-rating-hard    { background: #e0944a; }
.enc-rating-deadly  { background: #e06a6a; }
.enc-thresholds { font-size: 0.78rem; width: 100%; }
.add-encounter-member { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.qty-input { width: 4rem; }
.section-rule { border: none; border-top: 1px solid var(--border); margin: 2rem 0 1.25rem; }
.encounter-tools { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

/* --- Phase 6: combat tracker --- */
.combat-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.combat-add {
  display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
  padding-bottom: 1.25rem; border-bottom: 1px solid var(--border);
}
.combat-add select {
  font: inherit; padding: 0.35rem 0.5rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}

.initiative-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.combatant {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.7rem 0.9rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
}
.combatant.active-turn { border-color: var(--accent-2); box-shadow: inset 3px 0 0 var(--accent-2); background: var(--panel-2); }
.combatant.downed { opacity: 0.6; }
.combatant.downed .combatant-name { text-decoration: line-through; }

/* Death saving throws (a downed PC) */
.death-saves { display: flex; align-items: center; flex-wrap: wrap; gap: 0.4rem;
               font-family: sans-serif; font-size: 0.8rem; }
.death-status { color: var(--muted); }
.death-saves.is-dead .death-status { color: #e0796b; font-weight: bold; }
.death-saves.is-stable .death-status { color: #b5d68f; font-weight: bold; }
.ds-pips { display: inline-flex; gap: 0.1rem; }
.ds-pip { width: 1rem; height: 1rem; line-height: 1rem; text-align: center; font-size: 0.7rem;
          border-radius: 999px; border: 1px solid var(--border); color: var(--border); }
.ds-succ .ds-pip.on { color: #b5d68f; border-color: #5a7b3f; background: rgba(90,123,63,0.18); }
.ds-fail .ds-pip.on { color: #e0796b; border-color: #8a3f33; background: rgba(138,63,51,0.18); }
.ds-mark { font: inherit; font-family: sans-serif; font-size: 0.72rem; cursor: pointer;
           background: transparent; color: var(--muted); border: 1px solid var(--border);
           border-radius: 999px; padding: 0.05rem 0.4rem; }
.ds-mark:hover { color: var(--ink); border-color: var(--accent-2); }

/* Combat subtabs (Tracker / Log). Hidden without JS — both panes just stack. */
/* Character-sheet subtabs (Stats & Actions / Details & Lore). Hidden without JS
   so both panes just stack. Mirrors the combat tracker's subtab pattern. */
.sheet-tabs { display: none; gap: 0.4rem; margin: 0.25rem 0 1.25rem; border-bottom: 1px solid var(--border); }
#sheet.has-tabs .sheet-tabs { display: flex; }
.sheet-tab {
  font: inherit; font-size: 1rem; cursor: pointer; background: transparent; color: var(--muted);
  border: 1px solid transparent; border-bottom: none; border-radius: 7px 7px 0 0;
  padding: 0.5rem 1.1rem; margin-bottom: -1px;
}
.sheet-tab:hover { color: var(--ink); }
.sheet-tab.is-active {
  color: var(--ink); background: var(--panel);
  border-color: var(--border); border-bottom: 1px solid var(--panel); font-weight: 600;
}
#sheet.has-tabs .sheet-pane { display: none; }
#sheet.has-tabs .sheet-pane.is-active { display: block; }

.combat-tabs { display: none; gap: 0.35rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
#combat.has-tabs .combat-tabs { display: flex; }
.combat-tab {
  font: inherit; cursor: pointer; background: transparent; color: var(--muted);
  border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0;
  padding: 0.4rem 0.9rem; margin-bottom: -1px;
}
.combat-tab:hover { color: var(--ink); }
.combat-tab.is-active {
  color: var(--ink); background: var(--panel);
  border-color: var(--border); border-bottom: 1px solid var(--panel);
}
.combat-tab .tab-count {
  font-family: sans-serif; font-size: 0.7rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0 0.35rem;
}
#combat.has-tabs .combat-pane { display: none; }
#combat.has-tabs .combat-pane.is-active { display: block; }
.combat-pane.combat-log { margin-top: 0; padding-top: 0; border-top: none; }

/* Combat log — running record of attacks/damage/healing */
.combat-log { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.combat-log-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.combat-log-head h2 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.log-form {
  display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center;
  margin-bottom: 1rem; padding: 0.6rem 0.7rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.log-form select, .log-form input[type="text"], .log-form input[type="number"] {
  font: inherit; padding: 0.3rem 0.45rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.log-form .log-action { flex: 1 1 11rem; min-width: 8rem; }
.log-form .log-num { width: 4.2rem; }
.log-arrow { color: var(--muted); }
.log-apply { font-family: sans-serif; font-size: 0.75rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.2rem; }

.log-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.15rem;
            max-height: 22rem; overflow-y: auto; }
.log-entry { display: flex; gap: 0.5rem; align-items: baseline;
             padding: 0.25rem 0.1rem; border-bottom: 1px solid var(--border);
             font-size: 0.86rem; }
.log-round { flex: none; font-family: sans-serif; font-size: 0.62rem; color: var(--muted);
             border: 1px solid var(--border); border-radius: 999px; padding: 0.02rem 0.35rem; }
.log-text { color: var(--ink); flex: 1; }
.log-del-form { flex: none; }
.log-del { font: inherit; cursor: pointer; background: transparent; color: var(--border);
           border: none; padding: 0 0.2rem; line-height: 1; }
.log-del:hover { color: #e0796b; }
.log-roll { font-weight: bold; color: var(--accent-2); }
.log-dmg { font-weight: bold; color: #e0796b; }
.log-heal { font-weight: bold; color: #b5d68f; }
.log-entry.log-heal .log-round { border-color: #5a7b3f; }

.init-badge { flex: none; }
.init-static {
  display: inline-block; width: 3rem; text-align: center;
  font-weight: bold; font-size: 1.1rem; color: var(--accent-2);
  padding: 0.35rem 0.2rem;
}
.readonly-tag {
  font-family: sans-serif; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.05rem 0.5rem;
}
.you-tag {
  font-family: sans-serif; font-size: 0.65rem; text-transform: uppercase;
  color: #b5d68f; border: 1px solid #5a7b3f; border-radius: 999px;
  padding: 0.02rem 0.4rem; vertical-align: middle;
}
/* Magic-item effects (bonuses from equipped gear) */
.stat-bonus {
  font-family: sans-serif; font-size: 0.62rem; font-weight: bold;
  color: #8fc6e8; vertical-align: middle; margin-left: 0.1rem;
}
.prep-toggle.from-item { color: #8fc6e8; border-color: #38607a; background: rgba(56,96,122,0.18); cursor: default; }
.item-magic, .loot-magic { color: #8fc6e8; }

/* Attunement: header counter, per-item badge + toggle */
.attune-count {
  font-family: sans-serif; font-size: 0.7rem; font-weight: normal;
  color: var(--accent-2); margin-left: 0.6rem; vertical-align: middle;
}
.attune-count.over { color: #d98a3d; }
.attune-badge {
  font-family: sans-serif; font-size: 0.6rem; font-weight: bold;
  padding: 0.02rem 0.32rem; border-radius: 3px; vertical-align: middle;
  color: var(--muted); border: 1px solid var(--border);
}
.attune-badge.on { color: var(--accent-2); border-color: var(--accent-2); background: rgba(201,161,74,0.15); }
.attune-toggle {
  font-family: sans-serif; font-size: 0.72rem; cursor: pointer;
  color: var(--muted); background: none; border: 1px solid var(--border);
  border-radius: 4px; padding: 0.1rem 0.4rem;
}
.attune-toggle:hover { color: var(--ink); border-color: var(--accent-2); }
.attune-toggle.on { color: var(--accent-2); border-color: var(--accent-2); background: rgba(201,161,74,0.15); }
.loot-magic { font-family: sans-serif; font-size: 0.78rem; margin-left: 0.5rem; }
.magic-fields { width: 100%; margin: 0.3rem 0; }
.magic-fields > summary { cursor: pointer; color: var(--muted); font-family: sans-serif; font-size: 0.8rem; }
.magic-fields[open] > summary { color: var(--ink); margin-bottom: 0.5rem; }
.magic-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.magic-grid.armor-row { margin-bottom: 0.5rem; align-items: flex-end; }
.magic-grid .coin-input { width: 3.4rem; }
.magic-armor { display: flex; flex-direction: column; gap: 0.2rem; font-family: sans-serif; font-size: 0.8rem; color: var(--muted); }
.magic-armor select {
  font: inherit; padding: 0.3rem 0.4rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.armor-hint { font-family: sans-serif; font-size: 0.75rem; flex-basis: 100%; }
.form-hint { font-size: 0.8rem; margin: 0.5rem 0 0; }
.magic-spells { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.6rem; font-family: sans-serif; font-size: 0.82rem; color: var(--muted); }
.magic-spells select {
  font: inherit; padding: 0.3rem; min-width: 14rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}

/* Coin fields (loot coins + purse adjuster) */
.coin-field { display: inline-flex; align-items: center; gap: 0.3rem; font-family: sans-serif; font-size: 0.8rem; }
.coin-input {
  width: 4rem; font: inherit; padding: 0.3rem 0.4rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.purse-edit { margin-top: 0.4rem; }
.purse-edit > summary { cursor: pointer; color: var(--muted); font-family: sans-serif; font-size: 0.78rem; }
.purse-edit[open] > summary { color: var(--ink); }
.purse-form { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; margin-top: 0.5rem; }

.error-page { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 3rem; color: var(--accent-2); margin: 0; }
.error-msg { color: var(--muted); margin: 0.5rem 0 1.5rem; }
.equip-static { cursor: default; opacity: 0.85; }
.note-private { font-size: 0.75rem; font-weight: normal; }
.init-input {
  width: 3rem; text-align: center; font: inherit; font-weight: bold; font-size: 1.1rem;
  color: var(--accent-2); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.2rem;
}
.combatant-portrait { flex: none; }
.combatant-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.combatant-line { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.combatant-name { font-weight: bold; font-size: 1.05rem; }
.combatant-ac { font-family: sans-serif; font-size: 0.85rem; color: var(--muted); }

.hp-bar {
  position: relative; height: 1.25rem; border-radius: 6px; overflow: hidden;
  background: var(--bg); border: 1px solid var(--border); max-width: 320px;
}
.hp-fill { position: absolute; inset: 0 auto 0 0; background: #5a7b3f; transition: width 0.2s; }
.hp-fill.mid { background: #9a7b2f; }
.hp-fill.low { background: #7a3838; }
.hp-text {
  position: relative; z-index: 1; display: block; text-align: center;
  font-family: sans-serif; font-size: 0.8rem; line-height: 1.25rem; color: var(--ink);
}
.temp-hp { color: #8fc6e8; font-weight: bold; }

.condition-chips { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.cond-chip {
  font: inherit; font-family: sans-serif; font-size: 0.72rem; cursor: pointer;
  text-transform: capitalize; padding: 0.12rem 0.5rem; border-radius: 999px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.cond-chip:hover { color: var(--ink); }
.cond-chip.on { color: #e8b58f; border-color: #7a5a38; background: rgba(122,90,56,0.2); }

.combatant-actions { flex: none; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.hp-form, .temp-form { display: flex; gap: 0.25rem; }
.hp-amount {
  width: 3.2rem; font: inherit; padding: 0.3rem 0.4rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.btn-dmg, .btn-heal {
  font: inherit; font-family: sans-serif; font-size: 0.78rem; cursor: pointer;
  padding: 0.3rem 0.55rem; border-radius: 5px; white-space: nowrap;
}
.btn-dmg { background: transparent; color: #e8918f; border: 1px solid #7a3838; }
.btn-dmg:hover { background: #7a3838; color: #fff; }
.btn-heal { background: transparent; color: #b5d68f; border: 1px solid #5a7b3f; }
.btn-heal:hover { background: #5a7b3f; color: #fff; }

.cond-edit { position: relative; }
.cond-edit > summary { list-style: none; }
.cond-edit > summary::-webkit-details-marker { display: none; }
.cond-grid {
  display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem;
  padding: 0.6rem; max-width: 360px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}

/* De-emphasized text button (e.g. re-roll initiative once it's been rolled). */
.btn-text {
  font: inherit; font-family: sans-serif; font-size: 0.82rem; cursor: pointer;
  background: transparent; border: none; color: var(--muted);
  padding: 0.45rem 0.4rem; text-decoration: underline;
}
.btn-text:hover { color: var(--ink); }

/* Ended-combat banner */
.ended-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1rem;
  padding: 0.5rem 0.8rem; border-radius: 6px;
  font-family: sans-serif; font-size: 0.9rem;
  border: 1px solid #6b5f3f; background: rgba(107,95,63,0.15);
}

/* --- Graveyard --- */
.deceased-banner {
  margin-bottom: 1rem; padding: 0.55rem 0.85rem; border-radius: 6px;
  font-family: sans-serif; font-size: 0.9rem;
  border: 1px solid #5a4a5e; background: rgba(90,74,94,0.18); color: var(--ink);
}
.rest-menu { position: relative; display: inline-block; }
.rest-menu > summary { list-style: none; cursor: pointer; }
.rest-menu > summary::-webkit-details-marker { display: none; }
.rest-form {
  position: absolute; right: 0; z-index: 20; margin-top: 0.4rem; width: 17rem;
  display: flex; flex-direction: column; gap: 0.45rem;
  padding: 0.7rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.rest-form label { font-family: sans-serif; font-size: 0.78rem; }
.rest-form textarea {
  font: inherit; width: 100%; box-sizing: border-box; resize: vertical;
  background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 5px;
  padding: 0.4rem;
}
.grave-group { margin-bottom: 1.75rem; }
.grave-group-title { font-size: 1.05rem; margin: 0 0 0.7rem; }
.grave-count {
  font-family: sans-serif; font-size: 0.72rem; font-weight: normal; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.02rem 0.45rem; vertical-align: middle;
}
.grave-card { opacity: 0.92; }
.grave-card:hover { opacity: 1; }
.grave-epitaph { font-style: italic; color: var(--muted); font-size: 0.85rem; margin-top: 0.3rem; }

/* --- PC-to-PC trading --- */
.trade-block { margin-bottom: 0.9rem; }
.trade-subhead { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.4rem; font-weight: normal; text-transform: uppercase; letter-spacing: 0.04em; }
.trade-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.trade-offer {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  flex-wrap: wrap; padding: 0.45rem 0.7rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
}
.trade-in { border-left: 3px solid #8fc6e8; }
.trade-out { border-left: 3px solid var(--border); }
.trade-text { font-size: 0.9rem; }
.trade-actions { display: flex; align-items: center; gap: 0.4rem; }
.trade-pending {
  font-family: sans-serif; font-size: 0.65rem; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.02rem 0.4rem; margin-left: 0.3rem;
}
.btn-accept { color: #b5d68f; border-color: #5a7b3f; }
.trade-give { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.6rem; }
.trade-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.trade-lbl { font-family: sans-serif; font-size: 0.8rem; min-width: 5rem; color: var(--muted); }
.trade-to { color: var(--muted); font-size: 0.85rem; }
.trade-form select {
  font: inherit; padding: 0.3rem 0.45rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}

/* --- Party tab --- */
.party-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.party-card {
  padding: 1rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.party-card-head { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--ink); }
.party-card-head:hover .char-name { text-decoration: underline; }
.party-portrait { flex: none; }
.party-id { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.party-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

/* --- Phase 7: auth --- */
.topbar-right { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; justify-content: flex-end; }
.whoami { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.whoami-name { font-family: sans-serif; font-size: 0.85rem; color: var(--ink); white-space: nowrap; }
.logout-btn { padding: 0.2rem 0.2rem; white-space: nowrap; }

.admin-group { display: flex; align-items: center; gap: 0.5rem; }
.campaign-chip {
  font-family: sans-serif; font-size: 0.85rem; color: var(--muted);
  text-decoration: none; white-space: nowrap;
  padding: 0.25rem 0.7rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel-2);
}
.campaign-chip:hover { border-color: var(--accent); color: var(--accent); }
.campaign-chip.active { color: var(--ink); border-color: var(--accent); }
.active-badge { color: #8fd0a0; border-color: #3f6b4c; }
.campaign-list .user-row { gap: 0.5rem; }

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 2rem;
}
.auth-brand { font-size: 1.3rem; margin-bottom: 1.25rem; }
.auth-card h1 { margin: 0 0 0.5rem; font-size: 1.4rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.25rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.3rem; font-family: sans-serif; font-size: 0.85rem; color: var(--muted); }
.auth-form input {
  font: inherit; padding: 0.55rem 0.7rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
.auth-form input:focus { outline: none; border-color: var(--accent-2); }
.auth-form .btn { margin-top: 0.3rem; }
.auth-alt { margin-top: 1.25rem; font-size: 0.85rem; }

/* Users admin */
.signup-code { margin-bottom: 1.75rem; }
.signup-code h2, .users-heading { color: var(--accent-2); font-size: 1.1rem; }
.code-form input {
  font: inherit; padding: 0.45rem 0.6rem; min-width: 14rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
.user-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.user-row {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.7rem 0.9rem; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px;
}
.user-head { display: flex; align-items: center; gap: 0.5rem; min-width: 12rem; }
.user-name { font-weight: bold; }
.assign-form { display: flex; align-items: center; gap: 0.4rem; }
.assign-form select, .user-manage-body input {
  font: inherit; padding: 0.3rem 0.45rem;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 5px;
}
.assigned-to { font-family: sans-serif; font-size: 0.85rem; white-space: nowrap; }
.user-manage { margin-left: auto; }
.user-manage-body { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.5rem; align-items: center; }

/* --- World narrative layer: locations & factions (Phase 9a) --------------- */
.entity-form { max-width: 46rem; }
.entity-form .radio-row { display: flex; gap: 1.25rem; flex-wrap: wrap; padding-top: 0.15rem; }
.entity-form .radio { display: inline-flex; align-items: center; gap: 0.35rem; font-family: sans-serif; font-size: 0.9rem; }
.entity-form .radio input { width: auto; }
.breadcrumb { font-size: 0.85rem; margin: 0 0 0.25rem; }
.breadcrumb a { color: var(--muted); }
.sheet-section { margin: 1.5rem 0; }
.sheet-section > h2 { font-size: 1rem; margin-bottom: 0.6rem; }
.prose { white-space: pre-wrap; line-height: 1.55; max-width: 46rem; }

/* --- Known Entities sidebar nav (NPCs / locations / factions) ------------- */
.entity-nav { display: flex; flex-direction: column; gap: 1rem; }
.entity-group-head {
  display: flex; align-items: center; gap: 0.35rem;
  margin-bottom: 0.3rem;
}
.entity-toggle {
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--muted); font-size: 0.7rem; line-height: 1;
  width: 1rem; text-align: center; transition: transform 0.12s ease;
}
.entity-toggle:hover { color: var(--accent-2); }
.entity-group.collapsed .entity-toggle { transform: rotate(-90deg); }
.entity-group.collapsed .entity-group-body { display: none; }
.entity-group-link {
  font-family: sans-serif; font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
.entity-group-link:hover, .entity-group-link.active { color: var(--accent-2); }
.entity-count {
  font-family: sans-serif; font-size: 0.68rem; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.02rem 0.4rem; line-height: 1.4;
}
.entity-add {
  margin-left: auto;
  font-size: 1rem; line-height: 1; color: var(--muted); padding: 0 0.35rem;
  border: 1px solid var(--border); border-radius: 5px;
}
.entity-add:hover { color: var(--accent-2); border-color: var(--accent-2); }
.entity-list { list-style: none; margin: 0; padding: 0; }
.entity-list li { margin: 0; }
.entity-list a {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.22rem 0.3rem; border-radius: 5px; color: var(--ink);
  font-size: 0.92rem;
}
.entity-list a:hover { background: var(--bg); color: var(--accent-2); }
.entity-list .ent-icon { font-size: 0.85rem; opacity: 0.85; }
.entity-list .ent-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-list .ent-hidden { font-size: 0.8rem; opacity: 0.7; }
.entity-empty { color: var(--muted); font-size: 0.85rem; font-style: italic; margin: 0.1rem 0 0; }

/* --- Campaign journal (Phase 9b) ----------------------------------------- */
.note-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.note-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
.note-row:hover { border-color: var(--accent-2); }
.note-row-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.note-row-title { font-weight: 600; }
.note-row-snip { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46rem; }
.note-row-meta { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; font-size: 0.85rem; }
.vis-badge {
  font-family: sans-serif; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; padding: 0.08rem 0.45rem; border-radius: 999px;
}
.vis-private { background: rgba(150,150,150,0.18); color: var(--muted); border: 1px solid var(--border); }
.vis-shared { background: rgba(90,170,110,0.18); color: #8fcf9e; border: 1px solid rgba(90,170,110,0.4); }

/* --- Journal: toolbar (search / filter / sort) + nicer cards & rows ------- */
.journal-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  margin: 0.5rem 0 1rem;
}
.journal-search {
  flex: 1 1 14rem; min-width: 10rem; font: inherit; padding: 0.4rem 0.6rem;
  background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 6px;
}
.journal-sort { font-family: sans-serif; font-size: 0.8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.journal-sort select {
  font: inherit; padding: 0.32rem 0.5rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
}
.journal-empty { margin-top: 0.75rem; }

/* Folder cards */
.folder-card { display: flex; flex-direction: column; gap: 0.45rem; }
.folder-card .char-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.folder-count {
  flex: none; font-family: sans-serif; font-size: 0.72rem; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 0.02rem 0.5rem;
}
.folder-desc { font-size: 0.85rem; line-height: 1.35; }
.folder-foot { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.75rem; margin-top: auto; }

/* Note rows: a third sub-line for author + updated time */
.note-item { list-style: none; }
.note-row-sub { font-size: 0.74rem; }
.note-row-meta { flex-direction: column; align-items: flex-end; }

/* --- Journal entity mentions (Phase 9b) ---------------------------------- */
.mention-picker { display: flex; flex-wrap: wrap; gap: 1rem; }
.mention-group {
  flex: 1 1 12rem; min-width: 11rem; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.75rem; max-height: 14rem; overflow-y: auto;
}
.mention-group-label {
  display: block; font-family: sans-serif; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  margin-bottom: 0.4rem;
}
.mention-opt { display: flex; align-items: center; gap: 0.45rem; padding: 0.15rem 0; font-size: 0.92rem; }
.mention-opt input { width: auto; }
.mention-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.mention-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.65rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel); color: var(--ink); font-size: 0.9rem;
}
.mention-chip:hover { border-color: var(--accent-2); color: var(--accent-2); }
.mentioned-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.mentioned-list li { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; }

/* --- Quest / objective log (Phase 9c) ------------------------------------ */
.quest-status {
  font-family: sans-serif; font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; padding: 0.08rem 0.5rem; border-radius: 999px;
}
.quest-status-active    { background: rgba(210,170,70,0.18);  color: #e0c068; border: 1px solid rgba(210,170,70,0.4); }
.quest-status-completed { background: rgba(90,170,110,0.18);  color: #8fcf9e; border: 1px solid rgba(90,170,110,0.4); }
.quest-status-failed    { background: rgba(190,80,80,0.18);   color: #db8a8a; border: 1px solid rgba(190,80,80,0.4); }
.quest-card.quest-completed, .quest-card.quest-failed { opacity: 0.85; }

.obj-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.obj-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--panel);
}
.obj-ico { width: 1.1rem; text-align: center; font-weight: 700; flex-shrink: 0; }
.obj-desc { flex: 1; min-width: 0; }
.obj-done .obj-ico { color: #8fcf9e; }
.obj-done .obj-desc { text-decoration: line-through; color: var(--muted); }
.obj-failed .obj-ico { color: #db8a8a; }
.obj-failed .obj-desc { text-decoration: line-through; color: var(--muted); }
.obj-hidden { border-style: dashed; opacity: 0.75; }
.obj-hidden-tag { flex-shrink: 0; }
.obj-actions { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }
.obj-actions select { font: inherit; padding: 0.15rem 0.3rem; background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 5px; }
.btn-icon { background: none; border: 1px solid transparent; cursor: pointer; font-size: 0.95rem; line-height: 1; padding: 0.2rem 0.35rem; border-radius: 5px; color: var(--muted); }
.btn-icon:hover { border-color: var(--border); color: var(--ink); }
.obj-edit { position: relative; }
.obj-edit summary { list-style: none; cursor: pointer; padding: 0.2rem 0.35rem; border-radius: 5px; }
.obj-edit summary::-webkit-details-marker { display: none; }
.obj-edit summary:hover { background: var(--bg); }
.obj-edit-form { display: flex; gap: 0.4rem; margin-top: 0.4rem; }
.obj-edit-form input { font: inherit; flex: 1; padding: 0.3rem 0.45rem; background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 5px; }
.obj-add { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.obj-add input[type=text] { flex: 1; min-width: 14rem; font: inherit; padding: 0.4rem 0.55rem; background: var(--bg); color: var(--ink); border: 1px solid var(--border); border-radius: 6px; }
.obj-add-hidden { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); font-family: sans-serif; }
.obj-add-hidden input { width: auto; }
