
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=Crimson+Text:wght@400;600;700&display=swap');

:root {
  --paper: #f5eddb;
  --paper-dark: #e8dcc4;
  --ink: #29231e;
  --muted: #786b5a;
  --red: #8c302b;
  --border: #b6a58b;
  --white: #fffaf0;
  --gold: #d7aa63;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #d5ccbc;
  color: var(--ink);
  font-family: "Crimson Text", Georgia, serif;
  font-size: 17px;
  line-height: 1.45;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

input,
textarea,
select {
  max-width: 100%;
  color: var(--ink);
}

input[type="number"],
input[type="text"],
textarea {
  padding: 6px 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 3px;
}

input[type="checkbox"] {
  accent-color: var(--red);
  cursor: pointer;
}

input:focus-visible,
button:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: #29231e;
  color: var(--paper);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: Cinzel, Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
}

.brand-mark {
  color: var(--gold);
  font-size: 24px;
}

.page-navigation {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 5px;
}

.nav-button,
.print-button {
  padding: 7px 11px;
  border: 1px solid #756657;
  border-radius: 4px;
  color: var(--paper);
  background: transparent;
}

.nav-button:hover,
.nav-button.active {
  background: var(--red);
  border-color: var(--red);
}

.print-button {
  color: #29231e;
  background: var(--gold);
  border-color: var(--gold);
}

.book {
  max-width: 1150px;
  margin: 32px auto;
  padding: 0 18px;
}

.page {
  display: none;
  min-height: 950px;
  padding: 48px;
  background: var(--paper);
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px #0002;
}

.page.active {
  display: block;
}

.eyebrow {
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: Cinzel, Georgia, serif;
}

h1 {
  margin: 10px 0;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.2;
}

h2 {
  margin-top: 32px;
  padding-bottom: 8px;
  color: var(--red);
  border-bottom: 1px solid var(--border);
  font-size: 21px;
}

h3 {
  margin: 8px 0;
  font-size: 15px;
}

p {
  margin-top: 8px;
}

label {
  cursor: pointer;
}

.subtitle,
.placeholder,
.muted-text,
.section-help {
  color: var(--muted);
}

.subtitle {
  font-style: italic;
}

.section-help {
  margin-top: -4px;
  font-style: italic;
}

.profile-art {
  min-height: 360px;
  margin: 28px 0;
  display: grid;
  place-items: center;
  background: var(--paper-dark);
  border: 1px solid var(--border);
  color: var(--muted);
}

.profile-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0 28px;
  border-bottom: 3px double var(--red);
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.character-level {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 20px 0;
}

.character-level input {
  width: 76px;
}

.ability-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.ability-card,
.stat-card {
  position: relative;
  min-width: 0;
  padding: 12px 8px;
  text-align: center;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ability-card h3 {
  min-height: 36px;
}

.ability-card input {
  width: 64px;
  text-align: center;
}

.modifier,
.stat-card output {
  display: block;
  margin-top: 8px;
  color: var(--red);
  font-size: 24px;
  font-weight: 700;
}

.combat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.stat-card h3 {
  min-height: 38px;
  font-size: 13px;
}

.stat-card input[type="number"] {
  width: 78px;
  text-align: center;
  font-size: 20px;
}

.stat-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.option-row input[type="number"] {
  width: 80px;
}

.list-grid,
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
}

.save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

.save-row label,
.skill-row label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-row output,
.skill-row output {
  color: var(--red);
  font-size: 18px;
  font-weight: 700;
}

.skill-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px 22px;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
}

.skill-ability {
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.skill-row output {
  text-align: right;
}

.death-saves {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.death-saves > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.death-saves strong {
  width: 100%;
  font-family: Cinzel, Georgia, serif;
}

.death-saves label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.feature-card {
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 4px;
}

.feature-card h3 {
  color: var(--red);
}

.feature-card p {
  margin-bottom: 0;
}

/* Calculation information buttons and popovers. */

.calculation-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: 5px;
  z-index: 2;
}

.info-button {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--paper);
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.info-button:hover,
.info-button[aria-expanded="true"] {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.info-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: -8px;
  z-index: 50;
  display: block;
  width: 270px;
  max-width: min(82vw, 320px);
  padding: 14px;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px #0003;
  color: var(--ink);
}

.info-popover[hidden] {
  display: none;
}

.info-title {
  display: block;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--red);
  font-family: Cinzel, Georgia, serif;
  font-size: 14px;
}

.info-rows {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 12px;
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.info-rows dt {
  color: var(--muted);
}

.info-rows dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ability-card .calculation-info {
  position: absolute;
  top: 8px;
  right: 6px;
}

.stat-card .calculation-info {
  position: absolute;
  top: 8px;
  right: 6px;
}

.stat-card .info-popover {
  right: -6px;
}

#add-item-button,
#add-entry-button {
  margin-top: 16px;
  padding: 9px 14px;
  border: 1px solid var(--red);
  border-radius: 4px;
  color: var(--red);
  background: transparent;
}

