header.has-header-editor {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  column-gap: 24px;
  align-items: start;
  padding-right: 22px;
}

header.has-header-editor > .header-portrait-col,
header.has-header-editor > .header-portrait-box {
  grid-column: 1;
  grid-row: 1 / 5;
  align-self: center;
  justify-self: start;
}

header.has-header-editor > .header-portrait-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: var(--pg-portrait-width, 124px);
  flex-shrink: 0;
}

.header-brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--pg-portrait-width, 124px);
  padding: 2px 3px 0;
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
}

.header-brand-mark[hidden] {
  display: none !important;
}

.header-brand-mark-img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  filter:
    drop-shadow(0 2px 5px rgba(8, 5, 8, 0.85))
    drop-shadow(0 0 10px rgba(18, 12, 16, 0.55));
}

header.has-header-editor > small {
  grid-column: 2 / -1;
  grid-row: 1;
  padding-right: 48px;
}

header.has-header-editor > h1 {
  grid-column: 2 / -1;
  grid-row: 2;
  padding-right: 48px;
}

header.has-header-editor > p {
  grid-column: 2 / -1;
  grid-row: 3;
  max-width: 600px;
  margin-bottom: 0;
  padding-right: 48px;
}

header.has-header-editor > small,
header.has-header-editor > h1,
header.has-header-editor > p {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.88), 0 1px 3px rgba(0, 0, 0, 0.94);
}

header.has-header-editor > .header-campaign-badges {
  grid-column: 2;
  grid-row: 4;
  align-self: end;
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 12px;
  min-width: 0;
}

header.has-header-editor > .header-campaign-badges[hidden] {
  display: none !important;
}

.header-campaign-badges-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.header-campaign-badge-detail,
.mpg-card-badge-detail {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid #8a724d;
  background: rgba(20, 17, 23, 0.94);
  color: #f3e6ce;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55);
  max-width: 100%;
  overflow-wrap: anywhere;
}

.header-campaign-badge-detail[hidden],
.mpg-card-badge-detail[hidden] {
  display: none !important;
}

