/* ============================================================
   D&D 5e Character Sheet — style.css
   ============================================================ */

/* ---------- Google Font import fallback handled by HTML ---------- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=IM+Fell+English&display=swap');

/* ---------- CSS Custom Properties (Light Mode) ----------
   These variables are the base theme. The body.dark-mode selector
   below overrides them all to provide the dark theme. */
:root {
  --bg-page:      #050505;
  --bg-section:   #0d0d0f;
  --bg-header:    #000000;
  --bg-input:     #151518;
  --bg-table-alt: #111114;
  --bg-ability:   #09090b;

  --text-primary: #f2f2f2;
  --text-heading: #ff004f;
  --text-inverse: #ffffff;
  --text-muted:   #a8a8a8;
  --text-mod:     #ff4f86;

  --border-dark:   #ff004f;
  --border-medium: #8f173d;
  --border-light:  #3a0a1a;

  --accent-red:   #ff004f;
  --accent-green: #36d17c;
  --accent-gold:  #ff004f;

  --shadow:       rgba(0, 0, 0, 0.75);
  --shadow-inset: rgba(0, 0, 0, 0.5);

  --font-heading: 'Cinzel', 'Georgia', serif;
  --font-body:    'IM Fell English', 'Georgia', serif;

  --radius:       6px;
  --radius-lg:    10px;
  --transition:   0.2s ease;
}

body.dark-mode {
  --bg-page:      #050505;
  --bg-section:   #0d0d0f;
  --bg-header:    #000000;
  --bg-input:     #151518;
  --bg-table-alt: #111114;
  --bg-ability:   #09090b;

  --text-primary: #f2f2f2;
  --text-heading: #ff004f;
  --text-inverse: #ffffff;
  --text-muted:   #a8a8a8;
  --text-mod:     #ff4f86;

  --border-dark:   #ff004f;
  --border-medium: #8f173d;
  --border-light:  #3a0a1a;

  --accent-red:   #ff004f;
  --accent-green: #36d17c;
  --accent-gold:  #ff004f;

  --shadow:       rgba(0, 0, 0, 0.75);
  --shadow-inset: rgba(0, 0, 0, 0.5);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--bg-header);
  border-bottom: 3px solid var(--accent-gold);
  flex-wrap: wrap;
}

.toolbar-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--accent-gold);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}

.action-btn {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  background: #5c3010;
  color: #f5efe0;
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}

.action-btn:hover { background: var(--accent-gold); color: #1a0a00; }

/* ---------- Sheet Container ---------- */
.sheet-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
}

/* ---------- Pages ---------- */
.page { display: block; }

/* ---------- Sections ---------- */
.section {
  background: var(--bg-section);
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.6rem;
  box-shadow: 0 2px 6px var(--shadow);
  transition: background var(--transition), border-color var(--transition);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-medium);
  margin-bottom: 0.5rem;
  padding-bottom: 0.2rem;
}

/* ---------- Header Section ---------- */
.header-section { margin-bottom: 0.6rem; }

.header-grid {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1.2fr 1.3fr 1.3fr 0.6fr 1fr;
  gap: 0.5rem;
  align-items: end;
}

.header-grid .span-2 { grid-column: span 2; }

/* ---------- Field Groups ---------- */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-group label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-group.narrow input { max-width: 70px; }

/* ---------- Inputs, Selects, Textareas ---------- */
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  transition: border-color var(--transition), background var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(200, 151, 26, 0.25);
}

.large-input { font-size: 1rem; font-weight: 600; }

textarea { resize: vertical; line-height: 1.5; }
.large-textarea { min-height: 120px; }

select option { background: var(--bg-input); color: var(--text-primary); }

/* ---------- Combat Section ---------- */
.combat-section { margin-bottom: 0.6rem; }

.combat-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}

.combat-box {
  flex: 1;
  min-width: 100px;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius);
  padding: 0.4rem 0.5rem;
  text-align: center;
  background: var(--bg-section);
}

.combat-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.combat-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  width: 100%;
  text-align: center;
  border: none;
  background: transparent;
}

input.combat-value {
  border-bottom: 1px solid var(--border-medium);
}

.combat-value-input {
  font-size: 0.9rem;
  text-align: center;
}

.combat-value.read-only {
  border: none;
  background: none;
  cursor: default;
  font-size: 1.5rem;
  display: block;
  padding: 0.1rem 0;
}

/* Hit Points */
.hp-box { flex: 2; min-width: 200px; }
.hd-box { flex: 1.5; min-width: 160px; }
.death-box { flex: 2; min-width: 200px; }

.hp-row { display: flex; gap: 0.4rem; justify-content: center; }

.hp-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hp-field label {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hp-field input { width: 70px; text-align: center; font-size: 1rem; }

/* Death Saves */
.death-saves { display: flex; flex-direction: column; gap: 0.3rem; }
.death-row { display: flex; align-items: center; gap: 0.4rem; justify-content: center; }
.death-label { font-family: var(--font-heading); font-size: 0.6rem; text-transform: uppercase; min-width: 58px; text-align: right; }
.death-label.success { color: var(--accent-green); }
.death-label.failure { color: var(--accent-red); }
.death-checks { display: flex; gap: 0.3rem; }

/* Shield checkbox */
.shield-box { flex: 0 0 70px; min-width: 70px; }

/* ---------- Main Columns ---------- */
.main-columns {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0.6rem;
  align-items: start;
}

/* ---------- Proficiency Bonus ---------- */
.prof-section { text-align: center; }

.prof-circle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid var(--border-dark);
  background: var(--bg-ability);
  color: var(--text-inverse);
  margin: 0 auto;
}

.prof-label {
  font-family: var(--font-heading);
  font-size: 0.52rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-gold);
  text-align: center;
  line-height: 1.2;
}

.prof-value {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  margin-top: 2px;
}

/* ---------- Ability Blocks ---------- */
.abilities-section { padding: 0.4rem; }

.ability-block {
  border: 2px solid var(--border-dark);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  overflow: hidden;
}