#add-item-button:hover,
#add-entry-button:hover {
  color: var(--white);
  background: var(--red);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .page {
    padding: 30px;
  }

  .combat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ability-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .topbar {
    position: static;
    padding: 12px;
  }

  .page-navigation {
    flex-basis: 100%;
    order: 3;
  }

  .book {
    margin: 16px auto;
    padding: 0 8px;
  }

  .page {
    min-height: 0;
    padding: 22px;
  }

  .two-columns,
  .list-grid,
  .skills-grid,
  .features-grid,
  .death-saves {
    grid-template-columns: 1fr;
  }

  .combat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ability-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .skill-row {
    grid-template-columns: minmax(0, 1fr) 36px 38px 22px;
    gap: 5px;
  }
}

/* Reusable character selection and feature controls */
.character-options { display:flex; flex-wrap:wrap; gap: 1rem; margin: 1rem 0; }
.character-options label { display:flex; flex-direction:column; gap:.35rem; min-width:145px; flex:1; }
.character-options select { padding:.55rem; max-width:100%; }
.feature-toggles { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:.55rem 1rem; margin:1rem 0; }
.feature-toggles label { display:flex; align-items:center; gap:.5rem; }

/* Save controls: small, responsive toolbar alongside navigation. */
.save-controls { display:flex; align-items:center; flex-wrap:wrap; gap:.45rem; }
.save-controls button { padding:.45rem .65rem; cursor:pointer; }
#save-status { font-size:.75rem; opacity:.85; min-width:7rem; }
@media (max-width: 900px) { .save-controls { width:100%; justify-content:center; } }

/* Compact save toolbar. Text remains available to screen readers and as tooltips. */
.save-controls { gap: .3rem; }
.save-controls .save-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 29px;
  height: 29px;
  padding: 0;
  font-family: Arial, sans-serif;
  font-size: 18px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--paper);
  color: var(--red);
  cursor: pointer;
}
.save-controls .save-icon-button:hover,
.save-controls .save-icon-button:focus-visible {
  background: var(--red);
  color: var(--white);
}
#save-status { min-width: 0; margin-right: .3rem; }

/* Calculation panels are moved to document.body when opened.
   This avoids stacking contexts and clipping by adjacent cards/rows. */
.info-popover.info-popover-floating {
  position: fixed;
  z-index: 10000;
  top: 0;
  left: 0;
  right: auto;
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
}

/* Step 8A — Spell reference, using the existing parchment palette. */
.spell-summary { font-family: Cinzel, Georgia, serif; font-size: .85rem; color: var(--red); margin: 12px 0 20px; }
.spell-group { margin: 24px 0 32px; }
.spell-group-heading { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.spell-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 14px; }
.spell-card { display: flex; flex-direction: column; background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 15px 18px; }
.spell-card h3 { margin: 0 0 4px; color: var(--red); }
.spell-card p { margin: 6px 0; }
.spell-card .spell-meta, .spell-meta { font-size: .86rem; color: var(--muted); }
.spell-card > p:not(.spell-meta) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.spell-more { margin-top: auto; align-self: flex-start; padding: 9px 0 0; border: 0; background: transparent; color: var(--red); text-decoration: underline; }
.spell-detail { margin: 10px 0; border: 1px solid var(--border); background: var(--white); border-radius: 5px; }
.spell-detail > summary { cursor: pointer; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 5px 20px; padding: 12px 16px; color: var(--red); }
.spell-detail > summary::marker { color: var(--red); }
.spell-detail[open] > summary { border-bottom: 1px solid var(--border); }
.spell-detail-body { padding: 14px 16px 18px; }
.spell-facts { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr; gap: 5px 14px; margin: 0 0 12px; }
.spell-facts dt { font-weight: bold; }
.spell-facts dd { margin: 0; }

