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-box {
  grid-column: 1;
  grid-row: 1 / 5;
  align-self: center;
  justify-self: start;
}

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;
}

header .header-tools-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  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-portrait-box {
  position: relative;
  width: 124px;
  aspect-ratio: 3 / 4;
  padding: 6px;
  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;
}

.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;
}

.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;
}

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

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

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

.header-portrait-sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.header-portrait-sliders input[type="range"] {
  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-box {
    grid-row: 1 / 4;
  }

  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;
  }

  header.has-header-editor > .header-portrait-box {
    width: 84px;
    padding: 4px;
  }

  .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;
  }

  header.has-header-editor > .header-portrait-box {
    width: 74px;
    padding: 4px;
  }
}

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

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