.ability-header {
  background: var(--bg-ability);
  padding: 0.2rem 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.ability-name {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.05em;
}

.ability-full {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  color: #c8b090;
  text-transform: uppercase;
}

.ability-body { padding: 0.4rem 0.5rem; }

.score-mod-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

.score-col, .mod-col, .save-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-col label, .mod-col label, .save-col label {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.score-col input { width: 52px; text-align: center; font-size: 1rem; font-weight: 600; }

.mod-display {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-mod);
  width: 52px;
  text-align: center;
  border-bottom: 1px solid var(--border-medium);
  padding: 0.1rem 0;
}

.save-row { display: flex; align-items: center; gap: 0.3rem; }
.save-mod {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-mod);
}

/* Skills */
.skills-list { display: flex; flex-direction: column; gap: 2px; }

.skill-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.skill-mod {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-mod);
  min-width: 28px;
  text-align: right;
}

.skill-name {
  font-size: 0.78rem;
  color: var(--text-primary);
}

/* ---------- Checkboxes ---------- */
.checkbox-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.checkbox-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.check-mark {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-dark);
  border-radius: 3px;
  background: var(--bg-input);
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.check-mark.small { width: 13px; height: 13px; }
.check-mark.fail { border-color: var(--accent-red); }

.checkbox-label input[type="checkbox"]:checked + .check-mark {
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.checkbox-label input[type="checkbox"]:checked + .check-mark::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.check-mark.small::after { left: 2px; top: 0; width: 4px; height: 7px; }

.checkbox-label input[type="checkbox"]:checked + .check-mark.fail {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

.inline-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.inline-check-label input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Large checkbox */
.large-check .check-mark { width: 28px; height: 28px; border-radius: 4px; }
.large-check .check-mark::after { left: 7px !important; top: 2px !important; width: 8px !important; height: 14px !important; }

/* Expertise visual indicator — gold background for double-proficiency skills */
.check-mark.expertise {
  background: var(--accent-gold) !important;
  border-color: var(--accent-gold) !important;
}

.check-mark.expertise::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 0;
  width: 4px;
  height: 7px;
  border: 2px solid #1a0a00;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ---------- Heroic Inspiration ---------- */
.inspiration-section { text-align: center; }

/* ---------- Proficiencies ---------- */
.armor-training {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.sub-label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.mt-sm { margin-top: 0.4rem; }

/* ---------- Secondary Combat Stats ---------- */
.secondary-combat-grid {
  display: grid;
  grid-template-columns: 80px 1fr 120px 130px;
  gap: 0.5rem;
  align-items: start;
}

.speed-box { }
.speed-fields {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
}

.speed-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.speed-field label {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.speed-field input { width: 55px; text-align: center; }

/* ---------- Two-col section ---------- */
.two-col-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.two-col-section .section { margin-bottom: 0; }

/* ---------- Tables ---------- */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border-medium);
  font-size: 0.82rem;
  vertical-align: middle;
}

th {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-ability);
  color: var(--accent-gold);
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: var(--bg-table-alt); }

tbody td input[type="text"],
tbody td input[type="number"] {
  border: none;
  background: transparent;
  padding: 0.1rem 0.2rem;
  font-size: 0.82rem;
  width: 100%;
}

/* Weapons table */
.weapons-table th:nth-child(1) { width: 25%; }
.weapons-table th:nth-child(2) { width: 18%; }
.weapons-table th:nth-child(3) { width: 25%; }
.weapons-table th:nth-child(4) { width: 32%; }

/* Spell slots table */
.spell-slots-table { max-width: 400px; }
.spell-slots-table td { text-align: center; }

/* Diamond-style expended cells */
.spell-slots-table .level-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-heading);
  font-weight: 600;
}

.slot-diamonds {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.slot-diamond {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-dark);
  transform: rotate(45deg);
  background: var(--bg-input);
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.slot-diamond.expended {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

/* Spells table */
.spells-wrapper { max-height: 500px; overflow-y: auto; }
.spells-table th:nth-child(1) { width: 5%; }
.spells-table th:nth-child(2) { width: 22%; }
.spells-table th:nth-child(3) { width: 14%; }
.spells-table th:nth-child(4) { width: 10%; }
.spells-table th:nth-child(5),
.spells-table th:nth-child(6),
.spells-table th:nth-child(7) { width: 5%; }
.spells-table th:nth-child(8) { width: auto; }

/* Tracker table */
.tracker-table { width: 100%; }
.tracker-table td { padding: 0.3rem 0.5rem; }
.tracker-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  text-transform: uppercase;
  white-space: nowrap;
  width: 80px;
}

/* ---------- Page Layout ---------- */
.page-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  align-items: start;
}

.page-col { display: flex; flex-direction: column; gap: 0.6rem; }
.page-col .section { margin-bottom: 0; }

/* ---------- Sanity / Honor ---------- */
.sanity-honor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.sanity-honor-box { border: 1px solid var(--border-medium); border-radius: var(--radius); padding: 0.4rem; }
.sanity-honor-box h4 {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--text-heading);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.score-mod-pair {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.score-mod-pair > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.score-mod-pair label {
  font-family: var(--font-heading);
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.score-mod-pair input { width: 60px; text-align: center; }

/* ---------- Page 3: Spellcasting ---------- */
.spell-col { }
.details-col { }

.spell-header-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
}

.field-row {
  display: flex;
  gap: 0.5rem;
}

/* ---------- Attunement ---------- */
.attunement-section {
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-medium);
  padding-top: 0.4rem;
}

.attunement-section h4 {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  color: var(--text-heading);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.attunement-slots { display: flex; flex-direction: column; gap: 0.3rem; }

.attune-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: default;
}

.attune-row input[type="text"] { flex: 1; }

/* ---------- Coins ---------- */
.coins-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.coin-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 60px;
}

.coin-field label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
}

.coin-field input { text-align: center; }

