/* Add local visual changes here. The upstream styles remain in site/assets/. */
.pb-local-notification{position:fixed;z-index:2147483000;right:20px;bottom:20px;max-width:min(440px,calc(100vw - 40px));padding:14px 18px;border:1px solid #566477;border-radius:10px;background:#202630;color:#edf1f5;box-shadow:0 12px 36px #0006;font:14px/1.5 Inter,Arial,sans-serif}
.pb-local-notification[data-kind=error]{border-color:#d05c52}
.pb-local-notification[hidden]{display:none}
html.light .pb-local-notification{border-color:#cbbba6;background:#fffaf0;color:#39241b}
html.light .pb-local-notification[data-kind=error]{border-color:#aa4038}

/* Keep the drawer's contents at their normal width while its grid track moves.
   The engine already owns visuallyhidden/hidden; no second toggle is needed. */
html[data-interface="desktop"] body:has(.healthbar) #main-container {
  --pb-plan-width: 26em;
  display: grid !important;
  grid-template-columns: minmax(0, calc(var(--pb-plan-width) + .5em)) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  transition: grid-template-columns .35s ease;
}

html[data-interface="desktop"] body:has(.healthbar) #main-container:has(> #divBuild.visuallyhidden) {
  grid-template-columns: minmax(0, 0em) minmax(0, 1fr);
}

html[data-interface="desktop"] body:has(.healthbar) #divBuild {
  display: block;
  grid-area: 1 / 1;
  box-sizing: content-box;
  width: var(--pb-plan-width);
  min-width: var(--pb-plan-width);
  max-width: var(--pb-plan-width);
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition: transform .35s ease, visibility 0s;
}

html[data-interface="desktop"] body:has(.healthbar) #divBuild.visuallyhidden {
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .35s ease, visibility 0s linear .35s;
}

html[data-interface="desktop"] body:has(.healthbar) .main-column-right {
  grid-area: 1 / 2;
  /* The engine's end-of-transition margin change must not cause a final jump. */
  margin-left: 1em;
  padding-left: .5em;
}

@media (prefers-reduced-motion: reduce) {
  html[data-interface="desktop"] body:has(.healthbar) #main-container,
  html[data-interface="desktop"] body:has(.healthbar) #divBuild {
    transition: none !important;
  }
}

/* Keep the licenses action at the bottom of the scrollable sidebar. */
#mySidenav .sidenav-body{display:flex;flex-direction:column;min-height:calc(100% - 15px);box-sizing:border-box}
#mySidenav .sidenav-body>*{flex-shrink:0}
#mySidenav .sidenav-body>.menu-footer{margin:auto 0 0;padding-top:1.5em}
/* 2026-11-06 owner's menu layout: «Remaster: on/off» sits at the bottom, right of «Licenses». */
#mySidenav .sidenav-body>.menu-footer{display:flex;align-items:center;justify-content:space-between;gap:1em}
#mySidenav .menu-footer #sidenav-remaster-toggle{margin:0!important;padding-right:8px;text-align:right}
#mySidenav #sidenav-ogl{color:var(--ui-license-color,#ff5722)!important;font-weight:700;cursor:pointer}
#mySidenav #sidenav-ogl:hover{text-decoration:underline}

/* Rest options are checkboxes, using the existing native checked state. */
#root .pb-rest-option .checkbox-container{flex:0 0 20px;width:20px;height:20px;border:2px solid var(--pb-muted,#8390a0);border-radius:4px;background:transparent}
#root .pb-rest-option .checkbox-container img{width:20px;height:20px;opacity:0}
#root .pb-rest-option .checkbox-container::after{content:none;transform:none;transition:none}
#root .pb-rest-option .checkbox-container:has(img[src*="_checked"]){border-color:var(--pb-accent,#ff5722);background:var(--pb-accent,#ff5722)}
#root .pb-rest-option .checkbox-container:has(img[src*="_checked"])::after{content:"";position:absolute;left:5px;top:1px;width:5px;height:9px;border:solid #fff;border-width:0 2px 2px 0;border-radius:0;background:transparent;transform:rotate(45deg)}
/* One content gutter for every character tab, including nested spell views. */
#tabbed-area .tabbed-area-display-holder {
  box-sizing: border-box;
  padding-right: 14px;
  scrollbar-gutter: stable;
}
#tabbed-area .tabbed-area-display {
  box-sizing: border-box;
  width: 100%;
  margin-right: 0 !important;
}
#tabbed-area .tabbed-area-display .layout-tabbed-line {
  box-sizing: border-box;
  max-width: 100%;
  margin-right: 0 !important;
}
#tabbed-area .div-spell-level-new {
  padding-right: 0 !important;
}
#tabbed-area #layout-parent-spellcasters {
  margin-right: 0 !important;
}