/* Compact, four-column spell reference instead of large spell cards. */
#page-spells .spell-summary { margin: 5px 0 12px; }
#page-spells .spell-quick-group { margin: 12px 0 18px; }
#page-spells .spell-group-heading { margin: 0 0 5px; padding-bottom: 4px; font-size: 1.05rem; }
.spell-table-scroll { width: 100%; overflow-x: auto; }
.spell-quick-table { width: 100%; border-collapse: collapse; font-size: .91rem; line-height: 1.2; }
.spell-quick-table th { text-align: left; color: var(--muted); font-size: .77rem; letter-spacing: .02em; }
.spell-quick-table th, .spell-quick-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.spell-quick-table th:first-child, .spell-quick-table td:first-child { padding-left: 0; min-width: 110px; }
.spell-quick-table td:nth-child(2) { white-space: nowrap; }
.spell-quick-table td:nth-child(3) { min-width: 85px; }
.spell-quick-table td:nth-child(4) { white-space: nowrap; }
.spell-name-link { padding: 0; border: 0; background: none; color: var(--red); font-weight: bold; text-align: left; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.spell-resources, .metamagic-list { margin: 14px 0; }
.spell-resources > h2, .metamagic-list > h2 { margin: 0 0 7px; font-size: 1.12rem; }
.resource-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.resource-name { flex: 1; min-width: 110px; font-weight: 600; }
.resource-status { font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.resource-controls { display: flex; gap: 4px; }
.resource-button { width: 27px; height: 27px; padding: 0; border: 1px solid var(--border); border-radius: 4px; background: var(--white); color: var(--red); font-size: 20px; line-height: 1; }
.resource-button:disabled { opacity: .35; cursor: default; }
.resource-note { margin: 6px 0; font-size: .78rem; color: var(--muted); }
.metamagic-entry { border-bottom: 1px solid var(--border); padding: 6px 0; }
.metamagic-entry summary { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 5px 12px; cursor: pointer; }
.metamagic-entry summary strong { color: var(--red); }
.metamagic-entry summary span { font-size: .84rem; color: var(--muted); }
.metamagic-entry p { margin: 5px 0; font-size: .9rem; }

/* Step 8C: distinct spell sections without sacrificing compact rows. */
#page-spells .spell-summary { margin: 2px 0 13px; }
.spell-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 13px;
  align-items: start;
  margin-bottom: 13px;
}
.spell-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 2px 0 rgba(80, 52, 32, .08);
  overflow: hidden;
}
.spell-panel-resources { border-top: 4px solid var(--red); background: #fff9ed; }
.spell-panel-metamagic { border-top: 4px solid #a37b45; background: #f9f2e4; }
.spell-panel-repertoire { border-top: 4px solid #655748; background: #fffbf4; }
#page-spells .spell-resources,
#page-spells .metamagic-list { margin: 0; padding: 12px 16px 13px; }
#page-spells .spell-resources > h2,
#page-spells .metamagic-list > h2,
#page-spells .spell-panel-heading h2 {
  font-family: Cinzel, Georgia, serif;
  color: var(--red);
  font-size: .99rem;
  margin: 0 0 10px;
}
#page-spells .spell-panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 11px 16px 9px;
  background: #eee1cc;
  border-bottom: 1px solid var(--border);
}
#page-spells .spell-panel-heading h2 { margin: 0; }
.spell-panel-caption { font-size: .8rem; color: var(--muted); }
#page-spells .spell-quick-group { margin: 0; padding: 0 16px 10px; }
#page-spells .spell-quick-group + .spell-quick-group { border-top: 1px solid var(--border); }
#page-spells .spell-group-heading {
  margin: 0 -16px 5px;
  padding: 7px 16px;
  background: #f3e9d8;
  border-bottom: 1px solid #e3d4bc;
  color: #6b4635;
  font-size: .9rem;
}
#page-spells .spell-quick-table tbody tr:nth-child(even) { background: #f8f0e3; }
#page-spells .spell-quick-table tbody tr:hover { background: #f1e2c9; }
#page-spells .spell-quick-table th { padding-top: 5px; padding-bottom: 5px; }
#page-spells .spell-quick-table td { padding-top: 5px; padding-bottom: 5px; }
#page-spells .resource-row:last-of-type,
#page-spells .metamagic-entry:last-of-type { border-bottom: 0; }
#page-spells .resource-button:hover:not(:disabled) { background: var(--paper-dark); }
@media (max-width: 720px) {
  .spell-dashboard { grid-template-columns: minmax(0, 1fr); }
}