.cp label { background: #7a6a5a; }
.sp label { background: #8a8a9a; }
.ep label { background: #9a8a60; }
.gp label { background: #b8980a; }
.pp label { background: #7a5ab8; }

/* ---------- Notes Page ---------- */
.notes-section { height: calc(100vh - 140px); display: flex; flex-direction: column; }
.notes-textarea {
  flex: 1;
  resize: none;
  min-height: 500px;
  font-size: 0.95rem;
}

/* ---------- Spellcasting page column widths ---------- */
.page-columns.spells-page { grid-template-columns: 3fr 2fr; }
#page3 .page-columns { grid-template-columns: 3fr 2fr; }

/* ---------- Print Styles ---------- */
@media print {
  .toolbar { display: none !important; }
  body { background: white; }

  .page { display: block !important; }

  .sheet-container { max-width: 100%; padding: 0.5cm; }

  .section {
    border: 1px solid #999;
    box-shadow: none;
    break-inside: avoid;
  }

  input, select, textarea {
    border: none;
    border-bottom: 1px solid #999;
    background: transparent;
    color: #000;
  }

  .mod-display, .combat-value, .save-mod, .skill-mod, .prof-value {
    color: #000;
  }

  .toolbar-actions { display: none; }
  .two-col-section { grid-template-columns: 1fr 1fr; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .main-columns { grid-template-columns: 1fr; }
  .header-grid { grid-template-columns: 1fr 1fr; }
  .header-grid .span-2 { grid-column: span 2; }
  .secondary-combat-grid { grid-template-columns: 1fr 1fr; }
  .page-columns { grid-template-columns: 1fr; }
  #page3 .page-columns { grid-template-columns: 1fr; }
  .spell-header-grid { grid-template-columns: 1fr 1fr; }
  .two-col-section { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .toolbar { flex-direction: column; align-items: flex-start; }
  .toolbar-actions { margin-left: 0; }
  html { font-size: 13px; }
  .combat-grid { flex-direction: column; }
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); }

/* ---------- Focus Visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* ---------- Flex grow helper ---------- */
.flex-grow { flex: 1; }

/* ---------- Weapon section small tweak ---------- */
.weapons-section .table-wrapper { overflow-x: auto; }
/* ============================================================
   DICE ROLLER — Styles
   Append this to style.css
   ============================================================ */

/* ---------- Floating Action Button ---------- */
.dice-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent-gold);
  background: var(--bg-header);
  color: var(--accent-gold);
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.dice-fab:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 20px var(--shadow);
  background: var(--accent-gold);
  color: var(--bg-header);
}

/* ---------- Overlay & Panel ---------- */
.dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.35);
  animation: diceOverlayIn 0.2s ease;
}

.dice-overlay.hidden {
  display: none;
}

@keyframes diceOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dice-panel {
  width: 360px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-section);
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: dicePanelSlide 0.25s ease;
}

@keyframes dicePanelSlide {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- Panel Header ---------- */
.dice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dice-panel-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text-heading);
  letter-spacing: 0.05em;
  margin: 0;
}

.dice-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
  transition: color var(--transition);
}

.dice-close-btn:hover {
  color: var(--accent-red);
}

/* ---------- Quick-Roll Buttons ---------- */
.dice-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dice-quick-btn {
  flex: 1 1 auto;
  min-width: 40px;
  padding: 0.45rem 0.35rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-inverse);
  background: var(--bg-header);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), transform 0.1s ease;
}

.dice-quick-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-header);
}

.dice-quick-btn:active {
  transform: scale(0.93);
}

/* ---------- Advantage / Disadvantage ---------- */
.dice-adv-row {
  display: flex;
  gap: 0.4rem;
}

.dice-adv-btn {
  flex: 1;
  padding: 0.4rem 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--accent-green);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  background: var(--accent-green);
  color: #fff;
  transition: opacity var(--transition), transform 0.1s ease;
}

.dice-adv-btn:hover { opacity: 0.85; }
.dice-adv-btn:active { transform: scale(0.95); }

.dice-adv-btn--disadv {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

/* ---------- Custom Input ---------- */
.dice-custom-row {
  display: flex;
  gap: 0.4rem;
}

.dice-custom-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}

.dice-custom-input::placeholder {
  color: var(--text-muted);
}

.dice-custom-input:focus {
  border-color: var(--accent-gold);
}

.dice-roll-btn {
  padding: 0.4rem 0.9rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--accent-gold);
  color: var(--bg-header);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity var(--transition);
}

.dice-roll-btn:hover { opacity: 0.85; }

/* ---------- Result Display ---------- */
.dice-result {
  text-align: center;
  padding: 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  transition: background var(--transition);
}

.dice-result.hidden { display: none; }

