.tbe-character-profile { --tbe-profile-ink: #302b25; --tbe-profile-muted: #6d655c; --tbe-profile-line: #ddd5c9; --tbe-profile-paper: #f8f5ef; }
.tbe-character-profile .tbe-profile-intro { display: grid; grid-template-columns: minmax(180px, 29%) minmax(0, 1fr); gap: clamp(24px, 4vw, 48px); align-items: start; }
.tbe-character-profile .tbe-profile-portrait { margin: 0; }
.tbe-character-profile .tbe-profile-portrait img { display: block; width: 100%; height: auto; border-radius: 3px; }
.tbe-character-profile .tbe-profile-overview { min-width: 0; }
.tbe-character-profile .tbe-profile-overview h2 { margin: 0 0 18px; }
.tbe-character-profile .tbe-profile-summary p { margin-top: 0; }
.tbe-character-profile dl { margin: 0; }
.tbe-character-profile .tbe-profile-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.tbe-character-profile dt { color: var(--tbe-profile-muted); font-size: .82em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tbe-character-profile dd { margin: 3px 0 0; color: var(--tbe-profile-ink); overflow-wrap: anywhere; }
.tbe-character-profile .tbe-profile-campaign { border-top: 1px solid var(--tbe-profile-line); margin-top: 22px; padding-top: 15px; }
.tbe-character-profile .tbe-profile-campaign span { display: block; color: var(--tbe-profile-muted); font-size: .82em; }
.tbe-character-profile .tbe-profile-context { color: var(--tbe-profile-muted); }
.tbe-character-profile .tbe-profile-switch { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; }
.tbe-character-profile .tbe-profile-switch a[aria-current] { font-weight: 700; }
.tbe-character-profile .tbe-profile-edit { display: inline-block; margin-top: 18px; font-size: .9em; }
.tbe-character-profile .tbe-profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; margin-top: 32px; border: 1px solid var(--tbe-profile-line); background: var(--tbe-profile-line); }
.tbe-character-profile .tbe-profile-stats > div { background: var(--tbe-profile-paper); padding: 18px 16px; text-align: center; }
.tbe-character-profile .tbe-profile-stats dd { font: 400 1.6em 'Roboto Condensed', sans-serif; }
.tbe-character-profile .tbe-profile-section { clear: both; margin-top: 36px; padding-top: 26px; border-top: 1px solid var(--tbe-profile-line); }
.tbe-character-profile .tbe-profile-section h2 { margin-top: 0; margin-bottom: 18px; }
.tbe-character-profile .tbe-profile-abilities { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.tbe-character-profile .tbe-profile-abilities > div { padding: 12px 8px; border-bottom: 2px solid var(--tbe-profile-line); text-align: center; }
.tbe-character-profile .tbe-profile-abilities dt { font-size: .72em; letter-spacing: .02em; }
.tbe-character-profile .tbe-profile-abilities dd { font-size: 1.45em; }
.tbe-character-profile .tbe-profile-text { line-height: 1.65; }
.tbe-character-profile .tbe-profile-table-wrap { overflow-x: auto; }
.tbe-character-profile .tbe-profile-table { width: 100%; border-collapse: collapse; text-align: left; }
.tbe-character-profile .tbe-profile-table th, .tbe-character-profile .tbe-profile-table td { padding: 11px 14px; border-bottom: 1px solid var(--tbe-profile-line); }
.tbe-character-profile .tbe-profile-table thead { background: var(--tbe-profile-paper); }
.tbe-character-profile .tbe-profile-table tbody th { font-weight: 400; }
.tbe-character-profile .tbe-profile-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tbe-character-profile .tbe-profile-features details { border: 1px solid var(--tbe-profile-line); padding: 14px 16px; }
.tbe-character-profile .tbe-profile-features summary { cursor: pointer; font-weight: 700; }
.tbe-character-profile .tbe-profile-features p { margin: 12px 0 0; }
.tbe-character-profile .tbe-profile-legacy::after { content: ''; display: block; clear: both; }
.tbe-character-profile .tbe-profile-legacy-portrait { float: left; width: 29%; margin: 0 32px 24px 0; }
.tbe-character-profile .tbe-profile-legacy-portrait img { width: 100%; height: auto; display: block; }
.tbe-character-profile .tbe-profile-sheet { margin-top: 36px; border: 1px solid var(--tbe-profile-line); background: var(--tbe-profile-paper); }
.tbe-character-profile .tbe-profile-sheet > summary { padding: 20px 24px; cursor: pointer; color: var(--tbe-profile-ink); font: 400 1.5em 'Roboto Condensed', sans-serif; }
.tbe-character-profile .tbe-profile-sheet > summary span { display: block; margin: 5px 0 0 22px; font: 400 .6em 'Roboto', sans-serif; color: var(--tbe-profile-muted); }
.tbe-character-profile .tbe-profile-sheet-body { padding: 0 24px 24px; background: white; border-top: 1px solid var(--tbe-profile-line); }
.tbe-character-profile .tbe-profile-sheet-body .tbe-profile-stats { margin-top: 24px; }
@media (max-width: 700px) {
  .tbe-character-profile .tbe-profile-intro { grid-template-columns: 1fr; gap: 24px; }
  .tbe-character-profile .tbe-profile-portrait { max-width: 320px; }
  .tbe-character-profile .tbe-profile-abilities { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tbe-character-profile .tbe-profile-features { grid-template-columns: 1fr; }
  .tbe-character-profile .tbe-profile-legacy-portrait { float: none; width: min(100%, 320px); margin: 0 0 24px; }
}
@media (max-width: 380px) {
  .tbe-character-profile .tbe-profile-facts { grid-template-columns: 1fr; }
}



.tbe-character-profile .tbe-profile-sheet-link { display: inline-block; margin: 20px 16px 0 0; padding: 12px 18px; background: #513c26; color: #fff; border-radius: 3px; text-decoration: none; font-weight: 700; }
.tbe-character-profile .tbe-profile-sheet-link:focus-visible { outline: 3px solid #b78638; outline-offset: 3px; }
.tbe-character-profile .tbe-advancement-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tbe-character-profile .tbe-advancement-grid > div { padding: 20px; background: var(--tbe-profile-paper); border: 1px solid var(--tbe-profile-line); }
.tbe-character-profile .tbe-advancement-grid progress { width: 100%; accent-color: #715229; }
@media (max-width: 700px) { .tbe-character-profile .tbe-advancement-grid { grid-template-columns: 1fr; } }

/* Spellcasting is shared by the member portal and published character sheets. */
.tbe-character-profile .tbe-profile-spell-stats { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: .75rem; }
.tbe-character-profile .tbe-profile-spell-stats > div { padding: .85rem 1rem; background: #f3f6ef; border: 1px solid #d3dbce; border-radius: 7px; }
.tbe-character-profile .tbe-profile-spells h3 { margin: 1.4rem 0 .75rem; }
.tbe-character-profile .tbe-spell-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .8rem; }
.tbe-character-profile .tbe-spell-card { min-width: 0; padding: .85rem 1rem; border: 1px solid #d8cdbd; border-radius: 7px; background: #fafbf8; overflow-wrap: anywhere; }
.tbe-character-profile .tbe-spell-card > summary { cursor: pointer; font-weight: 700; font-size: 1rem; }
.tbe-character-profile .tbe-spell-card > summary span { display: block; margin-top: .3rem; font-size: .85rem; font-weight: 400; line-height: 1.5; }
.tbe-character-profile .tbe-spell-card p { margin: .75rem 0 0; line-height: 1.55; }
.tbe-character-profile .tbe-spell-card .tbe-spell-source,
.tbe-character-profile .tbe-spell-note { font-size: .85rem; color: #645d53; }
.tbe-character-profile .tbe-spell-meta { font-size: .9rem; }
@media(max-width:700px) { .tbe-character-profile .tbe-spell-grid { grid-template-columns:minmax(0,1fr); } }

/* Clickable d20 checks, shared by starting and campaign sheets. */
.tbe-rolls { margin: 1.5rem 0; }
.tbe-rolls [hidden] { display: none !important; }
.tbe-roll-controls { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.tbe-roll-controls label { display: flex; flex-direction: column; gap: .35rem; }
.tbe-roll-controls select, .tbe-roll-controls button { padding: .6rem .85rem; border: 1px solid #b9c8bb; border-radius: 5px; background: #fff; color: #263e30; font: inherit; }
.tbe-rolls button.tbe-roll-button { min-width: 3.2rem; min-height: 2.75rem; padding: .45rem .75rem; border: 1px solid #52745c; border-radius: 6px; background: #edf4ed; color: #244c32; font: inherit; font-weight: 700; cursor: pointer; }
.tbe-rolls button.tbe-roll-button:hover { background: #dcebdd; }
.tbe-rolls button:focus-visible, .tbe-rolls select:focus-visible { outline: 3px solid #b78638; outline-offset: 3px; }
.tbe-roll-result { position: sticky; top: 2.5rem; z-index: 5; padding: 1rem; border-left: 4px solid #52745c; background: #edf4ed; font-weight: 700; overflow-wrap: anywhere; }
.tbe-roll-history { font-size: .9rem; padding-left: 1.5rem; }
.tbe-roll-table-wrap { overflow-x: auto; margin: 1rem 0; }
.tbe-rolls table { width: 100%; border-collapse: collapse; text-align: left; }
.tbe-rolls caption { text-align: left; font-weight: 700; padding: .6rem 0; }
.tbe-rolls td, .tbe-rolls th { padding: .55rem; border-bottom: 1px solid #ded8cb; }
.tbe-roll-instructions, .tbe-roll-passives { font-size: .9rem; }
@media print { .tbe-rolls .tbe-roll-controls, .tbe-rolls .tbe-roll-result, .tbe-rolls .tbe-roll-history, .tbe-rolls .tbe-roll-instructions { display: none !important; } }

/* Equipped weapon attack and damage modes. */
.tbe-weapon-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.tbe-weapon-card { min-width: 0; padding: 1rem; border: 1px solid #d3dbce; border-radius: 7px; background: #fafbf8; }
.tbe-weapon-card h4 { margin: 0 0 .65rem; }
.tbe-weapon-card p { font-size: .9rem; }
.tbe-weapon-critical { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; }
.tbe-weapon-critical input { margin: 0; width: 1.1rem; height: 1.1rem; accent-color: #52745c; }
.tbe-weapon-mode { border-top: 1px solid #d3dbce; padding: .85rem 0 .25rem; }
.tbe-weapon-mode > div { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: .5rem; }
.tbe-light-extra { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; width: 100%; font-size: .85rem; }
@media(max-width:700px) { .tbe-weapon-grid { grid-template-columns: minmax(0,1fr); } }
@media print { .tbe-weapon-critical { display: none !important; } }

/* Compact weapon rows: one weapon per row, with optional details. */
.tbe-weapons-compact { grid-template-columns: minmax(0,1fr); gap: .5rem; }
.tbe-weapons-compact .tbe-weapon-card { display: grid; grid-template-columns: minmax(120px,150px) minmax(0,1fr) auto; align-items: center; gap: .75rem; padding: .7rem .85rem; }
.tbe-weapons-compact .tbe-weapon-identity h4 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.tbe-weapons-compact .tbe-weapon-details { margin: .2rem 0 0; border: 0; padding: 0; background: transparent; }
.tbe-weapons-compact .tbe-weapon-details > summary { padding: 0; font-size: .8rem; font-weight: 400; cursor: pointer; }
.tbe-weapons-compact .tbe-weapon-details p { margin: .4rem 0; font-size: .8rem; }
.tbe-weapons-compact .tbe-weapon-modes { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; min-width: 0; }
.tbe-weapons-compact .tbe-weapon-mode { padding: 0; border: 0; }
.tbe-weapons-compact .tbe-weapon-mode > strong { font-size: .78rem; }
.tbe-weapons-compact .tbe-weapon-mode > div { gap: .35rem; margin-top: .2rem; font-size: .85rem; }
.tbe-weapons-compact .tbe-weapon-critical { margin: 0; font-size: .8rem; gap: .4rem; }
.tbe-weapons-compact .tbe-light-extra { font-size: .75rem; }
.tbe-weapons-compact .tbe-weapon-unconfirmed { grid-column: 2 / -1; margin: 0; }
.tbe-weapons-compact .tbe-weapon-shield-note { width: 100%; margin: 0; font-size: .8rem; }
.tbe-weapon-roll-notes { margin: 0 0 .75rem; font-size: .85rem; }
@media(max-width:700px) {
  .tbe-weapons-compact .tbe-weapon-card { grid-template-columns: minmax(0,1fr) auto; }
  .tbe-weapons-compact .tbe-weapon-modes { grid-column: 1 / -1; grid-row: 2; }
  .tbe-weapons-compact .tbe-weapon-critical { grid-column: 2; grid-row: 1; }
  .tbe-weapons-compact .tbe-weapon-unconfirmed { grid-column: 1 / -1; }
}

/* Campaign equipment controls. */
.tbe-equipment-toggle { margin: .3rem 0 .3rem .75rem; padding: .5rem .75rem; min-height: 2.75rem; border: 1px solid #52745c; border-radius: 5px; background: #edf4ed; color: #244c32; font: inherit; cursor: pointer; }
.tbe-equipment-toggle:disabled { opacity: .6; cursor: wait; }
.tbe-equipment-toggle:focus-visible { outline: 3px solid #b78638; outline-offset: 3px; }
.tbe-equipment-status { padding: .5rem 0; }
.tbe-equipment-status:empty { display: none; }
.tbe-equipment-error { padding: .75rem; border-left: 4px solid #a9382e; background: #fff0ee; color: #87251e; }
.tbe-equipment-toggle[hidden] { display: none !important; }
@media print { .tbe-equipment-toggle,.tbe-equipment-status { display: none !important; } }

/* Carried weight / capacity, including coin weight. */
.tbe-load { --tbe-load-color: #39764c; margin: 1.25rem 0; padding: 1rem 1.15rem; border: 1px solid #d3dbce; border-radius: 8px; background: #f7faf5; }
.tbe-load-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.tbe-load-heading > span { font-size: .8rem; font-weight: 700; color: var(--tbe-load-color); }
.tbe-load .tbe-load-total { margin: .5rem 0 .65rem; }
.tbe-load-track { height: .85rem; border-radius: 99px; overflow: hidden; background: #dde5dc; }
.tbe-load-track > span { display: block; height: 100%; border-radius: inherit; background: var(--tbe-load-color); }
.tbe-load .tbe-load-breakdown, .tbe-load .tbe-load-room, .tbe-load .tbe-load-note { margin: .5rem 0 0; font-size: .8rem; line-height: 1.5; }
.tbe-load-near { --tbe-load-color: #8e600d; background: #fffaf0; border-color: #dfc98f; }
.tbe-load-over { --tbe-load-color: #a62d25; background: #fff2ef; border-color: #dba39d; }
.tbe-load-unknown { --tbe-load-color: #6d5d36; background: #faf8f1; }
.tbe-load .tbe-load-warning { margin: .6rem 0 0; color: #96271f; font-size: .9rem; }
.tbe-load-unavailable, .tbe-load-unknown .tbe-load-track > span { background: repeating-linear-gradient(135deg,#a89d80 0px,#a89d80 7px,#d9d2c0 7px,#d9d2c0 14px); }
.tbe-load-missing { margin-top: .6rem; font-size: .85rem; }
.tbe-load-missing p { font-size: .85rem; }

/* Guided Cleric level-up choices. */
.tbe-cleric-advance-form { display: grid; gap: 1rem; max-width: 760px; padding: 1rem; border: 1px solid #d3dbce; border-radius: 7px; background: #fafbf8; }
.tbe-cleric-advance-form label { display: block; font-weight: 700; }
.tbe-cleric-advance-form select, .tbe-cleric-advance-form input[type=number] { display: block; width: 100%; margin-top: .4rem; padding: .65rem; font: inherit; border: 1px solid #b9c8bb; border-radius: 5px; background: #fff; }
.tbe-cleric-spell-help { margin: 0; font-size: .9rem; }
.tbe-cleric-spell-help:empty, .tbe-cleric-advance-status:empty { display: none; }
.tbe-cleric-advance-form .tbe-levelup-confirm { display: flex; gap: .6rem; align-items: start; font-weight: 400; }
.tbe-levelup-button { padding: .8rem 1rem; border: 0; border-radius: 6px; background: #345d48; color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.tbe-levelup-button:disabled { opacity: .6; cursor: default; }
.tbe-cleric-advance-status[role=alert] { padding: .75rem; border-left: 4px solid #a9382e; background: #fff0ee; color: #87251e; }
.tbe-cleric-advance-form :focus-visible { outline: 3px solid #b78638; outline-offset: 3px; }

/* Completed rests and daily Cleric preparation. */
.tbe-rest-panel { margin: 0 0 1.5rem; padding: 1rem; border: 1px solid #c9d7cd; border-radius: 8px; background: #f5f8f3; }
.tbe-rest-heading, .tbe-rest-actions, .tbe-rest-submit { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.tbe-rest-heading { justify-content: space-between; }
.tbe-rest-panel button { padding: .65rem .9rem; border: 1px solid #52745c; border-radius: 5px; background: #345d48; color: #fff; font: inherit; cursor: pointer; }
.tbe-rest-panel button:disabled { opacity: .6; cursor: default; }
.tbe-rest-panel [hidden] { display: none !important; }
.tbe-rest-last, .tbe-rest-log { font-size: .85rem; }
.tbe-rest-form { display: grid; gap: 1rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #c9d7cd; }
.tbe-rest-form h3, .tbe-rest-form p { margin: 0; }
.tbe-rest-fields, .tbe-rest-spell-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.tbe-rest-form label { display: block; }
.tbe-rest-form select, .tbe-rest-form input:not([type=checkbox]) { display: block; width: 100%; box-sizing: border-box; padding: .6rem; margin-top: .35rem; font: inherit; border: 1px solid #b9c8bb; border-radius: 5px; background: #fff; }
.tbe-rest-form fieldset { padding: 1rem; border: 1px solid #c9d7cd; border-radius: 6px; }
.tbe-rest-form legend { padding: 0 .4rem; font-weight: 700; }
.tbe-rest-form .tbe-rest-check { display: flex; align-items: start; gap: .6rem; }
.tbe-rest-check input { margin-top: .3rem; }
.tbe-rest-spell-help { display: block; margin-top: .5rem; font-size: .8rem; line-height: 1.5; }
.tbe-rest-die { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; margin: .75rem 0; }
.tbe-rest-die label { flex: 1; min-width: 100px; }
.tbe-rest-status[role=alert] { padding: .75rem; border-left: 4px solid #a9382e; background: #fff0ee; color: #87251e; }
.tbe-rest-panel :focus-visible { outline: 3px solid #b78638; outline-offset: 3px; }
@media(max-width:700px) { .tbe-rest-fields, .tbe-rest-spell-grid { grid-template-columns: minmax(0,1fr); } }
@media print { .tbe-rest-controller, .tbe-rest-actions { display: none !important; } }

.tbe-rest-form h3 { font-size: 1.2rem; }

/* Rest panel spacing polish v1. */
.tbe-rest-panel .tbe-rest-last { margin: .65rem 0 0; }
.tbe-rest-panel .tbe-rest-form { gap: 1.15rem; }
.tbe-rest-panel .tbe-rest-form > h3 { margin: 0; line-height: 1.3; font-weight: 700; }
.tbe-rest-panel .tbe-rest-form > p { margin: 0; }
.tbe-rest-panel .tbe-rest-fields { margin: 0; }
.tbe-rest-panel .tbe-rest-form fieldset { min-width: 0; margin: 0; padding: 1rem; }
.tbe-rest-panel .tbe-rest-form fieldset > p { margin: 0 0 .85rem; }
.tbe-rest-panel .tbe-rest-form fieldset > select { margin: 0 0 .85rem; }
.tbe-rest-panel .tbe-rest-form [data-add-hit-die] { display: inline-block; margin: 0 0 .75rem; }
.tbe-rest-panel .tbe-rest-form .tbe-rest-healing-preview { margin: 0; font-size: .9rem; line-height: 1.5; }
.tbe-rest-panel .tbe-rest-form .tbe-rest-check { margin: 0; font-weight: 400; line-height: 1.5; }
.tbe-rest-panel .tbe-rest-check input[type=checkbox] { flex: 0 0 auto; margin: .3rem 0 0; }
.tbe-rest-panel .tbe-rest-status:empty { display: none; }
.tbe-rest-panel .tbe-rest-submit { margin: 0; gap: .65rem; }
.tbe-rest-panel .tbe-rest-spell-grid { margin-top: .85rem; }

/* Rest die alignment polish v2. */
.tbe-rest-panel .tbe-rest-die {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  align-items: end;
  gap: .65rem;
  margin: .85rem 0;
}
.tbe-rest-panel .tbe-rest-die > label {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  line-height: 1.4;
}
.tbe-rest-panel .tbe-rest-die input[type=number] {
  height: 2.75rem;
  min-height: 2.75rem;
  margin: .35rem 0 0;
  box-sizing: border-box;
}
.tbe-rest-panel .tbe-rest-die > button {
  height: 2.75rem;
  min-height: 2.75rem;
  margin: 0;
  box-sizing: border-box;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .tbe-rest-panel .tbe-rest-die { grid-template-columns: auto auto minmax(0,1fr); }
  .tbe-rest-panel .tbe-rest-die > label { grid-column: 1 / -1; }
}

/* Space below the Character Sheet header. */
.tbe-profile-sheet-body > .tbe-rest-panel { margin-top: 1.25rem; }