/* Step 8D — modern, compact spell rows with clearly separated spell levels. */
#page-spells #spell-list {
  display: grid;
  gap: 16px;
  padding: 15px 16px 18px;
}
#page-spells .spell-level-section {
  border: 1px solid #e0cfb4;
  border-radius: 9px;
  background: #f9f3e8;
  padding: 10px 11px 12px;
  min-width: 0;
}
#page-spells .spell-level-section:nth-child(2) { background: #f8f0e3; }
#page-spells .spell-level-section:nth-child(3) { background: #f6eddf; }
#page-spells .spell-level-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 3px 9px;
  margin-bottom: 8px;
  border-bottom: 1px solid #dcc7a9;
}
#page-spells .spell-level-header h3 {
  margin: 0;
  color: #784a35;
  font-family: Cinzel, Georgia, serif;
  font-size: .96rem;
}
#page-spells .spell-level-header span {
  color: var(--muted);
  font-size: .76rem;
  white-space: nowrap;
}
#page-spells .spell-compact-list { display: grid; gap: 5px; }
#page-spells .spell-compact-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #fffaf2;
  box-shadow: 0 1px 2px rgba(70, 40, 25, .07);
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  min-width: 0;
}
#page-spells .spell-compact-row:hover,
#page-spells .spell-compact-row:focus-visible {
  background: #fff;
  border-color: #d5b48a;
  box-shadow: 0 2px 5px rgba(70, 40, 25, .12);
  outline-offset: 2px;
}
#page-spells .spell-school-symbol {
  flex: 0 0 31px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eee0cd;
  color: #925c41;
  font-size: 19px;
  line-height: 1;
}
#page-spells .spell-row-main { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
#page-spells .spell-row-name { font-weight: 700; color: #673f31; font-size: .91rem; }
#page-spells .spell-row-meta { color: var(--muted); font-size: .76rem; }
#page-spells .spell-row-damage { color: #564639; font-size: .83rem; font-weight: 600; text-align: right; flex: 0 1 auto; }
#page-spells .spell-row-arrow { color: #ab9077; font-size: 24px; line-height: 1; padding-left: 2px; }
@media (max-width: 510px) {
  #page-spells #spell-list { padding: 11px 10px 13px; gap: 12px; }
  #page-spells .spell-level-section { padding: 8px; }
  #page-spells .spell-compact-row { gap: 7px; padding: 7px; }
  #page-spells .spell-school-symbol { flex-basis: 27px; width: 27px; height: 27px; }
  #page-spells .spell-row-damage { font-size: .76rem; max-width: 38%; }
}

/* Other Proficiencies & Languages — character sheet */
.other-proficiencies {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 10px 0 22px;
}
.other-proficiency-group {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 5px;
  padding: 12px 14px;
}
.other-proficiency-group h3 {
  color: var(--red);
  margin: 0 0 8px;
  font-size: 1rem;
}
.other-proficiency-group p { margin: 0; line-height: 1.55; }
.other-proficiency-group .proficiency-note {
  color: var(--muted);
  font-size: .87rem;
  margin-top: 8px;
}
@media (max-width: 600px) {
  .other-proficiencies { grid-template-columns: 1fr; }
}

/* Spell icons describe their gameplay purpose. Keep accents understated. */
#page-spells .spell-school-symbol { font-size: 17px; }
#page-spells .spell-icon-attack    { background: #f8e2d8; color: #9c493c; }
#page-spells .spell-icon-defense   { background: #dfe9ef; color: #416d87; }
#page-spells .spell-icon-illusion  { background: #ece1f4; color: #77558e; }
#page-spells .spell-icon-control   { background: #e7e4f0; color: #655c89; }
#page-spells .spell-icon-detection { background: #e0ece8; color: #437b68; }
#page-spells .spell-icon-utility   { background: #eee7d9; color: #8b704a; }

/* Explicitly distinguish absence of proficiency from an empty data field. */
.other-proficiency-group .no-tool-proficiency {
  color: #974b47;
  font-weight: 600;
}