.dice-result-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.dice-result-individual {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.dice-result-individual .die-val {
  display: inline-block;
  min-width: 1.5em;
  margin: 0.1rem;
  padding: 0.15rem 0.35rem;
  background: var(--bg-section);
  border: 1px solid var(--border-medium);
  border-radius: 3px;
  font-weight: 600;
  text-align: center;
}

.dice-result-individual .die-val--dropped {
  opacity: 0.4;
  text-decoration: line-through;
}

.dice-result-individual .die-val--crit {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.dice-result-individual .die-val--fumble {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.dice-result-total {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

/* Rolling animation */
.dice-result-total.rolling {
  animation: diceFlicker 0.08s steps(1) infinite;
}

@keyframes diceFlicker {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

/* ---------- History ---------- */
.dice-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dice-history-title {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dice-clear-btn {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  padding: 0.2rem 0.5rem;
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.dice-clear-btn:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.dice-history-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0;
  margin: 0;
}

.dice-history-list:empty::after {
  content: 'No rolls yet — give it a try!';
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

.dice-history-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.3rem 0.4rem;
  background: var(--bg-input);
  border-radius: 4px;
  font-size: 0.78rem;
  line-height: 1.3;
  border: 1px solid var(--border-light);
}

.dice-history-time {
  color: var(--text-muted);
  font-size: 0.68rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.dice-history-notation {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.dice-history-result {
  color: var(--text-primary);
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Print: Hide the dice roller ---------- */
@media print {
  .dice-fab,
  .dice-overlay {
    display: none !important;
  }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .dice-panel {
    width: 100%;
    max-height: 80vh;
  }

  .dice-fab {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }
}



/* ---------- Exhaustion Feature ---------- */
/* ---------- Exhaustion Tracker ---------- */
.exhaustion-section {
  padding: 0.6rem 0.8rem;
}

.exhaustion-levels {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exhaustion-level {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  background: var(--bg-input);
}

.exhaustion-level:hover {
  border-color: var(--border-medium);
  background: var(--bg-section);
}

.exhaustion-level input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.exhaustion-mark {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-dark);
  border-radius: 3px;
  background: var(--bg-input);
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.exhaustion-level input:checked + .exhaustion-mark {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

.exhaustion-level input:checked + .exhaustion-mark::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.exhaustion-num {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-heading);
  min-width: 18px;
  text-align: center;
}

.exhaustion-effect {
  font-size: 0.78rem;
  color: var(--text-primary);
}

/* Severity escalation colors when checked */
.exhaustion-level.level-1 input:checked ~ .exhaustion-effect { color: #b8860b; }
.exhaustion-level.level-2 input:checked ~ .exhaustion-effect { color: #cc6600; }
.exhaustion-level.level-3 input:checked ~ .exhaustion-effect { color: #cc3300; }
.exhaustion-level.level-4 input:checked ~ .exhaustion-effect { color: #aa1100; }
.exhaustion-level.level-5 input:checked ~ .exhaustion-effect { color: #880000; font-weight: 600; }
.exhaustion-level.level-6 input:checked ~ .exhaustion-effect { color: #660000; font-weight: 700; }

.exhaustion-level.level-1 input:checked ~ .exhaustion-num { color: #b8860b; }
.exhaustion-level.level-2 input:checked ~ .exhaustion-num { color: #cc6600; }
.exhaustion-level.level-3 input:checked ~ .exhaustion-num { color: #cc3300; }
.exhaustion-level.level-4 input:checked ~ .exhaustion-num { color: #aa1100; }
.exhaustion-level.level-5 input:checked ~ .exhaustion-num { color: #880000; }
.exhaustion-level.level-6 input:checked ~ .exhaustion-num { color: #660000; }

/* Checked row background escalation */
.exhaustion-level.level-1:has(input:checked) { background: rgba(184,134,11,0.08); border-color: #b8860b; }
.exhaustion-level.level-2:has(input:checked) { background: rgba(204,102,0,0.10); border-color: #cc6600; }
.exhaustion-level.level-3:has(input:checked) { background: rgba(204,51,0,0.12); border-color: #cc3300; }
.exhaustion-level.level-4:has(input:checked) { background: rgba(170,17,0,0.14); border-color: #aa1100; }
.exhaustion-level.level-5:has(input:checked) { background: rgba(136,0,0,0.16); border-color: #880000; }
.exhaustion-level.level-6:has(input:checked) {
  background: rgba(102,0,0,0.20);
  border-color: #660000;
  box-shadow: 0 0 8px rgba(139,26,26,0.4);
}


/* ---------- Conditions Feature ---------- */
/* ---------- Conditions Panel ---------- */
.conditions-section {
  padding: 0.6rem 0.8rem;
}

.conditions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.condition-toggle {
  cursor: pointer;
  position: relative;
}

.condition-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.condition-btn {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

.condition-btn:hover {
  border-color: var(--accent-gold);
  background: var(--bg-section);
}

/* Active / toggled-on state */
.condition-toggle input:checked + .condition-btn {
  background: var(--accent-red);
  color: #fff;
  border-color: var(--accent-red);
  box-shadow: 0 0 8px rgba(139, 26, 26, 0.45), 0 0 2px rgba(139, 26, 26, 0.25);
  font-weight: 600;
}

/* Exhaustion link variant */
.condition-exhaustion-link .condition-btn {
  border-style: dashed;
}

.condition-exhaustion-link input:checked + .condition-btn {
  background: #b8860b;
  border-color: #b8860b;
  border-style: solid;
  box-shadow: 0 0 8px rgba(184, 134, 11, 0.45);
}

/* Subtle pulse animation for active severe conditions */
@keyframes conditionPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(139, 26, 26, 0.3); }
  50% { box-shadow: 0 0 12px rgba(139, 26, 26, 0.6); }
}

.condition-toggle input:checked + .condition-btn {
  animation: conditionPulse 2.5s ease-in-out infinite;
}

/* Dark mode adjustments */
body.dark-mode .condition-toggle input:checked + .condition-btn {
  box-shadow: 0 0 10px rgba(200, 50, 50, 0.5), 0 0 3px rgba(200, 50, 50, 0.3);
}


/* ---------- Xp Feature ---------- */
/* ---------- XP Progress Bar ---------- */
.xp-progress-section {
  padding: 0.6rem 0.8rem;
}

.xp-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.4rem;
}

.xp-level-label {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-heading);
}

.xp-values {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.xp-bar-track {
  position: relative;
  width: 100%;
  height: 22px;
  background: var(--bg-input);
  border: 2px solid var(--border-dark);
  border-radius: 11px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  border-radius: 9px;
  background: linear-gradient(90deg, #8b6914, #c8971a, #e8b830, #c8971a);
  background-size: 200% 100%;
  animation: xpShimmer 3s ease-in-out infinite;
  transition: width 0.5s ease;
  min-width: 0;
}

@keyframes xpShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.xp-bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-heading);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 3px var(--bg-section);
  pointer-events: none;
}

.xp-milestone-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.xp-prev-label,
.xp-next-label {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* Level 20 max — full gold glow */
.xp-bar-fill.maxed {
  background: linear-gradient(90deg, #c8971a, #ffd700, #c8971a);
  box-shadow: 0 0 10px rgba(200, 151, 26, 0.6);
}


/* ---------- Portrait Feature ---------- */
/* ---------- Character Portrait ---------- */
.portrait-section {
  padding: 0.6rem 0.8rem;
  text-align: center;
}

.portrait-frame {
  width: 140px;
  height: 140px;
  margin: 0.5rem auto;
  border-radius: 50%;
  border: 4px solid var(--border-dark);
  box-shadow:
    0 0 0 3px var(--accent-gold),
    0 0 0 6px var(--border-dark),
    0 4px 12px var(--shadow);
  overflow: hidden;
  background: var(--bg-input);
  position: relative;
}

.portrait-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.portrait-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.portrait-placeholder-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.2rem;
}

.portrait-placeholder-text {
  font-family: var(--font-heading);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.portrait-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 0.5rem;
}

.portrait-upload-btn,
.portrait-clear-btn {
  font-size: 0.7rem !important;
  padding: 0.25rem 0.45rem !important;
  cursor: pointer;
}

/* Hover glow on the frame */
.portrait-frame:hover {
  box-shadow:
    0 0 0 3px var(--accent-gold),
    0 0 0 6px var(--border-dark),
    0 0 15px rgba(200, 151, 26, 0.3);
}


/* ---------- Rest Feature ---------- */
/* ---------- Rest Buttons ---------- */
.rest-section {
  padding: 0.6rem 0.8rem;
}

.rest-buttons {
  display: flex;
  gap: 0.5rem;
}

.rest-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem 0.6rem;
  border: 2px solid var(--border-dark);
  border-radius: var(--radius);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}

.rest-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px var(--shadow);
}

.rest-short {
  border-color: var(--accent-gold);
}

.rest-short:hover {
  background: rgba(200, 151, 26, 0.1);
}

.rest-long {
  border-color: #4a6fa5;
}

.rest-long:hover {
  background: rgba(74, 111, 165, 0.1);
}

.rest-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.rest-label {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-heading);
}

.rest-desc {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
}

/* Active press effect */
.rest-btn:active {
  transform: translateY(0);
  box-shadow: none;
}


/* ---------- Resistances Feature ---------- */
/* ---------- Resistances, Immunities & Vulnerabilities ---------- */
.resistances-section {
  padding: 0.6rem 0.8rem;
}

.resistances-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

.resistances-grid .field-group label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.resistances-grid textarea {
  min-height: 60px;
  font-size: 0.82rem;
}

/* Color-coded labels */
.resistances-grid .field-group:nth-child(1) label { color: var(--accent-green); }
.resistances-grid .field-group:nth-child(2) label { color: var(--accent-gold); }
.resistances-grid .field-group:nth-child(3) label { color: var(--accent-red); }

@media (max-width: 600px) {
  .resistances-grid {
    grid-template-columns: 1fr;
  }
}


/* ---------- Concentration Feature ---------- */
/* ---------- Concentration Tracker ---------- */
.concentration-section {
  padding: 0.6rem 0.8rem;
}

.concentration-widget {
  position: relative;
}

.concentration-inactive {
  text-align: center;
  padding: 0.4rem;
}

.concentration-none-text {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

.concentration-active {
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius);
  padding: 0.5rem;
  background: rgba(200, 151, 26, 0.06);
  animation: concentrationGlow 3s ease-in-out infinite;
}

@keyframes concentrationGlow {
  0%, 100% { box-shadow: 0 0 4px rgba(200, 151, 26, 0.2); }
  50% { box-shadow: 0 0 10px rgba(200, 151, 26, 0.4); }
}

.concentration-info {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
}

.concentration-spell-label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  min-width: 55px;
}

.concentration-spell-input,
.concentration-duration-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
}

.concentration-dismiss {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.3rem;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  background: var(--accent-red);
  color: #fff;
  border: 1px solid var(--accent-red);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.concentration-dismiss:hover {
  background: #a01010;
}

.concentration-start-btn {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.35rem;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  background: var(--bg-input);
  color: var(--text-heading);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.concentration-start-btn:hover {
  background: rgba(200, 151, 26, 0.15);
}

/* Hide start button when active */
.concentration-active:not([style*="display:none"]) ~ .concentration-start-btn {
  display: none;
}


/* ---------- Characters Feature ---------- */
/* ---------- Character Manager Modal ---------- */
.char-mgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.char-mgr-overlay.hidden {
  display: none;
}

.char-mgr-panel {
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  background: var(--bg-section);
  border: 3px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.char-mgr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--bg-ability);
  border-bottom: 2px solid var(--accent-gold);
}

.char-mgr-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--accent-gold);
  font-weight: 700;
}

.char-mgr-close {
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--accent-gold);
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

.char-mgr-close:hover {
  color: #fff;
}

.char-mgr-body {
  padding: 0.6rem 0.8rem;
  overflow-y: auto;
  flex: 1;
}

.char-mgr-actions-top {
  margin-bottom: 0.6rem;
  text-align: center;
}

.char-mgr-empty {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
  font-style: italic;
}

.char-mgr-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 0.4rem;
  background: var(--bg-input);
  transition: border-color var(--transition);
}

.char-mgr-entry:hover {
  border-color: var(--accent-gold);
}

.char-mgr-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.char-mgr-name {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-heading);
}

.char-mgr-meta {
  font-size: 0.7rem;
  color: var(--text-primary);
}

.char-mgr-date {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.char-mgr-entry-actions {
  display: flex;
  gap: 4px;
}

.char-mgr-btn {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  background: var(--bg-section);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.char-mgr-btn:hover {
  border-color: var(--accent-gold);
  background: var(--bg-input);
}

.char-mgr-btn.delete:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.char-mgr-btn.load {
  background: var(--accent-gold);
  color: #1a0a00;
  border-color: var(--accent-gold);
  font-weight: 600;
}

.char-mgr-btn.load:hover {
  background: #e8b830;
}


/* ---------- Inventory Feature ---------- */
/* ---------- Inventory Section ---------- */
.inventory-section {
  padding: 0.6rem 0.8rem;
}

.inventory-summary {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  background: var(--bg-input);
  flex-wrap: wrap;
}

.inv-weight-label {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-primary);
}

.inv-weight-label strong {
  color: var(--text-heading);
  font-size: 0.9rem;
}

.inv-encumbrance {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
}

.inv-normal { color: var(--accent-green); }
.inv-enc { color: #b8860b; background: rgba(184,134,11,0.1); }
.inv-heavy { color: var(--accent-red); background: rgba(139,26,26,0.1); }
.inv-over { color: #fff; background: var(--accent-red); }

.inv-capacity {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.inventory-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.inventory-table th {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-dark);
  padding: 0.3rem 0.4rem;
  text-align: left;
}

.inventory-table td {
  border-bottom: 1px solid var(--border-light);
  padding: 2px 3px;
}

.inventory-table input {
  width: 100%;
  font-size: 0.82rem;
  padding: 0.2rem 0.3rem;
}

.inv-num-input {
  width: 60px !important;
  text-align: center;
}

.inv-col-name { width: 30%; }
.inv-col-qty { width: 10%; text-align: center; }
.inv-col-wt { width: 12%; text-align: center; }
.inv-col-total { width: 12%; text-align: center; }
.inv-col-notes { width: 36%; }

.inv-row-total {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-mod);
  text-align: center;
}

.inventory-table tr:nth-child(even) {
  background: var(--bg-table-alt);
}


/* ---------- Pointbuy Feature ---------- */
/* ---------- Point Buy / Standard Array Modal ---------- */
.pointbuy-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.pointbuy-overlay.hidden {
  display: none;
}

.pointbuy-panel {
  width: 90%;
  max-width: 450px;
  max-height: 85vh;
  background: var(--bg-section);
  border: 3px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pointbuy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background: var(--bg-ability);
  border-bottom: 2px solid var(--accent-gold);
}

.pointbuy-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--accent-gold);
  font-weight: 700;
}

.pointbuy-close {
  font-size: 1.3rem;
  background: none;
  border: none;
  color: var(--accent-gold);
  cursor: pointer;
  padding: 0 0.3rem;
  line-height: 1;
}

.pointbuy-close:hover { color: #fff; }

/* Tabs */
.pointbuy-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-dark);
}

.pointbuy-tab {
  flex: 1;
  padding: 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  text-align: center;
  background: var(--bg-input);
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--transition);
}

.pointbuy-tab:hover { background: var(--bg-section); }

.pointbuy-tab.active {
  background: var(--accent-gold);
  color: #1a0a00;
  font-weight: 700;
}

.pointbuy-content {
  padding: 0.8rem;
  overflow-y: auto;
  flex: 1;
}

.pointbuy-content.hidden { display: none; }

/* Point Buy */
.pb-points-remaining {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  padding: 0.3rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.pb-cost-reference {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
  margin-bottom: 0.6rem;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.pb-cost-title {
  font-family: var(--font-heading);
  font-weight: 600;
  width: 100%;
  text-align: center;
  font-size: 0.6rem;
  text-transform: uppercase;
}

.pb-abilities {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pb-ability-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.pb-ab-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-heading);
  min-width: 38px;
}

.pb-minus, .pb-plus {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-medium);
  border-radius: 50%;
  background: var(--bg-section);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  line-height: 1;
}

.pb-minus:hover, .pb-plus:hover {
  border-color: var(--accent-gold);
  background: rgba(200, 151, 26, 0.15);
}

.pb-ab-score {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-mod);
  min-width: 32px;
  text-align: center;
}

.pb-ab-cost {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.pb-apply-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  justify-content: center;
}

.pb-reset-btn, .pb-apply-btn {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--border-medium);
  transition: all var(--transition);
}

.pb-reset-btn {
  background: var(--bg-input);
  color: var(--text-primary);
}

.pb-reset-btn:hover {
  border-color: var(--accent-gold);
}

.pb-apply-btn {
  background: var(--accent-gold);
  color: #1a0a00;
  border-color: var(--accent-gold);
  font-weight: 700;
}

.pb-apply-btn:hover { background: #e8b830; }
.pb-apply-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Standard Array */
.sa-instructions {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.5rem;
}

.sa-values {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.6rem;
}

.sa-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--accent-gold);
  border-radius: 50%;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-gold);
  background: var(--bg-input);
}

.sa-assignments {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sa-assign-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-input);
}

.sa-ab-name {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-heading);
  min-width: 38px;
}

.sa-select {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.25rem 0.4rem;
}

.sa-status {
  text-align: center;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  margin-top: 0.4rem;
  min-height: 1.2em;
}


/* ---------- Dice Roller ---------- */
/* ============================================================
   DICE ROLLER — Styles
   Append this to style.css
   ============================================================ */

/* ---------- Floating Action Button ---------- */
.dice-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent-gold);
  background: var(--bg-header);
  color: var(--accent-gold);
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.dice-fab:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 20px var(--shadow);
  background: var(--accent-gold);
  color: var(--bg-header);
}

/* ---------- Overlay & Panel ---------- */
.dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.35);
  animation: diceOverlayIn 0.2s ease;
}

.dice-overlay.hidden {
  display: none;
}

@keyframes diceOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.dice-panel {
  width: 360px;
  max-width: 95vw;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-section);
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: dicePanelSlide 0.25s ease;
}

@keyframes dicePanelSlide {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ---------- Panel Header ---------- */
.dice-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dice-panel-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text-heading);
  letter-spacing: 0.05em;
  margin: 0;
}

.dice-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
  transition: color var(--transition);
}

.dice-close-btn:hover {
  color: var(--accent-red);
}

/* ---------- Quick-Roll Buttons ---------- */
.dice-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dice-quick-btn {
  flex: 1 1 auto;
  min-width: 40px;
  padding: 0.45rem 0.35rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-inverse);
  background: var(--bg-header);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: background var(--transition), transform 0.1s ease;
}

.dice-quick-btn:hover {
  background: var(--accent-gold);
  color: var(--bg-header);
}

.dice-quick-btn:active {
  transform: scale(0.93);
}

/* ---------- Advantage / Disadvantage ---------- */
.dice-adv-row {
  display: flex;
  gap: 0.4rem;
}

.dice-adv-btn {
  flex: 1;
  padding: 0.4rem 0.5rem;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--accent-green);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  background: var(--accent-green);
  color: #fff;
  transition: opacity var(--transition), transform 0.1s ease;
}