header.has-header-editor > .header-tools-wrap {
  grid-column: 3;
  grid-row: 4;
  align-self: end;
  justify-self: end;
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

header .header-tools-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  min-height: 36px;
  padding: 7px 12px;
  background: linear-gradient(160deg, #2b2328, #18171c);
  border: 1px solid #96784f;
  border-radius: 6px;
  color: var(--gold, #d8b476);
  box-shadow: 0 4px 12px #0006;
}

header .header-tools-btn:hover,
header .header-tools-btn:focus-visible {
  background: #443139;
  border-color: var(--gold, #d8b476);
  color: #f6e3be;
}

header .header-tools-btn svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

header .header-save-session-btn,
header .header-switch-pg-btn,
header .header-guide-btn,
header .header-sidebar-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 7px;
  cursor: pointer;
  box-shadow: 0 4px 12px #0006;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.12s ease;
}

header .header-save-session-btn {
  background: linear-gradient(155deg, #214a37 0%, #143023 100%);
  border: 1px solid #7fb88f;
  color: #b5e6c3;
}

header .header-save-session-btn:hover,
header .header-save-session-btn:focus-visible {
  background: linear-gradient(155deg, #2b5f47 0%, #1b3f2f 100%);
  border-color: #b4e4c2;
  color: #ffffff;
  transform: translateY(-1px);
}

header .header-save-session-btn.is-saved {
  background: linear-gradient(155deg, #2d6a4e 0%, #1d4734 100%);
  border-color: #c5f0d1;
  color: #ffffff;
}

header .header-save-session-btn:disabled {
  opacity: 0.78;
  cursor: wait;
  transform: none;
}

header .header-switch-pg-btn {
  background: linear-gradient(155deg, #5d262f 0%, #37161d 100%);
  border: 1px solid rgba(232, 138, 146, 0.72);
  color: #f8bcc2;
}

header .header-switch-pg-btn:hover,
header .header-switch-pg-btn:focus-visible {
  background: linear-gradient(155deg, #742f3a 0%, #481d25 100%);
  border-color: #f4a8b0;
  color: #ffe8ea;
  transform: translateY(-1px);
}

header .header-guide-btn {
  background: linear-gradient(155deg, #28303e 0%, #171b24 100%);
  border: 1px solid #96a7c2;
  color: #dce4f4;
}

header .header-guide-btn:hover,
header .header-guide-btn:focus-visible {
  background: linear-gradient(155deg, #364155 0%, #212836 100%);
  border-color: #d7e2f5;
  color: #ffffff;
  transform: translateY(-1px);
}

header .header-guide-btn.is-active {
  background: linear-gradient(155deg, #4b2b36 0%, #291821 100%);
  border-color: #eccd92;
  color: #fff3d8;
  box-shadow: 0 0 0 1px rgba(236, 205, 146, 0.35), 0 4px 12px #0006;
}

header .header-sidebar-toggle-btn {
  background: linear-gradient(160deg, #2e2128, #19161d);
  border: 1px solid #a68553;
  color: var(--gold, #d8b476);
}

header .header-sidebar-toggle-btn:hover,
header .header-sidebar-toggle-btn:focus-visible {
  background: linear-gradient(160deg, #4b2d37, #271b21);
  border-color: #edd09a;
  color: #fff2d6;
  transform: translateY(-1px);
}

header .header-sidebar-toggle-btn.is-collapsed {
  border-color: #d8b476;
  background: linear-gradient(160deg, #462831, #24171c);
  color: #ffe8ba;
}

header .header-save-session-btn svg,
header .header-switch-pg-btn svg,
header .header-guide-btn svg,
header .header-sidebar-toggle-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-focal-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #f6d99a;
  background: rgba(24, 15, 20, 0.52);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.65), 0 0 10px rgba(246, 217, 154, 0.6);
  transform: translate(-50%, -50%) scale(0.75);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.is-adjusting > .header-focal-dot,
.is-adjusting .header-portrait-inner > .header-focal-dot {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Collapsible Left Sidebar */
body.mpg-nav-collapsed > .shell {
  grid-template-columns: minmax(0, 1fr) !important;
}

body.mpg-nav-collapsed > .shell > nav {
  display: none !important;
}

body.mpg-nav-collapsed > .shell > main {
  max-width: 100%;
}

:root {
  --pg-portrait-width: 124px;
  --pg-portrait-ratio: 3 / 4;
  --pg-portrait-frame-padding: 6px;
}

.header-portrait-box {
  position: relative;
  width: var(--pg-portrait-width);
  aspect-ratio: var(--pg-portrait-ratio);
  padding: var(--pg-portrait-frame-padding);
  border-radius: 9px;
  background: linear-gradient(145deg, #c69f61, #5a4326 42%, #8e6c3b 72%, #e0be80);
  box-shadow: 0 10px 26px #0009, inset 0 0 0 1px #f8dca555;
  flex-shrink: 0;
  box-sizing: border-box;
}

.header-portrait-box::before,
.header-portrait-box::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid #1d1519cc;
  border-radius: 7px;
  pointer-events: none;
}

.header-portrait-box::after {
  inset: -3px;
  border: 1px solid #b58d524d;
  border-radius: 11px;
}

.header-portrait-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid #352528;
  background: radial-gradient(circle at 50% 35%, #2d2028, #121116 80%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-portrait-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
}

.header-portrait-img[hidden] {
  display: none !important;
}

.header-portrait-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  text-align: center;
  color: #b49768;
}

.header-portrait-placeholder[hidden] {
  display: none !important;
}

.header-portrait-placeholder svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  opacity: .85;
}

.header-portrait-placeholder span {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #b6b0a6;
}

header .header-pencil {
  position: absolute;
  top: 22px;
  right: 20px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 5px;
  background: #17151ccc;
  border: 1px solid #ac8b5599;
  border-radius: 6px;
  color: var(--gold, #d8b476);
  cursor: pointer;
}

header .header-pencil:hover,
header .header-pencil:focus-visible {
  background: #443139;
  border-color: var(--gold, #d8b476);
}

header .header-pencil svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.header-editor-dialog {
  max-width: 740px;
}

.header-editor-dialog > form > label {
  margin-bottom: 12px;
}

.header-editor-dialog p {
  font: 13px/1.6 system-ui, sans-serif;
  color: var(--muted, #b6b0a6);
}

.header-editor-dialog textarea {
  min-height: 110px;
}

.header-portrait-editor {
  margin: 18px 0 8px;
  padding: 14px;
  border: 1px solid #675845;
  border-radius: 7px;
  background: #16141a99;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.header-portrait-editor h3 {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--gold, #d8b476);
}

.header-portrait-controls {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  max-width: 100%;
  min-width: 0;
}

.header-portrait-preview-frame {
  width: 116px;
  max-width: 100%;
}

.header-portrait-fields {
  min-width: 0;
  max-width: 100%;
}

.header-portrait-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  max-width: 100%;
}

.header-portrait-sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.header-portrait-sliders label {
  margin: 0;
  font-size: 12px;
  min-width: 0;
}

.header-portrait-sliders input[type="range"] {
  width: 100%;
  max-width: 100%;
  margin: 6px 0 2px;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--gold, #d8b476);
}

.header-portrait-reset-pos {
  margin-top: 8px;
  font-size: 12px;
  padding: 6px 10px;
}

.header-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.header-editor-backup {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #675845;
}

.header-editor-backup label {
  margin-top: 10px;
}

.header-sr-file {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

#status,
#warning {
  display: none !important;
}

#status.change-notice:not(:empty) {
  display: block !important;
  background: #ffe082 !important;
  color: #111 !important;
  border: 1px solid #d7aa29;
  border-radius: 6px;
  padding: 10px 13px;
  margin: 12px 0;
  line-height: 1.5;
  font-size: 13px;
}

#warning.has-warning:not(:empty) {
  display: block !important;
}

#warning.has-warning .banner {
  background: #ffe082 !important;
  color: #111 !important;
  border-color: #d7aa29 !important;
}

.notice {
  display: none !important;
}

@media (max-width: 760px) {
  header.has-header-editor {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    padding: 20px 14px 18px 14px;
    column-gap: 14px;
  }

  header.has-header-editor > .header-portrait-col,
  header.has-header-editor > .header-portrait-box {
    grid-row: 1 / 4;
  }

  header.has-header-editor > .header-portrait-col {
    gap: 6px;
  }

  header.has-header-editor > small,
  header.has-header-editor > h1,
  header.has-header-editor > p {
    padding-right: 44px;
  }

  header.has-header-editor > .header-campaign-badges {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 12px;
  }

  header.has-header-editor > .header-tools-wrap {
    grid-column: 1 / -1;
    grid-row: 5;
    margin-top: 12px;
  }

  header.has-header-editor > small {
    letter-spacing: 2px;
  }

  header.has-header-editor > h1 {
    font-size: clamp(20px, 5vw, 32px);
  }

  header .header-pencil {
    right: 14px;
    top: 16px;
    width: 34px;
    height: 34px;
  }

  :root {
    --pg-portrait-width: 84px;
    --pg-portrait-frame-padding: 4px;
  }

  header.has-header-editor > .header-portrait-col {
    width: var(--pg-portrait-width);
  }

  header.has-header-editor > .header-portrait-box,
  header.has-header-editor > .header-portrait-col > .header-portrait-box {
    width: var(--pg-portrait-width);
    padding: var(--pg-portrait-frame-padding);
  }

  .header-brand-mark {
    max-width: var(--pg-portrait-width);
    padding: 1px 1px 0;
  }

  .header-portrait-preview-frame {
    width: 104px;
  }

  header .header-tools-btn {
    font-size: 12px;
    padding: 6px 10px;
  }

  .header-portrait-sliders {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .header-portrait-controls {
    grid-template-columns: 1fr;
  }

  .header-portrait-preview-frame {
    margin: 0 auto;
  }
}

@media (max-width: 440px) {
  header.has-header-editor {
    padding: 18px 14px 16px 14px;
    column-gap: 12px;
  }

  header.has-header-editor > small,
  header.has-header-editor > h1,
  header.has-header-editor > p {
    padding-right: 40px;
  }

  header.has-header-editor > small {
    font-size: 11px;
    letter-spacing: 1.5px;
  }

  header.has-header-editor > h1 {
    font-size: 20px;
    letter-spacing: 1px;
  }

  header.has-header-editor > p {
    font-size: 13px;
    line-height: 1.45;
  }

  :root {
    --pg-portrait-width: 74px;
    --pg-portrait-frame-padding: 4px;
  }

  header.has-header-editor > .header-portrait-col {
    width: var(--pg-portrait-width);
    gap: 5px;
  }

  header.has-header-editor > .header-portrait-box,
  header.has-header-editor > .header-portrait-col > .header-portrait-box {
    width: var(--pg-portrait-width);
    padding: var(--pg-portrait-frame-padding);
  }
}

@media print {
  header .header-pencil,
  header .header-tools-wrap,
  header .header-campaign-badges,
  header .header-brand-mark,
  .header-editor-dialog,
  #status,
  #warning,
  .header-portrait-box.is-empty {
    display: none !important;
  }

  header.has-header-editor {
    padding-right: 0;
    column-gap: 16px;
  }
}