/* Combat: grouped overview, with all original editable fields retained. */
.combat-overview { margin-top: 16px; }
.combat-primary-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.combat-primary-grid .stat-card { padding: 18px 10px; }
.combat-primary-grid .stat-card h3 { min-height: 0; }
.combat-health-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.combat-health-panel, .combat-death-panel { background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 15px; min-width: 0; }
.combat-health-panel > h3, .combat-death-panel > h3 { font-family: Cinzel, Georgia, serif; font-size: 15px; text-align: center; margin: 0 0 12px; }
.combat-health-numbers { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.combat-health-numbers .stat-card, .combat-health-details .stat-card { border-color: #e8ddca; background: #faf7f0; }
.combat-health-numbers .stat-card h3, .combat-health-details .stat-card h3 { min-height: 0; }
.combat-health-bar { height: 9px; border-radius: 20px; background: #e8ddca; overflow: hidden; margin: 14px 2px; }
#hp-bar-fill { width: 100%; height: 100%; background: var(--red); transition: width 160ms ease; }
.combat-health-details { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.combat-death-panel .death-saves { display: flex; flex-direction: column; gap: 10px; }
.combat-death-panel .death-saves > div { padding: 12px; gap: 9px; background: #faf7f0; }
.combat-death-panel .death-saves strong { font-size: 13px; }
.character-stat-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
@media (max-width: 700px) {
  .combat-health-grid { grid-template-columns: 1fr; }
  .combat-primary-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
  .combat-primary-grid .stat-card { padding: 12px 4px; }
  .combat-primary-grid .stat-card input[type="number"] { max-width: 100%; }
  .character-stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

/* Compact combat presentation: preserve existing inputs/IDs, reduce nested boxes. */
.combat-overview { margin-top: 9px; }
.combat-primary-grid { gap: 9px; }
.combat-primary-grid .stat-card { padding: 10px 8px 9px; background: #faf7f0; }
.combat-primary-grid .stat-card h3 { font-size: 11px; letter-spacing: .025em; margin-bottom: 3px; }
.combat-primary-grid .stat-card output { margin-top: 2px; font-size: 25px; }
.combat-primary-grid .stat-card input[type="number"] { font-size: 23px; margin-top: 1px; }
.combat-primary-grid .stat-card small { margin-top: 0; font-size: 10px; }
.combat-health-grid { grid-template-columns: minmax(0,1.45fr) minmax(0,1fr); gap: 9px; margin-top: 9px; align-items: stretch; }
.combat-health-panel, .combat-death-panel { padding: 11px 13px; background: #faf7f0; }
.combat-health-panel > h3, .combat-death-panel > h3 { text-align: left; font-size: 13px; margin-bottom: 7px; }
.combat-health-numbers { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; align-items: center; }
.combat-health-numbers .stat-card { padding: 3px 5px 4px; border: 0; border-radius: 0; background: transparent; }
.combat-health-numbers .stat-card + .stat-card { border-left: 1px solid #e0d2bc; }
.combat-health-numbers .stat-card h3 { font-size: 11px; margin-bottom: 2px; }
.combat-health-numbers .stat-card input[type="number"], .combat-health-numbers .stat-card output { font-size: 28px; margin-top: 1px; }
.combat-health-bar { margin: 8px 2px 9px; height: 7px; }
.combat-health-details { gap: 0; border-top: 1px solid #e8ddca; padding-top: 7px; }
.combat-health-details .stat-card { padding: 2px 5px; border: 0; background: transparent; }
.combat-health-details .stat-card + .stat-card { border-left: 1px solid #e0d2bc; }
.combat-health-details .stat-card h3 { font-size: 11px; margin-bottom: 0; }
.combat-health-details .stat-card input[type="number"], .combat-health-details .stat-card output { font-size: 19px; margin-top: 2px; }
.combat-death-panel .death-saves { gap: 0; }
.combat-death-panel .death-saves > div { flex-wrap: nowrap; padding: 10px 1px; gap: 8px; border: 0; border-radius: 0; background: transparent; }
.combat-death-panel .death-saves > div + div { border-top: 1px solid #e8ddca; }
.combat-death-panel .death-saves strong { flex: 1; width: auto; min-width: 0; font-size: 11px; font-family: inherit; }
.combat-death-panel .death-saves label { font-size: 11px; gap: 2px; }
.combat-death-panel .death-saves input { margin: 0; }
.combat-overview > .option-row { margin-top: 7px; font-size: 12px; }
.character-stat-grid { gap: 9px; margin-top: 11px; }
.character-stat-grid .stat-card { padding: 9px 7px; }
.character-stat-grid .stat-card h3 { min-height: 28px; font-size: 11px; }
.character-stat-grid .stat-card output { margin-top: 3px; font-size: 21px; }
.character-stat-grid .stat-card input[type="number"] { font-size: 19px; }
@media (max-width: 700px) {
  .combat-health-grid { grid-template-columns: 1fr; }
  .combat-primary-grid { gap: 6px; }
  .combat-primary-grid .stat-card { padding: 9px 3px; }
  .combat-health-panel, .combat-death-panel { padding: 10px; }
}

/* Combat refinement: restrained line icons, HP and death saves in one compact panel. */
.combat-primary-grid .stat-card { display:flex; flex-direction:column; align-items:center; justify-content:center; padding:11px 8px 10px; }
.combat-stat-icon { height:22px; width:22px; color:#8e755b; margin-bottom:4px; }
.combat-stat-icon svg { width:100%; height:100%; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.combat-primary-grid .stat-card h3 { margin:0 0 3px; min-height:0; }
.combat-primary-grid .stat-card output { margin-top:2px; }
.combat-health-grid { display:block; }
.combat-health-panel { padding:13px 16px; }
.combat-health-panel .combat-death-panel { margin-top:12px; padding:11px 0 0; border:0; border-top:1px solid #e2d5c1; border-radius:0; background:transparent; }
.combat-health-panel .combat-death-panel > h3 { text-align:left; margin:0 0 8px; font-size:13px; }
.combat-health-panel .death-saves { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.combat-health-panel .death-saves > div, .combat-health-panel .death-saves > div + div { display:flex; align-items:center; justify-content:space-between; gap:7px; border:1px solid #e7dbc9; border-radius:5px; background:#f7f0e5; padding:10px 12px; }
.combat-health-panel .death-saves strong { font-size:13px; }
.combat-health-panel .death-saves label { font-size:12px; gap:3px; }
.combat-health-panel .death-saves input { width:16px; height:16px; }
@media(max-width:580px) {
 .combat-health-panel .death-saves { grid-template-columns:1fr; gap:7px; }
 .combat-health-panel .death-saves > div { padding:9px 10px; }
 .combat-primary-grid .stat-card { padding:9px 3px; }
 .combat-stat-icon { width:19px; height:19px; }
}

/* Match the regular sheet cards; keep success/failure rows darker. */
.combat-primary-grid .stat-card,
.combat-health-panel,
.combat-health-numbers .stat-card,
.combat-health-details .stat-card { background: var(--white); }
.combat-health-panel .death-saves > div,
.combat-health-panel .death-saves > div + div { background: #f7f0e5; }

/* Rest controls use the same quiet parchment treatment as other sheet fields. */
.rest-panel { margin-top: 12px; padding: 13px 15px; background: var(--white); border: 1px solid var(--border, #ddcfbc); border-radius: 12px; }
.rest-heading { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.rest-heading h3 { margin: 0; font-size: 1rem; }
.rest-heading span { color: #826d55; font-size: .84rem; }
.rest-actions { display: flex; gap: 9px; margin-top: 11px; }
.rest-button { background: #f0e7d9; border: 1px solid #d9c8af; color: #604b35; border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; }
.rest-button:hover { background: #e7d8c3; }
.rest-cancel { border: none; background: transparent; color: #806d5c; cursor: pointer; font: inherit; }
.rest-details { background: #f7f0e5; border-radius: 9px; padding: 11px 13px; margin-top: 11px; }
.rest-details p, .rest-note { margin: 8px 0 0; font-size: .84rem; color: #806d5c; line-height: 1.5; }
.rest-dice-controls { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-top: 10px; }
.rest-dice-controls input { width: 60px; padding: 6px; }
@media (max-width: 480px) { .rest-actions { flex-wrap: wrap; } }

/* Inventory: editable parchment cards, matching the character sheet. */
.inventory-money, .inventory-items { margin-top: 18px; }
.inventory-section-heading { display:flex; justify-content:space-between; align-items:baseline; gap:12px; margin-bottom:11px; }
.inventory-section-heading h2 { margin:0; }
.inventory-section-heading span { color:var(--muted); font-size:14px; }
.inventory-money { padding:16px; border:1px solid var(--border); border-radius:9px; background:var(--white); }
.inventory-coins { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; }
.inventory-coins label { display:flex; flex-direction:column; gap:5px; font-size:13px; color:var(--muted); font-weight:bold; }
.inventory-coins input { width:100%; min-width:0; }
#inventory-list { display:grid; gap:10px; }
.inventory-item { background:var(--white); border:1px solid var(--border); border-radius:9px; padding:13px 15px; }
.inventory-item-top { display:flex; align-items:center; gap:12px; }
.inventory-item-top .inventory-name { flex:1; min-width:0; font-size:18px; font-weight:600; }
.inventory-qty { display:flex; align-items:center; gap:6px; font-size:14px; color:var(--muted); }
.inventory-qty input { width:74px; }
.inventory-item-bottom { display:flex; align-items:center; justify-content:space-between; margin:9px 0; }
.inventory-equipped { display:flex; align-items:center; gap:6px; font-size:14px; }
.inventory-remove { border:0; background:none; color:var(--red); font-size:14px; padding:3px 6px; }
.inventory-remove:hover { text-decoration:underline; }
.inventory-notes { display:block; width:100%; resize:vertical; min-height:58px; }
.inventory-empty { margin:0; padding:24px; text-align:center; color:var(--muted); background:var(--white); border:1px dashed var(--border); border-radius:9px; }
#add-item-button { margin-top:12px; }
@media(max-width:550px) { .inventory-coins { grid-template-columns:repeat(3,minmax(0,1fr)); } .inventory-item-top { gap:7px; } .inventory-item { padding:11px; } }

/* Inventory: parchment currency tokens and read-first item cards. */
.inventory-coins { gap:9px; }
.inventory-coins .coin-card { padding:12px 10px; border:1px solid #d9c8ad; border-radius:9px; background:linear-gradient(145deg,#fffdf8,#f5ecdc); gap:9px; box-shadow:0 2px 5px #6046280c; }
.coin-head { display:flex; align-items:center; gap:9px; color:#493722; }
.coin-head > span:last-child { display:flex; flex-direction:column; gap:2px; }
.coin-head strong { font-size:14px; letter-spacing:.06em; }
.coin-head small { font-size:11px; font-weight:normal; color:var(--muted); }
.coin-medallion { width:31px; height:31px; border-radius:50%; display:grid; place-items:center; flex-shrink:0; border:2px double #846448; background:radial-gradient(circle at 32% 28%,#e7b98b,#9c5a37); color:#5c321e; font: bold 17px Georgia,serif; box-shadow:inset 0 0 0 2px #ffffff55,1px 2px 2px #0002; }
.coin-sp .coin-medallion { background:radial-gradient(circle at 30% 25%,#fff,#a0a1a4);color:#56565a;border-color:#86878a; }
.coin-ep .coin-medallion { background:radial-gradient(circle at 30% 25%,#f4deb0,#ae9256);color:#735729;border-color:#a98a4e; }
.coin-gp .coin-medallion { background:radial-gradient(circle at 30% 25%,#ffe9a0,#d09a30);color:#7b4e14;border-color:#bb8424; }
.coin-pp .coin-medallion { background:radial-gradient(circle at 30% 25%,#fafafa,#bacbd1);color:#586c73;border-color:#a4b4bc; }
.inventory-coins .coin-card input { text-align:center; font: 22px Georgia,serif; background:#fffaf2; }
.inventory-item { display:flex; align-items:center; gap:13px; padding:10px 12px; min-height:82px; }
.inventory-picture { width:66px; height:66px; flex:0 0 66px; object-fit:cover; border-radius:7px; border:1px solid #e0d0b6; background:#f1e6d5; }
.inventory-item-content { flex:1; min-width:0; }
.inventory-item-heading { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.inventory-item-heading strong { font: 19px Georgia,serif; color:#493722; }
.inventory-item-description { margin:5px 0 0; font-size:14px; color:var(--muted); white-space:pre-wrap; overflow-wrap:anywhere; }
.inventory-equipped-badge { background:#e8e8d4; border:1px solid #c8c9a7; border-radius:5px; padding:2px 7px; font-size:12px; color:#515b39; }
.inventory-item-actions { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.inventory-item-quantity { color:#6a5540; font:17px Georgia,serif; white-space:nowrap; margin-right:6px; }
.inventory-edit-button,.inventory-remove { border:1px solid transparent; background:transparent; color:#765c40; padding:5px 7px; border-radius:5px; font-size:15px; cursor:pointer; }
.inventory-edit-button:hover,.inventory-remove:hover { background:#f2e8d8; text-decoration:none; }
.inventory-remove { color:#a34b38; }
.inventory-editor { margin-top:5px; }
.inventory-editor[hidden], .inventory-item-details[hidden] { display:none; }
.inventory-editor-top { display:flex; align-items:center; flex-wrap:wrap; gap:9px; }
.inventory-editor-top .inventory-name { flex:1; min-width:150px; font-size:16px; }
.inventory-editor .inventory-notes { margin-top:9px; }
.inventory-image-controls { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-top:8px; }
.inventory-upload { font-size:13px; color:#6d4e2f; cursor:pointer; }
.inventory-upload input { display:block; max-width:230px; font-size:12px; margin-top:4px; }
.inventory-picture-remove { background:transparent; border:0; color:#9b4b3d; font-size:13px; cursor:pointer; }
@media(max-width:650px) { .inventory-coins { grid-template-columns:repeat(2,minmax(0,1fr)); } .inventory-item { gap:8px; } .inventory-picture { width:49px; height:49px; flex-basis:49px; } .inventory-item-actions { gap:2px; } .inventory-item-heading strong { font-size:16px; } }

/* Adventure journal — compact editor, elegant read-only session pages. */
.journal-heading { display:flex; justify-content:space-between; align-items:center; gap:16px; margin:10px 0 20px; }
.journal-heading p { margin:0; color:var(--muted); font-size:14px; }
#add-entry-button,.journal-primary { border:1px solid #72583b; border-radius:7px; background:#665035; color:#fffaf1; padding:10px 15px; cursor:pointer; white-space:nowrap; }
.journal-entries { display:grid; gap:16px; }
.journal-entry { border:1px solid #ddcbb0; border-radius:10px; background:var(--white); padding:19px 22px; box-shadow:0 2px 6px #6046280b; }
.journal-entry-top { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.journal-entry-meta { font-size:12px; letter-spacing:1.3px; color:#967550; font-weight:700; }
.journal-edit-button { background:transparent; border:1px solid #d8c7ab; color:#72583b; border-radius:6px; padding:6px 10px; cursor:pointer; }
.journal-entry-title { font:25px Georgia,serif; color:#493722; margin:8px 0 12px; }
.journal-entry-body { color:#514534; font-size:15px; line-height:1.65; overflow-wrap:anywhere; }
.journal-entry-body p { margin:4px 0; }
.journal-entry-body h3,.journal-entry-body h4 { font-family:Georgia,serif; color:#60482e; margin:14px 0 5px; }
.journal-entry-body h3 { font-size:20px; }.journal-entry-body h4 { font-size:17px; }
.journal-entry-body ul { padding-left:23px; margin:7px 0; }
.journal-entry-body blockquote { margin:9px 0; border-left:3px solid #c6a77b; padding:5px 13px; background:#f8f1e6; font-style:italic; }
.journal-entry-body code { background:#f4ecdf; border-radius:3px; padding:1px 4px; }
.journal-paragraph-gap { height:9px; }
.journal-fields { display:grid; grid-template-columns:140px 180px minmax(0,1fr); gap:12px; margin-bottom:13px; }
.journal-fields label { font-size:12px; color:#745d42; font-weight:600; }
.journal-fields input { box-sizing:border-box; display:block; width:100%; margin-top:5px; padding:9px; border:1px solid #d9c8ad; border-radius:6px; background:#fffaf3; color:#493722; font:15px Georgia,serif; }
.journal-toolbar { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:8px; }
.journal-toolbar button { border:1px solid #d8c7ab; background:#f7f0e5; color:#654b30; border-radius:5px; padding:6px 10px; cursor:pointer; }
.journal-toolbar button:hover,.journal-edit-button:hover { background:#eee1ce; }
.journal-notes { box-sizing:border-box; display:block; width:100%; min-height:235px; padding:13px; border:1px solid #d8c7ab; border-radius:7px; background:#fffdf8; color:#493722; font:15px/1.6 Georgia,serif; resize:vertical; }
.journal-format-help { font-size:12px; color:#8a755c; margin:8px 0; }
.journal-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:12px; }
.journal-delete { border:0; background:transparent; color:#a34b38; cursor:pointer; }
.journal-empty { color:var(--muted); font-style:italic; }
@media(max-width:700px) { .journal-fields { grid-template-columns:1fr 1fr; } .journal-title-field { grid-column:1/-1; } .journal-entry { padding:14px; } .journal-heading { align-items:flex-start; flex-direction:column; } }

/* Lightweight combat condition and concentration trackers. */
.status-tracker {margin: 14px 0 20px; padding: 16px 18px; border: 1px solid var(--line, #ded1bf); border-radius: 12px; background: var(--white, #fffdf9);}
.status-heading {display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin-bottom:12px;}
.status-heading h2 {margin:0; font-size:1.12rem;}
.status-heading span,.condition-reference,.concentration-heading small {color:var(--muted,#786f64); font-size:.82rem;}
.condition-active {display:flex; flex-wrap:wrap; gap:8px; min-height:25px; margin-bottom:10px;}
.condition-empty {color:var(--muted,#786f64); font-style:italic; font-size:.9rem;}
.condition-chip {display:inline-flex; align-items:center; gap:7px; background:#f7f0e5; border:1px solid #d9c7ab; border-radius:20px; padding:5px 8px 5px 12px; font-size:.87rem;}
.condition-chip button {padding:0 5px; background:transparent; border:0; font-size:1.15rem; cursor:pointer; color:#866a52;}
.condition-picker {display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
.condition-picker label {font-size:.86rem;}
.condition-picker select {flex:1; min-width:140px; padding:7px;}
.condition-picker button,.concentration-tracker button {padding:7px 12px;}
.condition-reference {margin-top:10px;}
.condition-reference summary {cursor:pointer;}
.condition-reference-list-item {padding:9px 0; border-bottom:1px solid #e9e0d2;}
.condition-reference-list-item strong {display:block; margin-bottom:2px;}
.condition-reference-list-item p {margin:0; line-height:1.5;}
.concentration-tracker {display:flex; flex-wrap:wrap; align-items:center; gap:12px; padding:12px 15px; margin:14px 0; background:var(--white,#fffdf9); border:1px solid var(--line,#ded1bf); border-radius:12px;}
.concentration-heading {display:flex; align-items:center; gap:10px; margin-right:auto;}
.concentration-heading div {display:flex; flex-direction:column; gap:2px;}
.concentration-icon {display:grid; place-items:center; height:35px; width:35px; border-radius:9px; color:#856e52; background:#f7f0e5; font-size:1.3rem;}
.concentration-tracker select {flex:1; min-width:175px; max-width:340px; padding:8px;}
@media (max-width:560px) {.concentration-tracker select {max-width:none; flex-basis:100%;}.status-heading {flex-wrap:wrap;}}

/* Journal search — subtle, compact and consistent with parchment cards. */
.journal-search-bar { display:flex; align-items:center; gap:10px; margin:0 0 18px; flex-wrap:wrap; }
.journal-search-input-wrap { display:flex; align-items:center; gap:8px; flex:1 1 280px; min-width:0; border:1px solid #d8c7ab; border-radius:8px; background:var(--white); padding:0 12px; }
.journal-search-input-wrap:focus-within { outline:2px solid #b79b73; outline-offset:1px; }
.journal-search-icon { color:#957755; font-size:25px; line-height:1; }
#journal-search { width:100%; min-width:0; height:43px; border:0; outline:0; background:transparent; color:#493722; font:15px Georgia,serif; }
#journal-search::placeholder { color:#9b8a75; }
.journal-search-clear { border:1px solid #d8c7ab; border-radius:6px; background:#f7f0e5; color:#72583b; padding:9px 12px; cursor:pointer; }
.journal-search-clear:hover { background:#eee1ce; }
.journal-search-clear[hidden] { display:none; }
.journal-search-count { margin-left:auto; color:var(--muted); font-size:12px; white-space:nowrap; }
.journal-no-results { border:1px dashed #d8c7ab; border-radius:8px; padding:24px; text-align:center; color:var(--muted); background:var(--white); }