.dice-adv-btn:hover { opacity: 0.85; }
.dice-adv-btn:active { transform: scale(0.95); }

.dice-adv-btn--disadv {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

/* ---------- Custom Input ---------- */
.dice-custom-row {
  display: flex;
  gap: 0.4rem;
}

.dice-custom-input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--transition);
}

.dice-custom-input::placeholder {
  color: var(--text-muted);
}

.dice-custom-input:focus {
  border-color: var(--accent-gold);
}

.dice-roll-btn {
  padding: 0.4rem 0.9rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--accent-gold);
  color: var(--bg-header);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity var(--transition);
}

.dice-roll-btn:hover { opacity: 0.85; }

/* ---------- Result Display ---------- */
.dice-result {
  text-align: center;
  padding: 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  transition: background var(--transition);
}

.dice-result.hidden { display: none; }

.dice-result-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.dice-result-individual {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.dice-result-individual .die-val {
  display: inline-block;
  min-width: 1.5em;
  margin: 0.1rem;
  padding: 0.15rem 0.35rem;
  background: var(--bg-section);
  border: 1px solid var(--border-medium);
  border-radius: 3px;
  font-weight: 600;
  text-align: center;
}

.dice-result-individual .die-val--dropped {
  opacity: 0.4;
  text-decoration: line-through;
}

.dice-result-individual .die-val--crit {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.dice-result-individual .die-val--fumble {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.dice-result-total {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

/* Rolling animation */
.dice-result-total.rolling {
  animation: diceFlicker 0.08s steps(1) infinite;
}

@keyframes diceFlicker {
  0%   { opacity: 1; }
  50%  { opacity: 0.4; }
  100% { opacity: 1; }
}

/* ---------- History ---------- */
.dice-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dice-history-title {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dice-clear-btn {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  padding: 0.2rem 0.5rem;
  background: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.dice-clear-btn:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.dice-history-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0;
  margin: 0;
}

.dice-history-list:empty::after {
  content: 'No rolls yet — give it a try!';
  display: block;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.5rem 0;
}

.dice-history-item {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.3rem 0.4rem;
  background: var(--bg-input);
  border-radius: 4px;
  font-size: 0.78rem;
  line-height: 1.3;
  border: 1px solid var(--border-light);
}

.dice-history-time {
  color: var(--text-muted);
  font-size: 0.68rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.dice-history-notation {
  color: var(--text-heading);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.dice-history-result {
  color: var(--text-primary);
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Print: Hide the dice roller ---------- */
@media print {
  .dice-fab,
  .dice-overlay {
    display: none !important;
  }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .dice-panel {
    width: 100%;
    max-height: 80vh;
  }

  .dice-fab {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    font-size: 1.3rem;
  }
}

/* ============================================================
   SRD PRESETS — shared layout helpers
   ============================================================ */

/* Inline wrapper for input + preset button side by side */
.input-with-btn {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex: 1;
}
.input-with-btn input {
  flex: 1;
  min-width: 0;
}

/* Small inline preset button (subclass) */
.preset-inline-btn {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  padding: 0.3rem 0.55rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-heading);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.preset-inline-btn:hover {
  background: var(--bg-table-alt);
  border-color: var(--accent-gold);
}

/* Section title row (title + browse button on same line) */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.section-title-row .section-title {
  margin-bottom: 0;
}

/* Section-level browse button (spells, feats) */
.preset-section-btn {
  font-family: var(--font-heading);
  font-size: 0.72rem;
  padding: 0.3rem 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-heading);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition);
}
.preset-section-btn:hover {
  background: var(--bg-table-alt);
  border-color: var(--accent-gold);
}

/* ============================================================
   SRD PRESETS — Subclass popup
   ============================================================ */
.srd-popup {
  position: absolute;
  z-index: 500;
  background: var(--bg-section);
  border: 1px solid var(--border-dark);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 24px var(--shadow);
  min-width: 200px;
  max-width: 280px;
  overflow: hidden;
}
.srd-popup.hidden { display: none; }
.srd-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.45rem 0.7rem;
  background: var(--bg-ability);
  border-bottom: 1px solid var(--border-dark);
}
.srd-popup-title {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  color: var(--text-inverse);
  font-weight: 600;
}
.srd-popup-close {
  background: none;
  border: none;
  color: var(--text-inverse);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
  opacity: 0.8;
}
.srd-popup-close:hover { opacity: 1; }
.srd-popup-list {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.3rem 0;
}
.srd-popup-item {
  font-family: var(--font-body);
  font-size: 0.82rem;
  text-align: left;
  padding: 0.45rem 0.9rem;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition);
}
.srd-popup-item:hover {
  background: var(--bg-table-alt);
  color: var(--text-heading);
}
.srd-popup-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.6rem 0.9rem;
  font-style: italic;
}

/* ============================================================
   SRD PRESETS — shared modal overlay + panel
   ============================================================ */
.srd-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.5rem 1rem 1rem;
  overflow-y: auto;
}
.srd-overlay.hidden { display: none; }
.srd-panel {
  background: var(--bg-section);
  border: 2px solid var(--border-dark);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px var(--shadow);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  max-height: 82vh;
  overflow: hidden;
}
.srd-panel--wide {
  max-width: 720px;
}
.srd-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  background: var(--bg-ability);
  border-bottom: 2px solid var(--border-dark);
  flex-shrink: 0;
}
.srd-panel-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text-inverse);
  margin: 0;
}
.srd-panel-close {
  background: none;
  border: none;
  color: var(--text-inverse);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 0.2rem;
  opacity: 0.8;
  transition: opacity var(--transition);
}
.srd-panel-close:hover { opacity: 1; }