/* Bottom of the skills column and Details workspace: 7 CSS px to the window. */
html[data-interface="desktop"] #container-row-2{height:var(--pb-available-row-height,calc(100dvh - 17.8em));min-height:0}
#container-section-skills{min-height:0;margin-top:7px!important;margin-bottom:7px!important}
#container-section-skills .section-skills{min-height:0}
#tabbed-area .details-root{height:calc(100% - 14px);min-height:0}
#tabbed-area .details-root>.tabbed-area-top-holder{flex:0 0 auto;margin-bottom:7px}
#tabbed-area .details-root>.div-notes{display:flex;flex:1 1 0;min-height:min(18rem,60dvh);margin-top:0;margin-bottom:0}

#tabbed-area{padding-bottom:7px}
#tabbed-area .details-root{margin-top:14px!important}

/* Audit: readable unselected choices in dark themes only. */
html:not(.light) .button-selection.red-text{color:#9aa5b4!important}

/* 2026-11-06 (rules audit): Bulk over 5 + Strength, the encumbered condition it gives, and a saved skill increase above its level. */
#tabbed-area .pb-encumbered{color:#ff6b6b!important;font-weight:600}
html.light #tabbed-area .pb-encumbered{color:#c0262d!important}
.condition.pb-auto-condition{opacity:.92}
.condition.pb-auto-condition .condition-name{font-style:italic}
html body #divBuild .div-button.pb-invalid-choice{outline:2px solid #e5484d!important;outline-offset:-2px}
html.light body #divBuild .div-button.pb-invalid-choice{outline-color:#c0262d!important}
/* The portrait (the owner 2026-11-08): the placeholder's frame, 8em x 12em (portrait_blank.jpg 208x312, 2:3); any picture
   fills it and is cut to it, never stretched or past its edge (old saves with pictures of any proportions too). */
html body img.portrait#portrait{width:8em;height:12em;object-fit:cover;object-position:center;display:block}

/* Primary sheet tabs and planner level headings, both languages and themes. */
html[data-interface="desktop"] .main-column-right .tabbed-area-menu > .section-menu,
#divBuild .subtitle-build { font-weight: 600; }


/* Let the condition controls move to their own row before their labels would overlap. */
html[data-interface="desktop"] #container-row-0 {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: .5em;
}
html[data-interface="desktop"] #container-row-0-col-0 {
  flex: 0 1 43em;
  min-width: 0;
  max-width: 100%;
}
html[data-interface="desktop"] #section-conditions {
  flex: 1 1 21em;
  min-width: 0;
  height: auto;
  margin: 0;
}
html[data-interface="desktop"] #section-conditions .grid-container {
  display: flex;
  flex-wrap: wrap;
  gap: .5em;
}
html[data-interface="desktop"] #section-conditions .grid-container > .grid-item {
  flex: 1 1 7em;
  min-width: min(7em, 100%);
  min-height: 2.6em;
  height: auto;
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
html[data-interface="desktop"] #section-conditions .div-conditions {
  height: auto;
  max-height: 9em;
}
html[data-interface="desktop"] #section-conditions .div-conditions:empty {
  display: none;
}
/* Slide the whole drawer so its labels keep their line breaks while it moves. */
html[data-interface="desktop"] #mySidenav {
  width: min(360px, 100vw) !important;
  white-space: normal;
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .22s cubic-bezier(.2, .7, .3, 1), visibility 0s linear .22s;
}

html[data-interface="desktop"] #mySidenav[aria-hidden="false"] {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  html[data-interface="desktop"] #mySidenav {
    transition: none;
  }
}
html[data-interface="desktop"] :is([data-pb-keyboard-button], #tabbed-area > .tabbed-area-menu > [role="tab"]):focus-visible {
  outline: 2px solid #ff995f;
  outline-offset: -2px;
}
html.light[data-interface="desktop"] :is([data-pb-keyboard-button], #tabbed-area > .tabbed-area-menu > [role="tab"]):focus-visible {
  outline-color: #780f12;
}

