/* =========================================================
   BONFIRE STYLES
   Mobile-first architecture:
   1. Base / mobile styles are the default.
   2. Small-screen adjustments follow the relevant component.
   3. Desktop-only changes are explicitly marked DESKTOP and use
      @media (min-width: 900px), unless a wider breakpoint is required.
   4. Version history belongs in Git/ZIP history, not in this stylesheet.
   ========================================================= */

/* =========================================================
   BONFIRE DESIGN TOKENS
   ========================================================= */
:root {
  --font-display: "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-alt: #ececeb;
  --ink: #343434;
  --muted: #6f6f6a;
  --line: #d3d3cf;
  --placeholder: #cfcfcd;
  --accent: #E85D35;
  --accent-dark: #C64A27;
  --danger: #ff5b62;

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --control-shadow: 0 5px 0 var(--ink);

  --content-max: 1180px;
  --mobile-nav-height: 88px;
}

/* =========================================================
   BASE
   ========================================================= */
* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #ededeb;
}

body {
  /* Resolve the shadow against the active character accent, not :root green. */
  --control-shadow-accent: 0 5px 0 var(--accent);
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #ededeb;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
}

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

h1, h2, h3,
.btn,
.nav-item,
.creator-tab,
.sheet-tab,
.text-action,
.eyebrow,
.character-copy h3 {
  font-family: var(--font-display);
}

button { -webkit-tap-highlight-color: transparent; }

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 8vw, 2.5rem);
  line-height: 1;
  letter-spacing: -.035em;
  font-weight: 900;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.5rem;
  line-height: 1.1;
  font-weight: 900;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.15rem;
  line-height: 1.2;
  font-weight: 900;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

.app {
  min-height: 100vh;
  padding-bottom: calc(var(--mobile-nav-height) + 20px);
}

/* =========================================================
   SHARED BUTTONS / CONTROLS
   ========================================================= */
.btn {
  min-height: 56px;
  padding: 0 24px;
  border: 4px solid var(--ink);
  border-radius: 18px;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background .12s ease;
}

.btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: var(--control-shadow);
}

.btn-primary:hover { background: var(--accent-dark); }

.btn-secondary {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--control-shadow);
}

.btn:active:not(:disabled):not(.btn-static):not([data-press-mode="selection"]) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.icon-button {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.text-action {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 2px 0;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.text-action-right { margin-left: auto; }


.field > span,
.resource > span,
.display-field > span {
  font-size: 1rem;
  font-weight: 500;
}

.field input,
.field textarea,
.text-input {
  width: 100%;
  min-height: 43px;
  padding: 8px 9px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--control-shadow);
  outline: none;
  transition: transform .1s ease, box-shadow .1s ease, border-color .1s ease;
}

.field textarea {
  height: 84px;
  resize: none;
  overflow-y: auto;
  line-height: 1.35;
}

.text-input.is-editing:not([readonly]):not([aria-readonly="true"]) {
  transform: translateY(0);
  border-color: var(--accent);
  box-shadow: var(--control-shadow-accent);
}

.text-input.is-pressed:not([readonly]):not([aria-readonly="true"]) {
  transform: translateY(5px);
  border-color: var(--ink);
  box-shadow: none;
}
.select {
  width: 100%;
  min-height: 43px;
  height: 43px;
  padding: 8px 9px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
  text-align: left;
  outline: none;
  box-shadow: none;
  transform: translateY(5px);
}


.checkbox {
  appearance: none;
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background .08s ease;
}

.checkbox:checked {
  transform: translateY(4px);
  background: var(--accent);
  box-shadow: none;
}

.radio {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
}

.radio:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.radio-indicator {
  width: 20px;
  height: 20px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  display: inline-block;
}

.radio-indicator.is-selected {
  border-color: var(--accent);
  background: var(--accent);
}

.stepper,
.resource-control {
  min-height: 50px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  padding: 5px;
}

.stepper strong,
.resource-control strong {
  text-align: center;
  font-weight: 600;
}

.stepper-button {
  width: 30px;
  height: 30px;
  justify-self: center;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--ink);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}

.stepper-button:active {
  transform: translateY(4px);
  box-shadow: none;
}

/* =========================================================
   SHARED LAYOUT / DATA
   ========================================================= */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-span { grid-column: 1 / -1; }

.form-section { display: grid; gap: 16px; }

.check-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.data-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
}

.data-row:nth-child(even) { background: var(--surface-alt); }

.row-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.info-button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: .72rem;
  cursor: pointer;
}

.icon-text-button,
.trash-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.muted { color: var(--muted); }

.avatar-placeholder,
.card-image-placeholder,
.auth-art-placeholder,
.update-placeholder {
  background: var(--placeholder);
}

.avatar-placeholder {
  width: 58px;
  height: 58px;
  border: 2px solid var(--ink);
  border-radius: 50%;
}


.expandable-stack,
.accordion-stack { display: grid; }

.expandable,
.accordion {
  border-bottom: 1px solid var(--line);
}

.expandable-heading,
.accordion-heading {
  padding: 0;
  text-align: left;
  width: 100%;
  min-height: 54px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
}

.expandable-content,
.accordion-content {
  padding-bottom: 14px;
}

.accordion:not(.is-open) .accordion-content { display: none; }

/* =========================================================
   AUTH
   ========================================================= */
.auth-page {
  min-height: 100vh;
  padding: 34px 20px 50px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-page > h1 { margin-top: 0; }

.auth-art-placeholder {
  width: 100%;
  height: 260px;
  border-radius: var(--radius-lg);
}

.auth-art-small { height: 190px; }

.auth-form { display: grid; gap: 18px; }

.auth-switch {
  margin-top: auto;
  text-align: center;
  color: var(--muted);
}

.auth-switch button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 900;
  cursor: pointer;
}

.legal-copy {
  color: var(--muted);
  font-size: .8rem;
}

.legal-copy strong { color: var(--accent); }

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  color: var(--line);
}

.divider span { height: 1px; background: var(--line); }
.divider em { font-style: normal; }

/* =========================================================
   HOME
   ========================================================= */
.home-page {
  padding: 34px 26px 36px;
}

.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.eyebrow {
  margin-bottom: 2px;
  font-weight: 800;
}

.new-character-card {
  display: grid;
  grid-template-columns: .95fr 1.55fr;
  min-height: 205px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.new-character-card > div:last-child {
  padding: 22px 18px;
}

.card-image-placeholder {
  min-height: 205px;
}

.character-list {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.character-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
}

.character-copy { flex: 1; min-width: 0; }
.character-copy h3 { margin-bottom: 4px; }
.character-copy p { margin-bottom: 0; }

.character-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trash-button {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
}

.trash-button:hover { background: var(--surface-alt); }

.updates { margin-top: 60px; }

.update-card {
  margin-bottom: 18px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.update-placeholder {
  height: 150px;
  margin: 0 24px;
}

.update-card > div:last-child { padding: 14px 24px 22px; }
.update-card p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.update-link { display: block; margin-left: auto; }

/* =========================================================
   CREATOR
   ========================================================= */
.creator-page {
  min-height: 100vh;
  padding-bottom: 82px;
}

.creator-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 26px 20px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.creator-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.creator-page .creator-tabs {
  display: flex;
  width: 100%;
  gap: 8px;
  overflow: visible;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.creator-page .creator-tab {
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  position: relative;
  padding: 0 2px 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  z-index: 1;
}

.creator-tab {
  flex: 0 0 auto;
  min-width: max-content;
  white-space: nowrap;
  border: 0;
  border-bottom: 3px solid var(--line);
  background: transparent;
  padding: 0 1px 8px;
  text-align: left;
  cursor: pointer;
}

.creator-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 900;
}

.creator-content {
  padding: 28px 20px 110px;
}

.creator-footer {
  position: fixed;
  z-index: 30;
  bottom: 0;
  left: 50%;
  width: min(100%, 560px);
  height: 78px;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-top: 1px solid var(--ink);
  background: var(--surface);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 34px;
}

.ability-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.ability-control {
  display: grid;
  gap: 5px;
}
.class-grid {
  display: grid;
  grid-template-columns: 70px 1fr 90px;
  gap: 12px;
}

.feature-groups {
  display: grid;
  gap: 18px;
}

.feature-group {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.feature-group h3 { font-size: 1rem; }

.spell-summary {
  display: grid;
  grid-template-columns: 1.5fr .75fr .75fr;
  gap: 12px;
}

/* =========================================================
   CHARACTER SHEET
   ========================================================= */


.class-lines {
  margin-bottom: 4px;
  font-weight: 600;
}

.sheet-avatar {
  padding: 0;
  cursor: pointer;
}


.resource {
  display: grid;
  gap: 5px;
}


.sheet-tab {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  padding: 0 0 6px;
  cursor: pointer;
}

.sheet-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 900;
}


.stat-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
}
@container sheet-space (min-width: 720px) {
  .stat-card-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@container sheet-space (max-width: 440px) {
  .stat-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat-card {
  padding: 10px 8px 8px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: center;
}

.stat-card strong {
  display: block;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  font-size: 1.35rem;
}

.stat-card > span {
  display: block;
  padding-top: 5px;
  font-size: .86rem;
}

.proficiency-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: -2px;
}

.section-title { margin-top: 28px; }

.sense-list {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.sense-list > div {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.sense-list > div:last-child { border-bottom: 0; }

.display-field {
  display: grid;
  gap: 5px;
}

.display-field > div {
  min-height: 43px;
  padding: 8px 9px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.display-field.is-multiline > div {
  min-height: 70px;
  white-space: pre-wrap;
}

.feature-row {
  width: 100%;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.feature-row span { color: var(--muted); }

/* =========================================================
   NAVIGATION
   ========================================================= */
.bottom-nav {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 0;
  width: min(100%, 560px);
  height: var(--mobile-nav-height);
  transform: translateX(-50%);
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  padding: 8px 14px;
}

.bottom-nav[hidden] { display: none; }

.nav-item {
  justify-self: center;
  width: 120px;
  min-height: 64px;
  border: 4px solid transparent;
  border-radius: 20px;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.nav-item.is-active {
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: var(--control-shadow);
}

.nav-icon {
  display: block;
  font-size: 1.4rem;
  line-height: .8;
}

/* =========================================================
   POPOVERS / MODALS
   ========================================================= */
.popover {
  position: absolute;
  z-index: 500;
  top: calc(100% + 8px);
  right: 0;
  width: auto;
  min-width: max-content;
  max-width: calc(100vw - 24px);
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: none;
}

.popover button {
  display: block;
  width: auto;
  min-width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.popover button:hover { background: var(--surface-alt); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  pointer-events: none;
}

.overlay.is-open { pointer-events: auto; }
/* A sheet's information dialogs belong to its panel, not the board underneath. */
body.bf-campaign-sheet-open:not(.bf-campaign-sheet-editor-open) > .overlay:not(.bf-board-dialog) {
  left:calc(100% - var(--campaign-board-sheet-width,520px));
}
body.bf-campaign-sheet-open:not(.bf-campaign-sheet-editor-open) > .overlay:not(.bf-board-dialog) .bf-dialog {
  max-width:calc(100% - 24px);
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.38);
  opacity: 0;
  transition: opacity .18s ease;
}

.overlay.is-open .overlay-backdrop { opacity: 1; }

.bottom-sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(100%, 560px);
  max-height: 90vh;
  overflow-y: auto;
  transform: translate(-50%, 100%);
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  padding: 48px 20px 22px;
  transition: transform .2s ease;
}

.overlay.is-open .bottom-sheet { transform: translate(-50%, 0); }

.modal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(calc(100% - 40px), 390px);
  max-height: 82vh;
  overflow-y: auto;
  transform: translate(-50%, -48%) scale(.98);
  opacity: 0;
  border-radius: 20px;
  background: var(--surface);
  padding: 46px 20px 20px;
  transition: transform .18s ease, opacity .18s ease;
}

.overlay.is-open .modal {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 20px;
  border: 0;
  background: transparent;
  font-size: 2rem;
  cursor: pointer;
}

.modal-copy { line-height: 1.5; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.sheet-form { display: grid; gap: 14px; }
.sheet-form h3 { margin: 8px 0 0; font-size: 1rem; }

body.overlay-open {
  overflow: hidden;
  touch-action: none;
}

body.overlay-open .bottom-sheet,
body.overlay-open .modal {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

/* =========================================================
   EMPTY
   ========================================================= */
.empty-page {
  min-height: 100vh;
  padding: 64px 26px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 14px;
}

/* =========================================================
   RESPONSIVE FOUNDATION
   ========================================================= */
@media (max-width: 390px) {
  

  .creator-tabs { gap: 10px; font-size: .82rem; }

  .ability-controls { gap: 12px 8px; }

  

  

  .bottom-nav { padding-left: 40px; padding-right: 40px; }
}

@media (min-width: 900px) {
  body { padding: 28px; }

  .app-shell {
    width: min(100%, var(--content-max));
    min-height: calc(100vh - 56px);
    border-radius: 28px;
    overflow: clip;
  }

  .app { padding-bottom: 100px; }

  

  .home-header { margin-bottom: 42px; }

  .new-character-card {
    grid-template-columns: 320px 1fr;
  }

  .card-image-placeholder { min-height: 240px; }

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

  .updates > h2 { grid-column: 1 / -1; }

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

  .creator-header {
    padding-left: clamp(40px, 6vw, 84px);
    padding-right: clamp(40px, 6vw, 84px);
  }

  .creator-tabs { gap: 16px; }

  .creator-footer,
  .bottom-nav {
    width: min(calc(100% - 56px), var(--content-max));
  }

  

  


  .auth-page {
    width: min(100%, 640px);
    margin: 0 auto;
  }
}


/* =========================================================
   CHARACTER SHEET CONTENT
   ========================================================= */

/* The sheet itself must never side-scroll. Only the tabs may scroll horizontally. */


/* Preserve the intentional horizontal swipe interaction only on the tab bar. */


/* Long content wraps instead of widening the page. */


/* Bottom nav is intentionally absent while viewing a character sheet. */


/* Inventory card view */
.inventory-section { width: 100%; }

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

.inventory-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 106px;
  padding: 12px 9px 10px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  text-align: left;
}

.inventory-card-name {
  margin-bottom: 7px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.inventory-card-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
}

.inventory-card-meta span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-card-amount {
  margin-top: auto;
  padding-top: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
}

.inventory-add-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
}

.inventory-divider {
  width: 100%;
  height: 1px;
  margin: 20px 0 62px;
  background: var(--line);
}

.inventory-empty {
  min-height: 70px;
  display: flex;
  align-items: center;
}

@container sheet-space (max-width: 440px) {
  .inventory-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .inventory-card { padding-left: 7px; padding-right: 7px; }
}
@container sheet-space (min-width: 900px) {
  .inventory-card-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}


/* =========================================================
   FORM AND CARD COMPONENTS
   ========================================================= */

/* Shared tertiary action: no underline, centered, reusable everywhere. */
.btn-tertiary {
  display: block;
  width: fit-content;
  margin: 0 auto;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.btn-tertiary:hover {
  color: var(--accent-dark);
}


/* Race/background conditional controls. */
.section-break {
  height: 1px;
  margin: 8px 0;
  background: var(--line);
}


.bonus-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(110px, .8fr) auto;
  gap: 10px;
  align-items: end;
}

.picker-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.bonus-delete {
  align-self: end;
  min-height: 43px;
}

/* Creator inventory uses exactly the same card component as the sheet. */
.inventory-creator .inventory-card {
  position: relative;
}


/* Standalone Updates page. */
.updates-standalone {
  margin-top: 0;
}

/* Desktop refinements for conditional creator content. */
@media (min-width: 900px) {
  .bonus-list,
  .proficiency-picker {
    max-width: 720px;
  }
}


/* =========================================================
   INTERACTION BEHAVIOUR
   ========================================================= */

.subsection-title {
  margin: 4px 0 0;
  font-size: 1.1rem;
}

.movement-creator {
  display: grid;
  gap: 12px;
  padding: 4px 0;
}


.spell-known-control {
  max-width: 240px;
}

/* Inventory cards are interactive controls now. */
button.inventory-card {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.inventory-card:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.item-action-sheet h2 {
  margin-right: 32px;
}

@media (max-width: 390px) {
}


/* =========================================================
   TAG AND OVERFLOW COMPONENTS
   ========================================================= */

/* Background conditional sections use the full available width. */
.bonus-list,
.proficiency-picker {display: grid;
  gap: 12px;
  padding-left: 33px;
width: 100%;
  max-width: none !important;
  padding-left: 0 !important;
}

.bonus-row,
.picker-row {
  width: 100%;
}

.personality-divider {
  margin-top: 12px;
  margin-bottom: 4px;
}

/* Comma-to-tag proficiency input. */


.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 7px;
  background: var(--surface-alt);
  font-size: .85rem;
}

.tag button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
}

.tag-entry {
  width: 100%;
  min-height: 32px !important;
  margin-top: 5px;
  padding: 2px 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  outline: none;
}


/* Prevent page-level horizontal overflow; intentional horizontal scrolling
   is limited to the sheet tab bar. */


/* Linked profile imagery with neutral placeholder fallback. */
.avatar-placeholder.has-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--placeholder);
}

/* Item action sheets deliberately only use the X in the upper corner. */
.item-action-sheet {display: grid;
  gap: 14px;
padding-bottom: 10px;
}


/* =========================================================
   INTERACTION DETAILS
   ========================================================= */

.avatar-placeholder-large {width: 100px;
  height: 100px;
width: 122px !important;
  height: 122px !important;
  margin: 0 auto 8px;
}

/* Tag fields stay visually in editing mode while the user keeps typing. */
.field-helper {
  margin: 0;
  color: var(--muted);
  font-size: .88rem;
}


.tag-input-shell:focus-within {
  border-color: var(--accent);
  box-shadow: var(--control-shadow-accent);
  transform: translateY(0);
}

.tag-entry,
.tag-entry.text-input,
.tag-entry.text-input.is-editing,
.tag-entry.text-input.is-pressed {
  min-height: 34px !important;
  margin-top: 5px;
  padding: 2px 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

/* Attack cards now share the same compact-card language as inventory. */
.attack-card-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 6px 0 14px;
}

.attack-card {
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--ink);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.attack-card:active {
  transform: translateY(4px);
  box-shadow: none;
}

.attack-card-name {
  display: block;
  margin-bottom: 9px;
  font-family: var(--font-display);
  font-size: 1rem;
}

.attack-card-stats {
  display: grid;
  grid-template-columns: .65fr 1.35fr;
  gap: 12px;
  margin-bottom: 8px;
}

.attack-card-stats span {
  min-width: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.attack-card-stats small {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 500;
}

.attack-card p {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (min-width: 700px) {
  .attack-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}


/* =========================================================
   CHARACTER CREATION DETAILS
   ========================================================= */

.info-sheet {
  min-height: 240px;
}

.info-sheet-header {
  position: sticky;
  top: -48px;
  z-index: 5;
  min-height: 58px;
  margin: -48px -20px 18px;
  padding: 18px 52px 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.info-sheet-header h2 {
  margin: 0;
}

.info-sheet-close {
  position: absolute;
  top: 14px;
  right: 20px;
}

.info-sheet-copy {
  line-height: 1.55;
}

.tag-input-shell.is-editing {
  transform: translateY(0);
  border-color: var(--accent);
  box-shadow: var(--control-shadow-accent);
}

.tag-input-shell.is-pressed {
  transform: translateY(5px);
  border-color: var(--ink);
  box-shadow: none;
}

.tag-input-shell {min-height: 52px;
  width: 100%;
  padding: 7px 8px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--control-shadow);
transform: translateY(0);
  transition: border-color .1s ease, box-shadow .1s ease, transform .1s ease;
transition: transform .1s ease, border-color .1s ease, box-shadow .1s ease;}

.custom-description-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.custom-description-row p {
  margin: 3px 0 0;
  color: var(--muted);
}

.component-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding-top: 4px;
}

.reaction-detail[hidden] {
  display: none;
}

/* =========================================================
   CHARACTER SHEET
   ========================================================= */


/* Identity */


/* Normal summary */


/* Hit Dice: ALWAYS one horizontal row: maximum | current */


/* Shared +/- resource control */


/* Tabs */


/* Pull handle */


/* Quick Edit */


/*
  Spacing is explicit instead of relying on inherited grid gaps:
  primary -> movement = 8px
  movement/primary -> HP = 8px
  HP -> Temp HP action = 8px
*/


/* EXACTLY 4px from Hit Dice label to its bar */


/* 8px clear space ABOVE and BELOW the button */


/* Persistent fade overlay */


/* Page Edit */


/* Global field label -> control spacing */


@media (max-width: 390px) {
  

  

  

  

  

  
}

@media (min-width: 900px) {
  
}

/* =========================================================
   SHARED FIELD LAYOUT
   ========================================================= */

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  min-width: 0;
  margin: 0;
}

/* =========================================================
   CHARACTER SHEET
   ========================================================= */

.sheet-page {
  --sheet-gutter: 26px;
  position: relative;
  width: 100%;
  min-height: 0;
  overflow-x: clip;
}

.sheet-header {
  --card-drag-y: 0px;
  position: sticky;
  top: 0;
  z-index: 120;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 24px var(--sheet-gutter) 0;
  box-sizing: border-box;
  overflow: visible;
  background: var(--surface);
  transform: translateY(var(--card-drag-y));
  transition: transform .16s ease;
}

.sheet-header.is-dragging { transition: none; }

.sheet-content {
  width: 100%;
  min-height: 0;
  padding: 28px var(--sheet-gutter) 40px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.sheet-identity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 18px;
  width: 100%;
  min-width: 0;
  margin: 0 0 22px;
  position: relative;
  z-index: 320;
}

.sheet-identity h1 {
  font-size: 30px;
}


.sheet-identity > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.sheet-identity .sheet-avatar {
  flex: 0 0 auto;
  margin-left: auto;
}

/* Normal */
.sheet-summary-grid,
.sheet-summary-movement {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.sheet-summary-grid.single-speed {
  grid-template-columns:
    minmax(36px, .62fr)
    minmax(66px, .92fr)
    minmax(52px, .72fr)
    max-content;
}

.sheet-summary-grid.has-extra-speed {
  grid-template-columns:
    minmax(36px, .62fr)
    minmax(66px, .92fr)
    minmax(52px, .72fr)
    max-content;
}

.sheet-summary-movement {
  grid-template-columns: repeat(2, minmax(0,1fr));
  margin-top: 12px;
}

.sheet-summary-stat {
  min-width: 0;
  text-align: left;
}

.sheet-summary-label {
  display: block;
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.2;
}

.sheet-summary-stat > strong {
  display: block;
  font-family: var(--font-body);
  font-size: 23px;
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
}


.value-divider {
  display: block;
  width: 1px;
  min-width: 1px;
  height: 28px;
  background: #CCC;
}

/* Shared resource control */
.shared-resource-control {
  display: grid;
  grid-template-columns: 38px minmax(0,1fr) 38px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 5px 6px;
  box-sizing: border-box;
}

.shared-resource-control .resource-control-value {
  display: grid;
  place-items: center;
  min-width: 0;
}

.shared-resource-control .stepper-button {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  margin: 0;
  justify-self: center;
}

.sheet-summary-hp {
  width: 100%;
  margin: 16px 0 0;
}

.sheet-summary-hp .hp-resource-control,
.quick-edit-hp .hp-resource-control {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.hp-number-strip {
  display: grid;
  grid-template-columns: minmax(0,1fr) 1px minmax(0,1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.hp-number-strip.has-temp {
  grid-template-columns: minmax(0,1fr) 1px minmax(0,1fr) 1px minmax(0,1fr);
}

.hp-number-strip > strong {
  width: 100%;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 25px;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

/* Tabs */
.sheet-tabs {
  display: flex;
  gap: 22px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.sheet-tabs::-webkit-scrollbar { display: none; }

.sheet-tabs-in-card {
  width: calc(100% + (var(--sheet-gutter) * 2));
  margin: 22px calc(var(--sheet-gutter) * -1) 0;
  padding: 12px var(--sheet-gutter) 14px;
  box-sizing: border-box;
  border-top: 1px solid var(--line);
}

/* Pull handle */
.sheet-pull-handle {
  position: absolute;
  left: 0;
  bottom: -28px;
  z-index: 220;
  width: 100%;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ns-resize;
  touch-action: none;
}

.sheet-pull-handle::before {
  content: "";
  position: absolute;
  left: 0;
  top: -1px;
  width: 100%;
  height: 17px;
  background: var(--surface);
  clip-path: polygon(0 0,100% 0,50% 100%);
  filter: drop-shadow(0 6px 5px rgba(0,0,0,.32));
}

.sheet-pull-handle span {
  position: absolute;
  left: 50%;
  top: 4px;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%);
}

/* Quick Edit: content-driven height, one grid owns the row spacing. */


.quick-edit-primary {
display: grid;
  align-items: end;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0;
}
.quick-edit-primary.has-extra-speed {
grid-template-columns: 50px 76px minmax(142px, 1fr);
}
.quick-edit-primary.single-speed {
grid-template-columns:
    minmax(42px, .58fr)
    minmax(68px, .86fr)
    minmax(46px, .62fr)
    minmax(104px, 1.2fr);
}
.quick-edit-movement {
display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0;
}


.quick-edit-hit-dice {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 4px;
  margin: 0;
}

.quick-edit-primary .field > span,
.quick-edit-movement .field > span,
.quick-edit-hit-dice > span {
  line-height: 1.2;
}

/* Input controls retain their 5px visual shadow.
   Reserve that shadow inside the row item so Quick Edit's 8px
   parent gap is an actual visible 8px between rows. */
.quick-edit-primary > .field,
.quick-edit-primary > .quick-edit-hit-dice,
.quick-edit-movement > .field {
  padding-bottom: 5px;
}


.quick-edit-hit-dice .shared-resource-control {
grid-template-columns: 26px minmax(0, 1fr) 26px;
  gap: 4px;
  width: 100%;
  min-width: 0;
  height: 43px;
  min-height: 43px;
  padding: 4px;
}

.quick-edit-hit-dice .stepper-button {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
}

.quick-edit-hit-dice .resource-control-value {
  min-width: 0;
  overflow: hidden;
}

.quick-edit-hit-dice .hit-dice-value {
  display: grid;
  grid-template-columns: minmax(0,1fr) 1px minmax(0,1fr);
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
}
.quick-edit-hit-dice .hit-dice-value > strong {
display: block;
  width: 100%;
  min-width: 0;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.quick-edit-hit-dice .value-divider { height: 22px; }

.quick-edit-primary .field input,
.quick-edit-movement .field input,
.quick-edit-hit-dice .shared-resource-control,
.quick-edit-hp .hp-resource-control {height: 43px;
  min-height: 43px;
  box-sizing: border-box;}

.quick-edit-hp .hp-resource-control {
}

.quick-edit-hp {
display: block;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.sheet-header-quick .hp-number-strip > strong {font-size: 18px;
  font-weight: 400;}
.quick-edit-temp-action {
display: grid;
  place-items: center;
  width: 100%;
  margin: 0;
  padding: 0;
}

.quick-edit-temp-action .btn-tertiary { margin: 0; }

/* Quick overlay */
.sheet-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(24,24,24,.46);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility 0s linear .18s;
}

.sheet-mode-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .18s ease, visibility 0s linear 0s;
}

.sheet-content.is-quick-dimmed {
  pointer-events: none;
  user-select: none;
}

/* Page Edit */
.sheet-header-page { padding-top: 24px; }
.sheet-content.is-page-editing { padding-top: 28px; }

.page-edit-section {
  display: grid;
  gap: 20px;
}

.page-edit-group {
  display: grid;
  gap: 12px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

@container sheet-space (max-width:390px) {
  .page-edit-ability-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
}
@container sheet-space (max-width:390px) {
  .sheet-page { --sheet-gutter: 18px; }
}


@container sheet-space (min-width:900px) {
  .quick-edit-primary.has-extra-speed {
    grid-template-columns: minmax(72px,.75fr) minmax(96px,1fr) minmax(168px,1.45fr);
  }
}
@container sheet-space (min-width:900px) {
  .sheet-page { --sheet-gutter: clamp(34px,4cqw,54px); }
}



/* Normal summary is always one physical row: AC | Initiative | Speed | Hit Dice. */
.sheet-summary-grid.single-speed,
.sheet-summary-grid.has-extra-speed {
  grid-auto-flow: column;
  align-items: start;
}

.sheet-summary-grid > * {
  min-width: 0;
}

.normal-speed-menu,
.normal-hit-dice {
  align-self: start;
}


/* =========================================================
   NORMAL HIT DICE — ISOLATED COMPONENT
   ========================================================= */

.normal-hit-dice {justify-self: end;
min-width: 0;
  justify-self: end;
  text-align: left;}

.normal-hit-dice-values {
  display: grid;
  grid-template-columns: max-content;
  align-items: center;
  gap: 10px;
  width: max-content;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: 23px;
  font-weight: 500;
  line-height: 1;
}

.normal-hit-dice-values > span {
  display: block;
  width: max-content;
  white-space: nowrap;
}

.normal-hit-dice-values .is-max {
  color: #CCC;
}

.normal-divider {
  width: 1px !important;
  min-width: 1px;
  height: 28px;
  background: #CCC;
}

/* =========================================================
   QUICK EDIT
   ========================================================= */

/*
  Important interaction rule:
  Filled Bonfire inputs receive `.is-pressed` from BF.wireFields:
    transform: translateY(5px);
    box-shadow: none;

  Hit Dice is not an input, but it represents already-filled data.
  `.filled-control` intentionally uses the exact same settled state.
  This means AC, Initiative and Hit Dice share both the same 43px
  box geometry AND the same 5px settled position.
*/

.filled-control {
  transform: translateY(5px);
  border-color: var(--ink);
  box-shadow: none;
}

.sheet-header-quick {height: auto;
  min-height: 0;
  max-height: none;
  padding-bottom: 18px;
height: auto;
  min-height: 0;
  max-height: none;
  padding-bottom: 18px;
height: auto;
  min-height: 0;
  max-height: none;
  padding-bottom: 18px;}

.sheet-header-quick .sheet-identity {margin-bottom: 18px;
margin-bottom: 18px;
margin-bottom: 18px;}

.qe-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 0;
  max-height: none;
  padding: 0 0 8px;
}

.qe-row {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.qe-row-stats {
  align-items: start;
}

.qe-row-stats.has-extra-speed {
  grid-template-columns: 50px 78px minmax(0, 1fr);
}

.qe-row-stats.single-speed {
  grid-template-columns:
    minmax(44px, .6fr)
    minmax(72px, .9fr)
    minmax(50px, .65fr)
    minmax(108px, 1.25fr);
}

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

.qe-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 43px;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.qe-label {
  display: block;
  align-self: end;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
}

.qe-input,
.qe-stepper-bar,
.qe-hp {
  box-sizing: border-box;
  height: 43px;
  min-height: 43px;
  max-height: 43px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
}

.qe-input {
  width: 100%;
  margin: 0;
}

/* Hit Dice is a settled/filled field, not an editable input. */
.qe-stepper-bar {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 26px;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 4px;
  background: var(--surface);
}

.qe-stepper-bar .stepper-button,
.qe-hp .stepper-button {
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  margin: 0;
  justify-self: center;
}

.qe-hit-dice-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.qe-hit-dice-values > span {
  min-width: 0;
  white-space: nowrap;
}

.qe-hit-max,
.qe-hp-max {
  color: #CCC;
}

.qe-divider {
  width: 1px !important;
  min-width: 1px;
  height: 22px;
  background: #CCC;
}

.qe-hp {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 5px 6px;
  background: var(--surface);
  box-shadow: none;
}

.qe-hp-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.qe-hp-values.has-temp {
  grid-template-columns:
    minmax(0, 1fr) 1px
    minmax(0, 1fr) 1px
    minmax(0, 1fr);
}

.qe-temp-action {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
}

.qe-temp-action .btn-tertiary {
  margin: 0;
}

@container sheet-space (max-width:390px) {
  .qe-row-stats.has-extra-speed {
    grid-template-columns: 48px 76px minmax(0, 1fr);
  }
}

@container sheet-space (min-width:900px) {
  .qe-row-stats.has-extra-speed {
    grid-template-columns: 72px 96px minmax(168px, 1.4fr);
  }
}


/* Normal-mode HP maximum */
.hp-number-strip > .is-max { color: #CCC !important; }


/* =========================================================
   NORMAL MODE — MULTI-SPEED MENU
   ========================================================= */

.normal-speed-menu {
  position: relative;
  min-width: 0;
  margin: 0;
}

.normal-speed-menu > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.normal-speed-menu > summary::-webkit-details-marker {
  display: none;
}

.normal-speed-menu > summary::marker {
  display: none;
  content: "";
}

.normal-speed-menu > summary strong {
  width: max-content;
  max-width: 100%;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--ink);
  font-family: var(--font-body);
  font-size: 23px;
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
}

.normal-speed-menu[open] > summary strong {
  border-bottom-color: var(--accent);
}

.normal-speed-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 260;
  display: grid;
  gap: 8px;
  min-width: 150px;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--control-shadow);
}

.normal-speed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
}

.normal-speed-row span {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
}

.normal-speed-row strong {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

/* Normal Ability tab typography */
.ability-card-modifier {
  font-weight: 400;
}

.sheet-content .section-title {
  font-size: 20px;
}


/* Normal attack cards: description preview is always one line. */
.attack-card > p {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}


/* Skills: proficient entries first, then a clear break before the rest. */
/* Shared lifted info-card interaction for Normal Mode content cards. */
.info-card {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--control-shadow);
  transform: translateY(0);
  transition: transform .08s ease, box-shadow .08s ease, border-color .08s ease;
  cursor: pointer;
}

.info-card:active {
  transform: translateY(5px);
  box-shadow: none;
}

.info-card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.info-card-copy {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
}

/* Normal Proficiency: balanced equal-height cards. */
.proficiency-display-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.proficiency-display-cell {
  display: flex;
  min-width: 0;
}

.proficiency-display-cell .display-field {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  min-height: 118px;
}

.proficiency-display-cell .display-field > div {
  height: 100%;
  min-height: 72px;
}

@media (max-width: 390px) {
  .proficiency-display-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.background-summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
/* Normal Feats spacing/alignment. */
.features-tab .accordion-content {
  display: grid;
  gap: 16px;
}

.features-tab .info-card {
  margin: 0;
}


/* Spell slot value strip: current | maximum. */
.spell-slot-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-width: 0;
}

.spell-slot-values strong {
  display: block;
  min-width: 0;
  text-align: center;
  font-weight: 600;
}

.spell-slot-values .value-divider {
  height: 24px;
}

.spell-slot-values .is-max {
  color: #CCC;
}


/* Shared Page Edit section heading typography matches Normal accordions. */
.sheet-section-heading {
  margin: 0;
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: left;
}

/* Ability comparison steppers: permanent/base | temporary/current. */
.comparison-stepper-value {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-width: 0;
}

.comparison-stepper-value.has-change {
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  gap: 6px;
}

.comparison-stepper-value strong {
  min-width: 0;
  text-align: center;
}

.comparison-stepper-value .is-base {
  color: #CCC;
}

.comparison-stepper-value .value-divider {
  height: 24px;
}

/* Page Edit ability sections. */
.page-edit-ability {
  gap: 24px;
}

.page-saving-card {
  color: inherit;
  font: inherit;
}

/* Page Edit Skills: one/two proficiency markers. */
/* Page Edit spell list rows are clickable, without an Edit label. */
.page-edit-spell-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
}

.page-edit-row-button {
  width: 100%;
  min-width: 0;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.page-edit-row-button strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}


/* Page Edit Features use the same lifted shared info card. */
.page-edit-feature-cards {
  display: grid;
  gap: 16px;
}
/* Creator feat summaries must be readable in full, not truncated to one line. */
.creator-feature-groups .info-card-copy {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}


/* Page Edit Proficiency: every tag box has the same baseline height,
   even when it is empty. */
.proficiency-tag-grid { align-items: stretch; }

/* All six proficiency groups share the same two-column grid. */

.proficiency-tag-grid .tag-field {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.proficiency-tag-grid .tag-input-shell {
  min-height: 96px;
  height: 100%;
  align-content: start;
}
.page-edit-section .tag-input-shell.is-pressed {
  transform: translateY(5px);
  box-shadow: none;
}

.page-edit-section .tag-field {
  padding-bottom: 5px;
}


.page-edit-background-description-field {
  display: grid;
  gap: 8px;
}

.page-edit-background-description-field .field {
  margin: 0;
}

.page-edit-background-description-field .btn-tertiary {
  justify-self: start;
}


/* Expertise is a smaller light-green filled dot beside the proficiency dot. */
.inventory-card.is-attuned {
  border-color: var(--accent);
  box-shadow: 0 4px 0 var(--accent);
}

button.inventory-card.is-attuned:active {
  box-shadow: 0 1px 0 var(--accent);
}


/* =========================================================
   SHARED SKILLS
   ========================================================= */

.skills-list {
  width: 100%;
  margin-top: 8px;
}

.grouped-skills {
  display: grid;
  gap: 0;
}

.skill-group {
  display: grid;
  width: 100%;
}

.skill-group-gap {
  height: 20px;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) 42px 42px 34px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 47px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: inherit;
  font: inherit;
  text-align: left;
  box-sizing: border-box;
}

.skill-row.is-alt {
  background: var(--surface-alt);
}

.skill-row.is-interactive {
  cursor: pointer;
}

.skill-row.is-interactive:active {
  transform: translateY(1px);
}

.skill-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

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

.skill-modifier {
  text-align: center;
  font-weight: 600;
}

.skill-proficiency-indicator {
  position: relative;
  display: block;
  width: 31px;
  height: 22px;
  justify-self: end;
}

.skill-proficiency-indicator.is-hidden {
  visibility: hidden;
}

.skill-prof-dot {
  position: absolute;
  top: 1px;
  left: 0;
  width: 20px;
  height: 20px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  box-sizing: border-box;
}

.skill-prof-dot.is-filled {
  border-color: var(--accent);
  background: var(--accent);
}

.skill-expertise-dot {
  position: absolute;
  top: 5px;
  right: 0;
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 58%, white);
}

@media (max-width: 390px) {
  .skill-row {
    grid-template-columns: minmax(0, 1fr) 38px 38px 31px;
    gap: 6px;
    padding-inline: 6px;
  }
}


.attunement-slot strong {
  font-size: 14px;
}

.attunement-slot span {
  font-size: 12px;
  color: var(--muted);
}


.check-row.is-disabled {
  opacity: .45;
  cursor: not-allowed;
}

.check-row.is-disabled .checkbox {
  pointer-events: none;
}


.attunement-section {
  display: grid;
  gap: 12px;
}

.attunement-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.attunement-slot-empty {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 106px;
  padding: 8px;
  border: 2px solid #CCC;
  border-radius: 9px;
  background: var(--surface);
  color: #999;
  font-size: 13px;
  box-sizing: border-box;
}


.inventory-section .inventory-card,
.attunement-section .inventory-card,
.equipment-section .inventory-card {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.2;
}

.inventory-section .inventory-card-name,
.attunement-section .inventory-card-name,
.equipment-section .inventory-card-name {
  font-size: 14px;
  font-weight: 500;
}

.inventory-section .inventory-card-meta,
.attunement-section .inventory-card-meta,
.equipment-section .inventory-card-meta {
  font-size: 12px;
  font-weight: 400;
}

.inventory-section .inventory-card-amount,
.attunement-section .inventory-card-amount,
.equipment-section .inventory-card-amount {
  font-size: 13px;
  font-weight: 400;
}


/* Character Creation — Ability: 2 columns x 3 rows. */
.creator-ability-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

/* Creator movement row: compact Movement, full Speed, Delete beside it. */


/* Full Character Creation custom Background descriptions use same field
   geometry as Personality Traits / Ideals / Bonds / Flaws. */
.creator-background-description {
  display: grid;
  gap: 8px;
}

.creator-background-description .field {
  margin: 0;
}


/* Creator Overview movement row: compact Movement, fixed Speed, red Delete. */
.movement-row {
  display: grid;
  grid-template-columns: minmax(82px, .8fr) 104px auto;
  gap: 8px;
  align-items: end;
  width: 100%;
  min-width: 0;
}

.movement-row .field {
  min-width: 0;
}

.movement-delete {align-self: end;
  min-height: 43px;
  margin: 0;
  padding-inline: 6px;
align-self: end;
  min-height: 43px;
  margin: 0;
  padding: 0 4px;
  
  white-space: nowrap;}

.movement-creator .btn-tertiary {
  margin-top: 8px;
}


.creator-feature-groups {
  display: grid;
  gap: 24px;
}

.creator-feature-groups .page-edit-group {
  display: grid;
  gap: 16px;
}

.creator-feature-groups .sheet-section-heading {
  margin: 0;
  padding: 0;
  font-size: 1.1rem;
  text-align: left;
}


/* =========================================================
   SHARED CUSTOM DROPDOWN
   Uses the same flat grey-stroke menu language as profile options.
   ========================================================= */

.custom-select-field {
  overflow: visible;
}

.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}
.custom-select-trigger { position: relative; z-index: 1; pointer-events: auto; }

.custom-select-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.custom-select-trigger > span:first-child {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.custom-select-chevron {
  font-size: 14px;
  line-height: 1;
}

.custom-select-trigger[aria-expanded="true"] {
  border-color: var(--line);
  box-shadow: none;
}


.select-menu.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.select-option {
  display: block;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.select-option:hover,
.select-option:focus-visible {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  outline: none;
}

.select-option.is-selected {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  outline: none;
}


.select-menu {position: absolute;
  z-index: 1600;
  top: calc(100% + 9px);
  left: 0;
  width: 100%;
  min-width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  max-height: 260px;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: none;
  overflow-y: auto;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;}

.select-menu::-webkit-scrollbar {
  width: 8px;
}

.select-menu::-webkit-scrollbar-track {
  background: transparent;
}

.select-menu::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}


/* =========================================================
   TABLER ICON SYSTEM
   ========================================================= */
.bf-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  color: currentColor;
  vertical-align: -0.125em;
  overflow: visible;
}

.bf-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.bf-icon-button .bf-icon {
  font-size: 18px;
}

.bf-icon-button.is-danger {
  color: var(--danger);
}

.stepper-button .bf-icon {
  font-size: 18px;
}

.modal-close .bf-icon,
.tag button .bf-icon {
  font-size: 17px;
}

.custom-select-chevron {
  display: inline-grid;
  place-items: center;
}

.custom-select-chevron .bf-icon {
  font-size: 16px;
}

.btn-tertiary.has-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-tertiary.has-icon .bf-icon {
  font-size: 16px;
}

.accordion-chevron {
  display: inline-grid;
  place-items: center;
}

.accordion-chevron .bf-icon {
  font-size: 18px;
}


.bf-icon-outline {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bf-icon-filled {
  fill: currentColor;
  stroke: none;
}


/* Shared destructive icon treatment */
.bf-icon-button.is-danger,
.trash-button {
  display: inline-grid;
  place-items: center;
  align-self: center;
  line-height: 0;
}

.bf-icon-button.is-danger .bf-icon,
.trash-button .bf-icon {
  width: 22px;
  height: 22px;
  font-size: 22px;
  vertical-align: middle;
}

.movement-delete {
  align-self: end;
  place-self: end center;
  min-height: 43px;
}


/* Shared Close icon size */
.modal-close .bf-icon,
.tag button .bf-icon,
.bf-icon-button[aria-label="Close"] .bf-icon,
.bf-icon-button[aria-label^="Close "] .bf-icon {
  width: 26px;
  height: 26px;
  font-size: 26px;
}

/* One shared open/closed chevron rule */
.chevron-open { display: none; }
.chevron-closed { display: inline-grid; place-items: center; }

[aria-expanded="true"] .chevron-closed,
.is-open > .accordion-heading .chevron-closed { display: none; }

[aria-expanded="true"] .chevron-open,
.is-open > .accordion-heading .chevron-open {
  display: inline-grid;
  place-items: center;
}

.chevron-open .bf-icon,
.chevron-closed .bf-icon {
  width: 18px;
  height: 18px;
  font-size: 18px;
}


/* =========================================================
   FIREBASE / AUTH
   ========================================================= */
.auth-invite-copy {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: .95rem;
}

.auth-error {
  margin: -2px 0 0;
  color: var(--danger);
  font-size: .9rem;
  font-weight: 600;
}

.firebase-loading {
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}

.firebase-loading h1 {
  margin-bottom: 12px;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}


/* =========================================================
   MOBILE TOUCH BEHAVIOUR
   Prevent Safari double-tap zoom on rapid UI interactions
   without disabling normal pinch-to-zoom accessibility.
   ========================================================= */
button,
.btn,
.btn-tertiary,
.text-action,
.stepper-button,
.custom-select-trigger,
.select-option,
.sheet-tab,
.creator-tab,
.nav-item,
.checkbox,
.radio,
input,
textarea {
  touch-action: manipulation;
}

button,
.btn,
.btn-tertiary,
.text-action,
.stepper-button,
.custom-select-trigger,
.select-option,
.sheet-tab,
.creator-tab,
.nav-item {
  -webkit-user-select: none;
  user-select: none;
}


.btn-tertiary,
.btn-tertiary:hover,
.btn-tertiary:focus,
.btn-tertiary:active,
.text-action,
.text-action:hover,
.text-action:focus,
.text-action:active {
  text-decoration: none;
}


/* Shared physical press state. .btn-static opts non-depressing tools out of movement.
   Actions/navigation still fire on the normal click event after release. */
.btn.is-pressed:not(:disabled):not(.btn-static):not([data-press-mode="selection"]),
.btn-tertiary.is-pressed:not(:disabled):not(.btn-static),
.stepper-button.is-pressed:not(:disabled),
.inventory-card.is-pressed,
.info-card.is-pressed,
.attack-card.is-pressed {
  transform: translateY(4px);
  box-shadow: none;
}

.btn.is-pressed:not(:disabled):not(.btn-static):not([data-press-mode="selection"]) {
  box-shadow: 0 1px 0 var(--ink);
}


/* =========================================================
   SHARED CONTROL ALIGNMENT / MOBILE POLISH
   ========================================================= */

/* Close is one shared, deliberately large control everywhere. */
.modal-close,
.bf-icon-button[aria-label="Close"],
.bf-icon-button[aria-label^="Close "] {
  display: inline-grid;
  place-items: center;
  line-height: 0;
}

.modal-close .bf-icon,
.info-sheet-close .bf-icon,
.bf-icon-button[aria-label="Close"] .bf-icon,
.bf-icon-button[aria-label^="Close "] .bf-icon {
  width: 32px;
  height: 32px;
  font-size: 32px;
}

/* Destructive icon controls use the same 43px filled-control height.
   This fixes Movement delete and gives future inline trash buttons the same baseline. */
.bf-icon-button.is-danger,
.movement-delete {
  min-width: 43px;
  width: 43px;
  min-height: 43px;
  height: 43px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  line-height: 0;
}

.bf-icon-button.is-danger .bf-icon,
.movement-delete .bf-icon,
.trash-button .bf-icon {
  width: 26px;
  height: 26px;
  font-size: 26px;
}

/* Checkbox labels align to the checkbox's pressed/filled visual state.
   One-line and wrapped labels now share the same centering rule. */
.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 29px;
}

.check-row > .checkbox {
  align-self: center;
}

.check-row > :not(.checkbox) {
  align-self: center;
}

/* Dropdown trigger follows the same physical-input premise:
   resting = filled/down, open = lifted with green highlight + green shadow. */
.custom-select-trigger[aria-expanded="false"] {
  transform: translateY(5px);
  border-color: var(--ink);
  box-shadow: none;
}

.custom-select-trigger[aria-expanded="true"] {
  transform: translateY(0);
  border-color: var(--accent);
  box-shadow: var(--control-shadow-accent);
}

/* Dropdown menu must match the input width exactly, never content-width. */
.custom-select {
  width: 100%;
  min-width: 0;
}

.select-menu {
  box-sizing: border-box;
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

.select-menu::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Modal actions use the same shared press system as every other button. */
.modal-actions .btn,
.modal-actions .text-action {
  touch-action: manipulation;
}


/* =========================================================
   EDITOR HEIGHT / DERIVED FIELDS / ACTION ALIGNMENT
   ========================================================= */

/* Center the shared tertiary actions specifically when they add attacks/spells. */
.btn-tertiary[data-add-attack],
.btn-tertiary[data-page-add-attack],
.btn-tertiary[data-add-spell],
.btn-tertiary[data-page-add-spell] {
  display: flex;
  width: max-content;
  margin-left: auto;
  margin-right: auto;
  justify-self: center;
}


/* =========================================================
   ONE INPUT STATE SYSTEM
   ========================================================= */

/* Editable input: lifted + green stroke/shadow while editing. */
.field input.text-input.is-editing:not([readonly]):not([aria-readonly="true"]),
.field textarea.text-input.is-editing {
  transform: translateY(0);
  border: 3px solid var(--accent);
  box-shadow: var(--control-shadow-accent);
}

/* Editable input: filled/resting state. */
.field input.text-input.is-pressed:not([readonly]):not([aria-readonly="true"]),
.field textarea.text-input.is-pressed {
  transform: translateY(5px);
  border: 3px solid var(--ink);
  box-shadow: none;
}

/* Derived / automatic values are display-like filled controls.
   Transparent stroke reserves identical geometry without looking editable. */
.field input[readonly].text-input,
.field input[aria-readonly="true"].text-input {
  transform: translateY(5px) !important;
  border: 3px solid transparent !important;
  background: var(--surface-alt);
  box-shadow: none !important;
  outline: none;
  cursor: default;
}


/* The whole character card is the vertical gesture surface.
   Horizontal tab scrolling remains allowed inside the tab strip. */
.sheet-header {
  touch-action: pan-x;
}

.sheet-tabs,
.sheet-tabs * {
  touch-action: pan-x;
}

.sheet-header input,
.sheet-header textarea,
.sheet-header button:not(.sheet-pull-handle),
.sheet-header [data-custom-select] {
  touch-action: manipulation;
}


/* =========================================================
   QUICK EDIT LAYOUT
   One explicit grid owns each row.
   ========================================================= */

.qe-shell {
  display: grid;
  gap: 32px;
  width: 100%;
  min-width: 0;
}

.qe-row-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

/* Extra movement tries the same row while each control can remain useful.
   On narrow phones CSS wraps the extra movement into its own responsive row. */
.qe-row-extra-movement {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  align-items: end;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.qe-hit-dice {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.qe-hit-dice .qe-stepper-bar {
  width: 100%;
  min-width: 0;
}

/* Tab strip is its own scroll container. */
.sheet-tabs {
  scroll-behavior: auto;
  scroll-snap-type: none;
}

@media (max-width: 370px) {
  .qe-row-stats {
    gap: 8px;
  }
}


/* =========================================================
   HANDLE / TAB SPACING
   ========================================================= */

/* Slightly taller triangular affordance and clearer air below the tab strip. */
.sheet-pull-handle {
  bottom: -34px;
  height: 34px;
}

.sheet-pull-handle::before {
  height: 22px;
}

.sheet-pull-handle span {
  top: 6px;
}

/* Tabs sit a little closer to HP, while the triangle gets more room below tabs. */
.sheet-tabs-in-card {
  margin-top: 14px;
  padding-top: 10px;
  padding-bottom: 10px;
  margin-bottom: 6px;
}

/* Horizontal tab movement remains native; vertical gestures can be claimed by the card. */
.sheet-tabs,
.sheet-tabs * {
  touch-action: pan-x;
}

/* =========================================================
   DEATH SAVING THROWS
   ========================================================= */
.death-save-control {
  display: grid;
  gap: 16px;
  width: 100%;
  padding-top: 4px;
  text-align: center;
}

.death-save-control h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.death-save-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: end;
  width: 100%;
}

.death-save-group {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.death-save-group > strong {
  font-size: 14px;
  font-weight: 700;
}

.death-save-circles {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 8px;
  justify-content: center;
}

.death-save-circle {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

.death-save-circle.is-filled.death-save-success {
  border-color: var(--accent);
  background: var(--accent);
}

.death-save-circle.is-filled.death-save-failure {
  border-color: var(--danger);
  background: var(--danger);
}

.death-save-health-action {
  display: grid;
  place-items: center;
}

.death-save-health-action .btn-tertiary {
  margin: 0;
}

.sheet-header-quick .death-save-control {
  margin-top: 0;
}


/* : Page Edit Ability is always 2 columns × 3 rows. */
.page-edit-ability-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}


/* creator Ability hierarchy + reliable two-column Page Edit abilities */
.page-edit-ability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 12px;
  width: 100%;
}

.creator-ability-step {
  gap: 18px;
}

.creator-ability-step > .sheet-section-heading {
  margin: 8px 0 0;
}

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

.creator-saving-throw {
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.creator-saving-throw .proficiency-circle {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
}

.creator-saving-throw .proficiency-circle.is-filled {
  border-color: var(--accent);
  background: var(--accent);
}

.creator-saving-throw strong {
  font-weight: 600;
}


/* =========================================================
   SPELL EDITOR / SPELL ADD FLOW
   ========================================================= */

.spell-add-row {
  display: grid;
  place-items: center;
  width: 100%;
  margin: 6px 0 18px;
}

.spell-add-row .btn-secondary {
  margin: 0;
}

/* Spell components use Bonfire's shared square checkbox component. */
.spell-component-checks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.spell-component-checks .check-row {
  align-items: center;
}


.custom-casting-time[hidden],
.reaction-detail[hidden],
[data-material-details][hidden] {
  display: none;
}


/* =========================================================
   ACCOUNT / ADMIN PREVIEW
   ========================================================= */
.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--line);
}
.preview-toolbar .eyebrow { margin: 0 0 2px; }
.preview-toolbar strong { font-family: var(--heading-font); }
.preview-account-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 18px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.preview-account-summary span { color: var(--muted); }
.preview-account-summary strong { text-align: right; }


/* =========================================================
   PASSWORD REQUIREMENTS
   Shared account-creation password strength checklist.
   ========================================================= */
.password-field-group {
  display: grid;
  gap: 10px;
}

.password-requirements {
  display: grid;
  gap: 3px;
  padding: 0 2px;
  font-size: .82rem;
  line-height: 1.3;
}

.password-requirement {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--danger);
  transition: color .12s ease;
}

.password-requirement.is-valid {
  color: var(--accent-dark);
}

.password-requirement-icon {
  width: 17px;
  flex: 0 0 17px;
  font-size: 1.15rem;
  line-height: 1;
  text-align: center;
  font-weight: 700;
}

.password-requirements.is-untouched .password-requirement {
  color: var(--muted);
}

.password-requirements.is-untouched .password-requirement-icon {
  opacity: .65;
}

/* =========================================================
   ACCOUNT / PLAN HOME STATES
   ========================================================= */
.home-create-actions {
  display: grid;
  gap: 22px;
  width: 100%;
}

.home-create-actions > .btn,
.character-limit-message > .btn {
  width: 100%;
}

.character-limit-message {
  display: grid;
  gap: 14px;
  text-align: center;
}

.character-limit-divider {
  height: 1.5px;
  width: 100%;
  margin-bottom: 4px;
  background: var(--line);
}

.character-limit-message h3,
.character-limit-message p {
  margin: 0;
}

.character-limit-message p {
  color: var(--muted);
}

/* =========================================================
   PROFILE PAGE
   ========================================================= */
.profile-page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 34px;
}

.profile-page-header h1 { margin: 0; }

.profile-details {
  display: grid;
  gap: 18px;
}


/* Normal-mode spell hierarchy: one Cantrip section, one Known Spells section. */
.known-spell-section {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.known-spell-section > .sheet-section-heading { margin: 0; }

.known-spell-levels {
  display: grid;
  gap: 28px;
}

.known-spell-level {
  display: grid;
  gap: 12px;
}

.known-spell-level-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
}

.known-spell-level-header h3 {
  margin: 0;
  font-family: "Nunito", sans-serif;
}

.known-spell-list {
  display: grid;
}

.spell-level-slots {
  min-width: 0;
}

/* =========================================================
   INVENTORY CURRENCY + DIRECT RESOURCE ENTRY
   ========================================================= */
.currency-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.currency-slot {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.currency-slot > span {
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  text-align: center;
  font-size: .8rem;
}

.currency-value {
  min-height: 50px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.stepper-value-button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  min-width: 0;
  width: 100%;
  min-height: 34px;
  padding: 0 2px;
  cursor: pointer;
}

.spell-known-overview { margin-bottom: 4px; }
.known-spell-level + .known-spell-level { margin-top: 24px; }
.spell-slots-display { display: grid; gap: 6px; }
.display-field-control {
  min-height: 50px;
  border: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform: translateY(5px);
}

@media (max-width: 390px) {
  .currency-row { gap: 6px; }
}

/* Currency editing uses the shared Bonfire field component. */
.currency-row.is-editable .currency-slot { display: block; }
.currency-row.is-editable .field { margin: 0; min-width: 0; }
.currency-row.is-editable .field > span { text-align: center; display: block; }
.currency-row.is-editable .field input { width: 100%; text-align: center; min-width: 0; }
.spell-slots-display .stepper { width: 100%; }

/* Resource, inventory and navigation polish. */

/* Normal-view currency uses the same settled, read-only visual language as
   Bonfire's other display fields: filled surface, reserved transparent stroke. */
.currency-row:not(.is-editable) {
  margin-bottom: 30px;
}

.currency-row:not(.is-editable) .currency-value {
  border: 3px solid transparent;
  background: var(--surface-alt);
  transform: translateY(5px);
  box-shadow: none;
}

/* Editable currency remains a normal shared Bonfire field. */
.currency-row.is-editable {
  margin-bottom: 28px;
}

/* The center of a shared resource control can be tapped for direct entry. */
.resource-control-value-button {
  appearance: none;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* When the sticky character card is dragged down, extend its own surface
   upward so the gesture never reveals the page/background behind it. */
.sheet-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  bottom: 100%;
  height: max(140px, calc(140px + var(--card-drag-y)));
  background: var(--surface);
  pointer-events: none;
}

/* Keep the primary mobile navigation viewport-bound and inside the shell.
   Route changes must not alter its geometry or create horizontal overflow. */
.bottom-nav {
  max-width: 560px;
  overflow: hidden;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.bottom-nav .nav-item {
  width: min(120px, 100%);
  max-width: 100%;
}

.updates-page,
.updates-standalone {
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

/* =========================================================
   creator progress + viewport navigation
   ========================================================= */
.creator-titlebar { display:flex; align-items:center; gap:10px; }
.creator-titlebar strong { font-family:var(--font-display); font-size:1rem; font-weight:900; }
.creator-tab.is-complete { color:var(--ink); border-bottom-color:var(--ink); }
.creator-tab.is-active { color:var(--accent); border-bottom-color:var(--accent); }
.creator-footer [data-creator-cancel] { margin-right:auto; }
.creator-saving-throw { grid-template-columns:minmax(0,1fr) auto 20px; }
.creator-saving-throw .proficiency-circle { justify-self:end; width:20px; height:20px; }
.creator-ability-step > .sheet-section-heading:last-of-type { margin-bottom:-10px; }

/* This is the single source of truth for the app's primary navigation.
   The element is a direct child of body in , so no route, app-shell overflow,
   transform or content height can change the containing block for position:fixed. */
.bottom-nav {
  position: fixed;
  z-index: 1000;
  left: 50%;
  right: auto;
  bottom: 0;
  width: min(100%, 560px);
  max-width: 560px;
  height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 40px max(8px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  align-items: center;
}
.bottom-nav[hidden] { display:none; }
.bottom-nav .nav-item { justify-self:center; width:min(120px,100%); min-width:0; max-width:100%; }
.home-page, .updates-page, .updates-standalone, .update-card, .update-card > div { min-width:0; max-width:100%; }
.updates-page { width:100%; overflow-x:hidden; padding-bottom:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 28px); }


/* =========================================================
   ACCOUNT CREATION PREVIEW — Shared visual treatment for email verification + Google path.
   ========================================================= */
.google-auth-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.google-mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: .85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line, #d7d7d2);
}

.verification-email {
  margin-top: -8px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.preview-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.45;
}

.google-preview-card {
  display: grid;
  gap: 18px;
  margin: 22px 0;
}


/* =========================================================
   ACCOUNT SAFETY + PROFILE DELETION — ========================================================= */
.verification-status {
  margin: 14px 0 0;
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.4;
}
.verification-status.is-error { color: var(--danger); }
.verification-status.is-success { color: var(--accent-dark); }
.preview-simulate-action { margin-top: 12px; }
.profile-danger-zone { margin-top: 34px; }
.profile-divider { height: 1px; width: 100%; background: var(--line); margin-bottom: 22px; }
.profile-delete-account { color: var(--danger); }
.btn-danger,
.btn-danger:hover,
.btn-danger:focus {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}


.sheet-tab-icon {
  display: none;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.sheet-tab-icon .bf-icon {
  width: 100%;
  height: 100%;
}

.sheet-character-title {
  display: none;
}



@container sheet-space (min-width:1280px) {
  .sheet-header-normal .sheet-tab-icon {
    width: 25px;
    height: 25px;
    flex-basis: 25px;
  }
}



/* introduced wrappers for desktop summary icons. Keep those wrappers
   visually inert below the desktop breakpoint so the established mobile
   character card remains unchanged. */

@container sheet-space (max-width:899px) {
  .sheet-summary-icon { display: none !important; }
  .sheet-summary-copy { display: contents !important; }
}



/* AC and Initiative use the same data size as the rest of the character-card data on mobile too. */

@container sheet-space (max-width:899px) {
  .sheet-header-normal .sheet-summary-stat > strong,
  .sheet-header-normal .sheet-summary-copy > strong {
    font-family: var(--font-body);
    font-size: 23px;
    font-weight: 500;
    line-height: 1.1;
  }
}


/* Spell slots mirror HP's max | current visual language on every viewport. */
.spell-slot-stepper .spell-slot-values {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  width: 100%;
}
.spell-slot-stepper .spell-slot-values strong {
  display: block;
  min-width: 0;
  text-align: center;
  font-weight: 600;
}
.spell-slot-stepper .spell-slot-values .is-max { color: #CCC; }
.spell-slot-stepper .spell-slot-values .value-divider {
  width: 1px;
  height: 24px;
  background: #CCC;
}


/* Attack proficiency is visible at a glance in both mobile and desktop. */
.attack-card-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.attack-title-proficiency {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
}

/* Information sheets use label/value pairs instead of flattening metadata into prose. */
.info-sheet-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  margin-bottom: 24px;
}
.info-sheet-meta-item {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.info-sheet-meta-item > span {
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.info-sheet-meta-item > strong {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}


.info-sheet-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.info-sheet-title-row h2 { min-width: 0; }
.info-title-proficiency { display: inline-block; }


/* Background custom descriptions grow with their content. */
.page-edit-background-description-field textarea {
  min-height: 100px;
  max-height: 350px;
  resize: none;
}

/* =========================================================
   DESKTOP — CHARACTER SHEET One authoritative desktop definition. Mobile remains governed by
   the base/mobile rules above.
   ========================================================= */
@media (min-width: 900px) {
    html:has(.app > .sheet-page),
  body:has(.app > .sheet-page) {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  /* The desktop sheet lives inside the body's existing 28px padding.
     Nothing inside the sheet is allowed to size itself against the raw viewport. */
    body:has(.app > .sheet-page) {
    box-sizing: border-box;
  }
    body:has(.app > .sheet-page) .app-shell {
    width: min(100%, var(--content-max));
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border-radius: 20px;
    background: var(--surface-alt);
  }
    body:has(.app > .sheet-page) .app {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
  }
    body:has(.app > .sheet-page) .sheet-page {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    margin: 0;
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
  }
    body:has(.app > .sheet-page) .sheet-header {
    position: relative;
    top: auto;
    flex: 0 0 auto;
  }
    body:has(.app > .sheet-page) .sheet-content {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-top: 54px;
    padding-bottom: 52px;
    background: var(--bg);
    border-radius: 0 0 20px 20px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
  }
    body:has(.app > .sheet-page) .sheet-content::-webkit-scrollbar { width: 9px; }
    body:has(.app > .sheet-page) .sheet-content::-webkit-scrollbar-track { background: transparent; }
    body:has(.app > .sheet-page) .sheet-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
  }

  /* Normal card: 2x2 stats left, portrait center, identity right. */
  
  
  
  
  
  
  
  
  

  
  
  
  
  
  
  
  
  

  /* Normal and Page Edit share exactly the same tab geometry. */
  
  
  
  
  
  
  
  

  /* One triangle treatment for all three modes. */
  
  
  
  

  /* Quick Edit. */
  
  
  
  
  
  
  

  /* Background Page Edit. */
  
  
  
  

  /* Desktop bottom sheets become centered modal windows. */
    .bottom-sheet,
  .bottom-sheet.bottom-sheet-editor {
    left:50%; top:50%; bottom:auto;
    width:min(calc(100% - 64px),620px); max-height:min(82dvh,760px);
    border-radius:22px; transform:translate(-50%,-48%) scale(.98); opacity:0;
    padding:48px 24px 24px; transition:transform .18s ease,opacity .18s ease;
  }
    .overlay.is-open .bottom-sheet,
  .overlay.is-open .bottom-sheet.bottom-sheet-editor { transform:translate(-50%,-50%) scale(1); opacity:1; }
    .bottom-sheet:has(.info-sheet) { display:flex; flex-direction:column; overflow:hidden; padding-bottom:0; }
    .bottom-sheet:has(.info-sheet) .sheet-form { display:block; min-height:0; max-height:min(82dvh,720px); overflow:hidden; }
    .info-sheet { display:flex; flex-direction:column; min-height:240px; max-height:min(82dvh,720px); }
    .info-sheet-header { position:relative; top:auto; flex:0 0 auto; min-height:58px; margin:0 0 18px; padding:8px 44px 14px 0; border-bottom:1px solid var(--line); background:var(--surface); }
    .info-sheet-scroll { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; padding:0 10px 22px 0; scrollbar-width:thin; scrollbar-color:var(--accent) transparent; }
    .info-sheet-scroll::-webkit-scrollbar { width:8px; }
    .info-sheet-scroll::-webkit-scrollbar-track { background:transparent; }
    .info-sheet-scroll::-webkit-scrollbar-thumb { background:var(--accent); border-radius:999px; }
}
@container sheet-space (min-width:900px) {
  .sheet-header-normal {
    display: grid;
    grid-template-columns: repeat(12,minmax(0,1fr));
    grid-template-rows: 150px auto auto;
    column-gap: clamp(18px,2.25cqw,34px);
    row-gap: 26px;
    padding-top: 24px;
  }
  .sheet-header-normal .sheet-summary-grid.single-speed,
  .sheet-header-normal .sheet-summary-grid.has-extra-speed {
    grid-column: 1 / 6;
    grid-row: 1;
    grid-auto-flow: row;
    grid-template-columns: repeat(2,minmax(132px,164px));
    grid-template-rows: repeat(2,auto);
    justify-content: start;
    align-content: start;
    align-self: start;
    column-gap: 28px;
    row-gap: 20px;
  }
  .sheet-header-normal .sheet-summary-grid > *,
  .sheet-header-normal .normal-hit-dice { justify-self: start; text-align: left; }
  .sheet-header-normal .sheet-summary-stat,
  .sheet-header-normal .normal-hit-dice,
  .sheet-header-normal .normal-speed-menu > summary {
    display: grid;
    grid-template-columns: 30px minmax(0,1fr);
    align-items: stretch;
    column-gap: 10px;
  }
  .sheet-header-normal .sheet-summary-icon {
    display: grid;
    place-items: stretch center;
    width: 30px;
    height: 100%;
    min-height: 48px;
  }
  .sheet-header-normal .sheet-summary-icon .bf-icon { width: 26px; height: 100%; }
  .sheet-header-normal .sheet-summary-copy { display:grid; gap:4px; min-width:0; }
  .sheet-header-normal .sheet-summary-label { font-size: clamp(14px,1.25cqw,18px); }
  .sheet-header-normal .sheet-summary-copy > strong,
  .sheet-header-normal .normal-hit-dice-values { font-size: clamp(22px,2cqw,30px); font-weight:500; line-height:1; }
  .sheet-header-normal .sheet-identity {
    grid-column: 1 / -1;
    grid-row: 1;
    display: block;
    width: 100%;
    height: 150px;
    margin: 0;
    position: relative;
    pointer-events: none;
  }
  .sheet-header-normal .sheet-identity .sheet-avatar {
    position:absolute; left:50%; top:0;
    width:150px; height:150px; min-width:150px; min-height:150px;
    margin:0; transform:translateX(-50%); border-radius:50%; overflow:hidden;
    pointer-events:auto;
  }
  .sheet-header-normal .sheet-identity .sheet-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
  .sheet-header-normal .sheet-identity > div:first-child {
    position:absolute; left:calc(50% + 108px); right:0; top:0;
    min-width:0; text-align:left; pointer-events:auto;
  }
  .sheet-header-normal .sheet-identity h1 { margin:5px 0 8px; font-size:clamp(30px,2.5cqw,40px); line-height:1; }
  .sheet-header-normal .class-lines { margin:0; font-size:clamp(14px,1.2cqw,17px); font-weight:500; line-height:1.2; }
  .sheet-header-normal .sheet-character-title { display:block; margin:0; padding-top:8px; border-top:1px solid var(--line); font-family:var(--font-display); font-size:clamp(13px,1.05cqw,15px); }
  .sheet-header-normal .sheet-summary-hp { grid-column:4 / 10; grid-row:2; width:100%; max-width:480px; justify-self:center; margin-top:-12px; }
  .sheet-header-normal .sheet-summary-hp::before { content:none; display:none; }
  .sheet-header-normal .sheet-tabs-in-card,
  .sheet-header-page .sheet-tabs-in-card {
    display:flex; justify-content:flex-start; gap:clamp(14px,2cqw,32px);
    width:calc(100% + (var(--sheet-gutter) * 2));
    margin-left:calc(var(--sheet-gutter) * -1); margin-right:calc(var(--sheet-gutter) * -1);
    padding-left:var(--sheet-gutter); padding-right:var(--sheet-gutter);
    border-top:0; overflow-x:auto; overflow-y:hidden; scrollbar-width:none;
  }
  .sheet-header-normal .sheet-tabs-in-card { grid-column:1 / -1; grid-row:3; margin-top:12px; }
  .sheet-header-page { padding-top:24px; }
  .sheet-header-normal .sheet-tabs-in-card::-webkit-scrollbar,
  .sheet-header-page .sheet-tabs-in-card::-webkit-scrollbar { display:none; }
  .sheet-header-normal .sheet-tab,
  .sheet-header-page .sheet-tab { flex:0 0 auto; display:inline-flex; align-items:center; gap:8px; font-size:clamp(14px,1.25cqw,18px); white-space:nowrap; }
  .sheet-header-normal .sheet-tab-icon,
  .sheet-header-page .sheet-tab-icon { display:inline-grid; place-items:center; width:25px; height:25px; flex:0 0 25px; }
  .sheet-header-normal .sheet-tab-icon .bf-icon,
  .sheet-header-page .sheet-tab-icon .bf-icon { width:25px; height:25px; }
  .sheet-header-normal .sheet-tab.is-active .sheet-tab-icon,
  .sheet-header-page .sheet-tab.is-active .sheet-tab-icon { color:var(--accent); }
  .sheet-header-normal .sheet-pull-handle,
  .sheet-header-page .sheet-pull-handle,
  .sheet-header-quick .sheet-pull-handle { bottom:-44px; height:44px; }
  .sheet-header-normal .sheet-pull-handle::before,
  .sheet-header-page .sheet-pull-handle::before,
  .sheet-header-quick .sheet-pull-handle::before {
    top:-1px; height:34px;
    filter:drop-shadow(0 1px 0 var(--line)) drop-shadow(1px 0 0 var(--line)) drop-shadow(-1px 0 0 var(--line)) drop-shadow(0 6px 5px rgba(0,0,0,.20));
  }
  .sheet-header-normal .sheet-pull-handle span,
  .sheet-header-page .sheet-pull-handle span,
  .sheet-header-quick .sheet-pull-handle span { top:7px; width:22px; height:3px; box-shadow:none; }
  .sheet-header-normal .sheet-pull-handle span::after,
  .sheet-header-page .sheet-pull-handle span::after,
  .sheet-header-quick .sheet-pull-handle span::after {
    content:""; position:absolute; left:50%; top:7px; width:14px; height:3px;
    border-radius:999px; background:var(--accent); transform:translateX(-50%);
  }
  .sheet-header-quick .qe-label { font-size:16px; font-weight:400; line-height:1.2; }
  .sheet-header-quick .qe-input,
  .sheet-header-quick .qe-hit-dice-values,
  .sheet-header-quick .qe-hp-values { font-size:26px; line-height:1; }
  .sheet-header-quick .qe-shell { grid-template-columns:minmax(0,.72fr) minmax(0,1.28fr); column-gap:20px; row-gap:22px; }
  .sheet-header-quick .qe-row-stats,
  .sheet-header-quick .qe-row-extra-movement { grid-column:1 / -1; }
  .sheet-header-quick .qe-hit-dice { grid-column:1; align-self:start; }
  .sheet-header-quick .qe-hp { grid-column:2; align-self:end; }
  .sheet-header-quick .qe-temp-action { grid-column:2; justify-items:center; margin-top:-16px; }
  .page-edit-background-core { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; align-items:start; }
  .page-edit-background-copy { display:grid; gap:16px; }
  .page-edit-background-description-field { gap:4px; }
  .page-edit-background-copy textarea,
  .page-edit-background-description-field textarea { min-height:100px; max-height:350px; resize:none; overflow-y:hidden; }
}


/* =========================================================
   SHEET POLISH
   ========================================================= */
/* Normal inventory currency uses the same white + grey-stroke display field
   language as the read-only spell/ability/save/attack fields. */
.currency-row:not(.is-editable) .currency-value {
  border: 1.5px solid var(--line);
  background: var(--surface);
  transform: none;
  box-shadow: none;
}

/* Quick Edit comparison fields: original value | edited value. */
.qe-input-shell {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  align-items: center;
  height: 43px;
  min-width: 0;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.qe-input-shell.has-change {
  grid-template-columns: minmax(0,1fr) 1px minmax(0,1fr);
  gap: 6px;
}
.qe-input-shell .qe-input {
  width: 100%; height: 100%; min-width: 0;
  border: 0; border-radius: 0; box-shadow: none; transform: none;
  background: transparent; text-align: center; padding: 0 4px;
}
.qe-start-value { color: var(--muted); text-align:center; font-size:inherit; }
.qe-input-shell .qe-divider { height: 24px; background: var(--line); }
.qe-field.has-icon { grid-template-columns: 28px minmax(0,1fr); column-gap:8px; }
.qe-field.has-icon .qe-stat-icon { grid-column:1; grid-row:1 / 3; display:grid; place-items:center; }
.qe-field.has-icon .qe-stat-icon .bf-icon { width:24px; height:100%; }
.qe-field.has-icon .qe-label,
.qe-field.has-icon .qe-input-shell,
.qe-field.has-icon .qe-stepper-bar { grid-column:2; }

/* Normal Background text follows the same 350px cap as Page Edit. */
.normal-background-view .display-field.is-multiline > div {
  max-height: 350px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.normal-background-view .display-field.is-multiline > div::-webkit-scrollbar { width:8px; }
.normal-background-view .display-field.is-multiline > div::-webkit-scrollbar-thumb { background:var(--accent); border-radius:999px; }

@media (min-width: 900px) {
  /* Info popups: the title bar belongs to the modal edges, not a padded inner
     box. This keeps title and close button aligned. */
  .bottom-sheet:has(.info-sheet) { padding:0; }
  .bottom-sheet:has(.info-sheet) .sheet-form { max-height:min(82dvh,720px); }
  .info-sheet-header {
    min-height:64px; margin:0; padding:20px 58px 16px 24px;
    display:flex; align-items:center; border-bottom:1px solid var(--line);
  }
  .info-sheet-header .modal-close,
  .info-sheet-close { top:16px; right:18px; left:auto; }
  .info-sheet-scroll { padding:20px 24px 24px; }
}

/* =========================================================
   QUICK EDIT — INPUTS / SPEED / BACKGROUND
   ========================================================= */
/* Quick Edit values are data inputs, not physical buttons. They never sink
   when filled: resting is centred, focus only changes the editing highlight. */
.qe-input-shell .qe-input.text-input,
.qe-input-shell .qe-input.text-input.is-pressed,
.qe-input-shell .qe-input.text-input.is-editing {
  transform: none !important;
  box-shadow: none !important;
  border: 0 !important;
  padding: 0 6px;
  text-align: center;
  line-height: 43px;
  height: 43px;
  min-height: 43px;
}
.qe-input-shell:focus-within {
  border-color: var(--accent);
  box-shadow: var(--control-shadow-accent);
}
.qe-input-shell.has-change .qe-start-value { color:#CCC; }

/* The stat icon owns a full column from the label to the bottom of the field,
   and its glyph is the same physical height as the 43px data input. */
.qe-field.has-icon { grid-template-columns:43px minmax(0,1fr); column-gap:10px; }
.qe-field.has-icon .qe-stat-icon {
  grid-column:1;
  grid-row:1 / 3;
  width:43px;
  height:100%;
  min-height:63px;
  display:grid;
  align-items:end;
  justify-items:center;
}
.qe-field.has-icon .qe-stat-icon .bf-icon { width:43px; height:43px; }

.qe-hp-field { display:grid; grid-template-rows:auto 43px; gap:4px; min-width:0; }
.qe-hp-field .qe-hp { height:43px; min-height:43px; }

/* A non-overflowing Background field must not swallow wheel scrolling from
   the page. At the 350px cap, normal scroll chaining still reaches the page. */
.normal-background-view .display-field.is-multiline > div {
  overscroll-behavior: auto;
}

/* Make the multi-speed disclosure sit above the rest of the card when open. */
.normal-speed-menu[open] { z-index:300; }
.normal-speed-popover { z-index:301; }


@container sheet-space (min-width:900px) {
  .sheet-header-normal .sheet-pull-handle::after,
  .sheet-header-page .sheet-pull-handle::after,
  .sheet-header-quick .sheet-pull-handle::after {
    content:"";
    position:absolute;
    left:0;
    top:-1px;
    width:100%;
    height:36px;
    background:var(--line);
    clip-path:polygon(0 0,100% 0,50% 100%);
    z-index:-2;
  }
  .sheet-header-normal .sheet-pull-handle::before,
  .sheet-header-page .sheet-pull-handle::before,
  .sheet-header-quick .sheet-pull-handle::before {
    left:1px;
    width:calc(100% - 2px);
    top:-1px;
    height:34px;
    z-index:-1;
  }
}


/* =========================================================
   QUICK EDIT — STRUCTURE / LIVE COMMIT
   ========================================================= */
/* Quick Edit fields are compact data blocks. The icon column spans the
   label and control, while the control itself never behaves like a button. */
.qe-field.has-icon {
  grid-template-columns: 43px minmax(0,1fr);
  grid-template-rows: auto 43px;
  column-gap: 10px;
  row-gap: 4px;
}
.qe-field.has-icon .qe-stat-icon {
  grid-column: 1;
  grid-row: 1 / 3;
  width: 43px;
  min-height: 63px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.qe-field.has-icon .qe-stat-icon .bf-icon {
  width: 43px;
  height: 43px;
}
.qe-field.has-icon .qe-label { grid-column:2; grid-row:1; }
.qe-field.has-icon .qe-input-shell,
.qe-field.has-icon .qe-stepper-bar { grid-column:2; grid-row:2; }

.qe-input-shell,
.qe-input-shell.has-change {
  height: 43px;
  min-height: 43px;
}
.qe-input-shell .qe-input.text-input,
.qe-input-shell .qe-input.text-input.is-pressed,
.qe-input-shell .qe-input.text-input.is-editing {
  height: 100%;
  min-height: 0;
  line-height: normal;
  transform: none !important;
  box-shadow: none !important;
  text-align: center;
}

.qe-hp-field {
  display: grid;
  grid-template-rows: auto 43px;
  gap: 4px;
  min-width: 0;
}
.qe-hp-field > .qe-label { grid-row:1; }
.qe-hp-field > .qe-hp { grid-row:2; width:100%; }


@container sheet-space (min-width:900px) {
  .sheet-header-quick .qe-shell {
    display:grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    column-gap: 20px;
    row-gap: 22px;
  }
  .sheet-header-quick .qe-row-stats {
    grid-column:1 / -1;
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:20px;
  }
  .sheet-header-quick .qe-row-extra-movement {
    grid-column:1 / -1;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:20px;
  }
  .sheet-header-quick .qe-hit-dice {
    grid-column:1;
    grid-row:auto;
    align-self:start;
  }
  .sheet-header-quick .qe-hp-field {
    grid-column:2;
    align-self:start;
  }
  .sheet-header-quick .qe-temp-action {
    grid-column:2;
    justify-items:center;
    margin-top:-14px;
  }
  .sheet-header-quick .qe-label { font-size:16px; }
  .sheet-header-quick .qe-input,
  .sheet-header-quick .qe-start-value,
  .sheet-header-quick .qe-hit-dice-values,
  .sheet-header-quick .qe-hp-values { font-size:22px; font-weight:400; }
}


/* =========================================================
   QUICK EDIT — RESOURCE ROW / ICON ALIGNMENT
   ========================================================= */
/* Labels sit above the data row. Icons sit beneath the labels, beside the
   input/resource control, so every Quick Edit stat reads the same way. */
.qe-field.has-icon {
  grid-template-columns: 43px minmax(0,1fr);
  grid-template-rows: auto 43px;
  column-gap: 10px;
  row-gap: 4px;
}
.qe-field.has-icon .qe-label {
  grid-column: 1 / -1;
  grid-row: 1;
}
.qe-field.has-icon .qe-stat-icon {
  grid-column: 1;
  grid-row: 2;
  width: 43px;
  height: 43px;
  min-height: 43px;
  display: grid;
  place-items: center;
}
.qe-field.has-icon .qe-input-shell,
.qe-field.has-icon .qe-stepper-bar,
.qe-field.has-icon .qe-hp {
  grid-column: 2;
  grid-row: 2;
  width: 100%;
  min-width: 0;
}
.qe-hp-field { display:grid; min-width:0; }


@container sheet-space (min-width:900px) {
  .sheet-header-quick .qe-hit-dice {
    grid-column:1;
    grid-row:3;
    align-self:start;
  }
  .sheet-header-quick .qe-hp-field {
    grid-column:2;
    grid-row:3;
    align-self:start;
  }
  .sheet-header-quick .qe-temp-action {
    grid-column:2;
    grid-row:4;
    justify-items:center;
    margin-top:-14px;
  }
}


/* =========================================================
   RESPONSIVE QUICK EDIT / DESKTOP CREATOR
   ========================================================= */
/* Quick Edit icons are a desktop enhancement only. Mobile returns to the
   original data-first controls with no stat icon column. */

@container sheet-space (max-width:899px) {
  .sheet-header-quick .qe-stat-icon { display: none !important; }
  .sheet-header-quick .qe-field.has-icon {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 43px;
    column-gap: 0;
    row-gap: 4px;
  }
  .sheet-header-quick .qe-field.has-icon .qe-label {
    grid-column: 1;
    grid-row: 1;
  }
  .sheet-header-quick .qe-field.has-icon .qe-input-shell,
  .sheet-header-quick .qe-field.has-icon .qe-stepper-bar,
  .sheet-header-quick .qe-field.has-icon .qe-hp {
    grid-column: 1;
    grid-row: 2;
  }
}


@media (min-width: 900px) {
  /* Character-card summary icons keep their natural square geometry instead
     of stretching vertically with the label/value wrapper. */
  
  

  /* Character Creation uses the same horizontal content gutter as the
     desktop character sheet rather than the mobile 20px content padding. */
    .creator-page { --sheet-gutter: clamp(34px, 4vw, 54px); }
    .creator-content {
    width: 100%;
    padding: 32px var(--sheet-gutter) 110px;
  }
    .creator-header {
    padding-left: var(--sheet-gutter);
    padding-right: var(--sheet-gutter);
  }

  /* Abilities and Saving Throws: 3 columns × 2 rows on desktop. */
    .creator-ability-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 18px;
  }
    .creator-saving-throws {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 18px;
  }

  /* Overview identity mirrors the desktop sheet: 150px portrait left,
     Name and profile-picture URL stacked directly to its right. */
    .creator-overview-identity {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    width: 100%;
  }
    .creator-overview-avatar,
  .creator-overview-avatar .avatar,
  .creator-overview-avatar .sheet-avatar {
    width: 150px;
    height: 150px;
    min-width: 150px;
    min-height: 150px;
  }
    .creator-overview-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
    .creator-overview-identity-fields {
    display: grid;
    gap: 16px;
    align-content: start;
    min-width: 0;
  }
}
@container sheet-space (min-width:900px) {
  .sheet-header-normal .sheet-summary-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 48px;
    min-height: 48px;
    align-self: start;
  }
  .sheet-header-normal .sheet-summary-icon .bf-icon {
    width: 28px;
    height: 28px;
    align-self: center;
  }
}


/* =========================================================
   DESKTOP — CHARACTER CREATION
   Creator is a viewport-contained sheet inside body padding. Only the
   creator content scrolls; header/footer stay in place.
   ========================================================= */
@media (min-width: 900px) {
  html:has(.creator-page),
  body:has(.creator-page) {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body:has(.creator-page) {
    box-sizing: border-box;
  }

  body:has(.creator-page) .app-shell {
    width: min(100%, var(--content-max));
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border-radius: 20px;
    background: var(--surface-alt);
  }

  body:has(.creator-page) .app {
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
  }

  .creator-page {
    --sheet-gutter: clamp(34px, 4vw, 54px);
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    border-radius: 20px;
    background: var(--surface);
  }

  .creator-header {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    padding: 26px var(--sheet-gutter) 12px;
  }

  .creator-content {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px var(--sheet-gutter) 40px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
  }
  .creator-content::-webkit-scrollbar { width: 8px; }
  .creator-content::-webkit-scrollbar-track { background: transparent; }
  .creator-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 999px;
  }

  .creator-footer {
    position: relative;
    inset: auto;
    transform: none;
    flex: 0 0 78px;
    width: 100%;
    height: 78px;
    padding: 8px var(--sheet-gutter);
    border-top: 1px solid var(--ink);
  }

  /* Overview: real 150x150 portrait, with Name + Profile picture in one row. */
  .creator-overview-identity {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 24px;
    align-items: end;
    width: 100%;
  }
  .creator-overview-avatar,
  .creator-overview-avatar .avatar-placeholder,
  .creator-overview-avatar .avatar-placeholder-large,
  .creator-overview-avatar .sheet-avatar {
    width: 150px !important;
    height: 150px !important;
    min-width: 150px;
    min-height: 150px;
    margin: 0 !important;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
  }
  .creator-overview-identity-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
    min-width: 0;
  }

  /* HP / Initiative / AC share one row and use the sheet stat icons. */
  .creator-overview-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }
  .creator-overview-stat {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    align-items: end;
    min-width: 0;
  }
  .creator-overview-stat-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 43px;
  }
  .creator-overview-stat-icon .bf-icon {
    width: 30px;
    height: 30px;
  }

  /* Movement is a horizontal set of cards. */
  .movement-creator { gap: 14px; }
  .creator-movement-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
  }
  .creator-movement-card {
    display: grid;
    gap: 10px;
    align-content: start;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }
  .creator-movement-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 32px;
  }
  .creator-movement-card > strong { min-height: 32px; display:flex; align-items:center; }
  .creator-movement-card .field { min-width: 0; }
  .creator-movement-card .movement-delete {
    min-width: 32px;
    width: 32px;
    min-height: 32px;
    height: 32px;
    align-self: auto;
  }
  .creator-movement-card .movement-delete .bf-icon { width: 18px; height: 18px; }

  .creator-class-section {
    display: grid;
    gap: 16px;
    padding-top: 4px;
  }
}

/* =========================================================
   DESKTOP — CREATOR REFINEMENT
   Desktop-only presentation. Mobile creator layout is left untouched.
   ========================================================= */
@media (min-width: 900px) {
  /* Match the sheet's grey content surface; only this inner pane scrolls. */
  .creator-page { background: var(--surface-alt); }
  .creator-header,
  .creator-footer { background: var(--surface); }
  .creator-content { background: var(--surface-alt); }

  /* Portrait top-aligns with the Name/Profile row. Stats sit below it. */
  .creator-overview-identity { align-items: start; }
  .creator-overview-identity-fields { align-items: start; }
  .creator-overview-avatar,
  .creator-overview-avatar .avatar-placeholder,
  .creator-overview-avatar .avatar-placeholder-large,
  .creator-overview-avatar .sheet-avatar,
  .creator-overview-avatar img {
    width:150px !important; height:150px !important;
    min-width:150px; min-height:150px; max-width:150px; max-height:150px;
    aspect-ratio:1/1; object-fit:cover;
  }
  .creator-overview-stats {
    width: calc(100% - 174px);
    margin-left: 174px;
    margin-top: -70px;
  }

  /* Movement cards and the Add Movement tile share one grid. */
  .creator-movement-card .field > span:empty { display:none; }
  .creator-movement-card .field { gap:0; }
  .creator-add-card {
    appearance:none;
    min-height:112px;
    padding:14px;
    border:1.5px dashed var(--line);
    border-radius:14px;
    background:transparent;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:8px;
    font:600 15px Nunito, sans-serif;
    color:var(--muted);
    cursor:pointer;
  }
  .creator-add-card:hover { border-color:var(--accent); color:var(--ink); }
  .creator-add-card-plus { font-size:26px; line-height:1; color:var(--accent); }

  /* Background option rows become equal cards, with the add action as the next card. */
  .creator-card-list {
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:12px;
    align-items:stretch;
  }
  .creator-option-card {
    min-width:0;
    min-height:112px;
    padding:14px;
    border:1px solid var(--line);
    border-radius:14px;
    background:var(--surface);
    align-items:start;
  }
  .creator-card-list > .creator-add-card { min-height:112px; }

  /* Creator Background uses the same text-area rhythm as sheet Page Edit. */
  .creator-content [data-background="personalityTraits"],
  .creator-content [data-background="ideals"],
  .creator-content [data-background="bonds"],
  .creator-content [data-background="flaws"],
  .creator-content [data-background-description-value] {
    min-height:100px;
    max-height:350px;
    resize:none;
    overflow-y:hidden;
  }
}

/* =========================================================
   DESKTOP — CREATOR POLISH
   ========================================================= */
@media (min-width: 900px) {
  /* Use the exact same page grey as Character Sheet content. */
  .creator-page,
  body:has(.creator-page) .app-shell { background: var(--surface); }
  .creator-content { background: var(--bg); }

}

/* =========================================================
   DESKTOP — CREATOR CARDS / EDITORS
   ========================================================= */
@media (min-width: 900px) {

  /* Added background choices are display cards, never secondary editors. */
  .creator-data-card {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
  }
  .creator-data-card-copy { display:flex; flex-direction:column; gap:6px; min-width:0; }
  .creator-data-card-label { font-family:var(--font-body); font-size:13px; color:var(--muted); }
  .creator-data-card-copy strong { font-family:var(--font-heading); font-size:18px; font-weight:600; }
  .creator-money-divider { margin-top:18px; margin-bottom:18px; }
}

/* =========================================================
   CREATOR — RESPONSIVE CARDS / PICKERS
   ========================================================= */
@media (min-width: 900px) {
}

@media (max-width: 899px) {
  /* Mobile Overview stays intentionally simpler: no stat icons. */
  .creator-overview-stat-icon { display: none !important; }
  .creator-overview-identity-fields {
    display: grid;
    gap: 16px;
  }
  .creator-overview-stats {
    display: grid;
    gap: 14px;
  }

  /* Mobile movement follows the same card language as desktop, two per row. */
  .creator-movement-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
  }
  .creator-movement-card,
  .creator-option-card {
    min-width: 0;
    min-height: 112px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }
  .creator-movement-card {
    display: grid;
    gap: 10px;
    align-content: start;
  }
  .creator-movement-card > strong {
    min-height: 32px;
    display: flex;
    align-items: center;
  }
  .creator-movement-card .field > span:empty { display: none; }
  .creator-movement-card .field { gap: 0; min-width: 0; }
  .creator-movement-card .movement-delete {
    min-width: 32px;
    width: 32px;
    min-height: 32px;
    height: 32px;
    padding: 0;
  }
  .creator-add-card {
    appearance: none;
    min-height: 112px;
    padding: 14px;
    border: 1.5px dashed var(--line);
    border-radius: 14px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: 600 15px Nunito, sans-serif;
    color: var(--muted);
    cursor: pointer;
  }
  .creator-add-card-plus { font-size: 26px; line-height: 1; color: var(--accent); }

  /* Background conditional choices use the same two-column card system. */
  .creator-card-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: stretch;
  }
  .creator-data-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .creator-data-card-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  .creator-data-card-label { font-family: var(--font-body); font-size: 13px; color: var(--muted); }
  .creator-data-card-copy strong { font-family: var(--font-heading); font-size: 18px; font-weight: 600; }

  /* Give the class controls the same breathing room as the surrounding sections. */
  .creator-class-section { display: grid; gap: 16px; padding-top: 4px; }
  .creator-class-section .class-grid { gap: 14px 12px; }

  /* Currency and the item list belong together visually on mobile. */
  .inventory-creator .creator-money-divider { margin: 12px 0 20px; }
}


/* =========================================================
   CREATOR — POPUPS / SCROLL / OVERVIEW
   ========================================================= */


@media (max-width: 899px) {
  /* Dialog dropdown placement is calculated from available viewport space. */

  /* Make the creator's own scroll region explicit and green. */
  .creator-content {
    overflow-y: scroll;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
    scrollbar-gutter: stable;
  }
  .creator-content::-webkit-scrollbar { width: 6px; }

  /* Pull inventory immediately up under currency. */
  .inventory-creator .creator-money-divider { margin: 6px 0 10px; }
}

@media (min-width: 900px) {
  /* In Overview, label sits above; icon and input share the row below. */
  .creator-overview-stat {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-rows: auto 43px;
    column-gap: 10px;
    row-gap: 4px;
    align-items: stretch;
  }
  .creator-overview-stat > .creator-overview-stat-icon {
    grid-column: 1;
    grid-row: 2;
    width: 30px;
    height: 43px;
    display: grid;
    place-items: center;
  }
  .creator-overview-stat > .creator-overview-stat-icon .bf-icon {
    width: 28px;
    height: 28px;
  }
  .creator-overview-stat > .field { display: contents; }
  .creator-overview-stat > .field > span {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
  }
  .creator-overview-stat > .field > input {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }


  /* Same tighter currency → inventory relationship on desktop. */
  .inventory-creator .creator-money-divider { margin: 8px 0 12px; }
}

/* =========================================================
   DESKTOP — CREATOR POLISH + NORMAL CARD RECOMPOSITION
   ========================================================= */
@media (min-width: 900px) {
  /* Creator Overview: use the same icon/control geometry as Quick Edit. */
    .creator-overview-stat {
    grid-template-columns: 43px minmax(0, 1fr);
    grid-template-rows: auto 43px;
    column-gap: 10px;
    row-gap: 4px;
  }
    .creator-overview-stat > .creator-overview-stat-icon {
    grid-column: 1;
    grid-row: 2;
    width: 43px;
    height: 43px;
    min-height: 43px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
    .creator-overview-stat > .creator-overview-stat-icon .bf-icon {
    width: 43px;
    height: 43px;
  }
    .creator-overview-stat > .field > span { grid-column: 2; grid-row: 1; }
    .creator-overview-stat > .field > input {
    grid-column: 2;
    grid-row: 2;
    height: 43px;
    min-height: 43px;
  }


  /* Desktop normal character card — consolidated. */
  

  
  
  
  

  
  
  
  
  
  
  

  

  
  
  

  
}
@container sheet-space (min-width:900px) {
  .sheet-header-normal {
    grid-template-columns: minmax(0, 481px) minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    column-gap: clamp(24px, 3cqw, 42px);
    row-gap: 0;
    align-items: stretch;
  }
  .sheet-header-normal .sheet-normal-left-identity {
    grid-column: 1;
    grid-row: 1;
    width: 481px;
    max-width: 100%;
    min-width: 0;
    align-self: end;
    padding-bottom: 15px;
    text-align: left;
  }
  .sheet-header-normal .sheet-normal-left-identity .class-lines {
    margin: 0 0 2px;
    font-size: clamp(14px, 1.2cqw, 17px);
    font-weight: 500;
    line-height: 1.2;
  }
  .sheet-header-normal .sheet-normal-left-identity h1 {
    margin: 0;
    font-size: clamp(30px, 2.5cqw, 40px);
    line-height: 1;
  }
  .sheet-header-normal .sheet-normal-left-identity .sheet-character-title {
    margin: 5px 0 0;
    padding-top: 5px;
    border-top: 1px solid var(--line);
    font-family: var(--font-display);
    font-size: clamp(13px, 1.05cqw, 15px);
  }
  .sheet-header-normal .sheet-summary-grid.single-speed,
  .sheet-header-normal .sheet-summary-grid.has-extra-speed {
    grid-column: 1;
    grid-row: 2;
    width: max-content;
    max-width: 100%;
    grid-template-columns: repeat(4, 112px);
    gap: 11px;
    margin: 0;
    padding-bottom: 15px;
    align-self: start;
  }
  .sheet-header-normal .sheet-summary-stat,
  .sheet-header-normal .normal-hit-dice,
  .sheet-header-normal .normal-speed-menu > summary {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 3px;
    align-items: center;
  }
  .sheet-header-normal .sheet-summary-label {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .sheet-header-normal .sheet-summary-icon {
    grid-column: 1;
    grid-row: 2;
    width: 30px;
    height: 30px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .sheet-header-normal .sheet-summary-icon .bf-icon { width: 28px; height: 28px; }
  .sheet-header-normal .sheet-summary-copy { display: contents; }
  .sheet-header-normal .sheet-summary-copy > strong,
  .sheet-header-normal .normal-hit-dice-values {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
  }
  .sheet-header-normal .sheet-summary-hp {
    grid-column: 1;
    grid-row: 3;
    width: 481px;
    max-width: 100%;
    margin: 0;
    padding-bottom: 18px;
    align-self: start;
  }
  .sheet-header-normal .sheet-normal-avatar {
    grid-column: 2;
    grid-row: 1 / 4;
    height: 100%;
    min-width: 0;
    max-width: 100%;
    justify-self: end;
    align-self: stretch;
    display: flex;
    overflow: hidden;
  }
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar {
    position: static;
    height: 100%;
    width: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    min-width: 0;
    min-height: 0;
    margin: 0;
    transform: none;
    border-radius: 50%;
  }
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
  }
  .sheet-header-normal .sheet-tabs-in-card {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 20px;
  }
}


/* =========================================================
   MOBILE — NORMAL CHARACTER IDENTITY
   The normal-sheet markup is shared with desktop, but the large desktop
   portrait/layout rules stay desktop-only. On mobile the identity remains
   on the left with the familiar 58px portrait anchored on the right.
   ========================================================= */

@container sheet-space (max-width:899px) {
  .sheet-header-normal .sheet-normal-left-identity {
    min-width: 0;
    padding-right: 76px;
    margin-bottom: 22px;
  }
  .sheet-header-normal .sheet-normal-left-identity .class-lines {
    margin: 0 0 4px;
  }
  .sheet-header-normal .sheet-normal-left-identity h1 {
    margin: 0;
    font-size: 30px;
    line-height: 1.05;
  }
  .sheet-header-normal .sheet-normal-avatar {
    position: absolute;
    top: 24px;
    right: var(--sheet-gutter);
    width: 58px;
    height: 58px;
    z-index: 321;
  }
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar {
    width: 58px;
    height: 58px;
    min-width: 58px;
    min-height: 58px;
    margin: 0;
  }
}


/* =========================================================
   DESKTOP — VIEWPORT / PRIMARY NAVIGATION
   Keep padded desktop routes inside the available body box and let the
   bottom navigation follow the same full width as the desktop app shell.
   ========================================================= */
@media (min-width: 900px) {
  /* Auth must size against the padded body, not against the raw viewport. */
  html:has(.auth-page),
  body:has(.auth-page) {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  body:has(.auth-page) .app-shell,
  body:has(.auth-page) .app {
    width: min(100%, var(--content-max));
    height: 100%;
    min-height: 0;
  }

  body:has(.auth-page) .app {
    padding-bottom: 0;
    overflow: auto;
  }

  body:has(.auth-page) .auth-page {
    min-height: 100%;
    height: auto;
  }

  /* The sheet already owns the padded viewport. Do not leave any route-level
     space below it. */
  body:has(.app > .sheet-page) {
    padding-bottom: 28px;
  }

  /* On desktop the primary nav spans the complete app/content width. */
  .bottom-nav {
    width: min(calc(100% - 56px), var(--content-max));
    max-width: var(--content-max);
    padding-left: clamp(40px, 6vw, 84px);
    padding-right: clamp(40px, 6vw, 84px);
  }
}


/* =========================================================
   DESKTOP — APP VIEWPORT / BOTTOM NAVIGATION
   The desktop home/updates shell lives inside the 28px body frame.
   Body never becomes taller than the viewport; route content owns any
   necessary scrolling. Primary navigation sits on the shell's bottom edge,
   preserving the outer gap and lower corner radius.
   ========================================================= */
@media (min-width: 900px) {
  html,
  body {
    height: 100dvh;
    min-height: 0;
  }

  body {
    overflow: hidden;
  }

  body:not(:has(.app > .sheet-page)):not(:has(.creator-page)):not(:has(.auth-page)) .app-shell {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body:not(:has(.app > .sheet-page)):not(:has(.creator-page)):not(:has(.auth-page)) .app {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(var(--mobile-nav-height) + 20px);
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
  }

  body:not(:has(.app > .sheet-page)):not(:has(.creator-page)):not(:has(.auth-page)) .app::-webkit-scrollbar {
    width: 9px;
  }

  body:not(:has(.app > .sheet-page)):not(:has(.creator-page)):not(:has(.auth-page)) .app::-webkit-scrollbar-track {
    background: transparent;
  }

  body:not(:has(.app > .sheet-page)):not(:has(.creator-page)):not(:has(.auth-page)) .app::-webkit-scrollbar-thumb {
    background: var(--accent);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
  }

  .bottom-nav {
    bottom: 28px;
    width: min(calc(100% - 56px), var(--content-max));
    max-width: var(--content-max);
    border-radius: 0 0 28px 28px;
  }
}


/* =========================================================
   SHARED POPUP UI SYSTEM
   One shell owns header, scrollable content, spacing and footer actions.
   Feature-specific popup classes are no longer used for layout.
   ========================================================= */
.bf-dialog-overlay .bf-dialog {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(90dvh, 760px);
}

.bf-dialog-header {
  position: relative;
  flex: 0 0 auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 18px 58px 16px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.bf-dialog-header h2 {
  margin: 0;
  font-family: var(--font-heading);
  line-height: 1.15;
}

.bf-dialog-header .bf-dialog-close {
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
}

.bf-dialog-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.bf-dialog-content {
  display: grid;
  align-content: start;
  gap: 18px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

/* Extra attack damage entries remain responsive inside the shared dialog scroll area. */
.additional-damage-list { display: grid; gap: 14px; }
.additional-damage-entry { display: grid; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.additional-damage-entry > .bf-icon-button { justify-self: end; }

.bf-dialog-content > .field,
.bf-dialog-content > .grid-2,
.bf-dialog-content > .check-row,
.bf-dialog-content > h3,
.bf-dialog-content > [data-custom-select] {
  margin-top: 0;
  margin-bottom: 0;
}

.bf-dialog-content::-webkit-scrollbar,
.bf-dialog-content textarea::-webkit-scrollbar { width: 8px; }
.bf-dialog-content::-webkit-scrollbar-track,
.bf-dialog-content textarea::-webkit-scrollbar-track { background: transparent; }
.bf-dialog-content::-webkit-scrollbar-thumb,
.bf-dialog-content textarea::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}

footer.bf-dialog-actions {
  position: static;
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 20px;
  margin: 0;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

footer.bf-dialog-actions .btn,
footer.bf-dialog-actions .text-action { flex: 0 0 auto; }

footer.bf-dialog-actions .btn { min-width: 112px; }

footer.bf-dialog-actions .text-action { margin: 0; }

footer.bf-dialog-actions .btn:last-child { margin-left: auto; }

footer.bf-dialog-actions .btn,
footer.bf-dialog-actions .text-action,
.bf-dialog-close { visibility: visible; }

footer.bf-dialog-actions:empty { display: none; }

.bf-dialog-info .bf-dialog-content { line-height: 1.5; }
.bf-dialog-info .info-title-proficiency { justify-self: start; }

footer.bf-dialog-actions .text-action + .btn { margin-left: 0; }

footer.bf-dialog-actions .text-action:first-child { margin-right: auto; }

footer.bf-dialog-actions .btn-primary { align-self: center; }

footer.bf-dialog-actions .btn-primary:only-child { margin-left: auto; }

footer.bf-dialog-actions .text-action:only-child { margin-right: 0; }

footer.bf-dialog-actions .btn { width: auto; }

footer.bf-dialog-actions { min-height: 76px; }

footer.bf-dialog-actions .btn,
footer.bf-dialog-actions .text-action { position: relative; z-index: 1; }

footer.bf-dialog-actions { overflow: visible; }

.bf-dialog-content .item-action-sheet {
  display: grid;
  gap: 12px;
}

.bf-dialog-content .item-action-sheet > h2 { display: none; }

@media (max-width: 899px) {
  .bf-dialog-overlay .bf-dialog {
    width: min(100%, 560px);
    max-height: 90dvh;
    border-radius: 24px 24px 0 0;
    top: auto;
    bottom: 0;
    transform: translate(-50%, 100%);
    opacity: 1;
  }
  .bf-dialog-overlay.is-open .bf-dialog { transform: translate(-50%, 0); }

  .bf-dialog-header { padding-left: 20px; }
  .bf-dialog-content { padding: 20px; }
  footer.bf-dialog-actions { padding: 16px 20px 22px; }
}

@media (min-width: 900px) {
  .bf-dialog-overlay .bf-dialog {
    left: 50%;
    top: 50%;
    bottom: auto;
    width: min(calc(100% - 64px), 640px);
    max-height: min(84dvh, 760px);
    border-radius: 22px;
    transform: translate(-50%, -48%) scale(.98);
    opacity: 0;
  }

  .bf-dialog-overlay.is-open .bf-dialog {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}


/* DESKTOP — SAFARI NORMAL CARD */

@container sheet-space (min-width:900px) {
  .sheet-header-normal .sheet-normal-avatar { min-width:0; min-height:0; align-items:center; justify-content:flex-end; overflow:visible; }
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar { width:min(100%, 220px); height:auto; max-width:220px; max-height:none; aspect-ratio:1 / 1; flex:0 1 220px; align-self:center; border-radius:50%; }
  .sheet-header-normal .sheet-tabs-in-card,
  .sheet-header-page .sheet-tabs-in-card { scroll-behavior:auto; }
  .sheet-header-normal .sheet-tab,
  .sheet-header-page .sheet-tab { position:relative; pointer-events:auto; }
}



/* =========================================================
   DESKTOP — MACOS / SAFARI PORTRAIT
   Keep the desktop portrait visibly substantial while preserving a true
   circle. Vertical sheet position is preserved in JS across inline updates.
   ========================================================= */

@container sheet-space (min-width:900px) {
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar {
    width: clamp(240px, 22cqw, 300px);
    height: auto;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    flex: 0 0 auto;
  }
}


/* =========================================================
   DESKTOP — NORMAL CHARACTER CARD
   Identity + 1×4 summary share the top row, separated by a divider.
   HP spans beneath them. The portrait uses the same top/bottom bounds as
   the identity/HP block and remains square on Safari.
   ========================================================= */

@container sheet-space (min-width:900px) {
  .sheet-header-normal {
    grid-template-columns: minmax(210px, 1fr) minmax(420px, 481px) 190px;
    grid-template-rows: auto auto auto;
    column-gap: clamp(20px, 2.4cqw, 34px);
    align-items: stretch;
  }
  .sheet-header-normal .sheet-normal-left-identity {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    max-width: none;
    min-width: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0;
    text-align: left;
  }
  .sheet-header-normal .sheet-normal-left-identity h1 {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .sheet-header-normal .sheet-summary-grid.single-speed,
  .sheet-header-normal .sheet-summary-grid.has-extra-speed {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    max-width: 481px;
    grid-template-columns: repeat(4, minmax(86px, 1fr));
    gap: 11px;
    margin: 0;
    padding: 0 0 0 clamp(20px, 2cqw, 28px);
    border-left: 1px solid var(--line);
    align-self: center;
  }
  .sheet-header-normal .sheet-summary-hp {
    grid-column: 1 / 3;
    grid-row: 2;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 18px 0 0;
    align-self: end;
  }
  .sheet-header-normal .sheet-normal-avatar {
    grid-column: 3;
    grid-row: 1 / 3;
    width: 190px;
    height: 190px;
    min-width: 190px;
    min-height: 190px;
    max-width: 190px;
    max-height: 190px;
    justify-self: end;
    align-self: stretch;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    overflow: visible;
  }
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar {
    width: 190px;
    height: 190px;
    min-width: 190px;
    min-height: 190px;
    max-width: 190px;
    max-height: 190px;
    aspect-ratio: 1 / 1;
    flex: 0 0 190px;
    align-self: stretch;
    margin: 0;
    border-radius: 50%;
  }
  .sheet-header-normal .sheet-tabs-in-card {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 20px;
  }
}


/* =========================================================
   SHARED DIALOG / STRUCTURED INFO
   One popup shell. Info metadata and complex editor field grids are content
   layouts only; they do not redefine dialog chrome.
   ========================================================= */
.info-sheet-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 24px;
  margin: 0;
}
.info-sheet-copy {
  margin-top: 2px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.spell-editor-overlay .bf-dialog-content > .grid-2,
.item-editor-overlay .bf-dialog-content > .grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: 100%;
}
.spell-editor-overlay .bf-dialog-content > *,
.item-editor-overlay .bf-dialog-content > * {
  min-width: 0;
}
.feature-editor-overlay textarea[name="description"] {
  height: 100px;
  min-height: 100px;
  max-height: 100px;
  resize: none;
  overflow-y: auto;
}
@media (min-width: 900px) {
  
    .spell-editor-overlay .bf-dialog,
  .item-editor-overlay .bf-dialog {
    width: min(calc(100% - 64px), 700px);
  }
}
@container sheet-space (min-width:900px) {
  .sheet-header-normal .sheet-summary-hp {
    padding-top: 8px;
  }
}


/* =========================================================
   UPGRADE / SUBSCRIPTION — v161
   Mobile first. Existing Bonfire buttons, type, colors and radii.
   ========================================================= */
.subscription-page.upgrade-page {display:grid;align-content:start;gap:22px;min-width:0;padding-bottom:calc(var(--mobile-nav-height) + 42px);}
.upgrade-page-header {margin-bottom:0;}
.upgrade-intro {display:grid;gap:12px;max-width:640px;}
.upgrade-intro .eyebrow {margin:0;color:var(--accent-dark);font-size:.78rem;letter-spacing:.09em;}
.upgrade-intro h2 {font-family:var(--font-display);font-weight:900;font-size:clamp(1.8rem,7vw,2.8rem);line-height:1.06;letter-spacing:-.035em;margin:0;}
.upgrade-intro>p {margin:0;color:var(--muted);}
.upgrade-intro .upgrade-active-plan {color:var(--ink);font-size:.9rem;margin-top:4px;}
.upgrade-plan-grid {display:grid;grid-template-columns:minmax(0,1fr);gap:24px;align-items:stretch;min-width:0;}
.upgrade-tier {position:relative;display:flex;flex-direction:column;gap:15px;min-width:0;padding:24px 20px 22px;border:2px solid var(--line);border-radius:var(--radius-lg);background:var(--surface);}
.upgrade-tier-featured {border:4px solid var(--ink);padding:22px 18px 20px;box-shadow:0 6px 0 var(--ink);margin-bottom:6px;}
.upgrade-tier-ribbon {position:absolute;right:18px;top:-15px;border:2px solid var(--ink);border-radius:999px;padding:4px 12px;background:var(--accent);color:#fff;font-family:var(--font-display);font-size:.8rem;font-weight:900;}
.upgrade-tier-heading {display:flex;align-items:flex-start;justify-content:space-between;gap:12px;}
.upgrade-tier-kicker {margin:0 0 6px;color:var(--muted);font-size:.8rem;font-weight:700;}
.upgrade-tier-heading h3 {margin:0;font-family:var(--font-display);font-size:1.75rem;font-weight:900;line-height:1.05;}
.upgrade-current-label {display:inline-block;flex:none;border:1.5px solid var(--line);border-radius:999px;padding:5px 10px;font-size:.75rem;font-weight:800;white-space:nowrap;}
.upgrade-tier-description {min-height:2.4em;margin:0;color:var(--muted);font-size:.94rem;}
.upgrade-tier-price {display:flex;flex-direction:column;gap:5px;min-height:73px;justify-content:center;}
.upgrade-tier-price strong {font-family:var(--font-display);font-size:clamp(1.65rem,6vw,2.15rem);font-weight:900;line-height:1.1;letter-spacing:-.035em;}
.upgrade-tier-price span {font-size:.82rem;color:var(--muted);}
.upgrade-tier-action .btn {width:100%;min-height:54px;}
.upgrade-tier-action .btn:disabled {cursor:default;opacity:.72;box-shadow:none;}
.upgrade-tier-includes {border-top:1.5px solid var(--line);padding-top:18px;margin-top:2px;}
.upgrade-tier-includes>p {margin:0 0 12px;font-family:var(--font-display);font-size:1rem;font-weight:900;}
.upgrade-tier-includes ul {display:grid;gap:12px;list-style:none;margin:0;padding:0;}
.upgrade-tier-includes li {display:grid;grid-template-columns:22px 1fr;gap:10px;align-items:start;font-size:.9rem;line-height:1.35;}
.upgrade-check {color:var(--accent-dark);font-weight:900;font-size:1.15rem;line-height:1;}
.upgrade-details {display:grid;gap:16px;margin-top:10px;}
.upgrade-details h2 {margin:0;font-size:1.45rem;}
.upgrade-detail-rows {display:grid;gap:12px;}
.upgrade-detail-rows>div {padding:17px 18px;border:1.5px solid var(--line);border-radius:var(--radius-md);background:var(--surface);}
.upgrade-detail-rows strong {display:block;margin-bottom:5px;font-family:var(--font-display);font-size:1.05rem;font-weight:900;}
.upgrade-detail-rows p {margin:0;color:var(--muted);font-size:.9rem;}
.upgrade-fineprint {font-size:.82rem;line-height:1.5;color:var(--muted);margin:2px 0 0;}
.upgrade-manage .btn {width:100%;}
.profile-subscription-action {display:grid;gap:16px;margin-top:22px;}
.profile-subscription-action .btn {width:100%;}
@media (min-width:900px) {
  /* Only this route expands the shell; the character sheet keeps its width. */
  .app-shell:has(.upgrade-page) {width:min(100%,var(--content-max));}
  .subscription-page.upgrade-page {gap:30px;padding:40px clamp(32px,4vw,64px) 80px;}
  .upgrade-intro {gap:16px;}
  .upgrade-plan-grid {grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;}
  .upgrade-tier {padding:26px 22px 24px;}
  .upgrade-tier-featured {padding:24px 20px 22px;}
  .upgrade-tier-description {min-height:4em;}
  .upgrade-details {max-width:1050px;}
  .upgrade-detail-rows {grid-template-columns:repeat(3,minmax(0,1fr));}
}
@media (max-width:360px) {
  .upgrade-tier {padding:20px 16px;}
  .upgrade-tier-featured {padding:18px 14px;}
  .upgrade-tier-heading h3 {font-size:1.55rem;}
}

/* =========================================================
   CHARACTER NOTES + CUSTOMIZE
   Mobile-first. Character themes only replace semantic accent tokens inside
   the active sheet; neutral Bonfire surfaces remain unchanged.
   ========================================================= */
.notes-editor-field {
  display: grid;
  gap: 8px;
}
.notes-editor {
  width: 100%;
  min-height: 280px;
  max-height: 58vh;
  resize: vertical;
  overflow-y: auto;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  line-height: 1.5;
}
.notes-editor:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: var(--control-shadow-accent);
}
.theme-picker {
  margin: 0;
  padding: 0;
  border: 0;
}
.theme-picker legend {
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-weight: 900;
}
.theme-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.theme-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.theme-choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 3px 0 var(--accent);
}
/* Radio must occupy its visible choice, not an unanchored absolute position.
   The old input could steal focus and scroll Customize off-screen. */
.theme-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  pointer-events: auto;
  z-index: 1;
}
.theme-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-swatch {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 2px solid var(--swatch);
  border-radius: 50%;
  background: var(--swatch-soft);
  box-shadow: inset 0 0 0 7px var(--swatch);
}

/* DESKTOP — 900px+ */
@media (min-width: 900px) {
  .theme-picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bf-dialog-notes .bf-dialog { width: min(680px, calc(100vw - 48px)); }
}


/* =========================================================
   CHARACTER NOTES — one viewport-locked layout
   The identity and footer stay fixed; only the writing surface scrolls.
   ========================================================= */
.character-notes-page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
}
.character-notes-header {
  flex: 0 0 auto;
  padding: 24px var(--sheet-gutter) 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.character-notes-header .sheet-identity { margin: 0; }
.character-notes-form {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
}
.character-notes-content {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  padding: 24px 18px 0;
  overflow: hidden;
  background: var(--surface);
}
.character-notes-content h2 { margin: 0 0 14px; }
.character-notes-editor {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0 0 24px;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  background: var(--surface);
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.character-notes-editor:focus { border: 0; outline: 0; box-shadow: none; }
.character-notes-editor::-webkit-scrollbar { width: 8px; }
.character-notes-editor::-webkit-scrollbar-track { background: transparent; }
.character-notes-editor::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 999px; }
.character-notes-actions {
  display: flex;
  position: static;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  margin-top: 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
@media (max-width: 899px) {
  .character-notes-header .class-lines { margin: 0 0 4px; }
  .character-notes-header .sheet-identity h1 { margin: 0; line-height: 1.05; }
  .character-notes-header .sheet-avatar { width: 58px; height: 58px; min-width: 58px; min-height: 58px; }
}
/* DESKTOP — 900px+ */
@media (min-width: 900px) {
  .character-notes-header,
  .character-notes-content,
  .character-notes-actions {
    padding-left: max(32px, calc((100% - var(--content-max)) / 2));
    padding-right: max(32px, calc((100% - var(--content-max)) / 2));
  }
}

/* Shared character-sheet content spacing (mobile first). */

.page-edit-background-core { display: grid; gap: 16px; }
.page-edit-background-copy { display: grid; gap: 20px; }
.normal-background-view { display: grid; gap: 18px; }
.normal-background-view .background-summary-row { margin-bottom: 4px; }

/* Sheet feature cards show their complete short summaries, as in Creation. */
.features-tab .info-card-copy,
.page-edit-feature-cards .info-card-copy {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

/* Health action chooser — shared responsive dialog, equal secondary actions. */
.health-action-choices {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  width: 100%;
}
.health-action-choices > .btn { width: 100%; min-width: 0; }

/* Companions — Bonfire v159 */
/* Companions: reuse the sheet header, content, tabs, stat cards and field components. */
.comp-sheet-page { min-height:100%; }
.comp-sheet-page .sheet-content { overflow-y:auto; }
.comp-top-actions { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:20px; }
.comp-muted { color:var(--text-muted); margin:5px 0 18px; }
.comp-list { display:grid; gap:12px; margin:20px 0; }
.comp-card { display:flex; align-items:center; gap:14px; width:100%; padding:14px; border:1px solid var(--line); border-radius:var(--radius-md,16px); background:var(--surface); text-align:left; font:inherit; color:inherit; cursor:pointer; }
.comp-card-copy { display:flex; flex:1; flex-direction:column; gap:4px; }
.comp-card-copy small { color:var(--text-muted); }
.comp-empty { padding:24px; border:1px dashed var(--line); border-radius:16px; }
.comp-companion-identity { display:flex; align-items:center; gap:18px; margin-bottom:20px; }
.comp-companion-identity h2,.comp-companion-title h2 { margin:0 0 8px; }
.comp-companion-title { margin-bottom:18px; }
.comp-hp-actions,.comp-form-actions { display:flex; gap:12px; flex-wrap:wrap; margin:18px 0; }
.comp-detail-section { margin-top:24px; }
.comp-notes-read { white-space:pre-wrap; overflow-wrap:anywhere; }
.comp-form { display:grid; gap:16px; }
.comp-form .sheet-tabs { margin-bottom:12px; }
.comp-form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:12px; }
.comp-edit-pane { display:grid; gap:16px; min-width:0; }
.comp-edit-pane[hidden] { display:none !important; }
.comp-editor-area { display:grid; gap:12px; }
.comp-portrait-editor { display:flex; align-items:center; gap:16px; }
.comp-portrait-editor .field { flex:1; min-width:0; }
.comp-movement-list { display:grid; gap:10px; }
.comp-movement-row { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto; gap:10px; align-items:end; }
.comp-toggle { display:flex; align-items:center; gap:10px; }
.comp-ability-mod { font-size:13px; color:var(--text-muted); }
@media(max-width:600px) { .comp-movement-row { gap:6px; } .comp-portrait-editor { align-items:flex-start; } }

/* Companion creation reuses Character Creation's native shell and spacing. */
.companion-creator-page .companion-creator-form { display: contents; }
.companion-creator-page .creator-content { min-width: 0; }
.companion-creator-page .creator-footer { justify-content: flex-end; }

/* Companion creation: align spacing with character creator */
.companion-creator-page .comp-overview-name { margin-bottom: 18px; }
.companion-creator-page .movement-creator { margin-top: 22px; }
.companion-creator-page .comp-portrait-editor { margin-bottom: 12px; }
.companion-creator-page .creator-movement-cards { align-items: stretch; }
.companion-creator-page .comp-action-entry { margin-bottom: 12px; }

/* Companion sheet: preserve owner header and use a separate companion summary card. */
.companion-creator-page .comp-overview-name { display:grid; gap:18px; }
.companion-creator-page .creator-tab.has-data:not(.is-active) { border-bottom-color:var(--text); font-weight:700; }
@media(max-width:450px){.companion-summary-card{padding:12px}.companion-summary-stats{gap:7px}.companion-summary-stats span{font-size:12px}.companion-summary-stats strong{font-size:16px}}

.companion-creator-page [data-comp-add-attack] { display:block; margin:14px auto; text-align:center; }
.companion-creator-page .comp-feature-helper { border-top:1px solid var(--line); padding-top:18px; margin:10px 0 4px; }

/* Companion sheet: fixed identity + draggable sheet card; only tab content scrolls. */
.comp-sheet-page:has(> .companion-sheet-header) {display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden;}
.comp-sheet-page > .comp-owner-header {position:relative;flex:none;min-height:0;padding:16px var(--sheet-gutter) 0;z-index:2;}
.comp-sheet-page > .comp-owner-header .sheet-identity {margin-bottom:12px;}
.comp-sheet-page > .companion-sheet-header {position:relative;top:auto;flex:none;z-index:121;min-height:0;margin:0;padding:14px var(--sheet-gutter) 0;touch-action:pan-x;}
.comp-sheet-page > .sheet-content {flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:0;}
.comp-sheet-page .companion-sheet-identity {display:flex;align-items:center;gap:14px;margin-bottom:14px;}
.comp-sheet-page .companion-sheet-identity h1 {font-size:24px;line-height:1.15;margin:0;}
.comp-sheet-page .companion-sheet-identity .sheet-character-title {margin:3px 0 0;}
.comp-sheet-page .companion-sheet-identity .sheet-avatar {width:54px!important;height:54px!important;flex:0 0 54px;border-radius:50%;overflow:hidden;}
.comp-sheet-page .companion-sheet-identity .sheet-avatar img {width:100%;height:100%;object-fit:cover;}
.comp-sheet-page .comp-mode-trigger {margin-left:auto;border:0;background:transparent;padding:8px;cursor:pointer;}
.comp-sheet-page .comp-feature-open,.comp-sheet-page .comp-page-feature {display:block;width:100%;border:0;background:none;text-align:left;padding:0;cursor:pointer;}
.comp-sheet-page .comp-detail-section {margin-top:16px;}
.comp-sheet-page .comp-inline-page {display:grid;gap:14px;padding:12px 0;}
.comp-sheet-page .comp-page-ability-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
.comp-sheet-page .comp-page-toggle,.comp-sheet-page .comp-page-skill {display:flex;justify-content:space-between;align-items:center;gap:12px;}
.comp-sheet-page .comp-page-skill select {max-width:150px;}
.comp-sheet-page .sheet-header-quick .qe-hit-dice {display:none;}
.comp-sheet-page .sheet-content.is-quick-dimmed {pointer-events:none;user-select:none;}
.comp-sheet-page .sheet-header-quick {z-index:121;}
.comp-sheet-page .sheet-content > h2 {margin:24px var(--sheet-gutter);}
.comp-sheet-page .comp-top-actions {padding:18px var(--sheet-gutter) 0;}
.comp-sheet-page .comp-list,.comp-sheet-page .comp-muted,.comp-sheet-page .comp-empty {margin-left:var(--sheet-gutter);margin-right:var(--sheet-gutter);}

/* Companion sheet v159.3: owner + companion card stay fixed; only tabs scroll. */
.app:has(.comp-sheet-page) {height:calc(100dvh - var(--mobile-nav-height, 0px));min-height:0;overflow:hidden;padding-bottom:0;}
.app:has(.comp-sheet-page) > .comp-sheet-page {height:100%;min-height:0;overflow:hidden;display:flex;flex-direction:column;}
.comp-sheet-page > .comp-owner-header {flex:0 0 auto;position:relative!important;z-index:123;padding-bottom:0;background:var(--surface);}
.comp-sheet-page > .companion-sheet-header {flex:0 0 auto;position:relative!important;top:0!important;transform:translateY(var(--card-drag-y, 0px));margin:0;z-index:122;background:var(--surface);}
.comp-sheet-page > .sheet-content {flex:1 1 0;min-height:0;overflow-y:auto!important;overflow-x:hidden;overscroll-behavior:contain;}
.comp-sheet-page .sheet-header-page.companion-sheet-header .sheet-summary-hp {display:none;}
.comp-sheet-page .companion-sheet-header .sheet-summary-hp {margin-top:4px;margin-bottom:6px;}
.comp-sheet-page .companion-sheet-header .sheet-summary-grid {margin-top:4px;margin-bottom:6px;}
.comp-sheet-page .companion-sheet-header .qe-shell {gap:8px;}
.comp-sheet-page .companion-sheet-header .qe-row {row-gap:8px;}
.comp-sheet-page .companion-sheet-header .qe-field {margin-block:0;}
.comp-sheet-page .companion-sheet-header .sheet-pull-handle {touch-action:none;}
.comp-sheet-page .companion-tab-body .page-edit-section {padding:0;}
.comp-sheet-page .companion-tab-body .page-edit-ability-grid {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;}
@media (max-width:600px) {.app:has(.comp-sheet-page) {height:calc(100dvh - var(--mobile-nav-height, 0px));}}

/* v159.4 companion sheet layout and tag parity */
.comp-sheet-page > .comp-owner-header {border-bottom:1px solid var(--border, #d3d3cf);}
.comp-sheet-page .companion-tag {display:block!important;min-height:1em;font-size:13px;color:var(--text-muted,#6f6f6a);}
.comp-sheet-page .companion-tab-body {padding-inline:var(--sheet-gutter);}
.comp-sheet-page .companion-tab-body {padding-bottom:max(44px,env(safe-area-inset-bottom));}
.comp-sheet-page .comp-page-tag-form {display:grid;gap:20px;margin-top:24px;}
.comp-sheet-page .comp-page-tag-form .tag-field {margin:0;}
.comp-sheet-page .comp-page-tag-form .comp-feature-helper {margin:0 0 2px;}
@media(max-width:600px){.app:has(.comp-sheet-page){height:100dvh!important;}.comp-sheet-page>.sheet-content{padding-bottom:env(safe-area-inset-bottom)!important;}}

/* v159.5 — Companion sheet polish; scoped to companions only. */
.comp-sheet-page .companion-tag {font-size:15px;line-height:1.4;margin-top:4px;}
.comp-sheet-page .companion-tab-body {padding-top:16px;}
.comp-sheet-page .companion-tab-body .sense-list {margin-top:12px;}
.comp-sheet-page .companion-tab-body .sheet-section-heading {margin-top:26px;}
.comp-sheet-page .companion-skills-divider {height:22px;}
.comp-sheet-page [data-companion-menu] {cursor:pointer;}
@media(max-width:600px) {
 .comp-sheet-page .companion-tab-body {padding-top:16px;}
}

/* v159.6 — Companion interaction corrections */
.comp-sheet-page .companion-avatar-popover {
  position:absolute;
  top:calc(100% + 8px);
  left:0!important;
  right:auto!important;
  transform:none!important;
}
.comp-sheet-page .comp-detail-heading {
  font-size:0.875rem;
  font-weight:600;
  line-height:1.35;
  margin:0 0 8px;
}
.comp-sheet-page .comp-detail-section { margin-top:20px; }
.comp-sheet-page .comp-readonly-tags {gap:6px;}
.comp-sheet-page .comp-readonly-tags .tag {white-space:normal;}

/* v159.7 — management cards reuse the character overview card. */
.comp-sheet-page .comp-list {margin-top:10px;gap:12px;}
.comp-sheet-page .comp-manage-card {width:100%;min-height:94px;box-sizing:border-box;}
.comp-sheet-page .comp-manage-card.is-quick-switch {border:3px solid var(--ink, #353535);padding:12.5px;}
.comp-sheet-page .comp-manage-card .character-copy h3 {font-weight:750;}
.comp-sheet-page .comp-manage-card .character-actions {flex-shrink:0;}
.comp-sheet-page .comp-manage-group-gap {height:20px;}

/* v159.8 companion management layout */
.comp-sheet-page .sheet-content:not(:has(.companion-tab-body)) > h2 {margin-top:8px;margin-bottom:2px;}
.comp-sheet-page .sheet-content:not(:has(.companion-tab-body)) > .comp-muted {margin-top:0;margin-bottom:6px;}
.comp-sheet-page .comp-manage-create-actions {margin:16px var(--sheet-gutter) 24px;}
.comp-sheet-page .comp-manage-create-actions > .btn,
.comp-sheet-page .comp-manage-create-actions .character-limit-message > .btn {width:100%;box-sizing:border-box;}
.comp-sheet-page .comp-manage-create-actions .character-limit-message {text-align:center;}

/* v159.9: companion pull handle uses the SAME geometry as the main sheet.
   Scope to companion to avoid changing existing main character behavior. */
@media (max-width:899px) {
  .comp-sheet-page .companion-sheet-header .sheet-pull-handle {
    bottom: -34px;
    height: 34px;
  }
  .comp-sheet-page .companion-sheet-header .sheet-pull-handle::before {
    height: 22px;
  }
}

/* v161.1 — Upgrade page refinements */
.upgrade-page-header h1 {font-size:1.125rem;line-height:1.25;font-weight:900;}
.upgrade-page-header {margin-bottom:0;}
.upgrade-tier-price {min-height:73px;}
@media (min-width:900px) {
  /* .app is the scrolling element on desktop; sticky must remain inside it. */
  .upgrade-page-header {
    position:sticky;
    top:0;
    z-index:20;
    background:var(--bg);
    padding:14px 0;
    margin-top:-14px;
  }
}

/* v162 — Profile redesign. Reuses existing button, bottom-sheet and spacing tokens. */
.profile-page-v162 {display:grid;align-content:start;gap:22px;padding-bottom:calc(var(--mobile-nav-height) + 48px);}
.profile-page-v162 .profile-page-header {margin-bottom:0;}
.profile-page-v162 .profile-page-header h1 {font-size:1.125rem;line-height:1.25;font-weight:900;}
.profile-page-v162 .profile-round-back {width:42px;height:42px;display:grid;place-items:center;border-radius:50%;border:1.5px solid var(--line);background:var(--surface);padding:0;flex:none;}
.profile-page-v162 .profile-round-back svg {width:19px;height:19px;}
.profile-page-v162 .profile-plan-card {border:1.5px solid var(--line);border-radius:var(--radius-lg,24px);background:var(--surface);padding:22px;display:grid;gap:12px;}
.profile-page-v162 .profile-plan-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;}
.profile-page-v162 .profile-kicker {font-size:12px;font-weight:700;letter-spacing:.07em;color:var(--muted);margin:0 0 6px;}
.profile-page-v162 .profile-plan-card h2 {font-family:Nunito,sans-serif;font-size:24px;margin:0;line-height:1.2;}
.profile-page-v162 .profile-plan-card > p {margin:0;color:var(--muted);font-size:14px;}
.profile-page-v162 .profile-account-section {display:grid;gap:8px;}
.profile-page-v162 .profile-account-section h2 {font-family:Nunito,sans-serif;font-size:21px;margin:6px 0 8px;}
.profile-page-v162 .profile-info-list {display:grid;}
.profile-page-v162 .profile-info-row {padding:17px 0;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:16px;min-width:0;}
.profile-page-v162 .profile-info-value {display:grid;gap:5px;min-width:0;overflow-wrap:anywhere;}
.profile-page-v162 .profile-info-label {font-size:13px;color:var(--muted);}
.profile-page-v162 .profile-info-value strong {font-size:16px;font-weight:600;color:var(--ink);}
.profile-page-v162 .profile-info-row .btn-tertiary {flex:none;}
.profile-page-v162 .profile-danger-zone {margin-top:8px;}
.profile-dialog-note {font-size:14px;color:var(--muted);margin:0 0 16px;}
@media (min-width:900px) {
  .profile-page-v162 {gap:28px;padding:40px clamp(32px,4vw,64px) 80px;}
  .profile-page-v162 .profile-page-header {position:sticky;top:0;z-index:20;background:var(--bg);padding:14px 0;margin-top:-14px;}
  .profile-page-v162 .profile-account-section {max-width:760px;}
}

/* Profile controls — v162.3; replaces superseded v162.1 / v162.2 overrides. */
.profile-round-back.stepper-button {
  width:34px;
  height:34px;
  padding:0;
  flex:none;
  border:3px solid var(--ink);
  border-radius:50%;
  background:var(--accent);
  color:#fff;
  box-shadow:0 4px 0 var(--ink);
  display:grid;
  place-items:center;
}
/* White secondary variant of the shared circular pressable button. */
.profile-round-back.stepper-button.campaign-secondary-menu {
  box-sizing:border-box;
  width:34px;
  min-width:34px;
  max-width:34px;
  height:34px;
  min-height:34px;
  max-height:34px;
  flex:0 0 34px;
  padding:0;
  border:3px solid var(--ink);
  border-radius:50%;
  background:#fff;
  color:var(--ink);
  font-size:20px;
  line-height:1;
  display:grid;
  place-items:center;
  box-shadow:0 4px 0 var(--ink);
}
.profile-round-back.stepper-button svg,
.profile-round-back.stepper-button .bf-icon {width:18px;height:18px;}
.profile-round-back.stepper-button:active,
.profile-round-back.stepper-button.is-pressed:not(:disabled) {
  transform:translateY(4px);
  box-shadow:none;
}
.profile-page-v162 .profile-plan-heading {justify-content:flex-start;}
.profile-page-v162 .profile-plan-action {width:100%;justify-self:stretch;margin-top:6px;}
.profile-page-v162 .profile-plan-action .btn-secondary {width:100%;}
.profile-page-v162 .profile-info-list {display:grid;gap:18px;}
.profile-page-v162 .profile-info-row {
  display:grid;
  grid-template-columns:minmax(0,1fr) 72px;
  gap:12px;
  align-items:end;
  min-width:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
}
.profile-page-v162 .profile-readonly-field {display:grid;gap:7px;min-width:0;}
.profile-page-v162 .profile-readonly-field > span {font-size:1rem;font-weight:500;color:var(--ink);}
.profile-page-v162 .profile-readonly-field > input {
  width:100%;min-width:0;min-height:43px;box-sizing:border-box;
  padding:8px 10px;border:1px solid var(--line);
  border-radius:var(--radius-sm);background:var(--surface);
  box-shadow:none;color:var(--ink);font:inherit;text-overflow:ellipsis;cursor:default;
}
.profile-page-v162 .profile-info-row .btn-tertiary {
  justify-self:end;align-self:end;min-height:43px;display:flex;
  align-items:center;justify-content:flex-end;
  width:100%;padding:0 2px;white-space:nowrap;
}
.profile-page-v162 .profile-row-action-spacer {display:block;width:72px;}
.profile-page-v162 .profile-danger-zone {
  display:flex;
  justify-content:flex-end;
  margin-top:44px;
  padding-bottom:12px;
}
@media(min-width:900px) {
  .profile-page-v162 .profile-info-list {gap:18px;}
  .profile-page-v162 .profile-info-row {grid-template-columns:minmax(0,1fr) 84px;}
  .profile-page-v162 .profile-row-action-spacer {width:84px;}
}


/* Bonfire v163 — Settings and Billing. Scoped to new pages. */
.bf-settings-page {display:grid;align-content:start;gap:25px;padding-bottom:76px;}
.bf-settings-page .bf-settings-header {margin-bottom:0;}
.bf-settings-header h1 {font-size:1.125rem;line-height:1.25;font-weight:900;}
.bf-settings-section {display:grid;gap:16px;min-width:0;}
.bf-settings-section h2 {font-family:var(--font-display);font-size:1.3rem;margin:0;}
.bf-settings-section p,.bf-settings-link p {color:var(--muted);font-size:.9rem;line-height:1.5;margin:3px 0 0;}
.bf-setting-row {display:flex;align-items:center;justify-content:space-between;gap:20px;min-width:0;padding:2px 0 10px;}
.bf-setting-row strong,.bf-settings-link strong {font-size:1rem;}
.bf-setting-stack {display:grid;grid-template-columns:minmax(0,1fr);gap:12px;width:100%;justify-items:stretch;}
.bf-settings-link:focus-visible {outline:3px solid var(--accent);outline-offset:3px;}
.bf-settings-muted {color:var(--muted);font-size:.88rem;line-height:1.5;}
.bf-settings-link {display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%;text-align:left;border:1.5px solid var(--line);border-radius:var(--radius-md);padding:17px;background:var(--surface);color:var(--ink);cursor:pointer;font:inherit;}
.bf-settings-link svg {width:20px;height:20px;flex:none;}
.bf-settings-empty {background:var(--surface);border:1.5px solid var(--line);border-radius:var(--radius-md);padding:18px;line-height:1.5;color:var(--muted);}
.bf-settings-empty strong {color:var(--ink);}
.bf-settings-section .btn-secondary,.bf-settings-section .btn-primary {width:100%;}
.bf-billing-preview {font-size:.8rem;font-weight:700;color:var(--muted);text-align:center;}
.bf-settings-page .profile-plan-card {gap:15px;}
.bf-settings-page .profile-plan-card h2 {font-size:1.55rem;}
.bf-billing-rows {display:grid;gap:12px;margin:12px 0;}
.bf-billing-rows>div {display:flex;justify-content:space-between;gap:18px;font-size:.9rem;}
.bf-billing-rows span {color:var(--muted);}
.bf-settings-select-label {font-size:.9rem;font-weight:600;}
.bf-settings-select {width:100%;min-width:0;border:1.5px solid var(--line);background:var(--surface);color:var(--ink);border-radius:var(--radius-sm);padding:12px;font:inherit;}
.bf-export-note {font-size:.8rem!important;}
@media(min-width:900px){.bf-settings-page {max-width:780px;margin:0 auto;width:100%;}}
/* Text size affects the app's rem-based type scale; layout remains responsive. */
html[data-bf-text-size="small"] {font-size:15px;}
html[data-bf-text-size="default"] {font-size:16px;}
html[data-bf-text-size="large"] {font-size:17px;}
html[data-bf-text-size="extra-large"] {font-size:18px;}
@media(prefers-reduced-motion:reduce){html:not([data-bf-motion="off"]) *,html:not([data-bf-motion="off"]) *::before,html:not([data-bf-motion="off"]) *::after {animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important;}}

/* v163.1 — Shared appearance settings and inline export. */
/* v164: Full-width text size slider, markers and no lifted shadow. */
.bf-text-size-control {display:block;box-sizing:border-box;width:100%;min-width:0;max-width:none;padding:12px 0 4px;}
.bf-text-size-control input[type="range"] {
  display:block;box-sizing:border-box;width:100%;min-width:0;max-width:none;height:28px;margin:0;padding:0;
  appearance:none;-webkit-appearance:none;cursor:pointer;touch-action:pan-y;
  background:transparent;border:0;box-shadow:none;outline-offset:5px;
}
.bf-text-size-control input[type="range"]::-webkit-slider-runnable-track {
  height:6px;border-radius:99px;background:var(--line);box-shadow:none;
}
.bf-text-size-control input[type="range"]::-moz-range-track {
  height:6px;border-radius:99px;background:var(--line);box-shadow:none;
}
.bf-text-size-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance:none;appearance:none;width:22px;height:22px;margin-top:-8px;
  border:3px solid var(--ink);border-radius:50%;background:var(--accent);box-shadow:none;
}
.bf-text-size-control input[type="range"]::-moz-range-thumb {
  width:16px;height:16px;border:3px solid var(--ink);border-radius:50%;
  background:var(--accent);box-shadow:none;
}
.bf-slider-ticks {display:flex;justify-content:space-between;align-items:start;margin:-3px 9px 0;pointer-events:none;}
.bf-slider-ticks span {width:2px;height:9px;background:var(--muted);border-radius:2px;}
.bf-text-size-labels {display:flex;justify-content:space-between;gap:6px;margin-top:10px;font-size:.75rem;color:var(--muted);}
/* High contrast switch: SVG-based geometry, shared for both states. */
.bf-switch {
  display:inline-block;
  position:relative;
  flex:none;
  width:49px;
  height:32px;
  cursor:pointer;
  vertical-align:middle;
}
.bf-switch input {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  opacity:0;
  margin:0;
  cursor:pointer;
  z-index:2;
}
.bf-switch-track {
  display:block;
  position:absolute;
  left:2px;
  top:10px;
  width:45px;
  height:20px;
  box-sizing:border-box;
  border:2px solid var(--ink);
  border-radius:10px;
  background:var(--surface);
  transition:background-color 180ms ease-out;
}
.bf-switch-thumb {
  position:absolute;
  left:-3px;
  top:-11px;
  width:24px;
  height:28px;
  box-sizing:border-box;
  border-radius:12px;
  background:var(--ink);
  transform:translateX(0);
  transition:transform 390ms cubic-bezier(.25,.1,.17,1.12);
}
.bf-switch-thumb::after {
  content:"";
  position:absolute;
  left:1px;
  top:1px;
  width:22px;
  height:22px;
  box-sizing:border-box;
  border:2px solid var(--ink);
  border-radius:11px;
  background:var(--surface);
  transition:background-color 180ms ease-out;
}
.bf-switch input:checked + .bf-switch-track {background:var(--accent);}
/* 45px track minus 24px thumb; same overhang at both ends. */
.bf-switch input:checked + .bf-switch-track .bf-switch-thumb {transform:translateX(21px);}
.bf-switch input:checked + .bf-switch-track .bf-switch-thumb::after {background:var(--accent);}
.bf-switch input:focus-visible + .bf-switch-track {outline:3px solid var(--accent);outline-offset:4px;}
.bf-switch input:disabled + .bf-switch-track {opacity:.5;}
@media (prefers-reduced-motion:reduce) {
  .bf-switch-track,.bf-switch-thumb,.bf-switch-thumb::after {transition:none!important;}
}
.bf-export-section .custom-select-field {min-width:0;}
.bf-settings-version {margin-top:16px;text-align:center;color:var(--muted);font-size:.8rem;}
html[data-bf-contrast="high"] {
  --ink:#171717;
  --muted:#424242;
  --line:#515151;
  --placeholder:#525252;
}
html[data-bf-contrast="high"] :focus-visible {outline:3px solid #156d50;outline-offset:2px;}

/* v164.1: range inputs are not lifted text fields. */
.bf-settings-page input[type="range"],
.bf-settings-page input[type="range"].text-input,
.bf-settings-page input[type="range"].text-input.is-pressed,
.bf-settings-page input[type="range"].text-input.is-editing {
  display:block;
  width:100%;
  min-width:0;
  min-height:0;
  height:28px;
  padding:0;
  margin:0;
  box-sizing:border-box;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  transform:none;
  transition:none;
  -webkit-appearance:none;
  appearance:none;
}

/* v165 — Low-profile, viewport-fixed beta build indicator.
   Intentionally outside .app-shell to avoid clipping/scrolling. */
.beta-build-indicator {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line, #D3D3CF);
  border-radius: 999px;
  background: var(--surface, #fff);
  color: var(--ink, #343434);
  font: 700 11px/1.1 "DM Sans", sans-serif;
  letter-spacing: .01em;
  pointer-events: none;
  box-shadow: 0 2px 7px rgb(0 0 0 / .06);
}
.beta-build-indicator__dot {width:6px;height:6px;border-radius:50%;background:var(--accent,#E85D35);}
.beta-build-indicator__version {font-weight:500;color:var(--muted,#6F6F6A);}
body.has-bottom-navigation .beta-build-indicator {
  bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
}
@media(max-width:480px) {
  .beta-build-indicator {right: max(10px, env(safe-area-inset-right));}
}

/* v165.1 — Persistent warning for genuine cross-device character conflicts */
.bf-save-conflict {position:fixed;z-index:20000;left:12px;right:12px;top:max(12px,env(safe-area-inset-top,0px));max-width:600px;margin:auto;padding:13px 15px;border:2px solid #923b32;border-radius:12px;background:#fff6f0;color:#64251f;box-shadow:0 6px 20px #0002;font:500 13px/1.5 "DM Sans",sans-serif;}
.bf-save-conflict button {font:700 12px "DM Sans",sans-serif;margin-left:8px;padding:5px 11px;border-radius:8px;border:1px solid currentColor;background:transparent;color:inherit;cursor:pointer;}

/* v165.2: save status reports sync acknowledgment rather than guessing from local state. */
.bf-save-status { position:fixed; z-index:1100; left:max(12px,env(safe-area-inset-left)); bottom:max(12px,env(safe-area-inset-bottom)); padding:6px 10px; border:1px solid var(--line,#d3d3cf); border-radius:999px; background:var(--surface,#fff); color:var(--ink,#343434); box-shadow:0 2px 7px #0001; font:600 11px/1.3 "DM Sans",sans-serif; pointer-events:none; }
body.has-bottom-navigation .bf-save-status { bottom:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom,0px) + 12px); }
.bf-save-status[data-status="offline"], .bf-save-status[data-status="error"] { border-color:#aa5247; color:#87362f; }
.bf-save-status[data-status="saving"] { color:var(--muted,#676767); }
.bf-save-status[hidden] { display:none; }

/* Library uses existing Bonfire form, card, and button tokens. */
.library-page { padding-bottom: 32px; }
.library-header { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.library-controls { display:grid; gap:12px; margin:24px 0; }
.library-filter-list { display:flex; flex-wrap:wrap; gap:8px; }
.library-filter {
  border:2px solid var(--line); border-radius:999px;
  padding:9px 13px; background:var(--surface); color:var(--ink);
  font:800 .9rem var(--font-display); cursor:pointer;
}
.library-filter.is-active { border-color:var(--accent); color:var(--accent-dark); }
.library-list { display:grid; gap:12px; }
.library-entry {
  width:100%; display:flex; gap:12px; justify-content:space-between; align-items:center;
  padding:16px; border:3px solid var(--ink); border-radius:var(--radius-md);
  background:var(--surface); color:var(--ink); text-align:left; cursor:pointer;
  box-shadow:0 4px 0 var(--ink);
  transform:translateY(0);
  transition:transform .1s ease, box-shadow .1s ease, border-color .1s ease;
}
.library-entry:active {
  transform:translateY(4px);
  box-shadow:none;
  border-color:var(--accent);
}
.library-entry:focus-visible {
  outline:3px solid var(--accent);
  outline-offset:3px;
}
.library-entry strong { display:block; font:900 1.04rem var(--font-display); }
.library-entry small { display:block; margin-top:5px; color:var(--muted); }
.library-empty { text-align:center; padding:45px 16px; }
.library-empty h2 { margin-bottom:10px; }
.library-empty p { max-width:35ch; margin:0 auto 22px; color:var(--muted); }
.library-error { color:#963629; }
@media (max-width:390px) {
  .nav-item { width:100%; min-width:0; min-height:58px; font-size:.87rem; }
  .bottom-nav { padding:8px 10px; }
}

/* v165.3.2: spell property markers sit just before the existing info control. */
.spell-row-markers { display:inline-flex; gap:5px; align-items:center; justify-content:flex-end; min-width:0; }
.spell-row-marker { display:inline-flex; align-items:center; justify-content:center; width:20px; height:20px; border:1.5px solid var(--accent); border-radius:50%; color:var(--accent-dark); background:var(--surface); font-family:var(--font-display); font-weight:900; font-size:0.7rem; line-height:1; }
.known-spell-list .data-row { grid-template-columns:auto minmax(0,1fr) auto auto; }
.known-spell-list .data-row > span:nth-child(2) { overflow-wrap:anywhere; }

/* v165.3.4 — Scoped, per-character appearance layers.
   Keep inputs, panels and cards on their original white surfaces. */
body:has(.app > .sheet-page) { background: var(--character-canvas, #345B49); }
.sheet-page { background: var(--character-content, #FFF1E1); }
.sheet-page .sheet-header,
.sheet-page .character-notes-header { background: var(--character-header, #FFFAF5); }
.sheet-page .sheet-content,
.sheet-page .character-notes-content { background: var(--character-content, #FFF1E1); }
@media (min-width:900px) {
  body:has(.app > .sheet-page) .sheet-page { background: var(--character-content, #FFF1E1); }
  body:has(.app > .sheet-page) .sheet-content { background: var(--character-content, #FFF1E1); }
}
.bf-appearance-layer { margin-top: 24px; }
.bf-appearance-help { margin: 0 0 12px; font-size: .88rem; line-height:1.45; color:var(--muted); }
.bf-appearance-divider { height: 1px; background: var(--line); margin-top: 22px; }
.bf-appearance-swatch { width: 28px; height: 28px; flex: 0 0 28px; border: 1.5px solid #34343455; border-radius: 50%; background: var(--swatch); }
.bf-form-validation { margin: 0 0 16px; padding: 12px 14px; background: #fff2ef; color: #83372d; border: 1.5px solid #a14d41; border-radius: 9px; font-size: .91rem; }
.bf-field-invalid { border-color: #a14d41 !important; outline: 2px solid #a14d4133; }

/* Customize uses its own stable viewport frame. Header and actions stay visible,
   and only the central area scrolls. No app-height or inherited sheet positioning. */
.bf-customize-page {
  position: fixed;
  inset: 0;
  z-index: 300;
  width: 100%;
  max-width: var(--content-max, 1180px);
  height: 100dvh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--character-content, #FFF1E1);
}
.bf-customize-page::before { display: none !important; }
.bf-customize-page-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(20px, env(safe-area-inset-top)) var(--sheet-gutter, 18px) 20px;
  border-bottom: 1px solid var(--line);
  background: var(--character-header, #FFFAF5);
}
.bf-customize-page-header h1 {
  margin: 3px 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  line-height: 1.12;
}
.bf-customize-page-header .eyebrow { margin: 0; }
.bf-customize-page-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}
.bf-customize-page-content {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 24px var(--sheet-gutter,18px) 36px;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--character-content, #FFF1E1);
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.bf-customize-page-content .theme-picker { margin-bottom: 16px; }
.bf-customize-page-content::-webkit-scrollbar { width: 8px; }
.bf-customize-page-content::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
}
.bf-customize-page-actions,
.bf-customize-page-form > .bf-customize-page-actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  align-self: stretch;
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
  padding: 14px var(--sheet-gutter,18px) calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
}
.bf-customize-page .theme-choice { background: #fff; }
.bf-customize-accent-example { max-width: 320px; margin: 12px 0 20px; }
.bf-customize-accent-example .stepper { background: #fff; }
.bf-customize-accent-example .stepper-button:disabled {
  opacity: 1;
  cursor: default;
  pointer-events: none;
  background: var(--accent);
  color: #fff;
}
.bf-customize-portrait-example { padding: 4px 0 12px; }
.bf-customize-portrait-example .sheet-avatar {
  display: block;
  width: 58px;
  height: 58px;
  pointer-events: none;
  border: 2px solid var(--character-portrait-border, var(--ink));
}
@media (min-width: 900px) {
  .bf-customize-page {
    top: 28px;
    bottom: 28px;
    width: min(calc(100% - 40px), var(--content-max, 1180px));
    height: calc(100dvh - 56px);
    border-radius: 20px;
  }
  .bf-customize-page-header,
  .bf-customize-page-content,
  .bf-customize-page-actions {
    padding-left: 32px;
    padding-right: 32px;
  }
}
/* Required fields use the same red raised-control treatment as the original. */
.bf-field-invalid,
.field input.bf-field-invalid,
.custom-select-trigger.bf-field-invalid {
  border-color:#a14d41!important;
  box-shadow:0 5px 0 #a14d41!important;
  outline:none!important;
}
.bf-field-invalid:focus-visible {outline:2px solid #a14d4166!important;outline-offset:2px;}


/* Alternating informational rows follow the character's selected sheet tint,
   while cards, fields, and controls retain their white surfaces. */
.sheet-page .data-row:nth-child(even),
.sheet-page .skill-row.is-alt {
  background:color-mix(in srgb,var(--character-content,#FFF1E1) 96%,#343434 4%);
}
/* The triangle belongs to the header in all three sheet modes. */
.sheet-header .sheet-pull-handle::before { background:var(--character-header,#FFFAF5)!important; }
.sheet-header::before { background:var(--character-header,#FFFAF5)!important; }

/* v165.3.8: Appearance colors are scoped to characters; the sheet canvas
   also supplies the visible desktop surround (html/body padding). */
html:has(.app > .sheet-page), html:has(.bf-customize-page),
body:has(.app > .sheet-page), body:has(.bf-customize-page) {
  background:var(--character-canvas,#345B49);
}
/* The unselected skill rows belong to the content surface, not white inputs. */
.sheet-page .skill-row:not(.is-alt) {background:var(--character-content,#FFF1E1);}
.sheet-page .skill-row.is-alt, .sheet-page .data-row:nth-child(even) {
  background:color-mix(in srgb,var(--character-content,#FFF1E1) 96%,#343434 4%);
}
body:has(.app > .sheet-page) .sheet-content {scrollbar-color:var(--accent) transparent;}
body:has(.app > .sheet-page) .sheet-content::-webkit-scrollbar-thumb {background:var(--accent);}
/* Portrait uses the same avatar component; just override its rim token. */
.sheet-page .sheet-avatar, .sheet-page .sheet-normal-avatar .sheet-avatar,
.sheet-page .avatar-placeholder.sheet-avatar {border-color:var(--character-portrait-border,var(--ink));}

/* The dedicated Customize route stays above Bonfire's scrollable app. */
body.bf-customize-open { overflow: hidden; }
body > .bf-customize-page { z-index: 1301; }
.bf-campaign-customize-backdrop{position:fixed;inset:0;z-index:1300;background:rgba(13,25,19,.62)}
body.bf-campaign-sheet-open.bf-customize-open::before {
  content:"";position:fixed;inset:0;z-index:1300;background:rgba(13,25,19,.48);
}

/* v165.3.12 — Appearance editor: packs and compact, reusable swatches. */
.bf-customize-intro { margin-bottom: 24px; }
.bf-customize-intro .eyebrow { color: var(--accent); font-weight: 900; letter-spacing: .07em; text-transform: uppercase; font-size: .72rem; }
.bf-customize-intro h2 { font: 900 clamp(1.35rem,2.4vw,1.85rem)/1.15 var(--font-display); margin: 6px 0 10px; }
.bf-customize-intro > p:last-child { max-width: 66ch; margin: 0; color: var(--muted); line-height: 1.5; }
.bf-pack-section h3,.bf-customize-detail-section h3 { margin: 0 0 8px; font: 900 1.14rem/1.3 var(--font-display); }
.bf-pack-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 14px; }
.bf-pack-choice { padding: 10px; display: flex; flex-direction: column; gap: 9px; align-items: stretch; min-width: 0; text-align: left; color: var(--ink); cursor: pointer; border: 2px solid var(--line); background: #fff; border-radius: 14px; font-family: var(--font-display); font-weight: 900; transition: border-color .12s,box-shadow .12s,transform .12s; }
.bf-pack-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 4px 0 var(--accent); }
.bf-pack-choice:active { transform: translateY(2px); box-shadow: none; }
.bf-pack-choice:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.bf-pack-name { padding: 0 3px 2px; }
.bf-pack-art { display: flex; flex-direction: column; gap: 0; height: 78px; padding: 7px; box-sizing:border-box; border-radius: 8px; background: var(--pack-canvas); overflow: hidden; }
.bf-pack-art-header { display: flex; gap: 7px; align-items: center; background: var(--pack-header); padding: 7px; border-radius: 6px 6px 0 0; }
.bf-pack-art-avatar { width: 17px; height: 17px; border-radius: 50%; background: var(--pack-accent); border: 2px solid #fff; box-sizing: border-box; }
.bf-pack-art-line { height: 6px; width: 45%; border-radius: 6px; background: #343434; opacity: .65; }
.bf-pack-art-content { flex: 1; display: flex; align-items: center; gap: 5px; padding: 9px; background: var(--pack-content); border-radius: 0 0 6px 6px; }
.bf-pack-art-content > span { height: 25px; flex: 1; background: white; border-radius: 5px; border: 1px solid #d3d3cf; }
.bf-customize-divider { background: var(--line); height: 1px; margin: 28px 0; }
.bf-customize-detail-section { margin-bottom: 14px; }
.bf-customize-page .bf-appearance-layer { margin-top: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb,var(--character-content,#FFF1E1) 80%,#fff 20%); }
.bf-customize-page .bf-appearance-layer legend { padding: 0 6px; }
.bf-customize-page .bf-swatch-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.bf-customize-page .theme-choice.bf-swatch-choice { width: 49px; height: 49px; min-height: 0; padding: 6px; flex: 0 0 49px; display: grid; place-items: center; border-radius: 12px; box-sizing: border-box; box-shadow: none; }
.bf-customize-page .bf-swatch-choice .bf-appearance-swatch { width: 30px; height: 30px; flex: 0 0 auto; }
.bf-customize-page .theme-choice.bf-swatch-choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.bf-customize-page .theme-choice.bf-swatch-choice:has(input:focus:not(:focus-visible)) { outline: none; }
.bf-customize-page .theme-choice.bf-swatch-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.bf-customize-portrait-example .sheet-avatar { width: 74px; height: 74px; box-sizing: border-box; border: 4px solid var(--character-portrait-border,var(--ink)); box-shadow: inset 0 0 0 2px white; }
.bf-customize-portrait-example { margin: 0 0 12px; }
/* An inset border for the portrait, including background-image avatars. */
.sheet-page .sheet-avatar, .sheet-page .sheet-normal-avatar .sheet-avatar,
.sheet-page .avatar-placeholder.sheet-avatar { border-width: 4px; box-sizing: border-box; }
@media (min-width: 700px) { .bf-pack-grid { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (prefers-reduced-motion: reduce) { .bf-pack-choice { transition: none; } }

/* v165.3.13: Reuse saved character appearance on the character list.
   Do not recolor white cards/fields or change character data. */
.character-list > .character-card {
  background: var(--character-card-header, #fff);
  border-color: var(--line);
}
.character-list > .character-card .avatar-placeholder,
.character-list > .character-card .avatar,
.character-list > .character-card .sheet-avatar {
  border: 4px solid var(--character-card-rim, var(--ink));
  box-sizing: border-box;
}

/* Searchable shared Library picker: stable height, accessible scrollable results. */
.bf-dialog-variant-library-picker .library-picker { display:flex; flex-direction:column; gap:12px; min-height:0; }
.bf-dialog-variant-library-picker .library-picker-count { margin:0; }
.bf-dialog-variant-library-picker .library-picker-results {
  display:grid; gap:8px; overflow-y:auto; overscroll-behavior:contain;
  max-height:min(45dvh, 360px); min-height:0; padding:2px 5px 5px 2px;
}
.bf-dialog-variant-library-picker .library-entry { width:100%; text-align:left; }

/* Notes Journal v165.3.18 — titled notes, independent scrolling and native controls. */
.bf-journal-page { z-index: 31; background:var(--character-content,#FFF1E1); }
.bf-journal-workspace {display:grid; grid-template-columns:270px minmax(0,1fr); flex:1 1 auto; min-height:0; overflow:hidden}
.bf-journal-sidebar {min-height:0; display:flex; flex-direction:column; border-right:1px solid var(--line); background:var(--character-content,#FFF1E1)}
.bf-journal-sidebar-head {display:flex; justify-content:space-between; align-items:center; padding:20px 16px 12px; gap:10px}
.bf-journal-sidebar-head span {font-size:.78rem;color:var(--muted)}
.bf-journal-list {overflow:auto; min-height:0; padding:0 12px 16px; scrollbar-color:var(--accent) transparent}
/* Notes cards reuse Bonfire's raised-to-pressed interaction. */
.bf-journal-row {
  display:flex; width:100%; align-items:center; gap:12px; text-align:left;
  padding:14px; margin:0 0 12px; background:var(--surface,#fff);
  border:3px solid var(--ink); border-radius:14px;
  box-shadow:0 4px 0 var(--ink); color:var(--ink);
  font:inherit; cursor:pointer; transform:translateY(0);
  transition:transform .12s ease,box-shadow .12s ease,border-color .12s ease,color .12s ease;
}
.bf-journal-row:hover:not(.is-active) { border-color:var(--ink); color:var(--ink); background:var(--surface,#fff); box-shadow:0 4px 0 var(--ink); transform:none; }
.bf-journal-row.is-active {
  color:var(--accent-dark); border-color:var(--accent);
  box-shadow:none; transform:translateY(4px);
}
.bf-journal-row:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
@media (prefers-reduced-motion:reduce) { .bf-journal-row { transition:none; } }
.bf-journal-row-copy {display:flex; flex:1; flex-direction:column; min-width:0;gap:4px}
.bf-journal-row-copy strong,.bf-journal-row-copy small{display:block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.bf-journal-row-copy small{color:var(--muted);font-size:.78rem}
.bf-journal-empty {padding:22px 12px;color:var(--muted)}
.bf-journal-empty strong{color:var(--ink)}
.bf-journal-detail {display:flex;flex-direction:column;min-width:0;min-height:0;overflow:hidden;background:var(--character-content,#FFF1E1)}
.bf-journal-detail-empty {margin:auto; text-align:center; padding:32px;color:var(--muted)}
.bf-journal-detail-empty h3 {color:var(--ink);font-family:var(--font-display);margin:0 0 10px}
.bf-journal-detail-empty p {margin:0;line-height:1.5}
.bf-journal-editor-header{flex:0 0 auto;display:flex;flex-direction:column;gap:5px;padding:16px 20px 12px}
.bf-journal-title-label {font-weight:800;font-family:var(--font-display);font-size:.83rem}
.bf-journal-title{font-family:var(--font-display);font-weight:800;font-size:1.1rem;max-width:100%;background:white}
.bf-journal-tools {display:flex;flex:0 0 auto;gap:5px;align-items:center;flex-wrap:wrap;padding:10px 18px;border-block:1px solid var(--line);background:white}
.bf-journal-tools button,.bf-journal-tools select{appearance:none;background:white;border:2px solid var(--line);border-radius:8px;min-width:37px;min-height:36px;padding:5px 8px;font-family:var(--font-display);font-weight:800;color:var(--ink);cursor:pointer}
.bf-journal-tools button:active{transform:translateY(2px)}
.bf-journal-tools button:focus-visible,.bf-journal-tools select:focus-visible {outline:3px solid var(--accent);outline-offset:2px}
.bf-journal-tools select {min-width:115px}
.bf-journal-tool-divider{height:26px;width:1px;background:var(--line);margin:0 5px}
.bf-journal-writing{flex:1 1 auto;min-height:0;padding:25px 24px;overflow:auto;line-height:1.65;outline:none;background:white;overflow-wrap:anywhere;scrollbar-color:var(--accent) transparent}
.bf-journal-writing:empty:before{content:attr(data-placeholder);color:var(--muted);pointer-events:none}
.bf-journal-writing h2,.bf-journal-writing h3{font-family:var(--font-display);margin:12px 0 8px}
.bf-journal-writing p {margin:0 0 12px}
.bf-journal-writing ul,.bf-journal-writing ol{padding-left:28px;margin:8px 0 12px}
.bf-journal-actions {display:flex; flex:0 0 auto;align-items:center;gap:12px;justify-content:space-between; padding:10px 18px calc(10px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--surface)}
.bf-journal-actions [data-note-status]{font-size:.8rem;color:var(--muted)}
.bf-journal-action-buttons {display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px}
.bf-journal-actions .btn{min-height:43px;padding:8px 19px;font-size:.9rem}
.bf-journal-actions .text-action {font-size:.85rem}
.bf-journal-delete {color:var(--danger)!important}
.bf-journal-mobile-back{display:none}
@media(max-width:700px){
 .bf-journal-add{padding-inline:10px!important}
 .bf-journal-workspace{display:flex; flex-direction:column}
 .bf-journal-sidebar{flex:1 1 auto;border-right:0}
 .bf-journal-workspace.has-editor .bf-journal-sidebar{display:none}
 .bf-journal-workspace:not(.has-editor) .bf-journal-detail{display:none}
 .bf-journal-mobile-back{display:inline-flex;align-self:flex-start;margin-bottom:4px}
 .bf-journal-editor-header{padding:10px 14px}
 .bf-journal-tools{padding:8px 10px;gap:4px}
 .bf-journal-writing{padding:18px 16px}
 .bf-journal-actions{display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:8px 12px calc(8px + env(safe-area-inset-bottom))}
 .bf-journal-action-buttons{justify-content:space-between;gap:3px}
 .bf-journal-actions .text-action {font-size:.77rem;padding:6px 4px}
 .bf-journal-actions .btn{min-height:40px;padding:6px 12px}
}
/* Portal to document body: avoid ancestor scroll clipping and mobile sheet heights. */
.bf-notes-root {position:fixed; inset:0; z-index:10000; background:var(--character-content,#FFF1E1)}
/* A journal inside a character side panel is a sheet view, not a fullscreen overlay. */
.bf-campaign-sheet-popout-body.has-character-notes {display:flex;flex-direction:column;overflow:hidden}
.bf-campaign-sheet-popout-body.has-character-notes > .sheet-page {display:none}
.bf-notes-root.is-embedded {position:relative;inset:auto;z-index:auto;display:flex;flex:1 1 auto;width:100%;height:100%;min-height:0;min-width:0;padding:0;background:var(--character-content,#FFF1E1);overflow:hidden}
.bf-notes-root.is-embedded .bf-journal-page {position:relative;inset:auto;display:flex;flex-direction:column;flex:1 1 auto;width:100%;max-width:none;height:100%;min-height:0;border-radius:0}
.bf-notes-root.is-embedded .bf-journal-workspace {display:flex;flex-direction:column;flex:1 1 auto;min-height:0}
.bf-notes-root.is-embedded .bf-journal-sidebar {flex:1 1 auto;min-height:0;border-right:0}
.bf-notes-root.is-embedded .bf-journal-workspace.has-editor .bf-journal-sidebar {display:none}
.bf-notes-root.is-embedded .bf-journal-workspace:not(.has-editor) .bf-journal-detail {display:none}
.bf-notes-root.is-embedded .bf-journal-detail {flex:1 1 auto;min-height:0}
.bf-notes-root.is-embedded .bf-journal-editor-header .bf-journal-back-round {display:inline-flex;flex:0 0 41px;width:41px;height:41px;min-width:41px;min-height:41px;align-items:center;justify-content:center;padding:0}
.bf-notes-root.is-embedded .bf-journal-title-field {flex:1;min-width:0}
.bf-notes-root.is-embedded .bf-journal-tools {flex-wrap:wrap;max-height:140px;overflow-y:auto}
.bf-notes-root.is-embedded .bf-journal-block-picker {min-width:120px}
.bf-notes-root.is-embedded .character-notes-header {padding:12px var(--sheet-gutter) 0}
.bf-notes-root.is-embedded .character-notes-header .sheet-identity {margin-bottom:14px}
.bf-notes-root .bf-journal-page {position:absolute;inset:0;width:100%;height:100%;max-height:100%;border-radius:0;box-shadow:none;overflow:hidden}
.bf-notes-root .bf-journal-page::before {display:none}
.bf-journal-writing small {font-size:.83em}
@media(max-width:700px){
 .bf-journal-workspace.has-editor .bf-journal-detail {flex:1 1 auto; min-height:0; height:100%}
}

/* Notes v165.3.19 — use the same centred application shell as other pages. */
.bf-notes-root {display:flex; justify-content:center; background:#ededeb; padding:0; box-sizing:border-box}
.bf-notes-root .bf-journal-page {
  position:relative; inset:auto; width:min(100%,1180px); max-width:1180px;
  height:100dvh; min-height:0; flex:0 1 1180px;
  border-radius:24px; box-shadow:none; overflow:hidden;
}
.bf-journal-workspace {grid-template-columns: minmax(200px,270px) minmax(0,1fr)}
.bf-journal-title-field .field {gap:5px}
.bf-journal-title-field .field > span {font-family:var(--font-display);font-weight:800;font-size:.83rem}
.bf-journal-title-field .bf-journal-title {font-family:var(--font-display);font-size:1.1rem}
.bf-journal-block-picker {min-width:145px; max-width:170px}
.bf-journal-block-picker .field {gap:0}
.bf-journal-block-picker .field > span {font-size:.72rem;font-weight:700}
.bf-journal-block-picker .custom-select {width:100%}
.bf-journal-block-picker .custom-select-trigger {min-height:36px;max-height:36px;font-size:.82rem;padding:4px 8px}
.bf-journal-tools .bf-journal-block-picker button {width:100%;min-width:0}
.bf-journal-tools [data-note-export-pdf] svg {width:18px;height:18px}
@media(max-width:700px){
  .bf-notes-root {padding:0;background:var(--character-content,#FFF1E1)}
  .bf-notes-root .bf-journal-page {width:100%;height:100dvh;border-radius:0}
  .bf-journal-block-picker {min-width:124px}
  .bf-journal-tools {flex-wrap:wrap; max-height:128px; overflow-y:auto}
  .bf-journal-actions {flex-direction:row;align-items:center}
  .bf-journal-actions [data-note-status] {flex:1}
}

/* Notes refinement v165.3.20: consistent controls, responsive toolbar and canvas. */
.bf-notes-root {background:var(--character-canvas,#345B49)}
.bf-notes-root .bf-journal-page {min-width:0}
/* The avatar popover is appended to document.body; Notes has a 10000 portal layer. */
.character-avatar-popover {z-index:10030}
.bf-journal-back-round, .bf-journal-all-label {display:none}
.bf-journal-tools {gap:7px; align-content:center}
.bf-journal-tools > button {
  display:inline-flex; flex:0 0 41px; width:41px; height:41px; min-height:41px; min-width:41px;
  justify-content:center;align-items:center; padding:0;
  border:3px solid var(--ink);border-radius:11px;
  background:#fff;color:var(--ink);box-shadow:0 3px 0 var(--ink);
  font-family:var(--font-display);font-size:1rem;font-weight:900;line-height:1;
}
.bf-journal-tools > button:active {transform:translateY(3px);box-shadow:none}
.bf-journal-tools > button .bf-icon {width:19px;height:19px}
.bf-journal-block-picker {flex:0 0 126px; min-width:0;max-width:126px}
.bf-journal-block-picker .custom-select-trigger {
  height:41px;min-height:41px;max-height:41px;border:3px solid var(--ink);
  box-shadow:0 3px 0 var(--ink);border-radius:11px;
}
.bf-journal-tools .bf-journal-block-picker button {width:100%}
@media(max-width:700px) {
 .bf-journal-topline.is-editing .bf-journal-back-round {display:inline-flex;flex:0 0 41px;width:41px;height:41px;min-height:41px;padding:0;align-items:center;justify-content:center}
 .bf-journal-topline.is-editing .bf-journal-notes-label {display:none}
 .bf-journal-topline.is-editing .bf-journal-all-label {display:inline}
 .bf-journal-title-field .field > span {display:none}
 .bf-journal-tools {display:flex; flex-wrap:wrap; overflow:visible;max-height:none;gap:7px;padding:10px}
 .bf-journal-tools > button {flex-basis:39px;width:39px;height:39px;min-height:39px;min-width:39px}
 .bf-journal-block-picker {flex:1 0 105px;max-width:148px}
 .bf-journal-tool-divider {display:none}
 .bf-journal-writing {min-height:0}
}
/* Shared confirmation/info dialogs must appear over the body-level Notes page. */
body:has(> .bf-notes-root) > .overlay {z-index:10050}

/* Notes v165.3.21: one responsive header, journal creation, and active editor tools. */
.bf-journal-topline .bf-journal-back-round {display:none}
.bf-journal-sidebar-head {padding-bottom:8px}
.bf-journal-sidebar > .bf-journal-add {
  display:block; align-self:stretch; flex:0 0 auto; margin:0 12px 16px;
  min-height:44px; width:calc(100% - 24px);
}
.bf-journal-tools > button.is-format-active,
.bf-journal-tools > button.is-format-active:hover {
  background:#fff;
  color:var(--accent); border-color:var(--accent);
  box-shadow:0 0 0 var(--accent-dark); transform:translateY(3px);
}
.bf-journal-tools > button.is-format-active:focus-visible {outline:2px solid var(--accent);outline-offset:3px}
.bf-journal-block-picker .field > span {display:none}
.bf-journal-block-picker .custom-select-trigger {display:flex;align-items:center;justify-content:space-between;gap:8px}
/* Shared select options are portalled to the body; they must rise above Notes. */
body:has(> .bf-notes-root) > .select-menu {z-index:10080}
@media(max-width:700px){
  .bf-journal-topline.is-editing .bf-journal-back-round {
    display:grid;place-items:center;
    flex:0 0 34px;width:34px;height:34px;min-height:34px;
    padding:0;margin:0;
  }
  .bf-journal-topline .bf-journal-title-heading,
  .bf-journal-topline.is-editing .bf-journal-title-heading {display:block;flex:1;margin:0}
  .bf-journal-sidebar > .bf-journal-add {margin-top:0}
}

/* Notes v165.3.22 — one responsive journal layout. */
@media (min-width: 701px) {
  .bf-notes-root {padding:20px 22px;}
  .bf-notes-root .bf-journal-page {height:100%;max-height:100%;border-radius:24px;}
  .bf-notes-root:not(.is-embedded) .bf-journal-editor-header .bf-journal-back-round {display:none;}
}
.bf-journal-block-picker .custom-select-trigger[aria-expanded="true"],
.bf-journal-block-picker .custom-select-trigger.is-format-active {
  background:var(--character-accent-soft,#e2f3ed);
  border-color:var(--accent);
  color:var(--accent-dark);
  box-shadow:none;
  transform:translateY(3px);
}
.bf-journal-block-picker .custom-select-trigger[aria-expanded="false"]:not(.is-format-active) {
  transform:none;
  box-shadow:0 3px 0 var(--ink);
}
@media(max-width:700px) {
  .bf-journal-editor-header {flex-direction:row;align-items:center;gap:10px;}
  .bf-journal-editor-header .bf-journal-back-round {
    display:inline-flex;flex:0 0 41px;width:41px;height:41px;min-width:41px;min-height:41px;
    align-items:center;justify-content:center;padding:0;margin:0;
  }
  .bf-journal-title-field {flex:1;min-width:0;}
  .bf-journal-title-field .field {min-width:0;}
  .bf-journal-title-field .field > span {display:none;}
}

/* v165.3.23 — Notes scroll is owned by the journal, not by the hidden sheet. */
html:has(body.bf-notes-open), body.bf-notes-open { overflow:hidden; }
body.bf-notes-open .bf-notes-root { overflow:hidden; }
.bf-notes-root .bf-journal-page {
  display:flex; flex-direction:column; min-height:0; max-height:100%;
}
.bf-notes-root .bf-journal-workspace {flex:1 1 auto;min-height:0;}
.bf-notes-root .bf-journal-detail {flex:1 1 auto; min-height:0;}
.bf-notes-root .bf-journal-writing {
  flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain;
  scrollbar-width:thin;
}
.bf-journal-tools > button.is-format-active,
.bf-journal-tools > button.is-format-active:hover {background:#fff;}

/* Notes v165.3.25: keep toolbar, writing surface and actions visually unified. */
.bf-notes-root .bf-journal-tools { border-top:0; border-bottom:0; }
.bf-notes-root .bf-journal-actions { border-top:0; }

/* v165.3.27 — shared Notes/Companions header geometry and character appearance. */
.bf-notes-root .character-notes-header {
  position:relative; top:auto; flex:0 0 auto; width:100%;
  background:var(--character-header,#FFFAF5);
  padding:24px var(--sheet-gutter) 0;
  box-sizing:border-box;
  z-index:120;
}
.bf-notes-root .character-notes-header .sheet-identity {
  /* Companion overview and Notes share the same identity/avatar markup. */
  margin-bottom:34px;
}
.comp-sheet-page > .comp-owner-header,
.comp-sheet-page > .companion-sheet-header {
  background:var(--character-header,#FFFAF5);
}
.comp-sheet-page .sheet-content {background:var(--character-content,#FFF1E1);}

/* Shared spell editor: compact square toggles directly below the spell name. */
.spell-editor-flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}
.spell-editor-flags .check-row { align-items: center; }
/* Spell property checkboxes all use BF.checkbox's shared .checkbox styling.
   Keep the Components group outside .field, whose input rule targets text fields. */
.spell-components-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.spell-components-label {
  font-size: 1rem;
  font-weight: 500;
}

/* Built-in Library content and CC attribution */
.library-license { margin: 24px 0 8px; font-size: .82rem; color: var(--muted); line-height: 1.5; }
.library-license summary { cursor: pointer; font-weight: 800; }
.library-license a { color: var(--accent-dark); }

/* SRD reference: reuse the shared spell form, without raised editable affordances. */
.spell-editor-overlay.is-readonly-spell .field input:not([type="checkbox"]),
.spell-editor-overlay.is-readonly-spell .field textarea,
.spell-editor-overlay.is-readonly-spell .custom-select-trigger {
  border: 1px solid var(--line) !important;
  box-shadow: none !important;
  transform: none !important;
  background: var(--surface) !important;
  color: var(--ink) !important;
  opacity: 1 !important;
  cursor: default !important;
}
.spell-editor-overlay.is-readonly-spell textarea {
  white-space: pre-wrap;
  overflow-y: auto !important;
  overflow-x: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
  resize: none;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.spell-editor-overlay.is-readonly-spell .checkbox:disabled { opacity: 1; cursor: default; }
.spell-editor-overlay.is-readonly-spell .custom-select-trigger .custom-select-chevron { display:none; }

/* v165.3.45 — Library browsing: Notes-style secondary category controls. */
.library-header {align-items:center; flex-wrap:wrap}
.library-header .btn-primary {min-height:44px; padding:8px 15px; font-size:.9rem; border-width:3px; border-radius:12px; white-space:normal}
.library-controls {gap:13px; margin:22px 0 18px}
.library-filter-list {gap:8px}
.library-filter-list .library-filter {min-height:41px; padding:7px 14px; border:3px solid var(--ink); border-radius:11px; background:#fff; box-shadow:0 3px 0 var(--ink); font:900 .95rem var(--font-display); color:var(--ink)}
.library-filter-list .library-filter:hover {background:#fff}
.library-filter-list .library-filter.is-active {background:var(--accent); color:#fff; border-color:var(--ink); box-shadow:0 3px 0 var(--ink)}
.library-filter-list .library-filter:active {transform:translateY(3px); box-shadow:none}
.library-filter-list .library-filter:focus-visible {outline:3px solid var(--accent); outline-offset:3px}
.library-search-wrap {position:relative; width:100%}
.library-search-wrap .library-search {padding-right:49px; min-height:49px}
.library-search-wrap .library-search:focus {border-color:var(--accent); box-shadow:var(--control-shadow-accent)}
.library-search-icon {position:absolute; right:15px; top:50%; transform:translateY(-50%); display:flex; pointer-events:none; color:var(--ink)}
.library-search-icon svg {width:21px; height:21px}
.library-refinements {display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px}
.library-refine-field {display:flex; flex-direction:column; gap:5px; min-width:0; font-size:.8rem; font-weight:800}
.library-refine-field select {min-width:0; min-height:43px; font-size:.85rem; padding:6px 7px; cursor:pointer}
.library-refine-field select:focus {border-color:var(--accent); box-shadow:var(--control-shadow-accent)}
.library-count {margin:0; color:var(--muted); font-size:.85rem}
.library-no-results {margin:25px 0}
.library-entry small {line-height:1.5}
.library-license {display:block; margin:26px 0 8px; font-size:.78rem; line-height:1.55}
.library-license p {margin:7px 0 0; overflow-wrap:anywhere}
@media(max-width:670px) {.library-refinements {grid-template-columns:1fr 1fr}.library-refine-field:first-child {grid-column:1/-1}.library-header .btn-primary {max-width:100%}}
@media(max-width:420px) {.library-header {align-items:flex-start}.library-header .btn-primary {width:100%}}

/* v165.3.46: Selected Library categories stay physically pressed, not primary. */
.library-filter-list .library-filter.is-active,
.library-filter-list .library-filter.is-active:hover,
.library-filter-list .library-filter.is-active:active,
.library-filter-list .library-filter.is-active.is-pressed {
  background:#fff;
  color:var(--ink);
  border-color:var(--ink);
  transform:translateY(3px);
  box-shadow:none;
}
/* Match shared Bonfire custom dropdown sizing inside the compact Library row. */
.library-refine-field .field {min-width:0;gap:5px}
.library-refine-field .custom-select {min-width:0}
.library-refine-field .custom-select-trigger {min-height:43px;font-size:.85rem}

/* v165.3.47 — Compact Library filter entry point, shared bottom-sheet fields. */
.library-search-row {display:flex;align-items:stretch;gap:10px;min-width:0}
.library-search-row .library-search-wrap {flex:1;min-width:0}
.library-open-filters {position:relative;flex:0 0 50px;width:50px;min-height:49px;display:inline-flex;align-items:center;justify-content:center;padding:8px;border-radius:12px}
.library-open-filters .bf-icon {width:23px;height:23px}
.library-open-filters:focus-visible {outline:3px solid var(--accent);outline-offset:3px}
.library-filter-dot {position:absolute;top:5px;right:5px;width:9px;height:9px;background:var(--accent);border:2px solid var(--ink);border-radius:50%}
.library-popup-filters {display:grid;grid-template-columns:1fr;gap:15px}
.library-popup-filters .library-refine-field {width:100%}
.library-popup-filters .custom-select-trigger {width:100%}
.library-clear-filters {margin-top:16px;width:100%}

/* v165.3.48 — Use the existing secondary control treatment for Library filters. */
.library-open-filters {border-width:3px; border-radius:12px;}
.library-open-filters.is-active,
.library-open-filters.is-active:hover,
.library-open-filters.is-active:active {color:var(--accent);border-color:var(--accent);background:var(--surface);transform:translateY(4px);box-shadow:none;}
.library-filter-list .library-filter.is-active,
.library-filter-list .library-filter.is-active:hover,
.library-filter-list .library-filter.is-active:active {color:var(--accent);border-color:var(--accent);background:var(--surface);transform:translateY(3px);box-shadow:none;}
/* Shared select triggers retain standard component typography in the bottom sheet. */
.bf-dialog-variant-library-filters .library-refine-field,
.bf-dialog-variant-library-filters .library-refine-field .field {font-size:inherit;}
.bf-dialog-variant-library-filters .custom-select-trigger {font-size:1rem;min-height:52px;}
.bf-dialog-variant-library-filters .custom-select-trigger > span:first-child {font-size:inherit;}

/* Campaign foundation: reuse Bonfire controls and list layout. */
.bottom-nav { grid-template-columns:repeat(4,minmax(0,1fr)); }
.campaigns-page { display:grid;align-content:start;gap:18px;padding-bottom:calc(var(--mobile-nav-height) + 30px); }
.campaign-header,.campaign-detail-header { display:flex;align-items:center;gap:12px;justify-content:space-between; }
.campaign-header h1,.campaign-title-group h1 { margin:0; }
.campaign-title-group { min-width:0;flex:1; }
.campaign-title-group h1 { overflow-wrap:anywhere; }
.campaign-title-group p,.campaign-caption { color:var(--muted, #626262);font-size:.87rem;line-height:1.5;margin:6px 0 0; }
.campaign-list { display:grid;gap:12px; }
.campaign-card { width:100%;display:grid;gap:5px;text-align:left;padding:18px;background:var(--surface,#fff);border:2px solid var(--ink,#222);border-radius:16px;box-shadow:var(--control-shadow);cursor:pointer;color:inherit;font:inherit; }
.campaign-card:active { transform:translateY(3px);box-shadow:none; }
.campaign-card-name { font-weight:800;font-size:1.12rem; }
.campaign-card-subtitle { font-size:.85rem;opacity:.72; }
.campaign-empty { display:grid;justify-items:center;align-content:center;gap:14px;text-align:center;padding:40px 14px; }
.campaign-empty h2,.campaign-empty p { margin:0; }
.campaign-empty-icon { font-size:2rem; }
.campaign-panel { display:grid;gap:14px; }
.campaign-panel h2,.campaign-panel h3,.campaign-panel p { margin:0; }
.campaign-panel p { line-height:1.55; }
.campaign-member { display:flex;justify-content:space-between;gap:12px;border:2px solid var(--ink,#222);border-radius:14px;padding:15px; }
.campaign-footer { padding-top:20px; }
@media(max-width:380px) { .campaign-header .btn { font-size:.8rem;padding-inline:10px; } .bottom-nav .nav-item { font-size:.77rem; } }

/* Campaigns reuse the Sheets create-action placement and full-size shared buttons. */
.campaign-collection { display:grid;gap:16px; }
.campaign-collection h2 { margin:0; }
.campaign-collection .home-create-actions { margin-top:0; }
.campaign-detail-header .profile-round-back { flex-shrink:0; }
.campaign-more { align-self:flex-start; }
.campaign-party-empty { padding-block:28px; }

/* Campaign header & Notes foundation v165.3.51 */
.campaign-detail-header {align-items:flex-start;}
.campaign-title-group .campaign-system {margin:8px 0 0;color:var(--muted,#626262);font-size:.875rem;}
.campaign-notes-heading {display:flex;justify-content:space-between;align-items:center;gap:12px;}
.campaign-notes-list {display:grid;gap:12px;}
.campaign-notes-list .campaign-card-subtitle {overflow-wrap:anywhere;white-space:normal;}

/* Campaigns use the same underline tabs as character sheets. */
.campaign-sheet-tabs { gap:22px; border-bottom:1px solid var(--line); padding:0; }
.campaign-sheet-tabs .sheet-tab { font:inherit; font-weight:700; padding:8px 0 10px; white-space:nowrap; }
.campaign-sheet-tabs .sheet-tab.is-active { color:var(--accent); font-weight:900; }
.campaign-detail-header { position:relative; }
/* The campaign detail has no primary bottom navigation; avoid its reserved whitespace. */
.campaigns-page:has(.campaign-detail-header) { padding-bottom:30px; }

.campaign-menu-anchor { position:relative; flex-shrink:0; align-self:flex-start; display:flex; align-items:flex-start; }

/* Campaign cards share the exact appearance custom properties and selectors as Sheets. */
/* Campaign character menu: center without a transform so the shared 4px
   pressed state moves only the button surface. */
.campaign-party-character { position:relative; min-width:0; }
.campaign-party-character > .character-card {
  width:100%;
  box-sizing:border-box;
  padding-right:52px;
  background:var(--character-card-header, #fff);
  border-color:var(--line);
}
.campaign-party-character .character-actions { margin-right:0; }
.campaign-character-menu,
.campaign-remote-character-menu {
  position:absolute;
  right:8px;
  top:0;
  bottom:0;
  margin-block:auto;
  z-index:4;
}
.campaign-party-character > .character-card .avatar-placeholder,
.campaign-party-character > .character-card .avatar,
.campaign-party-character > .character-card .sheet-avatar {
  border:4px solid var(--character-card-rim,var(--ink));
  box-sizing:border-box;
}

/* v165.3.56: One Campaigns collection with compact create/join actions. */
.campaign-create-join-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}
.campaign-create-join-actions > .btn { width: 100%; min-width: 0; }
.campaign-list + .campaign-create-join-actions { margin-top: 18px; }
.campaign-empty > .campaign-create-join-actions { max-width: 520px; margin-top: 4px; }
@media (max-width: 370px) {
  .campaign-create-join-actions { gap: 8px; }
  .campaign-create-join-actions > .btn { padding-inline: 8px; }
}

/* Read-only GM character inspection panel */
.campaign-gm-view{display:grid;gap:16px;max-height:62vh;overflow-y:auto;padding:4px 2px 16px;}
.campaign-gm-sheet-section{border-bottom:1px solid var(--border-color,#ddd);padding-bottom:12px;}
.campaign-gm-sheet-section h3{font-size:1rem;margin:0 0 6px;}
.campaign-gm-sheet-section p{white-space:pre-wrap;overflow-wrap:anywhere;font-size:0.95rem;line-height:1.5;margin:0;}
.campaign-remote-character[data-campaign-gm-view]{cursor:pointer;}

/* Full-page GM sheet inspector, using the established Bonfire sheet tabs. */
.campaign-gm-fullsheet{max-width:1100px;margin:0 auto;}
.campaign-gm-fullsheet .campaign-sheet-tabs{overflow-x:auto;}
.campaign-gm-sheet-content{display:grid;gap:20px;padding:20px 0 48px;}
.campaign-gm-fullsheet .campaign-gm-sheet-section{padding:18px;border:1px solid var(--border-color,#ddd);border-radius:12px;}
.campaign-gm-fullsheet .campaign-gm-sheet-section:last-child{border-bottom:1px solid var(--border-color,#ddd);}

/* Campaign publication selection uses shared text sizes and native accessible checkbox. */
.campaign-sharing-list{display:grid;gap:8px;max-height:min(50vh,420px);overflow:auto;}
.campaign-sharing-row{display:flex;align-items:center;gap:12px;padding:8px 4px;cursor:pointer;}
.campaign-sharing-row .checkbox{flex-shrink:0;}
.campaign-sharing-row span{display:flex;flex-direction:column;gap:3px;}
.campaign-sharing-row small{font-size:0.875em;opacity:.7;text-transform:capitalize;}

/* Campaign notes share the existing campaign surface without duplicating the journal editor. */
.campaign-notes-header{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;}
.campaign-notes-header h2{margin:0;}
.campaign-notes-list{display:grid;gap:12px;margin-top:18px;}
.campaign-note-card{display:flex;align-items:flex-start;gap:8px;border:1px solid var(--stroke,#292929);border-radius:12px;padding:14px;}
.campaign-note-open{display:flex;flex-direction:column;align-items:flex-start;gap:6px;flex:1;min-width:0;border:0;background:transparent;text-align:left;font:inherit;color:inherit;cursor:pointer;overflow-wrap:anywhere;}
.campaign-note-open strong{font-size:1rem;}
.campaign-note-open small,.campaign-note-open span{font-size:.875rem;opacity:.75;}
.campaign-note-menu{flex-shrink:0;}

/* Campaign browsing reuses the existing sheet/journal UI. */
.campaign-card-footer{display:flex;align-items:center;gap:12px;margin-top:10px;min-height:34px;}
.campaign-card-avatars{display:flex;align-items:center;padding-left:5px;}
.campaign-card-avatar{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:3px solid var(--campaign-avatar-rim,#41936b);border-radius:50%;overflow:hidden;background:#fff;margin-left:-5px;}
.campaign-card-avatar .avatar-placeholder{width:100%;height:100%;border:0;border-radius:50%;background-size:cover;background-position:center;}
.campaign-card-players{font-size:.875rem;color:var(--muted,#666);}
.campaign-shared-journal{margin-top:18px;min-height:360px;}
.campaign-shared-note-row{display:flex;align-items:center;gap:5px;}
.campaign-shared-note-row .bf-journal-row{flex:1;min-width:0;}
.bf-journal-sidebar-add{padding:14px 0;}
.campaign-readonly-sheet input:disabled,.campaign-readonly-sheet select:disabled{opacity:1;}

.campaign-shared-note-editor{display:flex;flex-direction:column;gap:16px;padding:20px;min-height:360px;}
.campaign-shared-note-body{width:100%;min-height:260px;flex:1;resize:vertical;background:transparent;border:1px solid var(--line,#ccc);border-radius:10px;padding:16px;font:inherit;line-height:1.6;color:inherit;}
.campaign-shared-note-body:focus{outline:2px solid var(--accent,#41936b);outline-offset:2px;}
.campaign-shared-note-body[readonly]{border-color:transparent;padding-left:0;resize:none;}

/* Campaign management inherits the shared icon-button and journal controls. */
.campaign-member-actions{display:flex;align-items:center;gap:10px}
.campaign-remote-character{position:relative}
.campaign-shared-note-body.bf-journal-writing{min-height:260px;white-space:normal;overflow:auto;resize:none}
.campaign-shared-note-body[contenteditable="true"]:focus{outline:2px solid var(--accent,#41936b)}

/* Campaign v165.3.66 — shared sheet geometry and contained note scrolling. */
.campaign-detail-page {display:flex;flex-direction:column;height:calc(100dvh - 12px);min-height:0;overflow:hidden;padding-bottom:0!important}
.campaign-detail-page .campaign-detail-header,.campaign-detail-page .campaign-sheet-tabs{flex:none}
.campaign-detail-page .campaign-panel{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:block;padding:12px 0 24px}
.campaign-detail-page .campaign-panel-notes{overflow:hidden;display:flex;flex-direction:column;padding:0}
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal{flex:1 1 auto;height:100%;min-height:0;margin:0}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar{overflow:hidden}
.campaign-detail-page .campaign-panel-notes .bf-journal-detail{background:#fff}
.campaign-shared-note-editor{height:100%;min-height:0;gap:0;padding:0;background:#fff;overflow:hidden}
.campaign-shared-note-editor .bf-journal-editor-header{padding:14px 18px}
.campaign-shared-note-editor .bf-journal-tools{border:0;background:#fff}
.campaign-shared-note-editor .bf-journal-writing{border:0!important;border-radius:0;outline-offset:-3px;flex:1;min-height:0;background:#fff;resize:none}
.campaign-shared-note-editor .bf-journal-actions{border:0;background:#fff}
.campaign-note-sharing{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:0 18px 12px;background:white;flex-wrap:wrap}
.campaign-note-edit-toggle{display:flex;align-items:center;gap:10px;font-size:.85rem;font-weight:600}
.campaign-note-edit-toggle .bf-switch{flex:none}
.campaign-shared-note-row{position:relative}
.campaign-shared-note-row .bf-journal-row{width:100%}
@media(max-width:700px){.campaign-detail-page{height:100dvh}.campaign-detail-page .campaign-panel-notes .bf-journal-workspace{height:100%}}

.campaign-shared-note-editor .bf-journal-editor-header{flex-direction:row;align-items:center;min-width:0}
.campaign-shared-note-editor .bf-journal-title-field{flex:1;min-width:0}
.campaign-note-editor-menu{flex:none;align-self:center}

/* v165.3.67 — Campaign layout repairs. Keep page fixed; scroll content only as needed. */
body:has(.campaign-detail-page){overflow:hidden}
body:has(.campaign-detail-page) .app-shell{min-height:0;overflow:hidden}
body:has(.campaign-detail-page) .app{height:100%;min-height:0;padding-bottom:0;overflow:hidden}
.campaigns-page.campaign-detail-page{height:100%;min-height:0;overflow:hidden;gap:18px;padding-bottom:0!important}
.campaign-detail-page .campaign-panel{min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-gutter:stable;padding:12px 0 24px}
.campaign-detail-page .campaign-panel-notes{overflow:hidden;padding:0}
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal{margin:0;min-height:0;height:100%}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar{min-width:0;overflow:hidden}
.campaign-detail-page .campaign-panel-notes .bf-journal-list{flex:1 1 auto;overflow-y:auto;padding:12px 12px 0}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-head{padding:12px 12px 8px}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add{padding:10px 12px 14px;width:100%;box-sizing:border-box}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add .btn{width:100%;display:flex;justify-content:center}
.campaign-shared-note-row{position:relative;display:block;min-width:0;margin-bottom:12px}
.campaign-shared-note-row .bf-journal-row{margin-bottom:0;padding-right:50px}
.campaign-note-card-menu{position:absolute;right:8px;top:50%;transform:translateY(-50%);z-index:1}
.campaign-detail-page .campaign-panel:not(.campaign-panel-notes) .campaign-member + .campaign-member{margin-top:12px}
.campaign-detail-page .campaign-panel:not(.campaign-panel-notes) .home-create-actions{margin-top:18px}


/* v165.3.68 — Campaign Notes parity and layout refinements. */
.campaign-detail-page{height:100%!important;min-height:0;}
.campaign-detail-page .campaign-panel{flex:1 1 auto;min-height:0;}
.campaign-detail-page .campaign-panel-notes{height:auto;}
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal{height:100%;min-height:0;}
.campaign-detail-page .campaign-panel-notes .bf-journal-list{padding:0;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-head{padding-left:0;padding-right:0;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add{padding:10px 0 14px;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add .btn{width:100%;}
.campaign-detail-page .campaign-panel:not(.campaign-panel-notes)>h2{margin-bottom:18px;}
.campaign-readonly-note-title{margin:0;font-family:var(--font-display);color:var(--ink);font-size:1.3rem;overflow-wrap:anywhere;}
.campaign-shared-note-row:has(.bf-journal-row.is-active) .campaign-note-card-menu,
.campaign-shared-note-row:has(.bf-journal-row:active) .campaign-note-card-menu{transform:translateY(calc(-50% + 4px));}
.campaign-detail-page .campaign-shared-note-editor .bf-journal-tools>button.is-format-active{border-color:var(--accent);color:var(--accent-dark);box-shadow:none;transform:translateY(3px);}
@media(min-width:701px){.campaign-detail-page .campaign-panel-notes .bf-journal-workspace{height:100%;}}

/* v165.3.69 — Campaign journal layout and native card actions. */
.campaign-detail-page .campaign-panel-notes .bf-journal-workspace{
  height:100%;min-height:0;grid-template-columns:minmax(215px,270px) minmax(0,1fr);column-gap:18px;
}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar{
  min-height:0;min-width:0;border-right:1px solid var(--line);padding:0 0 0 0;
}
.campaign-detail-page .campaign-panel-notes .bf-journal-detail{min-height:0;min-width:0;background:#fff;}
.campaign-detail-page .campaign-panel-notes .bf-journal-list{min-height:0;flex:1;overflow-y:auto;padding:0 0 12px;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-head{padding:10px 0 14px;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add{flex:0 0 auto;padding:12px 0 14px;width:100%;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add .btn{width:100%;min-height:50px;}
.campaign-shared-note-row{display:flex;position:relative;align-items:center;gap:0;margin:0 0 12px;padding:0;border:3px solid var(--ink);border-radius:14px;background:var(--surface,#fff);box-shadow:0 4px 0 var(--ink);transition:transform .12s ease,box-shadow .12s ease;}
.campaign-shared-note-row.is-active,.campaign-shared-note-row:active{transform:translateY(4px);box-shadow:none;}
.campaign-shared-note-row>.bf-journal-row{flex:1;min-width:0;width:auto;margin:0;border:0;box-shadow:none!important;transform:none!important;padding:14px;min-height:66px;background:transparent;}
.campaign-shared-note-row>.bf-journal-row:hover{box-shadow:none!important;transform:none!important;}
.campaign-shared-note-row>.campaign-note-card-menu{position:static;transform:none!important;margin:0 8px 0 0;z-index:1;}
.campaign-shared-note-row:has(.bf-journal-row:focus-visible){outline:3px solid var(--accent);outline-offset:2px;}
.campaign-detail-page .campaign-shared-note-body[contenteditable=true]:focus{outline:none!important;box-shadow:none!important;border:none!important;}
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal{flex:1;min-height:0;height:100%;}
.campaign-detail-page .campaign-panel-notes .campaign-shared-note-editor{height:100%;min-height:0;}
.campaign-detail-page .campaign-panel-notes .bf-journal-writing{min-height:0;}
.campaign-detail-page .campaign-panel-notes .bf-journal-actions{flex:0 0 auto;}
.campaign-detail-page .campaign-panel:not(.campaign-panel-notes) .campaign-member{align-items:center;min-height:64px;}
@media(max-width:700px){.campaign-detail-page .campaign-panel-notes .bf-journal-workspace{display:flex;flex-direction:column;gap:0}.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar{border-right:0}.campaign-detail-page .campaign-panel-notes .bf-journal-detail{flex:1}}

/* v165.3.70 — keep note controls inside the sidebar, next to its divider.
   The writing panel begins directly on the far side of that divider. */
.campaign-detail-page .campaign-panel-notes .bf-journal-workspace {
  column-gap:0;
}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar {
  padding:0 14px 0 0;
  box-sizing:border-box;
}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add {
  padding:12px 0 14px;
  width:100%;
  box-sizing:border-box;
}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add .btn {
  width:100%;
  box-sizing:border-box;
}
@media(max-width:700px){
  .campaign-detail-page .campaign-panel-notes .bf-journal-sidebar {padding-right:14px;}
}

/* v166: Align the shared Add Note button label on both axes.
   The button component remains BF.button.primary; only its container sizing is scoped. */
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar-add > .btn {
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  line-height:1.2;
  min-height:56px;
  padding-block:0;
}

/* v166.1: Campaign Notes use the full tab body without scrolling the page. */
.campaigns-page.campaign-detail-page {display:flex;flex-direction:column;align-content:stretch;min-height:0;height:100%;}
.campaign-detail-page .campaign-detail-header,.campaign-detail-page .campaign-sheet-tabs {flex:0 0 auto;}
.campaign-detail-page .campaign-panel-notes {display:flex;flex:1 1 0;min-height:0;overflow:hidden;padding:0;}
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal {display:grid;flex:1 1 0;min-height:0;height:100%;align-self:stretch;}
.campaign-detail-page .campaign-panel-notes .bf-journal-detail,
.campaign-detail-page .campaign-panel-notes .campaign-shared-note-editor {height:100%;min-height:0;}
.campaign-detail-page .campaign-shared-note-row.is-active {border-color:var(--accent,#41936b);box-shadow:none;transform:translateY(4px);}

/* Campaign viewport and campaign-list thumbnails. */
/* The campaign uses the same padded desktop viewport as the other pages. */
body:has(.campaign-detail-page) .app {padding-bottom:0!important;height:100%!important;min-height:0;}
.campaign-detail-page {height:100%!important;min-height:0!important;padding-bottom:0!important;}
.campaign-detail-page .campaign-panel-notes,.campaign-detail-page .campaign-shared-journal,.campaign-detail-page .bf-journal-workspace {flex:1 1 auto;min-height:0;height:100%;}
.campaign-card {position:relative;}
.campaign-card-thumbnail {
  position:absolute;right:0;top:0;width:50%;height:100%;
  object-fit:cover;object-position:center;border:0;
  border-radius:0 14px 14px 0;pointer-events:none;
}

.campaign-card:has(.campaign-card-thumbnail) {padding-right:calc(50% + 18px);min-height:156px;align-content:center;}

/* Campaign appearance — same palette tokens used by Customize Sheet. */
.campaign-detail-page { background:var(--campaign-content,#f7f7f5); }
.campaign-detail-page .campaign-detail-header { background-color:var(--campaign-header,#fff); }
.campaign-detail-page .campaign-panel { background-color:var(--campaign-content,#f7f7f5); }.campaign-overview-details{margin-top:48px;margin-bottom:32px}.campaign-overview-details-card{display:grid;grid-template-columns:minmax(0,40%) minmax(0,1fr);align-items:stretch;gap:24px;padding:24px;border:1px solid var(--line);border-radius:14px;background:var(--campaign-header,#fffaf5)}.campaign-overview-details-image{display:grid;place-items:center;min-height:180px;border-radius:9px;overflow:hidden;background:var(--campaign-content,#fff1e1)}.campaign-overview-details-image img{display:block;width:100%;height:100%;object-fit:cover}.campaign-overview-details-card p{align-self:start;margin:0;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.55}@media(max-width:620px){.campaign-overview-details-card{grid-template-columns:1fr}.campaign-overview-details-image{min-height:180px;aspect-ratio:16/9}}
.campaign-card { background-color:var(--campaign-card-header,#fff); }
.campaign-card:focus-visible { outline:2px solid var(--campaign-card-rim,#2fa47e);outline-offset:3px; }

/* v166.5 — Campaign layout has one edge-to-edge header and independently
   scrolling tab content. Keep a bottom inset inside the scroll container. */
html:has(.campaign-detail-page),body:has(.campaign-detail-page) {background:var(--campaign-outer-canvas,#ededeb);}
body:has(.campaign-detail-page) .app-shell {background:var(--campaign-outer-canvas,#ededeb);}
body:has(.campaign-detail-page) .app {background:var(--campaign-outer-canvas,#ededeb);}
.campaigns-page.campaign-detail-page {padding:0!important;gap:0;background:var(--campaign-content,#f7f7f5);}
.campaign-detail-page .campaign-detail-header {
  margin:0;min-height:170px;border-radius:0;padding:24px 26px 24px;
  width:100%;flex-shrink:0;background-color:var(--campaign-header,#fff);
}
.campaign-detail-page .campaign-sheet-tabs {
  margin:0;padding:0 26px;flex-shrink:0;background:var(--campaign-header,#fff);
}
.campaign-detail-page .campaign-panel {
  padding:22px 26px 32px;min-height:0;
  background:var(--campaign-content,#f7f7f5);
}
.campaign-detail-page .campaign-panel-notes {padding:0;background:#fff;}
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal,
.campaign-detail-page .campaign-panel-notes .bf-journal-workspace,
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar,
.campaign-detail-page .campaign-panel-notes .bf-journal-detail {background:#fff;}
.campaign-detail-page .campaign-member {background:#fff;}
.campaign-detail-page .campaign-panel:not(.campaign-panel-notes) {scroll-padding-bottom:32px;}
@media(max-width:600px) {
  .campaign-detail-page .campaign-detail-header {padding-inline:18px;}
  .campaign-detail-page .campaign-sheet-tabs {padding-inline:18px;}
  .campaign-detail-page .campaign-panel:not(.campaign-panel-notes) {padding-inline:18px;}
}

/* Campaign frame: identical outer geometry to the Campaigns list. Desktop
   body already reserves 28px on each side, including the bottom. Do NOT
   size the shell to 100dvh or subtract a second internal gutter. */
body:has(.campaign-detail-page) .app-shell {
  min-height:0;
  overflow:hidden;
  background:var(--campaign-outer-canvas,#ededeb);
}
body:has(.campaign-detail-page) .app {
  min-height:0;
  padding:0;
  overflow:hidden;
  background:var(--campaign-content,#f7f7f5);
}
.campaigns-page.campaign-detail-page {
  min-height:0;
  height:100%;
  overflow:hidden;
  border-radius:inherit;
  background:var(--campaign-content,#f7f7f5);
}
@media(min-width:900px) {
  body:has(.campaign-detail-page) .app-shell {
    height:100%; /* same as .app-shell on the Campaigns list */
    border-radius:28px;
  }
  body:has(.campaign-detail-page) .app {
    height:100%;
    border-radius:28px;
  }
}
@media(max-width:899px) {
  body:has(.campaign-detail-page) .app-shell {height:100dvh;}
  body:has(.campaign-detail-page) .app {height:100%;}
}
.campaign-detail-page .campaign-panel-notes,
.campaign-detail-page .campaign-panel-notes .campaign-shared-journal,
.campaign-detail-page .campaign-panel-notes .bf-journal-workspace,
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar {
  background:var(--campaign-content,#f7f7f5);
}
.campaign-detail-page .campaign-panel-notes .bf-journal-detail,
.campaign-detail-page .campaign-panel-notes .campaign-shared-note-editor {background:#fff;}
.campaign-detail-page .campaign-panel-notes .bf-journal-sidebar {padding-inline:14px;}

/* Campaign packs show a cover, tab bar and campaign content—not an avatar. */
.bf-campaign-customize-page .bf-campaign-pack-art {padding:7px;gap:0;}
.bf-campaign-pack-header {display:flex;flex-direction:column;justify-content:center;gap:5px;padding:8px 9px;background:var(--pack-header);border-radius:5px 5px 0 0;min-height:29px;}
.bf-campaign-pack-title {display:block;width:62%;height:5px;background:#393939;border-radius:3px;opacity:.72;}
.bf-campaign-pack-description {display:block;width:82%;height:3px;background:#393939;border-radius:3px;opacity:.34;}
.bf-campaign-pack-tabs {display:flex;align-items:end;gap:7px;height:10px;padding:0 9px;background:var(--pack-header);}
.bf-campaign-pack-tabs i {display:block;width:23%;height:4px;border-radius:2px 2px 0 0;background:#494949;opacity:.4;}
.bf-campaign-pack-tabs i:first-child {height:6px;opacity:.8;}
.bf-campaign-pack-body {flex:1;display:flex;gap:6px;padding:7px 9px;background:var(--pack-content);border-radius:0 0 5px 5px;}
.bf-campaign-pack-body>span {flex:1;background:#fff;border-radius:3px;border:1px solid #d8d8d8;}

/* Notes writing canvas meets the right edge; only the sidebar is inset. */
.campaign-detail-page .campaign-panel-notes .bf-journal-detail,
.campaign-detail-page .campaign-panel-notes .campaign-shared-note-editor,
.campaign-detail-page .campaign-panel-notes .bf-journal-workspace,
.campaign-detail-page .campaign-panel-notes {padding-right:0;margin-right:0;}

/* Campaign invitation manager: uses the existing dialog and button components. */
.campaign-invites {display:flex;flex-direction:column;gap:16px;}
.campaign-invites p {margin:0;}
.campaign-invites-actions {display:flex;}
.campaign-invites-actions .btn {width:100%;}
.campaign-invite-entry {display:flex;flex-direction:column;gap:12px;padding:16px 0;border-top:1px solid #ddd;}
.campaign-invite-heading {display:flex;justify-content:space-between;gap:12px;align-items:center;}
.campaign-invite-heading span {font-size:.85em;opacity:.75;}
.campaign-invite-label {display:flex;flex-direction:column;gap:5px;font-size:.85em;}
.campaign-invite-label input {display:block;width:100%;min-width:0;box-sizing:border-box;padding:10px;border:1px solid #aaa;border-radius:8px;background:var(--surface,#fff);color:inherit;font:inherit;}
.campaign-invite-buttons {display:flex;flex-wrap:wrap;gap:8px;}
.campaign-invite-buttons .btn {flex:1 1 auto;}

/* Shared image cropper: square preview and touch-friendly drag controls. */
.bf-image-cropper { display:grid; gap:16px; }
.bf-crop-file-label { display:grid; gap:8px; font-weight:700; }
.bf-crop-file-label input { max-width:100%; font-weight:400; }
.bf-crop-stage { width:min(100%,320px); aspect-ratio:1; margin-inline:auto; border:3px solid var(--border-strong,#333); border-radius:18px; overflow:hidden; background:#eee; }
.bf-crop-stage canvas { width:100%; height:100%; display:block; touch-action:none; cursor:grab; }
.bf-crop-stage canvas:active { cursor:grabbing; }
.bf-crop-zoom-label { display:grid; gap:8px; }
.bf-crop-zoom-label input { width:100%; }
.bf-crop-help { font-size:.875rem; margin:0; }
.bf-profile-upload { align-self:start; }

/* Shared picture-upload controls replace the former image URL inputs. */
.bf-image-upload-field { display:flex; flex-direction:column; align-items:flex-start; gap:10px; min-width:0; }
.bf-image-upload-label { font-weight:600; font-size:14px; }
.bf-image-upload-field .btn { align-self:flex-start; }
.bf-campaign-thumbnail-preview { width:100%; max-width:420px; aspect-ratio:16/9; border-radius:12px; background-size:cover; background-position:center; }

/* v167.4: upload-first portrait and campaign-art controls */
.bf-avatar-upload { position:relative; display:flex; align-items:center; justify-content:center; background:transparent; border:0; padding:0; border-radius:50%; cursor:pointer; }
.bf-avatar-upload-icon { position:absolute; bottom:2px; right:2px; display:grid; place-items:center; width:30px; height:30px; border-radius:50%; background:var(--surface,#fff); color:var(--text,#222); border:1px solid var(--border,#ccc); box-shadow:0 2px 8px #0002; pointer-events:none; }
.bf-avatar-upload:focus-visible,.bf-campaign-create-upload:focus-visible { outline:3px solid var(--accent,#4c8); outline-offset:3px; }
.bf-campaign-create-art { display:flex; flex-direction:column; gap:8px; }
.bf-campaign-create-upload { display:flex; align-items:center; justify-content:center; width:100%; aspect-ratio:16/9; max-height:210px; border-radius:14px; border:2px dashed var(--border-strong,#aaa); background-color:var(--surface-secondary,#f2f2f2); background-size:cover; background-position:center; cursor:pointer; color:var(--text,#222); }
.bf-campaign-create-upload [data-campaign-art-label] { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; font-weight:700; }
.bf-campaign-create-upload.has-image [data-campaign-art-label] { background:#ffffffed; border-radius:8px; padding:8px 14px; }
.bf-crop-zoom-label input { accent-color:var(--accent,#5a8); cursor:pointer; }

/* v167.5: equal-width main navigation and image control actions. */
.bottom-nav {grid-template-columns:repeat(4,minmax(0,1fr));}
.bottom-nav .nav-item {width:100%;max-width:none;min-width:0;justify-self:stretch;}
.bf-picture-control {position:relative;display:inline-flex;align-items:center;justify-content:center;max-width:100%;}
.bf-picture-control-wide {display:flex;width:100%;}
.bf-picture-control-wide .bf-campaign-create-upload {width:100%;}
.bf-campaign-create-art {position:relative;}
.bf-picture-remove {position:absolute;z-index:3;bottom:2px;left:2px;display:grid;place-items:center;width:30px;height:30px;border:1px solid var(--line,#ddd);border-radius:50%;background:var(--surface,#fff);color:var(--ink,#222);cursor:pointer;box-shadow:0 2px 8px #0002;}
.bf-picture-remove-wide {left:auto;right:10px;bottom:10px;}
.bf-picture-remove:hover {color:var(--danger,#c43);}
.bf-campaign-edit-upload {max-height:210px;}
.bf-campaign-edit-upload.has-image [data-campaign-art-label] {background:#ffffffd9;padding:8px;border-radius:50%;}

/* v167.6: use the real circular portrait crop and clear picture actions. */
.bf-crop-circle .bf-crop-stage { border-radius:50%; }
.bf-picture-remove { color:#c73535; }
.bf-picture-remove:hover, .bf-picture-remove:focus-visible { color:#a71616; }
.bf-avatar-upload-icon { bottom:4px; right:4px; }
.bf-picture-control:not(.bf-picture-control-wide) > .bf-picture-remove { top:3px; right:3px; bottom:auto; left:auto; }

/* Campaign note export shares the existing journal footer layout. */
.campaign-note-footer-buttons{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap}

/* Onboarding uses the existing home-page shell; it never changes campaign height rules. */
.bf-getting-started{max-width:100%;}
.bf-getting-started-lead{margin:0 0 22px;color:var(--text-muted,#6b7280);line-height:1.6;max-width:580px;}
.bf-getting-started-steps{display:grid;gap:12px;}
.bf-getting-started-step{display:grid;grid-template-columns:45px minmax(0,1fr);gap:14px;padding:18px;border-radius:16px;background:var(--card-bg,#fff);border:1px solid rgba(0,0,0,.08);}
.bf-getting-started-number{font-weight:800;color:var(--accent,#2e7554);font-size:1.1rem;}
.bf-getting-started-step h2{font-size:1.07rem;margin:0 0 7px;}
.bf-getting-started-step p{margin:0 0 14px;line-height:1.55;color:var(--text-muted,#6b7280);}
.bf-getting-started-action,.bf-getting-started-done{display:flex;justify-content:flex-start;}
.bf-getting-started-done{margin-top:20px;}
.bf-first-character-actions{display:flex;flex-wrap:wrap;align-items:center;gap:10px;}
@media(max-width:520px){.bf-getting-started-step{grid-template-columns:32px minmax(0,1fr);padding:14px;}}

/* Contextual onboarding stays inside existing Library and Campaigns layouts. */
.bf-context-empty{padding:18px 16px;margin-block:10px 16px;border:1px solid var(--line,#dedede);border-radius:14px;background:var(--surface-secondary,#f5f5f5);line-height:1.55;}
.bf-context-empty h2{font-size:1.05rem;margin:0 0 8px;}
.bf-context-empty p{margin:0 0 10px;}
.bf-context-empty p:last-child{margin-bottom:0;}
.bf-context-hint{font-size:.875rem;opacity:.8;}

/* Personal Library usage: count owned entries, not the bundled SRD catalog. */
.library-quota { margin: 6px 0 0; font-size: .86rem; color: var(--muted); }


/* v169.14 — Firebase authentication action pages. Shared .btn, .text-input and
   stepper-button tokens are defined above; only page layout lives here. */
body.auth-page { box-sizing:border-box; width:100%; max-width:none; min-height:100dvh; margin:0; padding:24px; display:grid; grid-template-columns:minmax(0,1fr); place-items:center; background:#ededeb; }
.auth-action-frame { width:min(100%,510px); min-width:0; margin-inline:auto; }
.auth-action-card { background:var(--surface); border-radius:28px; padding:clamp(24px,5vw,40px); box-shadow:0 2px 12px #0000000d; }
.auth-back-control { display:inline-flex; align-items:center; gap:12px; color:var(--ink); font-family:var(--font-display); font-size:14px; font-weight:800; text-decoration:none; }
.auth-back-round { display:grid; place-items:center; width:34px; height:34px; border:3px solid var(--ink); border-radius:50%; background:var(--accent); color:#fff; box-shadow:0 4px 0 var(--ink); transition:transform .08s,box-shadow .08s; }
.auth-back-control:active .auth-back-round { transform:translateY(4px); box-shadow:none; }
.auth-back-control:focus-visible { outline:2px solid var(--accent); outline-offset:5px; border-radius:8px; }
.auth-page .eyebrow { font-size:11px; letter-spacing:.12em; font-weight:700; color:var(--accent); }
.auth-heading { margin:28px 0 26px; }
.auth-heading h1 { font-size:clamp(27px,5vw,35px); line-height:1.15; margin-bottom:12px; }
.auth-heading p { line-height:1.55; }
#action-description { color:var(--muted); margin:0; }
#reset-form { display:grid; gap:12px; }
#reset-form label { font-size:1rem; font-weight:500; margin-top:7px; }
.password-row { position:relative; }
.password-row .text-input { padding-right:76px; }
.password-row .visibility { position:absolute; right:10px; top:50%; transform:translateY(-50%); padding:6px; color:var(--accent); font-size:13px; }
.auth-page .primary-action { display:flex; justify-content:center; align-items:center; width:100%; margin-top:14px; text-align:center; text-decoration:none; }
.auth-page .primary-action:disabled { opacity:.6; cursor:wait; }
.auth-page .btn.is-pressed:not(:disabled):not(.btn-static) { transform:translateY(4px); box-shadow:0 1px 0 var(--ink); }
.auth-page .text-input.is-pressed { transform:none; border-color:var(--ink); box-shadow:var(--control-shadow); }
.auth-page .text-input.is-editing, .auth-page .text-input:focus { transform:none; border-color:var(--accent); box-shadow:var(--control-shadow-accent); outline:none; }
.auth-page .footnote { text-align:center; color:var(--muted); font-size:12px; margin:17px 0 0; }
#action-feedback { padding:13px 15px; border-radius:var(--radius-sm); background:#fff2f2; border:1px solid #efb3b3; color:#8f3131; margin:0 0 20px; line-height:1.45; font-size:14px; }
#action-feedback[hidden], #reset-form[hidden], .preview-notice[hidden] { display:none!important; }
.preview-options { display:grid; gap:12px; }
.auth-page .preview-option { display:grid; gap:5px; min-height:64px; padding:12px 16px; text-decoration:none; }
.auth-page .preview-option span { color:var(--muted); font-size:13px; }
.preview-notice { padding:10px 13px; border-radius:var(--radius-sm); background:#e5f4ee; color:#23654c; font-size:13px; font-weight:600; }
@media(max-width:540px) { body.auth-page {padding:14px;} .auth-action-card {border-radius:22px;} }

/* v169.18 Race Library: existing controls with responsive card arrangement. */
.race-editor-tabs{position:sticky;top:-1px;z-index:5;padding:6px 0 12px;background:var(--surface);}
.race-editor-tabs .library-filter-list{flex-wrap:nowrap;overflow-x:auto;padding-bottom:5px;}
.race-editor-tabs .library-filter{flex-shrink:0;}
.race-editor-body{display:grid;gap:16px;min-width:0;}
.race-size-section{display:grid;gap:10px;}
.race-size-section h3{margin:0;}
.race-movement-row{display:flex;flex-wrap:wrap;gap:12px;align-items:stretch;}
.race-movement-row .creator-movement-card,.race-movement-row .creator-add-card{flex:0 1 170px;width:auto;min-width:150px;max-width:220px;align-self:stretch;box-sizing:border-box;}
.race-movement-row .creator-movement-card .field,.race-movement-row .creator-movement-card input{width:100%;min-width:0;max-width:100%;box-sizing:border-box;}
.race-movement-row .creator-add-card{margin:0;min-height:120px;}
.race-asi-grid{display:flex;flex-wrap:wrap;gap:12px;align-items:stretch;}
.race-asi-card{flex:0 1 210px;min-width:190px;max-width:255px;display:grid;gap:10px;border:1px solid var(--line);border-radius:14px;background:var(--surface);padding:12px;box-sizing:border-box;}
.race-asi-card-top{display:flex;align-items:center;gap:8px;min-width:0;}
.race-asi-card-top .field{flex:1;min-width:0;}
.race-asi-card .stepper{justify-content:center;}
.race-asi-grid>.creator-add-card{flex:0 1 210px;min-width:190px;max-width:255px;min-height:110px;margin:0;}
.race-trait-row,.race-subrace-row{display:flex;align-items:stretch;gap:10px;min-width:0;}
.race-trait-card{flex:1;min-width:0;text-align:left;display:flex;align-items:center;gap:8px;}
.race-trait-card strong{min-width:0;flex:1;}
.race-trait-card small{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.race-subrace-back{display:flex;align-items:center;gap:10px;}
@media(max-width:480px){.race-movement-row .creator-movement-card,.race-movement-row .creator-add-card{flex:1 1 140px;min-width:135px;}.race-asi-card,.race-asi-grid>.creator-add-card{flex:1 1 175px;min-width:145px;}.race-asi-card-top{flex-wrap:wrap;}}

/* v169.19: Race editor uses shared profile back control and lifted Feature cards. */
.race-editor-tabs{top:0;padding:0 0 12px;margin-top:-2px;background:var(--surface);z-index:12;}
.race-editor-tabs::before{content:"";position:absolute;inset:-22px -24px 100% -24px;background:var(--surface);pointer-events:none;}
.race-subrace-back,.race-feature-back{display:flex;align-items:center;gap:12px;}
.race-subrace-back .profile-round-back,.race-feature-back .profile-round-back{flex:0 0 auto;}
.race-feature-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:12px;align-items:stretch;}
.race-trait-row{position:relative;min-width:0;}
.race-trait-row .info-card{width:100%;min-width:0;text-align:left;display:flex;flex-direction:column;align-items:stretch;justify-content:center;cursor:pointer;}
.race-trait-row .info-card-copy{display:flex;flex-direction:column;gap:7px;min-width:0;}
.race-trait-row .info-card-copy small{white-space:normal;overflow-wrap:anywhere;}
.race-trait-row .bf-icon-button{flex:0 0 auto;}
.race-feature-choice-card{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding:14px;border:1px solid var(--line);border-radius:14px;}
.race-feature-choice-card>.field:first-child{grid-column:1/-1;}
.race-feature-choice-card>.bf-icon-button{justify-self:end;align-self:end;}
[data-feature-choices]{display:grid;gap:12px;}
.race-read-only .field input:disabled,.race-read-only .field textarea:disabled,.race-read-only select:disabled{opacity:1;color:var(--text);-webkit-text-fill-color:var(--text);cursor:default;}
.race-read-only .custom-select-trigger:disabled{opacity:1;cursor:default;}
@media(max-width:480px){.race-feature-choice-card{grid-template-columns:1fr;}}

/* v169.20 — shared race editor behavior and SRD passive field parity. */
.race-feature-grid{display:flex;flex-direction:column;gap:12px;}
.race-trait-row{width:100%;}
.race-trait-row .info-card-title,.race-subrace-row .info-card-title{font-family:var(--font-display);font-size:16px;font-weight:700;color:var(--ink);line-height:1.2;}
.race-feature-choice-card{display:flex;flex-direction:column;align-items:stretch;gap:12px;}
.race-feature-choice-card>.field{width:100%;}
.race-feature-choice-card>.bf-icon-button{align-self:flex-end;}
.race-editor-sticky-head{position:sticky;top:0;z-index:14;background:var(--surface);padding:0 0 12px;}
.race-editor-sticky-head .race-editor-tabs{position:static;margin:0;padding:6px 0 0;}
.race-editor-tabs::before{display:none;}
.race-editor-sticky-head .race-subrace-back{padding:8px 0 12px;}
.race-read-only .field input:not([type="checkbox"]),.race-read-only .field textarea,.race-read-only .custom-select-trigger{
 border:1px solid var(--line)!important;box-shadow:none!important;transform:none!important;background:var(--surface)!important;color:var(--ink)!important;opacity:1!important;cursor:default!important;
}
.race-read-only .custom-select-trigger .custom-select-chevron{display:none;}
.race-feature-proficiency{display:grid;gap:10px;border:1px solid var(--line);padding:12px;border-radius:var(--radius-sm);}
[data-feature-profs]{display:grid;gap:12px;}
[data-feature-profs][hidden]{display:none;}
.race-feature-proficiency .tag-field{display:flex;flex-wrap:wrap;gap:6px;align-items:center;}
.race-feature-proficiency .tag-field .text-input{flex:1 1 160px;min-width:0;}

/* v169.21: Race editor layout and readonly semantics. */
.race-editor-sticky-head{padding:0 0 10px;margin:0;background:var(--surface);isolation:isolate;}
.race-editor-sticky-head .race-editor-tabs{padding:0;margin:0;background:var(--surface);}
.race-editor-sticky-head .library-filter-list{padding-top:0;margin:0;}
.race-editor-sticky-head::before{content:"";position:absolute;left:-24px;right:-24px;bottom:100%;height:36px;background:var(--surface);pointer-events:none;}
.race-read-only .tag-input-shell{border:1px solid var(--line);box-shadow:none;transform:none;background:var(--surface);pointer-events:none;}
.race-read-only .tag{cursor:default;}
.race-read-only .stepper,.race-read-only .stepper-button{box-shadow:none!important;transform:none!important;border-color:var(--line)!important;}
.race-read-only .stepper-button{pointer-events:none;}
.race-subrace-source{margin-top:9px;display:block;}
.race-feature-inline{display:grid;gap:15px;min-width:0;padding-top:4px;}
.race-feature-inline h3{margin:0;}
.race-feature-inline .race-feature-back{position:sticky;top:0;z-index:12;background:var(--surface);padding:4px 0 10px;}
.race-feature-spells{display:grid;gap:12px;}
[data-feature-spells]{display:grid;gap:12px;}
[data-feature-spells][hidden]{display:none;}
.race-feature-spell-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(120px,.45fr) auto;gap:10px;align-items:end;border:1px solid var(--line);padding:12px;border-radius:var(--radius-sm);}
.race-feature-spell-row .field{min-width:0;}
@media(max-width:480px){.race-feature-spell-row{grid-template-columns:minmax(0,1fr) minmax(115px,.6fr)}.race-feature-spell-row>.bf-icon-button{grid-column:2;justify-self:end}}

/* Race Feature grant controls: contextual choices and stable nested navigation. */
.race-feature-inline .race-feature-back{padding:0 0 6px;margin:0;min-height:44px;}
.race-feature-inline{padding-top:0;gap:12px;}
.race-grant-choice{display:grid;gap:8px;margin-top:12px;}
.race-choice-divider{height:1px;background:var(--line);margin:4px 0 8px;}
.race-grant-choice .muted{margin:0;}
.race-grant-choice [data-grant-count-wrap]{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.race-grant-choice [hidden]{display:none!important;}
.race-feature-spell-row{grid-template-columns:minmax(0,1fr) minmax(115px,.42fr) auto;}
.race-feature-inline .race-navigation-back,.race-subrace-back .race-navigation-back{pointer-events:auto!important;opacity:1!important;cursor:pointer!important;}
.race-read-only .race-navigation-back{pointer-events:auto!important;}

/* Race editor shared-control corrections (v169.23). */
.race-read-only .race-navigation-back,.race-read-only .race-navigation-back.stepper-button{pointer-events:auto!important;box-shadow:var(--shadow-sm, 0 3px 0 var(--ink))!important;border-color:var(--ink)!important;transform:none!important;cursor:pointer!important;}
.race-read-only .race-navigation-back:active,.race-read-only .race-navigation-back.is-pressed{transform:translateY(3px)!important;box-shadow:none!important;}
.race-feature-inline{gap:8px!important;}
.race-feature-inline .race-feature-back{padding:0!important;min-height:unset!important;margin:0!important;}
.race-grant-choice{order:0;}
.race-choice-toggle-row{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.race-choice-toggle-row .muted{margin:4px 0 0;}
.race-feature-proficiency [data-prof-fixed][hidden]{display:none;}
.race-selected-skills{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px;}
.race-selected-skills .tag{display:inline-flex;align-items:center;gap:6px;}
.race-feature-proficiency .tag-input-shell{width:100%;}
.race-spell-picker{position:relative;min-width:0;}
.race-spell-suggestions{position:absolute;z-index:80;left:0;right:0;top:100%;background:var(--surface);border:2px solid var(--ink);border-radius:var(--radius-sm);box-shadow:0 4px 0 var(--ink);max-height:230px;overflow:auto;}
.race-spell-suggestions[hidden]{display:none;}
.race-spell-suggestion{display:block;padding:10px 12px;width:100%;text-align:left;border:0;background:transparent;color:var(--ink);font:inherit;cursor:pointer;}
.race-spell-suggestion:hover,.race-spell-suggestion:focus-visible{background:var(--surface-alt,#eee);}

/* v169.24: race editor uses the shared dialog, switches and dropdown geometry. */
.race-feature-inline{display:flex;flex-direction:column;gap:12px!important;padding:0!important;margin:0!important;}
.race-feature-inline>.race-feature-back{position:static!important;display:flex;align-items:center;gap:12px;min-height:0!important;margin:0 0 2px!important;padding:0!important;}
.race-feature-inline>.race-feature-back strong{line-height:1.25;}
.race-feature-inline>.race-feature-back .profile-round-back{flex-shrink:0;margin:0;}
.race-feature-spell-row{grid-template-columns:minmax(0,1fr) auto!important;align-items:center;}
.race-feature-spell-row .race-spell-picker{min-width:0;}
.race-grant-choice{gap:10px;margin:2px 0 8px!important;}
.race-grant-choice .race-choice-prof-type[hidden], .race-grant-choice [hidden]{display:none!important;}
.race-feature-proficiency[hidden],.race-feature-spell-row[hidden],.race-feature-proficiency+button[hidden], [data-add-feature-spell][hidden]{display:none!important;}
.race-feature-inline .race-choice-divider{display:none!important;}
.race-spell-suggestions{padding:4px;box-sizing:border-box;}
.race-spell-suggestion{border-radius:var(--radius-sm);min-height:40px;}

.bf-dialog-content:has(> .race-feature-inline){padding-top:10px!important;}
.race-feature-inline>.race-feature-back{margin-bottom:0!important;}
.race-spell-suggestions{border:2px solid var(--ink);box-shadow:0 4px 0 var(--ink);border-radius:var(--radius-sm);background:var(--surface);}

/* v169.26: use the existing dropdown option styling for Race spell suggestions. */
.race-spell-suggestions.select-menu{z-index:10025;min-width:0;max-width:none;box-sizing:border-box;border:2px solid var(--line);border-radius:var(--radius-sm);background:var(--surface);padding:6px;box-shadow:none;}
.race-spell-suggestions.select-menu .select-option{min-height:34px;padding:6px 8px;border-radius:5px;font:inherit;color:var(--ink);}
.race-grant-choice .race-choice-count{display:flex;flex-direction:column;align-items:flex-start;gap:8px;}
.race-choice-count .stepper{align-self:flex-start;}
.race-ability-choice-row{margin:12px 0;}
.race-ability-choice-row .muted{margin:4px 0 0;}
.race-ability-choice-settings{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px;margin:10px 0 20px;}
.race-ability-choice-settings .field{align-items:flex-start;gap:9px;}
.race-asi-grid[hidden]{display:none!important;}
.race-skill-select .field{width:100%;}

/* v169.26: Race grant choice visibility and shared green dropdown treatment. */
.race-feature-proficiency[hidden],.race-feature-spell-row[hidden],
[data-feature-prof-add][hidden],[data-add-feature-spell][hidden],
.race-choice-prof-type[hidden],.race-choice-count[hidden]{display:none!important;}
.race-spell-suggestions.select-menu .select-option:hover,
.race-spell-suggestions.select-menu .select-option:focus-visible,
.race-spell-suggestions.select-menu .select-option.is-selected{
  background:color-mix(in srgb,var(--accent) 17%,var(--surface));
  color:var(--accent-dark);outline:none;
}
.race-creator-asi-choice{display:grid;gap:10px;margin-bottom:12px;}
.race-creator-asi-choice .field{display:flex;flex-direction:column;align-items:flex-start;gap:8px;}

/* Race/Feature source info uses BF.infoButton, shared with spell details.
   Place the ability info inside the VALUE column, never near the + control. */
.creator-ability-stepper-wrap { min-width: 0; }
.creator-ability-stepper-wrap .stepper { width: 100%; }
.stepper-value-with-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}
.stepper-value-with-info .info-button { flex: 0 0 20px; }
.creator-skill-entry { position: relative; min-width: 0; }
/* The skill row itself is clickable: keep the independent info action outside
   that button, immediately to the left of the ability abbreviation. */
.creator-skill-source {
  position: absolute;
  right: 146px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}
.info-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }


/* Background Library: existing Bonfire popup, controls, and full-width Feature cards. */
/* Backgrounds use the very same Library tab controls and sticky shell as Races. */
.background-editor-tabs{position:sticky;top:0;z-index:12;background:var(--surface);margin:0;padding:0 0 10px;}
.background-editor-tabs .race-editor-tabs{position:static;margin:0;padding:0;background:var(--surface);}
.background-editor-tabs .library-filter-list{display:flex;flex-wrap:nowrap;overflow-x:auto;gap:8px;scrollbar-width:none;}
.background-editor-tabs .library-filter-list::-webkit-scrollbar{display:none;}
.background-editor-tabs .library-filter{flex:0 0 auto;}
.background-read-only .text-input,.background-read-only textarea,.background-read-only input[readonly],.background-read-only select:disabled{opacity:1!important;color:var(--ink);-webkit-text-fill-color:var(--ink);cursor:default;}
.background-read-only .field{opacity:1!important;}
.background-read-only .background-feature-head .profile-round-back{pointer-events:auto;opacity:1;cursor:pointer;}
.background-inventory{display:grid;gap:12px;}
.background-inventory h3{margin:8px 0 0;}
.background-inventory .inventory-card-grid{margin:0;}
.background-inventory .creator-add-card{min-height:105px;}
.background-inventory-details{display:grid;gap:12px;padding:12px;border:1px solid var(--line);border-radius:var(--radius-sm);}
.background-inventory .currency-row{margin-bottom:0;}
.background-editor-section{display:flex;flex-direction:column;gap:14px;padding:8px 0 14px}
.background-editor-list{display:flex;flex-direction:column;gap:12px;min-width:0}
.background-editor-card{display:flex;align-items:stretch;gap:8px;min-width:0}
.background-editor-card .info-card-title{font-family:var(--font-display);color:var(--ink);font-weight:800}
.background-editor-card .icon-button{align-self:center;flex:none}
.background-editor-grant{display:flex;flex-direction:column;gap:10px;min-width:0}
.background-editor-grant-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.background-readonly-tags{display:flex;gap:6px;flex-wrap:wrap}
.background-skill-choice{display:flex;align-items:end;gap:8px}
.background-skill-choice>.field{flex:1;min-width:0}
.background-skill-row{display:flex;flex-direction:column;gap:10px}
.background-feature-head{display:flex;align-items:center;gap:12px;margin:0 0 8px}
.background-feature-head .profile-round-back{flex:none}

.background-editor-card>.info-card{flex:1;min-width:0;width:100%;text-align:left}
.background-editor-card>.info-card .info-card-copy{display:block;white-space:normal;overflow-wrap:anywhere;margin-top:6px}


/* SRD Background: same passive field treatment as the Race and Spell readers. */
.background-read-only .field input:not([type="checkbox"]),
.background-read-only .field textarea,
.background-read-only .custom-select-trigger {
  border:1px solid var(--line)!important;
  box-shadow:none!important;
  transform:none!important;
  background:var(--surface)!important;
  color:var(--ink)!important;
  opacity:1!important;
  cursor:default!important;
}
.background-read-only .custom-select-chevron{display:none;}
.background-read-only .stepper,.background-read-only .stepper-button:not(.profile-round-back){box-shadow:none!important;transform:none!important;border-color:var(--line)!important;}
.background-read-only .stepper-button:not(.profile-round-back){pointer-events:none;}
.background-read-only .profile-round-back:active{transform:translateY(3px);box-shadow:none;}
.background-read-only .currency-value{border:1px solid var(--line);box-shadow:none;background:var(--surface);}

/* Background editor alignment with Race editor and Library spacing. */
.background-editor-section{gap:18px;padding:14px 0 24px;min-width:0;}
.background-editor-section>.field,.background-editor-section>.textarea-field{margin:0;}
.background-editor-list{gap:14px;}
.background-proficiencies>.muted,.background-editor-section>.muted{margin:0 0 2px;}
.background-proficiencies .race-feature-proficiency{gap:14px;padding:14px;}
.background-proficiencies .race-choice-toggle-row{min-width:0;}
.background-proficiencies .background-skill-choice{align-items:flex-end;}
.background-proficiencies .background-skill-choice .field{flex:1;}
.background-inline-add{width:100%;min-height:86px;}
.background-inventory{gap:16px;}
.background-inventory h3{margin:12px 0 0;}
.background-inventory .background-choice-help{margin:0;}
.background-equipment-choice{display:flex;gap:10px;align-items:flex-end;min-width:0;}
.background-equipment-choice>.field{flex:1;min-width:0;margin:0;}
.background-equipment-choice>.icon-button,.background-equipment-choice>.bf-icon-button{flex:none;}
.background-feature-head{margin-bottom:16px;}
.background-editor-section .race-feature-grid{width:100%;}
/* Remove the browser's number steppers; Bonfire uses its own controls. */
.currency-row input[type="number"]{-moz-appearance:textfield;appearance:textfield;}
.currency-row input[type="number"]::-webkit-inner-spin-button,
.currency-row input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}

/* Background feature detail shares Race feature form spacing in edit and SRD read-only. */
.background-feature-inline{display:flex;flex-direction:column;gap:12px!important;padding:0!important;margin:0!important;min-width:0;}
.background-feature-inline>.background-feature-head{margin:0 0 2px!important;display:flex;align-items:center;gap:12px;}
.background-feature-inline>.field,.background-feature-inline>.textarea-field{margin:0!important;min-width:0;}
.background-feature-inline>.check-row{margin:0!important;min-width:0;}
.background-feature-inline>.race-feature-proficiency{margin:0;min-width:0;}
.background-feature-inline .tag-field,.background-feature-inline .field{min-width:0;}
.background-starting-item-card{cursor:default!important;pointer-events:none;transform:none!important;box-shadow:none!important;}
.background-starting-item-card:hover,.background-starting-item-card:active{transform:none!important;box-shadow:none!important;}

/* Class Library: same contained horizontal tab scrolling as the character sheet.
   A min-width:0 chain prevents long labels from stretching the popup's grid. */
[data-class-content],
.class-editor-sticky-head,
.class-editor-tabs { width:100%; min-width:0; max-width:100%; box-sizing:border-box; }
.class-editor-tab-list {
  display:flex; flex-wrap:nowrap; width:100%; min-width:0; max-width:100%;
  overflow-x:auto; overflow-y:hidden; scrollbar-width:none;
  overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch;
  scroll-behavior:auto; padding-bottom:5px;
}
.class-editor-tab-list::-webkit-scrollbar { display:none; }
.class-editor-tab-list > .library-filter { flex:0 0 auto; white-space:nowrap; }

/* Class spellcasting: same field and section rhythm as Race/Background editors. */
.class-spellcasting-editor .class-spell-section{display:flex;flex-direction:column;gap:12px;min-width:0;}
.class-spellcasting-editor .class-spell-section h3,
.class-spellcasting-editor .class-spell-section p{margin:0;}
.class-spellcasting-editor .class-spell-counter{display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;margin:0;}
.class-spellcasting-editor .class-spell-counter>.stepper{flex-shrink:0;}
.class-spellcasting-editor .class-spell-section>.field{margin:0;}

/* v27: contained class tab navigation, matching Character Sheet's centered active tab.
   Persistent controls make both ends reachable with mouse, keyboard and touch. */
.class-editor-sticky-head .class-editor-tab-controls{display:flex;align-items:center;gap:6px;width:100%;min-width:0;max-width:100%;}
.class-editor-tab-controls>.class-editor-tabs{flex:1 1 0;min-width:0;width:0;max-width:100%;overflow:hidden;}
.class-editor-tab-controls .class-editor-tab-list{width:100%;min-width:0;max-width:100%;overflow-x:auto;overflow-y:hidden;touch-action:pan-x;scrollbar-width:none;}
.class-editor-tab-controls .class-editor-tab-list::-webkit-scrollbar{display:none;}
.class-tab-scroll-button{display:flex;align-items:center;justify-content:center;flex:0 0 30px;width:30px;height:38px;padding:0;border:0;background:transparent;color:var(--ink);cursor:pointer;}
.class-tab-scroll-button:disabled{opacity:.25;cursor:default;}
.class-tab-scroll-button:focus-visible{outline:2px solid var(--accent);outline-offset:1px;border-radius:6px;}

/* Class library: passive SRD progression counters and required-field feedback. */
.class-spellcasting-editor .class-spell-readonly-count{display:inline-flex;align-items:center;justify-content:center;min-width:2.5rem;padding:0.3rem 0.55rem;border-radius:6px;background:var(--surface-subtle,#f3f3f1);font-variant-numeric:tabular-nums;font-weight:600;cursor:default;user-select:text;}
.class-editor-section .class-field-error,.race-feature-inline .class-field-error{display:block;color:#a14d41;font-size:0.75rem;margin-top:4px;}
/* The class level is a read-only view navigator, not a rule editor field. */
.background-read-only .custom-select:has([data-class-spell-level]) .custom-select-trigger{cursor:pointer!important;}
.background-read-only .custom-select:has([data-class-spell-level]) .custom-select-chevron{display:inline-flex;}

/* Feature resources — shared editor and Character Sheet counters. */
.feature-resource-editor { margin-top: 20px; }
.feature-resource-editor .feature-resource-item { display: grid; gap: 12px; }
.feature-resource-header { display:flex;align-items:center;justify-content:space-between;gap:12px; }
.feature-resource-item .field { margin-bottom:0; }

/* v34 — Shared Class Library import layout and inline validation. */
.creator-identity-details {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:12px;width:100%;}
.creator-overview-identity-fields {min-width:0;}
.creator-race-section {display:grid;gap:14px;padding-top:4px;}
.creator-class-import-heading {display:grid;grid-template-columns:minmax(90px,0.38fr) minmax(0,1fr);gap:12px;align-items:start;}
.creator-class-import-heading .field,.creator-import-choice-grid .field,.creator-import-equipment-grid .field {min-width:0;}
.creator-import-group {display:grid;gap:12px;margin-bottom:20px;}
.creator-import-group h3 {margin:0;}
.creator-import-group .field-helper {margin:0;color:var(--muted);}
.creator-import-choice-grid,.creator-import-equipment-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;}
.creator-import-equipment-choice {min-width:0;display:grid;gap:12px;align-content:start;}
.creator-import-custom-item[hidden] {display:none;}
.creator-import-error {display:block;color:#a14d41;font-size:0.75rem;margin-top:5px;}
@media(max-width:650px){.creator-import-choice-grid,.creator-import-equipment-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}
@media(max-width:390px){.creator-class-import-heading{grid-template-columns:minmax(72px,0.4fr) minmax(0,1fr);gap:8px;}}

.creator-overview-identity-fields {display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr);gap:12px;align-items:start;}
.creator-identity-details {grid-template-columns:repeat(2,minmax(0,1fr));}
.creator-import-grant-grid {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;}
.creator-import-grant {display:grid;gap:6px;border:1px solid var(--line);border-radius:10px;padding:12px;min-width:0;}
.creator-import-grant strong {font-size:.86rem;}
.creator-import-grant span {font-size:.83rem;overflow-wrap:anywhere;color:var(--muted);}
@media(max-width:650px){.creator-overview-identity-fields{grid-template-columns:minmax(0,1fr);}.creator-import-grant-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}

/* v35 — consistent character-creation step introductions and Race fields. */
.creator-step-intro { display:grid;gap:8px;margin-bottom:22px; }
.creator-step-intro h2 { margin:0;font-size:1.3rem;line-height:1.3; }
.creator-step-intro p { margin:0;color:var(--muted);line-height:1.5; }
.creator-step-divider { border-bottom:1px solid var(--line);margin-top:8px; }
.creator-race-fields {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;}
.creator-race-fields .field {min-width:0;}
@media(max-width:420px){.creator-race-fields {gap:8px;}}

/* Shared full-width creator tabs; import attention is used by Character Creation. */
.creator-page .creator-tabs { gap: clamp(3px, .65vw, 10px); }
.creator-page .creator-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 0;
  gap: 4px;
  min-width: 0;
  min-height: 40px;
  font-size: clamp(.64rem, 1.35vw, .9rem);
  font-weight: 400;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  pointer-events: auto;
}
.creator-page .creator-tab.is-active { font-weight: 900; }
.creator-page .creator-tab .creator-import-alert { margin-left: auto; flex: 0 0 auto; }
.creator-page .creator-tab.has-import-attention {
  color: #a87900;
  border-bottom-color: #d5a319;
}
.creator-import-alert {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 3px;
  border-radius: 50%;
  background: #efc448;
  color: #3d3000;
  font-size: 11px;
  font-weight: 900;
  vertical-align: text-top;
}
.creator-import-pending {
  outline: 2px solid #e8bf4f;
  outline-offset: 4px;
  border-radius: 7px;
  background: rgba(232, 191, 79, .09);
}
@media (max-width: 520px) {
  .creator-page .creator-tab {
    font-size: .63rem;
    padding-inline: 0;
  }
  .creator-import-alert { width: 12px; height: 12px; font-size: 9px; margin-left: 1px; }
}

/* Library-derived spell limits are informational, not editable counters. */

/* Feature resources: an attached sub-section; never restyle the shared info-card. */
.sheet-feature-with-resources { min-width: 0; }
.sheet-feature-with-resources .sheet-feature-resource-list {
  display: grid;
  gap: 10px;
  margin: -7px 0 0;
  padding: 18px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface);
}
.sheet-feature-with-resources > .info-card { position: relative; z-index: 1; }
.sheet-feature-resource-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.sheet-feature-resource-description { display: grid; gap: 3px; }
.sheet-feature-resource-description small { color: var(--muted); }
.sheet-feature-resource-actions { display: flex; align-items: center; }
.sheet-feature-resource-actions .stepper { margin: 0; }
.creator-feature-with-resources .info-card { width: 100%; }

/* v42: four equal columns on mobile, in both creation screens. */
@media (max-width: 600px) {
  .creator-page .creator-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 6px;
    width: 100%;
    overflow: visible;
  }
  .creator-page .creator-tabs > .creator-tab {
    width: 100%;
    min-width: 0;
    min-height: 42px;
    padding: 7px 2px 6px;
    font-size: .74rem;
    text-align: left;
    white-space: normal;
    overflow-wrap: normal;
  }
}
/* Show a single centered entry point until the section has been populated. */
.creator-section-action { display: flex; justify-content: center; margin: 14px 0 18px; }
.creator-section-action > .btn { min-width: min(100%, 200px); }
.creator-multiclass-heading { margin-top: 20px; }

/* v43: keep selected-section actions beneath their content. */
.creator-section-action > .btn-tertiary { margin-inline: auto; }
/* Inline Multiclass fields use the same unboxed spacing as other creation sections. */
.creator-manual-multiclass {
  display: grid;
  gap: 14px;
  margin-block: 14px 20px;
  min-width: 0;
}
.creator-manual-multiclass-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.creator-manual-multiclass-heading > strong { min-width: 0; overflow-wrap: anywhere; }
.creator-manual-multiclass .class-grid,
.creator-manual-multiclass .class-grid .field { min-width: 0; }
@media (max-width: 400px) {
  .creator-manual-multiclass .class-grid { grid-template-columns: 60px minmax(0, 1fr) 82px; gap: 8px; }
}


/* v55: the existing portrait upload action belongs within the circular photo. */
.creator-overview-avatar .bf-avatar-upload-icon {
  top: 50%; left: 50%; right: auto; bottom: auto;
  transform: translate(-50%, -50%);
}
.creator-overview-avatar.has-image .bf-avatar-upload-icon { opacity: 0; }
.creator-overview-avatar.has-image:hover .bf-avatar-upload-icon,
.creator-overview-avatar.has-image:focus-visible .bf-avatar-upload-icon { opacity: 1; }
/* Shared stat-card divider. */
.stat-card .ability-score-divider { display:inline-block; width:1px; height:1em; margin:0 8px; vertical-align:-.12em; background:var(--muted); opacity:.28; }


/* Ability/source information sits beside the saving throw name, never in the proficiency icon space. */
.creator-saving-throw-wrap { min-width: 0; }
.creator-saving-throw-line { display: flex; align-items: center; gap: 5px; min-height: 42px; padding: 5px 9px; }
.creator-saving-throw-name, .creator-saving-throw-toggle { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.creator-saving-throw-name { min-width: 0; text-align: left; padding: 4px 0; }
.creator-saving-throw-toggle { margin-left: auto; display: flex; align-items: center; gap: 12px; padding: 5px 0 5px 7px; }
.creator-saving-throw-toggle strong { font-weight: 600; }
.creator-saving-throw-line .creator-saving-throw-source { position: static; transform: none; flex: none; }
.creator-saving-throw-toggle .proficiency-circle { width: 14px; height: 14px; border: 2px solid var(--ink); border-radius: 50%; background: transparent; }
.creator-saving-throw-toggle .proficiency-circle.is-filled { border-color: var(--accent); background: var(--accent); }
/* Read-only creation resources retain the same attached row and stepper shape as sheet. */
.creator-feature-with-resources { min-width: 0; }
.creator-feature-with-resources .stepper-button { cursor: default; }
/* Shared compact currency editor and attached pounds suffix. */
.currency-editor-entry { display:flex; align-items:end; gap:10px; margin:0 0 12px; }
.currency-editor-entry > .field { flex:1; min-width:0; margin-bottom:0; }
.currency-editor-entry > button { flex:0 0 auto; margin-bottom:4px; }
.currency-add-action { display:flex; justify-content:center; margin-top:4px; }
.currency-empty { text-align:center; padding:8px 0 0; }
.creator-currency-actions, .page-edit-inventory > .inventory-add-row { margin-top:0; }
/* A single bordered input group; reset the shared .field input focus/border treatment. */
.item-weight-field { min-width:0; }
.item-weight-field .item-weight-input {
  display:flex; align-items:center; gap:3px; width:100%; min-height:43px;
  padding:0 10px; border:3px solid var(--ink); border-radius:var(--radius-sm);
  background:var(--surface); box-shadow:var(--control-shadow); box-sizing:border-box;
}
.item-weight-field .item-weight-input:focus-within { border-color:var(--accent); }
.item-weight-field .item-weight-input input,
.item-weight-field .item-weight-input input:focus {
  display:block; flex:0 0 auto; width:3ch; min-width:0; max-width:calc(100% - 25px);
  min-height:34px; height:34px; margin:0; padding:0;
  border:0 !important; outline:0 !important; box-shadow:none !important;
  background:transparent; border-radius:0; transform:none !important;
  color:var(--ink); font:inherit; line-height:34px;
}
.item-weight-unit { flex:0 0 auto; font-size:.85rem; color:var(--muted); pointer-events:none; }
.item-weight-input input::-webkit-inner-spin-button,
.item-weight-input input::-webkit-outer-spin-button { -webkit-appearance:none; margin:0; }
.item-weight-input input[type="number"] { appearance:textfield; -moz-appearance:textfield; }
/* Spell school/components stay on the same line as the name on both screens. */
.spell-row-identity { min-width:0; display:flex; flex-direction:row; align-items:baseline; flex-wrap:wrap; gap:3px 9px; overflow-wrap:anywhere; }
.spell-row-name { font-weight:inherit; }
.spell-row-details { display:inline-flex; flex-wrap:wrap; gap:4px 8px; font-size:.86rem; line-height:1.3; color:var(--muted); font-weight:400; }
/* Sheet skills use a single list, with column-aligned, view-only filters. */
.skill-filter-header {
  display:grid; grid-template-columns:minmax(0,1.7fr) 42px 42px 34px;
  gap:8px; align-items:end; padding:0 8px 10px;
  border-bottom:1px solid var(--line); margin-bottom:8px;
}
.skill-filter-header button {
  min-width:0; border:0; background:transparent; color:var(--ink);
  padding:5px 0; font:600 .84rem var(--font-body,inherit); cursor:pointer;
  display:flex; gap:2px; align-items:center; justify-content:flex-start;
}
.skill-filter-header button:nth-child(2) { justify-content:center; }
.skill-filter-header button:last-child { justify-content:flex-end; white-space:nowrap; }
.skill-filter-header button:nth-child(2)[aria-pressed="true"] { text-decoration:underline; text-underline-offset:4px; }
.skill-filter-header button.skill-proficiency-filter { align-items:center; justify-content:flex-end; }
.skill-proficiency-filter .skill-proficiency-indicator { transform:scale(.74); transform-origin:right center; }
.skill-proficiency-filter .skill-proficiency-indicator.level-0 .skill-prof-dot { background:transparent; }
.skill-filter-header svg { width:10px; height:10px; flex:none; }
.skill-filter-header button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.skill-filter-empty { padding:16px 8px; }
@media (max-width:390px) {
  .skill-filter-header { grid-template-columns:minmax(0,1fr) 38px 38px 31px; gap:6px; padding-inline:6px; }
  .skill-filter-header button { font-size:.76rem; }
}

/* v57: currency action belongs directly to the row, without the old gap. */
.inventory-creator .currency-row.is-editable,
.page-edit-inventory .currency-row.is-editable { margin-bottom:8px; }

/* Align all four spell-row columns in Creation and the Sheet, including Cantrips. */
.creator-spell-row { grid-template-columns:auto minmax(0,1fr) auto auto; }
.spell-prepared-spacer { display:block; width:20px; height:20px; }
.known-spell-list .data-row > .spell-row-identity,
.creator-spell-row > .spell-row-identity { overflow-wrap:anywhere; }

/* Current HP uses familiar health thresholds; Temp HP uses the sheet's appearance accent. */
.sheet-page[data-hp-status="healthy"] { --hp-status-color:#248553; }
.sheet-page[data-hp-status="wounded"] { --hp-status-color:#b88732; }
.sheet-page[data-hp-status="critical"] { --hp-status-color:#c65353; }
.sheet-page .hp-number-strip > strong:not(.is-max):not(.is-temp),
.sheet-page .qe-hp-values > span:not(.qe-hp-max):not(.qe-divider):not(.qe-temp-hp-value) { color:var(--hp-status-color); }
.sheet-page .hp-number-strip > .is-temp,
.sheet-page .qe-hp-values > .qe-temp-hp-value { color:var(--temp-hp-color,#345B49); }

/* Shop is a signed-in destination with no commerce until packs launch. */
.bottom-nav { grid-template-columns:repeat(4,minmax(0,1fr)); }
.shop-coming-soon { max-width:600px; padding:40px 22px; margin:0 auto; }
.shop-coming-soon h1 { margin:8px 0 18px; }
.shop-coming-soon p:not(.eyebrow) { color:var(--muted); line-height:1.6; }


/* v60: directional controls stay inside the existing draggable triangle.
   The original decorative two-stroke mark is superseded by actual chevrons. */
.sheet-pull-handle.sheet-mode-handle {
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:flex-start;
  gap:0;
  cursor:ns-resize;
  touch-action:none;
}
.sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow {
  position:relative;
  z-index:1;
  display:grid;
  place-items:center;
  flex:0 0 13px;
  width:34px;
  height:13px;
  min-height:0;
  margin:0;
  padding:0;
  border:0;
  border-radius:2px;
  background:transparent;
  color:var(--accent);
  line-height:1;
  cursor:pointer;
  touch-action:none;
}
.sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow .bf-icon,
.sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow svg {
  width:17px;
  height:17px;
  stroke-width:2.8;
  pointer-events:none;
}
.sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:0;
}

@container sheet-space (min-width:900px) {
  .sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow { flex-basis:15px;height:15px; }
}

/* Keep both arrows inside the triangular canvas, including single-arrow modes. */
.sheet-pull-handle.sheet-mode-handle:has(.sheet-mode-arrow:only-child) .sheet-mode-arrow {
  margin-top:4px;
}
/* Header buttons normally use touch-action:manipulation; directional arrows must allow drag. */
.sheet-header .sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow {touch-action:none;}

/* Keep both chevrons INSIDE the narrow mobile triangle. The triangle itself
   is 22px tall; two 17px icons cannot fit even when their buttons are 13px. */

@container sheet-space (max-width:899px) {
  .sheet-pull-handle.sheet-mode-handle {
    justify-content: flex-start;
    padding-top: 1px;
    box-sizing: border-box;
    gap: 0;
  }
  .sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow {
    flex: 0 0 10px;
    width: 30px;
    height: 10px;
    margin: 0;
  }
  .sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow .bf-icon,
  .sheet-pull-handle.sheet-mode-handle .sheet-mode-arrow svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.8;
  }
  .sheet-pull-handle.sheet-mode-handle:has(.sheet-mode-arrow:only-child) .sheet-mode-arrow {
    margin-top: 4px;
  }
}


/* v64 — Independent Color and Effects controls. */
.bf-customize-page .bf-appearance-subheading {
  margin: 15px 0 9px;
  color: var(--ink);
  font: 800 .87rem/1.3 var(--font-display);
}
.bf-customize-page .bf-effects-subheading { margin-top: 18px; }
.bf-effect-options { display: flex; flex-wrap: wrap; gap: 9px; }
.bf-effect-choice { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.bf-effect-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bf-effect-choice span {
  display: inline-flex; align-items: center; min-height: 38px; padding: 7px 13px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
  color: var(--ink); font: 800 .86rem/1.2 var(--font-display);
}
.bf-effect-choice input:checked + span { border-color: var(--accent); box-shadow: 0 2px 0 var(--accent); }
.bf-effect-choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.bf-customize-page .bf-effects-coming { margin-bottom: 0; }
/* Subtle, always-visible points of starlight around the character sheet.
   Decorative only; no scripts, no hit targets, and no cross-shaped rays. */
.bf-canvas-stars { display: none; position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
@media (min-width: 700px) {
  body[data-bf-canvas-effect="stars"]:has(.app > .sheet-page) .bf-canvas-stars,
  body[data-bf-canvas-effect="stars"].bf-customize-open .bf-canvas-stars { display: block; }
  /* The starfield is a pointer-transparent, earlier body sibling. Never assign
     a stacking context to .app-shell: the Quick Edit dimmer lives outside it,
     while the Quick Edit header needs to stay above that dimmer. */
  .bf-canvas-stars i {
    position: absolute; display: block; border-radius: 50%;
    background: #fff7db; opacity: .64;
    box-shadow: 0 0 3px 1px rgba(255, 247, 219, .16);
    animation: bf-star-twinkle 9s ease-in-out infinite;
  }
  .bf-canvas-stars i:nth-child(1) { left: 18.8%; top: 59.9%; width: 3px; height: 3px; animation-delay: -0.2s; animation-duration: 11.9s; }
  .bf-canvas-stars i:nth-child(2) { left: 48.8%; top: 56.5%; width: 2px; height: 2px; animation-delay: -3.8s; animation-duration: 11.6s; }
  .bf-canvas-stars i:nth-child(3) { left: 92.2%; top: 72.6%; width: 3px; height: 3px; animation-delay: -10.3s; animation-duration: 7.9s; }
  .bf-canvas-stars i:nth-child(4) { left: 71.5%; top: 13.9%; width: 2px; height: 2px; animation-delay: -3.5s; animation-duration: 10.8s; }
  .bf-canvas-stars i:nth-child(5) { left: 48.5%; top: 51.1%; width: 2px; height: 2px; animation-delay: -5.9s; animation-duration: 8.4s; }
  .bf-canvas-stars i:nth-child(6) { left: 52.1%; top: 24.7%; width: 3px; height: 3px; animation-delay: -6.1s; animation-duration: 10.0s; }
  .bf-canvas-stars i:nth-child(7) { left: 95.1%; top: 27.5%; width: 3px; height: 3px; animation-delay: -3.5s; animation-duration: 12.1s; }
  .bf-canvas-stars i:nth-child(8) { left: 64.8%; top: 17.5%; width: 4px; height: 4px; animation-delay: -8.2s; animation-duration: 8.6s; }
  .bf-canvas-stars i:nth-child(9) { left: 3.9%; top: 57.7%; width: 2px; height: 2px; animation-delay: -9.9s; animation-duration: 7.3s; }
  .bf-canvas-stars i:nth-child(10) { left: 63.8%; top: 78.1%; width: 3px; height: 3px; animation-delay: -11.6s; animation-duration: 8.7s; }
  .bf-canvas-stars i:nth-child(11) { left: 92.4%; top: 66.7%; width: 3px; height: 3px; animation-delay: -12.9s; animation-duration: 12.7s; }
  .bf-canvas-stars i:nth-child(12) { left: 33.8%; top: 43.0%; width: 2px; height: 2px; animation-delay: -7.8s; animation-duration: 9.9s; }
  .bf-canvas-stars i:nth-child(13) { left: 44.5%; top: 35.9%; width: 3px; height: 3px; animation-delay: -0.3s; animation-duration: 12.1s; }
  .bf-canvas-stars i:nth-child(14) { left: 32.1%; top: 35.7%; width: 2px; height: 2px; animation-delay: -7.9s; animation-duration: 10.0s; }
  .bf-canvas-stars i:nth-child(15) { left: 20.8%; top: 69.3%; width: 4px; height: 4px; animation-delay: -0.1s; animation-duration: 12.6s; }
  .bf-canvas-stars i:nth-child(16) { left: 20.7%; top: 96.6%; width: 2px; height: 2px; animation-delay: -0.9s; animation-duration: 7.8s; }
  .bf-canvas-stars i:nth-child(17) { left: 8.6%; top: 32.6%; width: 2px; height: 2px; animation-delay: -11.2s; animation-duration: 12.5s; }
  .bf-canvas-stars i:nth-child(18) { left: 65.3%; top: 13.5%; width: 2px; height: 2px; animation-delay: -2.4s; animation-duration: 10.8s; }
  .bf-canvas-stars i:nth-child(19) { left: 96.3%; top: 46.0%; width: 4px; height: 4px; animation-delay: -2.2s; animation-duration: 11.4s; }
  .bf-canvas-stars i:nth-child(20) { left: 15.2%; top: 48.1%; width: 3px; height: 3px; animation-delay: -4.1s; animation-duration: 11.9s; }
  .bf-canvas-stars i:nth-child(21) { left: 41.1%; top: 89.2%; width: 3px; height: 3px; animation-delay: -3.0s; animation-duration: 7.1s; }
  .bf-canvas-stars i:nth-child(22) { left: 44.9%; top: 76.1%; width: 2px; height: 2px; animation-delay: -5.8s; animation-duration: 8.7s; }
  .bf-canvas-stars i:nth-child(23) { left: 77.0%; top: 76.1%; width: 4px; height: 4px; animation-delay: -3.5s; animation-duration: 9.1s; }
  .bf-canvas-stars i:nth-child(24) { left: 68.1%; top: 94.3%; width: 3px; height: 3px; animation-delay: -3.4s; animation-duration: 7.2s; }
  .bf-canvas-stars i:nth-child(25) { left: 28.2%; top: 5.1%; width: 4px; height: 4px; animation-delay: -9.1s; animation-duration: 7.2s; }
  .bf-canvas-stars i:nth-child(26) { left: 51.2%; top: 31.2%; width: 3px; height: 3px; animation-delay: -0.7s; animation-duration: 8.5s; }
  .bf-canvas-stars i:nth-child(27) { left: 78.3%; top: 60.6%; width: 3px; height: 3px; animation-delay: -11.2s; animation-duration: 7.6s; }
  .bf-canvas-stars i:nth-child(28) { left: 74.8%; top: 55.3%; width: 3px; height: 3px; animation-delay: -2.5s; animation-duration: 8.7s; }
  .bf-canvas-stars i:nth-child(29) { left: 94.5%; top: 25.0%; width: 3px; height: 3px; animation-delay: -11.6s; animation-duration: 11.8s; }
  .bf-canvas-stars i:nth-child(30) { left: 57.3%; top: 58.0%; width: 3px; height: 3px; animation-delay: -4.4s; animation-duration: 9.3s; }
  .bf-canvas-stars i:nth-child(31) { left: 16.3%; top: 81.4%; width: 2px; height: 2px; animation-delay: -4.7s; animation-duration: 10.8s; }
  .bf-canvas-stars i:nth-child(32) { left: 16.1%; top: 65.5%; width: 3px; height: 3px; animation-delay: -10.2s; animation-duration: 9.3s; }
  .bf-canvas-stars i:nth-child(33) { left: 37.8%; top: 48.9%; width: 4px; height: 4px; animation-delay: -0.4s; animation-duration: 12.1s; }
  .bf-canvas-stars i:nth-child(34) { left: 17.1%; top: 44.0%; width: 2px; height: 2px; animation-delay: -5.4s; animation-duration: 8.0s; }
  .bf-canvas-stars i:nth-child(35) { left: 9.6%; top: 56.7%; width: 3px; height: 3px; animation-delay: -4.2s; animation-duration: 9.1s; }
  .bf-canvas-stars i:nth-child(36) { left: 89.5%; top: 27.3%; width: 2px; height: 2px; animation-delay: -10.3s; animation-duration: 7.9s; }
  .bf-canvas-stars i:nth-child(37) { left: 98.2%; top: 42.9%; width: 2px; height: 2px; animation-delay: -6.3s; animation-duration: 11.3s; }
  .bf-canvas-stars i:nth-child(38) { left: 87.4%; top: 72.7%; width: 3px; height: 3px; animation-delay: -3.4s; animation-duration: 7.9s; }
  .bf-canvas-stars i:nth-child(39) { left: 2.9%; top: 85.2%; width: 2px; height: 2px; animation-delay: -2.9s; animation-duration: 10.6s; }
  .bf-canvas-stars i:nth-child(40) { left: 48.8%; top: 37.3%; width: 4px; height: 4px; animation-delay: -3.6s; animation-duration: 8.9s; }
  .bf-canvas-stars i:nth-child(41) { left: 49.2%; top: 59.7%; width: 2px; height: 2px; animation-delay: -1.3s; animation-duration: 9.7s; }
  .bf-canvas-stars i:nth-child(42) { left: 53.5%; top: 82.9%; width: 4px; height: 4px; animation-delay: -2.3s; animation-duration: 7.3s; }
  .bf-canvas-stars i:nth-child(43) { left: 38.7%; top: 59.1%; width: 3px; height: 3px; animation-delay: -8.8s; animation-duration: 9.0s; }
  .bf-canvas-stars i:nth-child(44) { left: 85.0%; top: 75.2%; width: 2px; height: 2px; animation-delay: -4.6s; animation-duration: 8.8s; }
  .bf-canvas-stars i:nth-child(45) { left: 59.3%; top: 10.3%; width: 3px; height: 3px; animation-delay: -5.9s; animation-duration: 12.0s; }
  .bf-canvas-stars i:nth-child(46) { left: 45.6%; top: 73.1%; width: 2px; height: 2px; animation-delay: -4.9s; animation-duration: 8.8s; }
  .bf-canvas-stars i:nth-child(47) { left: 14.4%; top: 77.5%; width: 2px; height: 2px; animation-delay: -3.4s; animation-duration: 10.8s; }
  .bf-canvas-stars i:nth-child(48) { left: 27.6%; top: 33.3%; width: 2px; height: 2px; animation-delay: -2.5s; animation-duration: 10.9s; }
  .bf-canvas-stars i:nth-child(49) { left: 47.7%; top: 67.7%; width: 2px; height: 2px; animation-delay: -11.3s; animation-duration: 11.9s; }
  .bf-canvas-stars i:nth-child(50) { left: 69.8%; top: 78.6%; width: 2px; height: 2px; animation-delay: -11.5s; animation-duration: 7.4s; }
  .bf-canvas-stars i:nth-child(51) { left: 80.0%; top: 65.7%; width: 3px; height: 3px; animation-delay: -12.3s; animation-duration: 6.9s; }
  .bf-canvas-stars i:nth-child(52) { left: 81.8%; top: 80.1%; width: 3px; height: 3px; animation-delay: -1.7s; animation-duration: 8.3s; }
  .bf-canvas-stars i:nth-child(53) { left: 20.0%; top: 80.0%; width: 3px; height: 3px; animation-delay: -5.1s; animation-duration: 7.8s; }
  .bf-canvas-stars i:nth-child(54) { left: 37.7%; top: 83.8%; width: 2px; height: 2px; animation-delay: -7.9s; animation-duration: 12.2s; }
  .bf-canvas-stars i:nth-child(55) { left: 80.6%; top: 74.2%; width: 3px; height: 3px; animation-delay: -10.4s; animation-duration: 11.3s; }
  .bf-canvas-stars i:nth-child(56) { left: 97.6%; top: 39.6%; width: 2px; height: 2px; animation-delay: -11.9s; animation-duration: 11.5s; }
  .bf-canvas-stars i:nth-child(57) { left: 5.4%; top: 3.9%; width: 2px; height: 2px; animation-delay: -12.7s; animation-duration: 10.9s; }
  .bf-canvas-stars i:nth-child(58) { left: 98.4%; top: 6.8%; width: 3px; height: 3px; animation-delay: -1.2s; animation-duration: 9.8s; }
  .bf-canvas-stars i:nth-child(59) { left: 90.3%; top: 12.8%; width: 3px; height: 3px; animation-delay: -0.6s; animation-duration: 8.1s; }
  .bf-canvas-stars i:nth-child(60) { left: 40.4%; top: 95.9%; width: 2px; height: 2px; animation-delay: -5.7s; animation-duration: 11.9s; }
  .bf-canvas-stars i:nth-child(61) { left: 68.8%; top: 29.5%; width: 2px; height: 2px; animation-delay: -7.3s; animation-duration: 11.1s; }
  .bf-canvas-stars i:nth-child(62) { left: 72.5%; top: 32.5%; width: 3px; height: 3px; animation-delay: -11.8s; animation-duration: 9.2s; }
  @keyframes bf-star-twinkle {
    0%, 20%, 48%, 78%, 100% { opacity: .62; transform: scale(1); }
    33% { opacity: .96; transform: scale(1.4); }
    65% { opacity: .44; transform: scale(.85); }
  }
  @media (prefers-reduced-motion: reduce) {
    .bf-canvas-stars i { animation: none; opacity: .64; }
  }
}

/* Campaign creation and GM Library sharing */
.campaign-sharing-category{display:grid;gap:5px}
.campaign-sharing-category h3{font-size:1rem;margin:0}.campaign-sharing-category-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:12px 0 5px}.campaign-sharing-select-all{display:flex;align-items:center;gap:8px;font-size:.85rem;cursor:pointer}
.campaign-sharing-category:first-child .campaign-sharing-category-head{margin-top:0}

/* Bonfire Boards: use the Campaign palette and shared Bonfire controls. */
.campaign-detail-page .campaign-panel-boards{padding:0!important;min-height:0;overflow:hidden;flex:1;display:flex;background:var(--campaign-content,#fff1e1)}
.bf-boards-root{flex:1;min-width:0;min-height:0;display:flex}
.bf-board-workspace{position:relative;flex:1;min-width:0;min-height:0;display:flex;color:var(--ink,#323732);background:var(--campaign-content,#fff1e1)}
.bf-board-sidebar{width:212px;flex:0 0 212px;background:var(--campaign-header,#ffFAF5);border-right:1px solid var(--line,#dedbd2);display:flex;flex-direction:column;overflow:hidden;transition:width .16s ease,flex-basis .16s ease}
.bf-board-sidebar.is-collapsed{width:43px;flex-basis:43px}
.bf-board-sidehead{height:54px;flex-shrink:0;display:flex;justify-content:space-between;align-items:center;gap:5px;padding:0 12px;border-bottom:1px solid var(--line,#dedbd2);white-space:nowrap}
.bf-board-sidehead strong{font-size:13px}
.bf-board-collapse{flex-shrink:0}
.bf-board-sidebar.is-collapsed .bf-board-sidehead{padding:0 4px;justify-content:center}
.bf-board-sidebar.is-collapsed .bf-board-sidehead strong,.bf-board-sidebar.is-collapsed .bf-board-list,.bf-board-sidebar.is-collapsed .bf-board-sidebar-actions{display:none}
.bf-board-list{padding:11px;display:flex;flex-direction:column;gap:9px;overflow-y:auto;flex:1}
.bf-board-card{min-width:0}
.bf-board-card-title{display:block;align-self:stretch;flex:none;width:100%;min-width:0;min-height:36px;margin:0;padding:4px 0;border:0;background:transparent;color:inherit;text-align:left;white-space:normal;cursor:pointer}
.bf-board-card-title strong{display:block;width:100%;margin:0;font-size:1rem;font-weight:700;text-align:left;overflow-wrap:anywhere}
.bf-board-size,.campaign-card-media{display:block;font-size:.72rem;font-weight:500;opacity:.65;margin-top:3px}
.bf-board-sidebar-actions{padding:10px;border-top:1px solid var(--line,#ddd)}
.bf-board-sidebar-actions .btn{width:100%}
.bf-board-main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column}
.bf-board-viewport{flex:1;min-height:0;position:relative;overflow:auto;touch-action:pan-x pan-y;background:var(--campaign-canvas,#e2e4db);overscroll-behavior:contain;scroll-behavior:auto;-webkit-user-select:none;user-select:none}
.bf-board-floating-toolbar{z-index:20;width:max-content;max-width:100%;display:flex;align-items:center;gap:2px;padding:5px 7px;background:var(--campaign-header,#ffFAF5);border:1px solid var(--line,#ccc);box-shadow:0 4px 18px #21352626;border-radius:12px}
.bf-board-floating-toolbar[hidden]{display:none!important}.bf-board-empty:not([hidden]){position:absolute;inset:0;z-index:15;display:grid;place-items:center;text-align:center;padding:24px;background:var(--campaign-canvas,#e2e4db)}.bf-board-empty>div{max-width:420px}.bf-board-empty h2{margin-bottom:8px}.bf-board-empty p{margin-bottom:18px}
.bf-board-floating-toolbar .btn{white-space:nowrap;width:40px;height:38px;min-width:40px;min-height:38px;display:grid;place-items:center;padding:0;border:0;border-radius:8px}
.bf-board-floating-toolbar .btn svg{width:19px;height:19px;margin:0;vertical-align:middle}
.bf-board-object-layer{position:absolute;inset:0;pointer-events:none}
.bf-board-map-frame,.bf-board-note{position:absolute;pointer-events:auto;box-shadow:0 5px 18px #283d2a24}
.bf-board-map-frame{min-width:350px;min-height:160px;border:1px solid #b4b9ab;border-radius:10px;background:var(--campaign-header,#ffFAF5);display:flex;flex-direction:column;overflow:visible}
.bf-board-grid-header{min-width:0;min-height:52px;flex-shrink:0;background:var(--campaign-header,#ffFAF5);border-radius:9px 9px 0 0;padding:7px 10px;display:flex;align-items:center;justify-content:space-between;gap:8px;cursor:grab;touch-action:none;user-select:none}
.bf-board-grid-header strong{flex:1;min-width:0;font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bf-board-object-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-shrink:0;min-width:0;margin-left:auto;cursor:default}
.bf-board-object-actions svg{width:15px;height:15px}
.bf-board-grid-body{position:relative;flex:1;min-height:0;overflow:visible;border-top:1px solid #b4b9ab;border-radius:0 0 9px 9px;background:color-mix(in srgb,var(--campaign-canvas,#e2e4db) 75%,var(--campaign-header,#fffaf5) 25%)}
.bf-board-grid-image-clip{position:absolute;inset:0;border-radius:0 0 9px 9px;overflow:hidden;pointer-events:none}
.bf-board-grid-image{position:absolute;inset:0;background-size:cover;background-position:center;background-repeat:no-repeat;pointer-events:none;transform-origin:center}
/* Live map-picture adjustment is a state of the existing grid, not a modal overlay. */
.bf-board-object-layer.is-image-editing>.bf-board-map-frame:not(.is-image-focus),
.bf-board-object-layer.is-image-editing>.bf-board-note,
.bf-board-object-layer.is-image-editing>.bf-board-canvas-item{opacity:.2;pointer-events:none}
.bf-board-map-frame.is-image-focus{z-index:20;box-shadow:0 8px 28px #243d3655}
.bf-board-map-frame.is-image-focus .bf-board-grid-image-clip{overflow:visible;pointer-events:none}
.bf-board-map-frame.is-image-focus .bf-board-grid-image{pointer-events:auto;cursor:grab;touch-action:none;outline:2px dashed #e85d35;outline-offset:0}
.bf-board-map-frame.is-image-focus .bf-board-grid-image:active{cursor:grabbing}
.bf-board-map-frame.is-image-focus .bf-board-token-layer,
.bf-board-map-frame.is-image-focus .bf-board-effect-layer{opacity:.23;pointer-events:none}
.bf-board-map-frame.is-image-focus .bf-board-token,
.bf-board-map-frame.is-image-focus .bf-board-effect-hit{pointer-events:none}
.bf-board-image-scale-handle{position:absolute;bottom:-7px;right:-7px;width:16px;height:16px;border:2px solid #345b49;border-radius:3px;background:#fff;pointer-events:auto;cursor:nwse-resize;z-index:3}
.bf-board-image-live-tools{position:absolute;top:52px;left:8px;right:8px;z-index:22;display:flex;flex-wrap:wrap;align-items:center;gap:7px;padding:8px;border:1px solid #345b49;border-radius:7px;background:#fffaf5f2;box-shadow:0 3px 12px #162a222a;cursor:default;touch-action:auto}
.bf-board-image-live-tools .field{display:flex;align-items:center;gap:6px;min-width:120px;max-width:145px;font-size:12px;font-weight:600}
.bf-board-image-live-tools .field > span{white-space:nowrap}
.bf-board-image-live-tools .custom-select{min-width:0;flex:1}
.bf-board-image-live-tools .custom-select-trigger{min-width:0;min-height:30px;height:30px;padding:3px 7px;font-size:12px}
.bf-board-image-live-tools .bf-board-tool-divider{height:28px;margin:0 6px}
.bf-board-image-live-tools .stepper-button{width:30px;height:30px;min-width:30px;flex:0 0 30px}
.bf-board-image-live-tools .btn{min-height:31px;padding:4px 9px;font-size:12px;white-space:nowrap}
.bf-board-image-scale-readout{min-width:44px;text-align:center;font-size:12px;font-weight:700}
.bf-board-image-edit-button:disabled{opacity:.45}

.bf-board-grid-lines{position:absolute;inset:0;border-radius:0 0 9px 9px;background-image:linear-gradient(#fff9e788 1px,transparent 1px),linear-gradient(90deg,#fff9e788 1px,transparent 1px);pointer-events:none}
.bf-board-map-placeholder{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);font-size:12px;color:#4e6652;background:#ffFAF5bf;border-radius:7px;padding:9px 13px;white-space:nowrap;pointer-events:none}
.bf-board-token-layer{position:absolute;inset:0;overflow:hidden;pointer-events:none}
.bf-board-effect-layer{position:absolute;inset:0;overflow:hidden;pointer-events:none}
.bf-board-effect{position:absolute;z-index:1;pointer-events:none}
.bf-board-effect-shape{position:absolute;transform:translate(-50%,-50%);pointer-events:none;overflow:visible}
.bf-board-effect-hit{position:absolute;left:0;top:0;transform:translate(-50%,-50%);padding:0;margin:0;border:0;background:transparent;pointer-events:auto;cursor:pointer}
.bf-board-effect-selection{position:absolute;left:0;top:0;transform:none;box-sizing:border-box;border:2px solid #e85d35;border-radius:3px;pointer-events:none}
.bf-board-effect-delete{position:absolute;left:0;right:0;margin:0 auto;top:calc(100% + 9px);width:34px;height:34px;min-width:34px;border-radius:50%;background:#fff;pointer-events:auto;display:grid;place-items:center;padding:0}
.bf-board-effect-delete svg{width:16px;height:16px}
.bf-board-viewport:not(.is-select-tool) .bf-board-effect-hit{pointer-events:none}
.bf-board-effect-preview{position:absolute;inset:0;opacity:.72;pointer-events:none}
.bf-board-ping-layer{position:absolute;inset:0;z-index:40;pointer-events:none;overflow:visible}
.bf-board-ping{position:absolute;width:74px;height:74px;transform:translate(-50%,-50%);border:3px solid var(--ping-color,#e85d35);border-radius:50%;box-sizing:border-box;animation:bf-board-ping-expand .7s ease-out forwards;pointer-events:none}
.bf-board-ping.is-echo{animation-delay:125ms}
@keyframes bf-board-ping-expand{0%{opacity:1;transform:translate(-50%,-50%) scale(.7)}40%{opacity:1;transform:translate(-50%,-50%) scale(1)}100%{opacity:0;transform:translate(-50%,-50%) scale(1)}}
@media (prefers-reduced-motion:reduce){.bf-board-ping{animation:bf-board-ping-expand .25s ease-out forwards}}
.bf-board-viewport.is-effect-tool .bf-board-grid-body{cursor:crosshair}
.bf-board-token{position:absolute;z-index:2;box-sizing:border-box;border:3px solid var(--token-rim,#345b49);border-radius:50%;display:flex;align-items:center;justify-content:center;color:white;background:#345b49;font-weight:800;font-size:12px;box-shadow:0 2px 6px #12231655;cursor:pointer;pointer-events:auto;touch-action:none;user-select:none}
.bf-board-token.can-move{cursor:grab}
.bf-board-token-face{position:absolute;inset:0;overflow:hidden;border-radius:50%;display:grid;place-items:center;pointer-events:none}
.bf-board-token-face img{width:100%;height:100%;object-fit:cover}
.bf-board-token.is-selected{z-index:5}
.bf-board-token-selection{position:absolute;inset:-7px;border:1.5px solid #e85d35;border-radius:2px;pointer-events:none;transform-origin:center center;z-index:8}
.bf-board-token-size,.bf-board-token-rotate{position:absolute;width:13px;height:13px;border:2px solid #345b49;background:white;border-radius:3px;pointer-events:auto;touch-action:none}
.bf-board-token-size{right:-7px;bottom:-7px;cursor:nwse-resize}
.bf-board-token-rotate{left:calc(50% - 9px);top:-35px;width:18px;height:18px;border-radius:50%;cursor:crosshair;display:grid;place-items:center}
.bf-board-token-rotate svg{width:12px;height:12px}
.bf-board-token-actions{position:absolute;top:calc(100% + 12px);left:50%;transform:translateX(-50%);display:flex;gap:7px;z-index:10;pointer-events:auto}
.bf-board-token-actions .stepper-button{box-sizing:border-box;width:34px!important;min-width:34px!important;max-width:34px!important;height:34px!important;min-height:34px!important;max-height:34px!important;flex:0 0 34px!important;aspect-ratio:1;border-radius:50%!important;padding:0!important;line-height:1;display:grid;place-items:center;background:#fff!important;color:#345b49!important}
.bf-board-token-actions svg{width:14px;height:14px}
.bf-board-token-condition-ring{position:absolute;top:var(--condition-position);left:var(--condition-position);width:var(--condition-diameter);height:var(--condition-diameter);pointer-events:none;overflow:visible;z-index:2;transform-origin:center;animation:bf-board-condition-orbit var(--condition-speed,24s) linear infinite}
@keyframes bf-board-condition-orbit{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.bf-board-token-condition-ring{animation:none}}
.bf-board-token-aura{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);border:2px solid;border-radius:50%;pointer-events:none;z-index:-1;box-sizing:border-box}
.bf-board-token-aura.is-square{border-radius:3px}
.bf-board-token:has(.bf-board-token-health) .bf-board-token-name{top:calc(100% + 5px)}
.bf-board-token-name{position:absolute;top:calc(100% + 5px);left:50%;transform:translateX(-50%);background:#fffaf5;padding:2px 6px;border-radius:5px;white-space:nowrap;font-size:11px;color:#345b49;box-shadow:0 1px 4px #0003;pointer-events:none;z-index:4}
.bf-board-token-health{position:absolute;left:-3px;right:-3px;top:-12px;height:7px;border:1px solid #273a2e;border-radius:10px;background:#c7d0c6;overflow:hidden;pointer-events:none;z-index:8}
.bf-board-token-health>span{display:block;height:100%;background:var(--hp-status-color,#248553);border-radius:inherit}
.bf-board-token-health[data-hp-status="healthy"]{--hp-status-color:#248553}
.bf-board-token-health[data-hp-status="wounded"]{--hp-status-color:#b88732}
.bf-board-token-health[data-hp-status="critical"]{--hp-status-color:#c65353}
.bf-board-token-death-icon{position:absolute;inset:0;display:grid;place-items:center;background:#16201abb;color:#fff;border-radius:50%;pointer-events:none;z-index:4}
.bf-board-token-death-icon svg{width:55%;height:55%}
.bf-board-condition-add{display:grid;gap:12px;margin-bottom:20px}
.bf-board-condition-add>.btn{justify-self:start}
.bf-board-condition-current{border-top:1px solid #d6ded3;padding-top:16px}
.bf-board-condition-list-heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:10px}
.bf-board-condition-item{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid #d6ded3}
.bf-board-condition-item>span:nth-child(2){flex:1}
.bf-board-condition-swatch{width:16px;height:16px;border-radius:50%;flex-shrink:0}
.bf-board-condition-item .stepper-button{box-sizing:border-box;flex:0 0 34px;width:34px;height:34px;padding:0;border-radius:50%;background:#fff;display:grid;place-items:center;color:var(--ink)}
.bf-board-condition-item .stepper-button .bf-icon{display:block;width:17px;height:17px;stroke:currentColor}
/* Existing token settings still use the compact native color field. */
.bf-board-color-field{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:13px 0;font-weight:600}
.bf-board-color-field input{width:48px;height:36px;cursor:pointer}
/* Board color palette uses the same square choice / round swatch as Customize. */
.bf-board-palette{border:0;padding:0;margin:8px 0 14px;min-width:0}
.bf-board-palette legend,.bf-board-control-label{font-weight:700;margin-bottom:9px}
.bf-board-palette-row{display:flex;flex-wrap:nowrap;gap:6px;max-width:100%;overflow-x:auto;padding:2px 2px 6px}
.bf-board-palette-choice.theme-choice{box-sizing:border-box;flex:0 0 39px;width:39px;height:39px;min-height:0;padding:5px;display:grid;place-items:center;border-radius:10px}
.bf-board-palette-choice .bf-appearance-swatch{width:25px;height:25px;flex:none}
.bf-board-palette-choice:has(input:checked),.bf-board-palette-custom.is-selected{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.bf-board-palette-choice input[type="radio"]{position:absolute;opacity:0;pointer-events:none}
.bf-board-palette-choice:has(input:focus-visible),.bf-board-palette-choice:focus-within{outline:2px solid var(--accent);outline-offset:2px}
.bf-board-palette-custom{position:relative;overflow:hidden}
.bf-board-palette-custom svg{width:20px;height:20px}
.bf-board-palette-custom input[type="color"]{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}

.bf-board-health-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.bf-board-viewport.is-pan-tool,.bf-board-viewport.is-pan-tool .bf-board-grid-header,.bf-board-viewport.is-pan-tool .bf-board-note,.bf-board-viewport.is-pan-tool .bf-board-token{cursor:grab}
.bf-board-viewport.is-pan-tool:active{cursor:grabbing}
.bf-board-movement-ruler{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:4}
.bf-board-distance-line{stroke:var(--ruler-color,#345b49);stroke-width:4;stroke-linecap:round}
.bf-board-distance-origin{fill:var(--ruler-color,#345b49)}
.bf-board-distance-label-bg{fill:#345b49}
.bf-board-distance-label{fill:#fff;font-size:11px;font-weight:700;text-anchor:middle;dominant-baseline:middle}
.bf-board-token:active,.bf-board-grid-header:active,.bf-board-note:active{cursor:grabbing}
.bf-board-note{z-index:25;touch-action:none;min-width:320px;min-height:110px;background:var(--note-color,#fff0b7);border:1px solid color-mix(in srgb,var(--note-border,#fff0b7) 70%,#345b49);border-radius:8px;display:flex;flex-direction:column;overflow:visible;color:#5c5031}
.bf-board-note-controls{min-width:0;min-height:42px;flex-shrink:0;display:flex;align-items:center;justify-content:flex-end;gap:7px;padding:5px 8px;cursor:grab;touch-action:none}.bf-board-note-controls .bf-board-visibility{margin-left:auto}
.bf-board-note-text{padding:4px 12px 12px;flex:1;min-height:32px;font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;overflow-wrap:anywhere;color:#17271d;outline:none;user-select:text;cursor:text}
.bf-board-note-text:focus-visible{box-shadow:inset 0 0 0 2px #345b49;border-radius:4px}
.bf-board-note-text:empty:before{content:attr(data-placeholder);color:#5b6257;pointer-events:none}
.bf-board-image-settings-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:end;gap:12px;margin:12px 0}.bf-board-image-fit,.bf-board-image-scale{min-width:0;display:grid;align-content:end;grid-template-rows:auto 44px;gap:6px;margin:0}.bf-board-image-scale .bf-board-control-label,.bf-board-image-fit .field>span{display:block;font-size:14px;font-weight:500;line-height:20px;margin:0}.bf-board-image-fit .field{margin:0;display:contents}.bf-board-image-settings-row .stepper,.bf-board-image-settings-row .custom-select{height:44px;min-height:44px;width:100%;max-width:none;box-sizing:border-box}.bf-board-image-settings-row .stepper{display:flex;align-items:center;justify-content:space-between;transform:translateY(5px)}.bf-board-image-settings-row .custom-select-trigger{height:44px;min-height:44px;box-sizing:border-box}
.bf-board-image-scale .stepper{width:100%;max-width:none}
.bf-board-image-position{display:grid;gap:6px;margin:14px 0}
.bf-board-image-position-preview{position:relative;overflow:hidden;width:100%;height:155px;border:2px solid #a7b6a5;border-radius:8px;background:#d6dbcc;touch-action:none;cursor:grab}
.bf-board-image-position-preview:active{cursor:grabbing}
.bf-board-image-position-preview [data-image-position-art]{position:absolute;inset:0;background-size:cover;background-repeat:no-repeat;pointer-events:none}
.bf-board-image-preview-grid{position:absolute;inset:0;background-image:linear-gradient(#fff8 1px,transparent 1px),linear-gradient(90deg,#fff8 1px,transparent 1px);background-size:32px 32px;pointer-events:none}
@keyframes bf-board-swatch-in{from{opacity:0;transform:translateY(5px) scale(.8)}to{opacity:1;transform:translateY(0) scale(1)}}
.bf-board-quick-colors{position:fixed;z-index:10040;display:flex;align-items:center;gap:4px;padding:6px;border:1px solid var(--line,#d5d7cf);border-radius:10px;background:var(--campaign-header,var(--surface,#fffaf5));box-shadow:0 6px 22px #172a2433;width:max-content;max-width:calc(100vw - 16px)}.bf-board-quick-swatch{display:grid;place-items:center;flex:0 0 27px;width:27px;height:27px;padding:3px;border:1px solid #89958b;border-radius:6px;background:#fff;cursor:pointer;opacity:0;transform:translateY(5px) scale(.8);animation:bf-board-swatch-in 180ms ease-out both;animation-delay:calc(var(--swatch-order,0) * 55ms)}.bf-board-quick-swatch:after{content:"";width:100%;height:100%;border-radius:50%;background:var(--swatch)}.bf-board-quick-swatch:hover,.bf-board-quick-swatch:focus-visible,.bf-board-quick-swatch[aria-pressed="true"]{outline:2px solid var(--ink,#345b49);outline-offset:1px}
@media (prefers-reduced-motion: reduce){.bf-board-quick-swatch{animation:none;opacity:1;transform:none}}
.bf-board-canvas-item{position:absolute;box-sizing:border-box;pointer-events:auto;z-index:2;touch-action:none}.bf-board-canvas-item-body,.bf-board-canvas-item-body img{display:block;width:100%;height:100%;object-fit:contain}
.bf-board-canvas-shape{width:100%;height:100%;box-sizing:border-box;border:2px solid var(--shape-color,#E85D35);background:color-mix(in srgb,var(--shape-color,#E85D35) 20%,transparent);border-radius:2px}
.bf-board-canvas-shape.is-circle{border-radius:50%}
.bf-board-marquee{position:absolute;pointer-events:none;box-sizing:border-box;border:1.5px solid #345b49;background:#345b4920;z-index:100}
.bf-board-map-frame.is-multi-selected,.bf-board-note.is-multi-selected,.bf-board-canvas-item.is-multi-selected{outline:2px solid #345b49;outline-offset:4px}
.bf-board-token.is-multi-selected{box-shadow:0 0 0 3px #fff,0 0 0 5px #345b49}
.bf-board-effect.is-multi-selected .bf-board-effect-shape{filter:drop-shadow(0 0 3px #345b49)}.bf-board-canvas-item-select{position:absolute;inset:0;width:100%;height:100%;border:0;padding:0;background:transparent;cursor:pointer}.bf-board-viewport:not(.is-select-tool) .bf-board-canvas-item-select{pointer-events:none}.bf-board-canvas-item.is-selected{outline:2px solid #e85d35;outline-offset:5px}.bf-board-canvas-item-actions{position:absolute;top:calc(100% + 12px);left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:12px;white-space:nowrap;z-index:4}.bf-board-canvas-item-actions .bf-board-visibility{margin:0}.bf-board-canvas-item-actions .bf-board-object-button{flex:0 0 34px;width:34px;height:34px;border-radius:50%;background:white}
.bf-board-resize{position:absolute;background:#ffFAF5;border:1px solid #849a86;border-radius:6px;box-shadow:0 2px 7px #0002;z-index:8;touch-action:none}
.bf-board-resize.is-right{right:-8px;top:calc(50% - 23px);width:16px;height:46px;cursor:ew-resize}
.bf-board-resize.is-bottom{bottom:-8px;left:calc(50% - 23px);width:46px;height:16px;cursor:ns-resize}
.bf-board-resize.is-corner{bottom:-8px;right:-8px;width:17px;height:17px;cursor:nwse-resize}
.bf-board-map-frame.is-private,.bf-board-note.is-private{outline:1px dashed #aeb7ad}
.bf-board-preview .is-private{display:none}
@media(max-width:699px){.bf-board-sidebar{width:148px;flex-basis:148px}.bf-board-list{padding:7px}.bf-board-card{padding:7px}.bf-board-floating-toolbar{padding:5px;left:6px}.bf-board-floating-toolbar .btn{padding:8px 6px;font-size:11px}.bf-board-sidehead{padding:0 6px}.bf-board-sidehead strong{font-size:11px}}

/* v74: All Campaign tabs share the full-window workspace on desktop. */
@media (min-width:900px) {
  body:has(.campaign-detail-page){padding:0!important}
  body:has(.campaign-detail-page) .app-shell{width:calc(100% - var(--campaign-board-sheet-width,0px));max-width:none;height:100dvh!important;border-radius:0!important;margin:0!important}
  body:has(.campaign-detail-page) .app{height:100dvh!important;border-radius:0!important;margin:0!important}
  body:has(.campaign-detail-page) .campaign-detail-page{border-radius:0!important}
}
/* Overview and Players scroll inside the same full-height Campaign shell. */
.campaign-detail-page .campaign-panel:not(.campaign-panel-notes):not(.campaign-panel-boards){flex:1 1 auto;min-height:0;align-content:start;overflow-y:auto;}
/* The board toolbar/zoom controls float over the viewport, not inside the zoomed scene. */
.bf-board-stage-space{position:relative;pointer-events:none;width:0;height:0;min-width:0;min-height:0;background-image:radial-gradient(#abb2a9 .9px,transparent .9px);background-size:18px 18px;background-position:0 0}
.bf-board-stage{position:absolute;left:0;top:0;transform-origin:top left;pointer-events:none;width:0;min-width:0;height:0;min-height:0}
.bf-board-stage .bf-board-object-layer{pointer-events:none}
.bf-board-zoom-controls button:disabled{opacity:.35;cursor:default}



/* v75 Campaign and Boards polish — reuse existing Notes cards and resource stepper. */
.campaign-detail-page .campaign-detail-header{
  min-height:0!important;padding:13px 24px 11px!important;gap:10px;
}
.campaign-detail-page .campaign-title-group h1{font-size:clamp(1.35rem,2.2vw,1.8rem);line-height:1.15}
.campaign-detail-page .campaign-sheet-tabs{min-height:42px;align-items:end;gap:20px}
.campaign-detail-page .campaign-sheet-tabs .sheet-tab{padding:7px 0 9px}
.bf-board-main{position:relative}
.bf-board-note-text,.bf-board-note-text[contenteditable="true"]{-webkit-user-select:text;user-select:text}
.bf-board-floating-toolbar .btn:hover{background:var(--campaign-content,#fff1e1)}
.bf-board-floating-toolbar .btn.is-active{background:color-mix(in srgb,var(--accent,#e85d35) 22%,var(--campaign-header,#fffaf5) 78%);color:var(--ink,#345b49);box-shadow:none}
.bf-board-floating-toolbar .btn[data-tip]{position:relative}
.bf-board-floating-toolbar .btn[data-tip]:hover::after,.bf-board-floating-toolbar .btn[data-tip]:focus-visible::after{content:attr(data-tip);position:absolute;bottom:calc(100% + 12px);left:50%;transform:translateX(-50%);white-space:nowrap;pointer-events:none;background:var(--campaign-header,#fffaf5);color:var(--ink,#345b49);border:1px solid var(--line,#ddd);padding:6px 9px;border-radius:7px;font-size:12px;font-weight:500;line-height:1.2;box-shadow:0 3px 8px #0002;z-index:50}

.bf-board-shape-tool{display:flex;align-items:center;position:relative;gap:0}.bf-board-floating-toolbar .bf-board-shape-main{border-radius:8px 0 0 8px;width:32px;min-width:32px}.bf-board-floating-toolbar .bf-board-shape-chevron{border-radius:0 8px 8px 0;width:15px;min-width:15px}.bf-board-floating-toolbar .bf-board-shape-chevron svg{width:12px;height:12px}.bf-board-shape-preview{position:absolute;pointer-events:none;border:2px solid #E85D35;background:#E85D3533;box-sizing:border-box;z-index:8}
.bf-board-shape-cursor{position:absolute;width:15px;height:15px;transform:translate(5px,5px);border:1.5px solid var(--ink,#345b49);border-radius:2px;background:#fff9;pointer-events:none;z-index:60}
.bf-board-shape-cursor[data-shape="circle"]{border-radius:50%}
.bf-board-shape-cursor::before,.bf-board-shape-cursor::after{content:"";position:absolute;background:var(--ink,#345b49);pointer-events:none}
.bf-board-shape-cursor::before{width:9px;height:1px;left:-15px;top:-7px}
.bf-board-shape-cursor::after{width:1px;height:9px;left:-11px;top:-11px}
.bf-board-grid-picker{border:0;padding:0;margin:12px 0;min-width:0}
.bf-board-grid-picker legend{font-weight:700;margin-bottom:8px}
.bf-board-grid-picker-options{display:grid;grid-template-columns:repeat(auto-fill,minmax(100px,1fr));gap:10px}
.bf-board-grid-choice{min-width:0;display:grid;gap:6px;cursor:pointer}
.bf-board-grid-choice input{position:absolute;opacity:0;width:1px;height:1px}
.bf-board-grid-choice-image{min-height:77px;aspect-ratio:4/3;display:grid;place-items:center;background-color:#dbe1d8;background-size:cover;background-position:center;border:2px solid var(--line,#a8b2a7);border-radius:9px;overflow:hidden}
.bf-board-grid-choice-image svg{width:24px;height:24px;opacity:.5}
.bf-board-grid-choice input:checked + .bf-board-grid-choice-image{border-color:var(--accent,#e85d35);box-shadow:0 0 0 2px var(--accent,#e85d35)}
.bf-board-grid-choice input:focus-visible + .bf-board-grid-choice-image{outline:2px solid var(--ink,#345b49);outline-offset:3px}
.bf-board-grid-choice-label{font-size:12px;text-align:center;overflow-wrap:anywhere}
.bf-board-aura-radius{display:grid;gap:7px;margin-bottom:12px}
.bf-board-aura-radius .stepper{max-width:240px}
.bf-board-tool-options{min-width:0;width:max-content;max-width:160px;padding:4px;background:var(--campaign-header,var(--surface,#fffaf5));border-color:var(--line,#ccc);color:var(--ink,#345b49)}.bf-board-tool-options button{min-width:0;min-height:30px;padding:5px 10px;font-size:12px;color:inherit;display:flex;align-items:center;gap:8px}.bf-board-tool-options button svg{width:16px;height:16px;flex:none}.bf-board-tool-options button:hover{background:var(--campaign-content,var(--surface-alt,#f4ebe0))}
.bf-board-tool-divider{width:1px;height:25px;background:var(--line,#ccc);margin:0 4px;flex:none}
.bf-campaign-sheet-popout{position:fixed;right:0;top:0;width:var(--campaign-board-sheet-width,520px);height:100dvh;min-width:340px;overflow:hidden;display:flex;flex-direction:column;z-index:1100;border-left:3px solid #345b49;background:#fffaf5;box-shadow:-5px 0 20px #0002}
.bf-campaign-sheet-editor{position:fixed;inset:0;z-index:1350;display:grid;place-items:center;padding:20px;box-sizing:border-box;background:rgba(13,25,19,.66)}
.bf-campaign-sheet-editor-content{width:min(1120px,100%);height:min(900px,calc(100dvh - 40px));min-height:0;overflow:hidden;border-radius:20px;background:var(--surface);box-shadow:0 10px 40px #0005;container:sheet-space / inline-size}
.bf-campaign-sheet-editor-content .creator-page{height:100%;min-height:0;max-height:100%;overflow:auto}
.bf-campaign-sheet-popout-header{background:#345b49;color:#fff;display:flex;gap:12px;align-items:center;justify-content:space-between;padding:7px 12px;flex:none}
.bf-campaign-sheet-popout-header .stepper-button{background:#fff;flex:0 0 34px;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;color:#345b49}
.bf-campaign-sheet-popout-body{min-height:0;min-width:0;flex:1;overflow:auto;container:sheet-space / inline-size}
.bf-campaign-sheet-popout-body .sheet-page{min-height:100%;height:100%;width:100%;min-width:0;max-width:100%}
/* The same sheet renderer responds to its available width in either route. */
.app:has(> .sheet-page) { container: sheet-space / inline-size; }
@container sheet-space (max-width:720px){
  /* Narrow sheet layout, shared by full-page and campaign-side sheets. */
  .sheet-page{--sheet-gutter:12px}
  .sheet-header-normal{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 78px;grid-template-rows:auto auto auto auto;column-gap:10px;row-gap:9px;align-items:center;padding:12px;min-width:0}
  .sheet-header-normal .sheet-normal-left-identity{grid-column:1;grid-row:1;width:auto;max-width:100%;min-width:0;height:auto;padding:0;margin:0;display:flex;flex-direction:column;justify-content:center;align-self:center}
  .sheet-header-normal .sheet-normal-left-identity h1{font-size:clamp(19px,4cqw,27px);line-height:1.1;overflow-wrap:anywhere}
  .sheet-header-normal .sheet-normal-avatar{position:relative;top:auto;right:auto;grid-column:2;grid-row:1;width:78px;height:78px;min-width:0;min-height:0;max-width:78px;max-height:78px;display:flex;justify-content:center;align-items:center;overflow:visible}
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar{width:76px;height:76px;min-width:0;min-height:0;max-width:76px;max-height:76px;flex:0 0 76px;aspect-ratio:1}
  .sheet-header-normal .sheet-summary-grid.single-speed,
  .sheet-header-normal .sheet-summary-grid.has-extra-speed{grid-column:1 / -1;grid-row:2;grid-auto-flow:row;grid-template-columns:repeat(4,minmax(0,1fr));width:100%;max-width:none;min-width:0;gap:7px;margin:0;padding:0;border:0}
  .sheet-header-normal .sheet-summary-hp{grid-column:1 / -1;grid-row:3;width:100%;max-width:100%;min-width:0;margin:0;padding:0;justify-self:stretch}
  .sheet-header-normal .sheet-tabs-in-card{grid-column:1 / -1;grid-row:4;width:100%;min-width:0;max-width:100%;margin:0;overflow-x:auto}
  .sheet-content{min-width:0;max-width:100%;overflow-x:hidden;padding-inline:12px}
}
@container sheet-space (max-width:440px){
  .sheet-page{--sheet-gutter:9px}
  .sheet-header-normal{grid-template-columns:minmax(0,1fr) 60px;gap:7px;padding:9px}
  .sheet-header-normal .sheet-normal-avatar{width:60px;height:60px;max-width:60px;max-height:60px}
  .sheet-header-normal .sheet-normal-avatar .sheet-avatar{width:58px;height:58px;max-width:58px;max-height:58px;flex-basis:58px}
  .sheet-header-normal .sheet-summary-grid.single-speed,
  .sheet-header-normal .sheet-summary-grid.has-extra-speed{gap:5px}
  .sheet-header-normal .sheet-summary-stat,
  .sheet-header-normal .normal-hit-dice,
  .sheet-header-normal .normal-speed-menu{min-width:0;width:100%;justify-self:stretch}
  .sheet-header-normal .sheet-summary-stat{grid-template-columns:23px minmax(0,1fr);gap:4px}
  .sheet-header-normal .sheet-summary-label{font-size:11px}
  .sheet-header-normal .sheet-summary-copy>strong{font-size:18px}
}

.bf-campaign-sheet-resize{position:absolute;left:0;top:0;bottom:0;width:10px;cursor:ew-resize;z-index:5;touch-action:none}
.bf-campaign-sheet-resize:focus-visible{outline:3px solid #e85d35;outline-offset:-3px}
@media(max-width:720px){body.bf-campaign-sheet-open .app-shell{width:100%!important}.bf-campaign-sheet-popout{width:min(var(--campaign-board-sheet-width,520px),95vw)}}

.bf-board-bottom-controls{position:absolute;left:50%;bottom:19px;transform:translateX(-50%);z-index:30;display:flex;align-items:center;gap:10px;max-width:calc(100% - 16px);pointer-events:none}
.bf-board-bottom-controls>*{pointer-events:auto}
.bf-board-zoom-controls{display:grid;grid-template-columns:34px minmax(55px,auto) 34px;gap:2px;padding:4px 7px;min-height:46px;border:0;box-shadow:0 4px 18px #21352626;border-radius:12px;background:#fff;align-items:center;pointer-events:auto}
.bf-board-zoom-controls .stepper-button{width:29px;height:29px;min-width:29px;border:3px solid var(--ink);border-radius:50%;background:var(--accent);color:#fff;box-shadow:0 3px 0 var(--ink)}
.bf-board-zoom-controls .stepper-button:active{transform:translateY(3px);box-shadow:none}
.bf-board-zoom-controls .stepper-button svg{width:15px;height:15px}
.bf-board-zoom-controls .bf-board-zoom-level{border:0;background:transparent;color:var(--ink);font:inherit;font-size:12px;font-weight:700;min-width:55px;cursor:pointer}
@media(max-width:700px){
  .campaign-detail-page .campaign-detail-header{padding:11px 14px 9px!important}
  .campaign-detail-page .campaign-sheet-tabs{padding-inline:14px;gap:16px}
  .bf-board-sidebar{width:175px;flex-basis:175px}
  .bf-board-list{padding:0 6px}
  .bf-board-sidehead{padding:9px 6px}
  .bf-board-sidebar-actions{padding:8px 6px}
  .bf-board-bottom-controls{bottom:13px;gap:5px}
}


/* Boards use the same raised card geometry as Campaign Notes. The card surface
   contains both controls and text, so the entire top presses into its shadow. */
.campaign-detail-page .campaign-panel-boards .bf-board-sidebar.bf-journal-sidebar{
  width:270px;flex:0 0 270px;box-sizing:border-box;padding:0 14px;
  background:var(--campaign-content,#f7f7f5);border-right:1px solid var(--line);min-width:0;
}
.campaign-detail-page .campaign-panel-boards .bf-board-sidehead.bf-journal-sidebar-head{
  height:auto;min-height:0;padding:10px 0 14px;gap:10px;border:0;
}
.campaign-detail-page .campaign-panel-boards .bf-board-sidehead strong{font:inherit;font-size:1rem;font-weight:700}
.campaign-detail-page .campaign-panel-boards .bf-board-list.bf-journal-list{
  flex:1 1 auto;min-height:0;overflow-y:auto;padding:0 0 12px;gap:0;
}
.campaign-detail-page .campaign-panel-boards .bf-board-card.campaign-shared-note-row{
  display:block;position:relative;margin:0 0 12px;padding:0;gap:0;
  border:0;border-radius:14px;background:transparent;box-shadow:none;transform:none;
}
.campaign-detail-page .campaign-panel-boards .bf-board-card.campaign-shared-note-row.is-active{
  border:0;transform:none;box-shadow:none;
}
.campaign-detail-page .campaign-panel-boards .bf-board-card-surface{
  background:var(--surface,#fff);border:3px solid var(--ink);border-radius:14px;
  box-shadow:0 4px 0 var(--ink);display:flex;flex-direction:column;align-items:stretch;min-width:0;padding:10px 14px 14px;
  transform:translateY(0);transition:transform .12s ease,box-shadow .12s ease,border-color .12s ease;
}
.campaign-detail-page .campaign-panel-boards .bf-board-card.is-active .bf-board-card-surface,
.campaign-detail-page .campaign-panel-boards .bf-board-card:has(.bf-board-card-title:active) .bf-board-card-surface{
  transform:translateY(4px);box-shadow:none;border-color:var(--accent);
}
.bf-board-card-controls{display:flex;align-items:center;justify-content:flex-end;gap:9px;padding:0 0 7px;flex:none}
.bf-board-share-switch{display:flex;align-items:center;justify-content:center;gap:8px;font-size:11px;white-space:nowrap;cursor:pointer;flex:none}
.bf-board-share-switch .bf-switch{display:inline-flex;flex:none;align-items:center}
.bf-board-share-switch .sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.bf-board-collapse.profile-round-back.stepper-button,
.bf-board-object-button.profile-round-back.stepper-button,
.bf-board-menu-button.profile-round-back.stepper-button{
  box-sizing:border-box;width:34px;height:34px;min-width:34px;flex:0 0 34px;
  padding:0;display:grid;place-items:center;border-radius:50%;
  background:#fff;color:var(--ink);border-color:var(--ink);
}
.bf-board-menu-button svg{width:17px;height:17px}
.bf-board-object-button svg,.bf-board-collapse svg{width:16px;height:16px}

.bf-board-visibility{display:flex;align-items:center;gap:9px;font-size:11px;white-space:nowrap;cursor:pointer}
.bf-board-grid-body .bf-board-map-placeholder{z-index:0}
.campaign-detail-page .campaign-panel-boards .bf-board-sidebar-actions.bf-journal-sidebar-add{
  padding:12px 0 14px;width:100%;border:0;
}
.campaign-detail-page .campaign-panel-boards .bf-board-sidebar-actions .btn{
  width:100%;min-height:56px;display:flex;align-items:center;justify-content:center;
}
.campaign-detail-page .campaign-panel-boards .bf-board-sidebar.bf-journal-sidebar.is-collapsed{
  width:48px;flex:0 0 48px;padding:0 7px;
}
.campaign-detail-page .campaign-panel-boards .bf-board-sidebar.is-collapsed .bf-board-sidehead{
  justify-content:center;padding:10px 0;
}
/* The canvas derives its geometry from the viewport, zoom and placed objects.
   Remove obsolete 2200 × 1500px minimums so the stage can grow naturally. */
.bf-board-setting-check{display:flex;align-items:center;gap:10px;margin:12px 0;font-size:14px}
.bf-board-upload-field{display:flex;flex-direction:column;align-items:flex-start;gap:8px}
.bf-board-file-input{max-width:100%;font:inherit}
.bf-picture-file-field .bf-picture-control{width:100%;position:relative}
.bf-picture-file-field .bf-picture-file-trigger{width:100%;min-height:76px;box-sizing:border-box;display:flex;align-items:center;justify-content:center;gap:10px;cursor:pointer;background-image:none;word-break:break-word;padding:10px 14px}
.bf-picture-file-field .bf-picture-file-trigger svg{width:21px;height:21px;flex:none}.bf-picture-file-field .bf-picture-file-preview{display:block;width:100%;height:150px;object-fit:contain;object-position:center;border-radius:6px}.bf-picture-file-field .bf-picture-file-preview[hidden],.bf-picture-file-field [data-picture-placeholder][hidden]{display:none}.bf-picture-file-field [data-picture-placeholder]{display:flex;align-items:center;gap:8px}
.bf-picture-file-field .bf-picture-file-input{position:absolute;width:1px;height:1px;opacity:0;overflow:hidden;pointer-events:none}
.bf-picture-file-field:focus-within .bf-picture-file-trigger{outline:2px solid var(--accent,#e85d35);outline-offset:3px}
.bf-picture-file-field .bf-crop-help{margin:0}
@media(max-width:700px){
 .campaign-detail-page .campaign-panel-boards .bf-board-sidebar.bf-journal-sidebar{width:190px;flex-basis:190px;padding-inline:10px}
 .bf-board-card-controls{gap:5px;padding-right:6px}
 .bf-board-share-switch{gap:5px;font-size:10px}
}

/* Campaign dice log: a second, collapsible workspace sidebar. */
.bf-board-roll-panel{position:relative;display:flex;flex:0 0 var(--bf-dice-width,240px);width:var(--bf-dice-width,240px);min-width:0;min-height:0;background:var(--campaign-header,#fffaf5);border-left:1px solid var(--line,#dedbd2);transition:width .16s ease,flex-basis .16s ease}
.bf-board-roll-panel.is-collapsed{flex-basis:44px;width:44px}
.bf-dice-log-content{display:flex;flex:1;min-width:0;min-height:0;flex-direction:column}
.bf-dice-log-head{display:flex;align-items:center;justify-content:space-between;gap:6px;min-height:54px;padding:0 10px;border-bottom:1px solid var(--line,#dedbd2)}
.bf-dice-log-head strong{display:flex;align-items:center;gap:7px;min-width:0;font-size:13px;white-space:nowrap}
.bf-dice-log-head strong svg{width:17px;height:17px}
.bf-dice-log-head .stepper-button{flex:0 0 32px;width:32px;height:32px}
.bf-board-roll-panel.is-collapsed .bf-dice-log-head{padding:0 5px;justify-content:center}
.bf-board-roll-panel.is-collapsed .bf-dice-log-head strong,.bf-board-roll-panel.is-collapsed .bf-dice-log-body{display:none}
.bf-dice-log-body{display:flex;flex:1;flex-direction:column;min-height:0;overflow-y:auto;padding:11px;gap:12px}
.bf-dice-form{display:grid;gap:12px;min-width:0}
.bf-dice-field{display:grid;gap:5px;min-width:0;font-size:12px;font-weight:600}
.bf-dice-types{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));column-gap:7px;row-gap:15px;padding-bottom:4px}
.bf-dice-types .btn{min-width:0;min-height:40px;padding:5px;font-size:12px;box-sizing:border-box;flex:0 0 auto;transition:transform .08s ease,box-shadow .08s ease,background .12s ease}
/* Dice reuse the shared secondary button. Selection is persistent; pointer-press styling is reserved for ordinary action buttons. */
.bf-dice-types .btn[aria-pressed="true"]{background:color-mix(in srgb,var(--accent,#e85d35) 22%,var(--surface,#fff));border-color:var(--accent,#e85d35);color:var(--ink,#345b49);transform:translateY(4px);box-shadow:0 1px 0 var(--accent,#e85d35)}
.bf-dice-steps{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.bf-dice-stepper{display:flex;align-items:center;justify-content:space-between;gap:3px}
.bf-dice-stepper .stepper-button{flex:0 0 27px;width:27px;height:27px;min-width:27px;padding:2px}
.bf-dice-stepper output{font-size:13px;font-weight:700;font-variant-numeric:tabular-nums}
.bf-dice-form .field{min-width:0;margin:0}
.bf-dice-form .custom-select{width:100%}
.bf-dice-advantage{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.bf-dice-advantage .check-row{display:flex;align-items:center;gap:6px;font-size:12px}
.bf-dice-private{display:flex;align-items:center;gap:8px;font-size:12px}
.bf-dice-roll-button{width:100%;display:flex;justify-content:center;align-items:center;min-height:44px;font-weight:700}
.bf-dice-history{display:grid;align-content:start;gap:8px}
.bf-dice-result{padding:10px;border-radius:10px;border:1px solid var(--line,#dedbd2);background:var(--campaign-content,#fff1e1);font-size:12px}
.bf-dice-result-head,.bf-dice-result-calc{display:flex;align-items:center;justify-content:space-between;gap:7px}
.bf-dice-result-head time,.bf-dice-result small{color:var(--muted,#707770);font-size:10px}
.bf-dice-result-label{padding:5px 0;overflow-wrap:anywhere}
.bf-dice-result-calc{padding:6px 0;border-top:1px solid var(--line,#dedbd2);font-weight:600}
.bf-dice-result-calc strong{font-size:23px;font-variant-numeric:tabular-nums;color:var(--accent,#e85d35)}
.bf-dice-private-tag{margin-left:5px;font-size:10px;color:var(--muted,#707770)}
.bf-dice-empty{text-align:center;color:var(--muted,#707770);font-size:12px}
.bf-board-dice-trigger{position:relative;flex:0 0 50px;width:50px;min-width:50px;pointer-events:auto}
.bf-board-dice-button{display:grid;place-items:center;box-sizing:border-box;flex:none;width:50px;min-width:50px;max-width:50px;height:50px;min-height:50px;max-height:50px;padding:0;margin:0;aspect-ratio:1;border-radius:50%;background:var(--campaign-header,#fffaf5);border:1px solid var(--line,#dedbd2);box-shadow:0 4px 18px #21352626;color:var(--ink,#345b49)}
.bf-board-dice-button svg{width:22px;height:22px}
.bf-board-dice-button[aria-expanded="true"]{background:color-mix(in srgb,var(--accent,#e85d35) 20%,var(--campaign-header,#fffaf5))}
.bf-dice-picker{position:absolute;left:0;bottom:calc(100% + 12px);width:min(322px,calc(100vw - 24px));max-height:min(65dvh,580px);overflow-y:auto;z-index:60;border:1px solid var(--line,#dedbd2);border-radius:13px;background:var(--campaign-header,#fffaf5);box-shadow:0 7px 25px #0003;padding:10px}
.bf-dice-picker[hidden]{display:none}
.bf-dice-animation{position:fixed;inset:0;z-index:1600;display:grid;place-items:center;pointer-events:none;background:#07140c25}
.bf-dice-animation-card{display:flex;align-items:center;flex-direction:column;gap:12px;min-width:220px;max-width:min(90vw,360px);padding:24px 24px 17px;border:1px solid var(--line,#dedbd2);border-radius:17px;background:var(--campaign-header,#fffaf5);box-shadow:0 18px 55px #0004;color:var(--ink,#345b49)}
/* One coordinated reveal. The die fades while its rolled face remains visible;
   the modifier travels directly into that number as the total takes over. */
.bf-dice-animation-math{position:relative;display:grid;place-items:center;width:220px;height:138px;isolation:isolate}
.bf-dice-animation-die{position:relative;display:grid;place-items:center;width:116px;height:116px;color:var(--accent,#e85d35)}
.bf-dice-animation-die svg{width:104px;height:104px;stroke-width:1.6;animation:bf-dice-spin 1.85s cubic-bezier(.12,.7,.15,1) both,bf-dice-art-fade 3.9s linear both}
.bf-dice-animation-die .bf-dice-face,.bf-dice-animation-die .bf-dice-total{position:absolute;inset:0;display:grid;place-items:center;color:var(--ink,#345b49);font-size:30px;font-weight:800;font-variant-numeric:tabular-nums}
.bf-dice-animation-die .bf-dice-face{animation:bf-dice-face-reveal 3.9s both}
.bf-dice-animation-die .bf-dice-total{animation:bf-dice-total-impact 3.9s both}
.bf-dice-animation-modifier{position:absolute;left:calc(50% + 63px);top:50%;font-size:27px;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap;animation:bf-dice-modifier-merge 3.9s both}
.bf-dice-roll-choice{font-size:12px;text-align:center;color:var(--ink,#345b49)}
.bf-dice-roll-choice strong{color:var(--accent,#e85d35)}
.bf-dice-result-draws{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:11px}
.bf-dice-result-draws .is-discarded{opacity:.6;text-decoration:line-through}
.bf-dice-result-draws .is-kept{color:var(--accent,#e85d35);font-weight:800}
.bf-dice-animation-card small{text-align:center;font-size:12px}
.bf-dice-animation-progress{width:100%;height:4px;margin-top:8px;background:color-mix(in srgb,var(--accent,#e85d35) 18%,white);border-radius:10px;overflow:hidden}
.bf-dice-animation-progress span{display:block;width:100%;height:100%;background:var(--accent,#e85d35);transform-origin:left;animation:bf-dice-countdown 3.9s linear forwards}
@keyframes bf-dice-countdown{to{transform:scaleX(0)}}
@keyframes bf-dice-spin{from{transform:rotate(0)}to{transform:rotate(1440deg)}}
@keyframes bf-dice-art-fade{0%,48%{opacity:1}66%,100%{opacity:0}}
@keyframes bf-dice-face-reveal{0%,45%{opacity:0}55%,77%{opacity:1}81%,100%{opacity:0}}
@keyframes bf-dice-modifier-merge{0%,54%{opacity:0;transform:translate(0,-50%)}56%{opacity:1;transform:translate(-3px,-50%)}75%{opacity:1;transform:translate(-57px,-50%) scale(.8)}79%,100%{opacity:0;transform:translate(-67px,-50%) scale(.55)}}
@keyframes bf-dice-total-impact{0%,76%{opacity:0;transform:scale(.88)}80%{opacity:1;transform:scale(1.33)}87%{opacity:1;transform:scale(.96)}93%,100%{opacity:1;transform:scale(1)}}
@media (prefers-reduced-motion:reduce){.bf-dice-animation-die svg,.bf-dice-animation-die .bf-dice-face,.bf-dice-animation-die .bf-dice-total,.bf-dice-animation-modifier{animation:none}.bf-dice-animation-die svg,.bf-dice-animation-die .bf-dice-face,.bf-dice-animation-modifier{display:none}}
@media(max-width:800px){.bf-board-roll-panel{--bf-dice-width:185px}.bf-dice-log-body{padding:7px}.bf-dice-steps{gap:4px}}
@media(max-width:580px){.bf-board-roll-panel:not(.is-collapsed){position:absolute;right:0;top:0;bottom:0;z-index:45;width:min(280px,80vw);box-shadow:-5px 0 20px #0002}}