/* Filters row */
.srd-panel-filters {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.srd-search {
  flex: 1 1 160px;
  min-width: 0;
  padding: 0.35rem 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.82rem;
}
.srd-filter-select {
  padding: 0.35rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
}

.srd-browser-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 0.35rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* Scrollable list area */
.srd-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.4rem 0;
}
.srd-list.hidden { display: none; }
.srd-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem;
  text-align: center;
}

/* ============================================================
   SRD PRESETS — Spell rows
   ============================================================ */
.srd-spell-row {
  padding: 0.45rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.srd-spell-row:last-child { border-bottom: none; }
.srd-spell-row:hover { background: var(--bg-table-alt); }

.srd-spell-main {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.srd-spell-lvl {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-inverse);
  background: var(--bg-ability);
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  min-width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}
.srd-spell-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-heading);
}
.srd-spell-school {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
}
.srd-spell-comp {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}
.srd-spell-meta {
  display: flex;
  gap: 0.8rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  flex-wrap: wrap;
}
.srd-tag {
  font-size: 0.65rem;
  font-family: var(--font-heading);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-weight: 600;
  flex-shrink: 0;
}
.srd-tag--conc   { background: #1a4a6a22; color: var(--text-mod); border: 1px solid var(--text-mod); }
.srd-tag--ritual { background: #1a5c1a22; color: var(--accent-green); border: 1px solid var(--accent-green); }
.srd-tag--phb    { background: #4a1a6a22; color: #8b5cf6; border: 1px solid #8b5cf6; }

/* ============================================================
   SRD PRESETS — Feat rows
   ============================================================ */
.srd-feat-row {
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.srd-feat-row:last-child { border-bottom: none; }
.srd-feat-row:hover { background: var(--bg-table-alt); }

.srd-feat-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.15rem;
}
.srd-feat-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ============================================================
   SRD PRESETS — Rules reference cards
   ============================================================ */
.srd-rules-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-dark);
  flex-shrink: 0;
}
.srd-rules-tab {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  padding: 0.55rem 1.1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.srd-rules-tab:hover  { color: var(--text-heading); }
.srd-rules-tab.active { color: var(--accent-gold); border-bottom-color: var(--accent-gold); }

.srd-rule-card {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border-light);
}
.srd-rule-card:last-child { border-bottom: none; }
.srd-rule-name {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 0.2rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.srd-rule-type {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--text-muted);
  font-style: italic;
}
.srd-rule-desc {
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* ============================================================
   MONSTER BROWSER
   ============================================================ */
.monster-row {
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}
.monster-row:last-child { border-bottom: none; }
.monster-row:hover,
.monster-row--open { background: var(--bg-table-alt); }

.monster-row-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.8rem;
  flex-wrap: wrap;
}
.monster-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-heading);
}
.monster-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
  flex: 1;
}