@media (max-width: 950px) {
  html[data-interface="desktop"] body:has(.healthbar) #main-container {
    display: block !important;
    height: calc(100dvh - 3.8em);
    overflow: auto;
    min-height: 0;
  }
  html[data-interface="desktop"] body:has(.healthbar) #divBuild {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    max-height: min(16em, 28dvh);
    overflow: auto;
    transition: none;
  }
  html[data-interface="desktop"] body:has(.healthbar) #divBuild.visuallyhidden {
    display: none;
  }
  html[data-interface="desktop"] #divTopButtons {
    display: flex;
    flex-wrap: wrap;
    gap: .4em;
  }
  html[data-interface="desktop"] #divTopButtons > aside {
    flex: 1 0 100%;
  }
  html[data-interface="desktop"] #divTopButtons > .div-button {
    flex: 1 1 min(100%, 12em);
    min-width: 0;
    width: auto !important;
    margin: 0 !important;
  }
  html[data-interface="desktop"] body:has(.healthbar) .main-column-right {
    height: auto;
    margin: .5em 0 0;
  }
  html[data-interface="desktop"] #container-row-0-col-0 {
    flex: 1 1 100%;
  }
  html[data-interface="desktop"] #container-row-0-col-0 > :is(.section-top, .section-defenses) {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-height: 7em;
  }
  html[data-interface="desktop"] #container-row-2 {
    height: max(28em, 55dvh);
  }
}

@media (max-width: 680px) {
  html[data-interface="desktop"] #container-row-2 {
    flex-direction: column;
    height: auto;
  }
  html[data-interface="desktop"] #container-section-skills {
    height: 16em;
  }
  html[data-interface="desktop"] #tabbed-area {
    flex: none;
    height: max(28em, 55dvh);
  }
}

@media (max-width: 600px) {
  html[data-interface="desktop"] .section-top > div > div:first-child {
    flex-wrap: wrap;
  }
  html[data-interface="desktop"] .section-top > div > div:first-child > div:has(> .button-name) {
    flex: 1 1 min(100%, 16em);
    min-width: 0;
  }
  html[data-interface="desktop"] .section-top .button-name {
    width: 100%;
  }
}

@media (max-width: 410px) {
  html[data-interface="desktop"] .section-defenses .defense-lines {
    grid-template-columns: minmax(0, 1fr);
    gap: .4em;
  }
}

/* Use the shared armor-class silhouette inside the engine's existing grid cell. */
.section-defenses .ac-holder > .ac-image {
  visibility: hidden;
}
.section-defenses .ac-holder::before {
  content: "";
  grid-area: 1 / 1;
  background-color: var(--ui-action, #ff5722);
  mask: url("/assets/images/ui/armor-class-frame.svg") center / contain no-repeat;
  filter: var(--shop-glyph, none);
  pointer-events: none;
}
:root.light .section-defenses .ac-holder::before {
  background-color: var(--ui-action, #500000);
}

/* Align the desktop defenses and keep room for both shield rows. */
html[data-interface="desktop"] body .section-defenses {
  height: auto;
  min-height: 6.5em;
  align-items: center;
  --sheet-shield-track: var(--shop-chosen, var(--ui-surface, #2d3037));
  --sheet-shield-level: var(--shop-badge, var(--ui-muted, #3d4a5e));
  --sheet-shield-text: var(--ui-ink, #edf0f4);
}
html.light body .section-defenses {
  --sheet-shield-track: var(--shop-chosen, var(--ui-surface, #f3e8d3));
  --sheet-shield-level: var(--shop-badge, var(--ui-muted, #5b6b82));
  --sheet-shield-text: var(--ui-ink, #34241a);
}
:is(.section-defenses, .familiar-healthbar) {
  --sheet-hp-height: 34px;
}
html[data-interface="desktop"] body :is(.section-defenses, .familiar-healthbar) {
  --sheet-hp-fill: var(--shop-meter, var(--ui-action, #c64a45));
  --sheet-hp-track: var(--shop-meter-missing, var(--ui-surface, #3b2426));
}
html.light body :is(.section-defenses, .familiar-healthbar) {
  --sheet-hp-fill: var(--shop-meter, var(--ui-action, #a8322a));
  --sheet-hp-track: var(--shop-meter-missing, var(--ui-surface, #e4d2c2));
}
/* Use the painted width of the 76 x 86 shield with its 5 px stroke. */
.section-defenses .ac-holder {
  inline-size: calc(5.5em * 73 / 86);
}
.section-defenses .ac-holder > .ac-image { inline-size: 100%; }
.section-defenses .ac-holder::before { mask-size: auto 100%; }
.section-defenses .defense-lines {
  /* The two icons retain their pixel width when the text scales. */
  --saves-width: calc(30px + 6.7em);
  align-items: center;
}
html[data-interface="desktop"] body .section-defenses .defense-second-line {
  inline-size: max-content;
  max-inline-size: 100%;
  justify-self: end;
}
.section-defenses .saves-button {
  column-gap: .25em;
}
.section-defenses .saves-button > * { margin-inline: 0; }
.section-defenses .saves-button > .dice-proficiency { margin-inline-end: 0 !important; }
.section-defenses .saves-button > .section-skill-total {
  inline-size: auto;
}
.section-defenses .saves-button > .section-skill-name {
  white-space: normal;
  overflow-wrap: anywhere;
}
@media (min-width: 411px) {
  html[data-interface="desktop"] body .section-defenses .defense-lines {
    grid-template-columns: minmax(0, 1fr) var(--saves-width);
  }
}
.section-defenses .defense-top-line {
  --hp-height: 24px;
  --hp-motion: 400ms cubic-bezier(.2,.74,.22,1);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  padding-block-start: calc(var(--hp-height) + 4px);
}
.section-defenses .defense-top-line > .healthbar {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  z-index: 1;
  height: var(--sheet-hp-height);
  transform: translateY(-50%);
  transition: top var(--hp-motion), height var(--hp-motion), transform var(--hp-motion);
}
.section-defenses .defense-top-line > .shield-healthbar {
  height: 22px;
  margin: 0 !important;
}
.section-defenses .defense-top-line > .grid-container {
  display: grid;
  grid-template-columns: minmax(0, 9.4em) minmax(0, 5.6em) minmax(0, 1fr);
  grid-auto-flow: row;
  align-content: center;
  align-items: center;
  gap: .25em .65em;
  block-size: 2.6em;
  min-width: 0;
}
.section-defenses .defense-top-line > .grid-container > .grid-item {
  min-width: 0;
  margin: 0;
  line-height: 1.14;
  white-space: normal;
  overflow-wrap: anywhere;
}
.familiar-healthbar { height: var(--sheet-hp-height); }
.section-defenses :is(.healthbar, .shield-healthbar) > .progress-bar-container,
.familiar-healthbar > .progress-bar-container {
  grid-template-rows: 1fr;
  height: 100%;
}
.section-defenses :is(.healthbar, .shield-healthbar) .progress-bar-text,
.familiar-healthbar .progress-bar-text {
  display: flex;
  align-items: center;
  padding: 0 .45em;
}
:is(.section-defenses .healthbar, .familiar-healthbar) .progress-bar-container { background-color: var(--sheet-hp-track); }
:is(.section-defenses .healthbar, .familiar-healthbar) .progress-bar-red { background-color: var(--sheet-hp-fill); }
.section-defenses .shield-healthbar .progress-bar-container { background-color: var(--sheet-shield-track); }
.section-defenses .shield-healthbar .progress-bar-shield {
  background-color: color-mix(in srgb, var(--sheet-shield-level) 55%, var(--sheet-shield-track));
}
.section-defenses .shield-healthbar .progress-bar-text { color: var(--sheet-shield-text); }
.section-defenses .shield-healthbar:has(.progress-bar-shield.invisible) .progress-bar-text {
  visibility: hidden;
}
.section-defenses .defense-top-line > :is(.shield-healthbar, .grid-container) {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 220ms ease-in-out, transform 240ms ease-out, visibility 0ms 240ms;
}
/* The engine keeps the shield gauge in the DOM and toggles its invisible class. */
.section-defenses .defense-top-line:has(.progress-bar-shield:not(.invisible)) > .healthbar {
  top: 0;
  height: var(--hp-height);
  transform: none;
}
.section-defenses .defense-top-line:has(.progress-bar-shield:not(.invisible)) > :is(.shield-healthbar, .grid-container) {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition-delay: 160ms, 160ms, 0ms;
}
.section-defenses .defense-top-line:has(.progress-bar-shield:not(.invisible)) > .grid-container {
  transition-delay: 245ms, 245ms, 0ms;
}
@media (max-width: 550px) {
  .section-defenses .defense-top-line > .grid-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    block-size: 4.5em;
  }
  .section-defenses .defense-top-line > .grid-container > .div-button-simple {
    grid-column: 1 / -1;
    justify-self: start;
    inline-size: min(100%, 11em);
  }
}
@media (max-width: 410px) {
  html[data-interface="desktop"] body .section-defenses .defense-second-line { justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .section-defenses .defense-top-line > :is(.healthbar, .shield-healthbar, .grid-container) {
    transition: none;
  }
}

/* Character summary: controls above movement and the six ability modifiers. */
html[data-interface="desktop"] .section-top {
  --summary-divider: var(--ui-line, #2d4059);
  --summary-accent: var(--ui-action, #ff5722);
  --summary-planner-width: 124px;
}
html[data-interface="desktop"].light .section-top {
  --summary-divider: var(--ui-line, #d7bc95);
  --summary-accent: var(--ui-action, #500000);
}
html[data-interface="desktop"] .section-top > div {
  display: block !important;
  inline-size: 100%;
}
html[data-interface="desktop"] .section-top > div > div:first-child {
  display: grid;
  grid-template: "plan name level xp" / var(--summary-planner-width) minmax(0,1fr) 62px 64px;
  gap: 7px;
  reading-flow: grid-rows;
}
html[data-interface="desktop"] .section-top > div > div:first-child > div {
  min-inline-size: 0;
}
html[data-interface="desktop"] .section-top > div > div:first-child > div:first-child { grid-area: plan; }
html[data-interface="desktop"] .section-top > div > div:first-child > div:nth-child(2) { grid-area: level; }
html[data-interface="desktop"] .section-top > div > div:first-child > div:nth-child(3) { grid-area: xp; }
html[data-interface="desktop"] .section-top > div > div:first-child > div:has(> .button-name) {
  grid-area: name;
}
html[data-interface="desktop"] .section-top > div > div:first-child > div > :is(.div-button,.button-show-plan) {
  inline-size: 100% !important;
  block-size: 44px;
  min-block-size: 44px;
  max-block-size: 44px;
}
html[data-interface="desktop"] .section-top .button-show-plan {
  display: grid;
  grid-template-columns: 14px min-content;
  align-items: center;
  justify-content: start;
  gap: 8px;
  white-space: pre-line;
}
html[data-interface="desktop"] .section-top .button-show-plan::before {
  content: "";
  block-size: 14px;
  background: currentColor;
  mask: url("/assets/images/ui/icon_cog.png") center / contain no-repeat;
}
html[data-interface="desktop"] .section-top .button-show-plan[aria-expanded="true"] {
  background: transparent;
}
html[data-interface="desktop"] .section-top .button-show-plan[aria-expanded="false"] {
  border-color: color-mix(in srgb, var(--summary-accent) 32%, var(--summary-divider));
  box-shadow: 0 0 6px color-mix(in srgb, var(--summary-accent) 26%, transparent);
}
html[data-interface="desktop"] .section-top > div > :is(.speedsizerow,.speedsizerow.pb-aligned-abilities) {
  grid-template-columns: minmax(5.8em,.85fr) minmax(6.5em,1fr) repeat(6,minmax(0,.44fr));
  inline-size: 100%;
  padding-block-start: 6px;
  margin-top: 7px !important;
  border-block-start: 1px solid var(--summary-divider);
}
html[data-interface="desktop"] .section-top .speedsizerow .speed-size-img {
  height: 2.4em;
  width: auto;
}
html[data-interface="desktop"] .section-top .ability-span + .ability-span {
  border-inline-start: 1px solid var(--summary-divider);
}
@media (max-width: 600px) {
  html[data-interface="desktop"] .section-top > div > :is(.speedsizerow,.speedsizerow.pb-aligned-abilities) {
    grid-template-columns: repeat(6,minmax(0,1fr));
  }
}
@media (max-width: 520px) {
  html[data-interface="desktop"] .section-top > div > div:first-child {
    grid-template: "plan name" "level xp" / var(--summary-planner-width) minmax(0,1fr);
  }
}