/* Detail stat block (hidden by default) */
.monster-detail {
  padding: 0 0.8rem 0.6rem;
  border-top: 1px dashed var(--border-light);
}
.monster-detail.hidden { display: none; }

.monster-stat-block { font-size: 0.8rem; color: var(--text-primary); }

.monster-sb-type {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0.35rem;
}

.monster-sb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.2rem;
  margin-bottom: 0.4rem;
}
.monster-stat-row {
  display: flex;
  gap: 0.3rem;
}
.monster-stat-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--text-heading);
}
.monster-stat-val {
  font-size: 0.78rem;
  color: var(--text-primary);
}

.monster-sb-abilities {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.monster-sb-ability {
  background: var(--bg-ability);
  color: var(--text-inverse);
  border-radius: var(--radius);
  padding: 0.2rem 0.5rem;
  text-align: center;
  min-width: 2.8rem;
}
.monster-sb-ab-label {
  font-family: var(--font-heading);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.monster-sb-ab-score {
  font-size: 0.82rem;
  font-weight: 600;
}
.monster-sb-ab-mod {
  font-size: 0.65rem;
  opacity: 0.85;
}

.monster-sb-notes {
  font-size: 0.78rem;
  color: var(--text-primary);
  line-height: 1.5;
  margin-top: 0.35rem;
  white-space: pre-wrap;
}

/* ============================================================
   Print: hide SRD modals/popups
   ============================================================ */
@media print {
  .srd-overlay,
  .srd-popup,
  .preset-inline-btn,
  .preset-section-btn { display: none !important; }
}

/* ---------- Drive Sync + Source Manager ---------- */
.drive-panel { max-width: 720px; }
.drive-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: center;
}
.source-manager-heading {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.8rem 0 0.4rem;
  border-bottom: 1px solid var(--border-medium);
  padding-bottom: 0.2rem;
}
.drive-note {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
  margin-top: 0.7rem;
  text-align: center;
}

.vtt-modal {
  width: min(96vw, 1400px);
  height: 90vh;
}

.vtt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}

.vtt-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  height: calc(90vh - 120px);
}

#mapViewport {
  overflow: auto;
  background: #111;
  border: 2px solid var(--accent, #ff004f);
  border-radius: 12px;
}

#mapCanvas {
  position: relative;
  min-width: 900px;
  min-height: 600px;
  transform-origin: top left;
}

#mapImage {
  display: block;
  max-width: none;
  width: 100%;
  user-select: none;
  pointer-events: none;
}

#gridLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.18) 1px, transparent 1px);
  background-size: 50px 50px;
}

#gridLayer.hidden {
  display: none;
}

#tokenLayer {
  position: absolute;
  inset: 0;
}

.vtt-token {
  position: absolute;
  width: 50px;
  height: 50px;
  border-radius: 999px;
  border: 3px solid #ff004f;
  cursor: grab;
  object-fit: cover;
  background: #222;
}

.vtt-token.selected {
  outline: 3px solid white;
}

.combat-panel {
  overflow: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem;
}

.combatant {
  display: grid;
  grid-template-columns: 1fr 54px 36px;
  gap: .35rem;
  align-items: center;
  padding: .4rem;
  border-bottom: 1px solid var(--border);
}

.combatant.active {
  background: rgba(255, 0, 79, .18);
  border-radius: 8px;
}

.system-field {
  display: grid;
  gap: .25rem;
  margin-bottom: .75rem;
}

/* ---------- Source-defined sheet extensions ---------- */
.source-sheet-extensions { display: flex; flex-direction: column; gap: 0.6rem; }
.source-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
}
.source-field textarea { min-height: 72px; }
.source-html-block {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  padding: 0.55rem;
  margin-bottom: 0.5rem;
  background: var(--bg-input);
}
.source-html-block h4 {
  font-family: var(--font-heading);
  color: var(--text-heading);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}
.source-html-block h4 span {
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: none;
  font-weight: 400;
}
.source-html-content {
  color: var(--text-primary);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.source-html-content ul,
.source-html-content ol { margin-left: 1.2rem; }
.source-html-content table { margin-top: 0.4rem; }
.source-ability-block .ability-full { color: var(--text-muted); }
