.profile-heading { display: flex; align-items: center; justify-content: space-between; margin-block: 12px 6px; }
#roleDesk .profile-heading h3 { margin: 0; }
.profile-heading button { padding: 3px 8px; min-height: 25px; font-size: 12px; }
#profileVisual { max-width: 502px; margin-inline: auto; container: profile-card / inline-size; }
.profile-composition { position: relative; color: #39291f; }
.modern-paper, .classic-paper, .classic-points {
  position: relative;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.modern-paper {
  aspect-ratio: 502 / 541;
  --paper: url("/profile/character.png");
  --corner: 9%;
  --shoulder: 7%;
  --bottom: 96.67%;
}
/* Mirror the unused top-left frame over the close-button socket. Clip the
   two empty handles below the body without moving the native slot coordinates. */
.modern-paper::before, .modern-paper::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: var(--paper) center / 100% 100% no-repeat;
}
.modern-paper::before { clip-path: polygon(0 0,calc(100% - var(--corner) + 1px) 0,calc(100% - var(--corner) + 1px) var(--shoulder),100% var(--shoulder),100% var(--bottom),0 var(--bottom)); }
.modern-paper::after { background-color: white; transform: scaleX(-1); clip-path: inset(0 calc(100% - var(--corner)) calc(100% - var(--shoulder)) 0); }
.classic-paper { aspect-ratio: 210 / 350; background-image: url("/profile/classic.png"); }
.classic-points { aspect-ratio: 243 / 166; background-image: url("/profile/classic-points.png"); }
#profileVisual[data-skin=modern] :is(.classic-paper,.classic-points),
#profileVisual[data-skin=classic] .modern-paper { display: none; }
.profile-composition :is(dl,dt,dd) { margin: 0; }
.modern-paper dl {
  position: absolute;
  display: grid;
  grid-auto-rows: 1fr;
  font-size: clamp(.79rem, 2.7cqi, .97rem);
}
.modern-paper dl > div {
  display: grid;
  grid-template-columns: 27% minmax(0,1fr);
  align-items: center;
  min-height: 0;
}
.modern-paper :is(dt, dd) {
  min-width: 0;
  font-size: inherit;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.modern-paper dt { color: #5b4736; }
#profileInfo, #profileStats { left: 45.8%; width: 50.8%; }
#profileInfo { top: 11.46%; height: 33.64%; }
#profileStats { top: 57.67%; height: 28.84%; }
#profileStats dd { display: flex; align-items: baseline; gap: .45em; }
#profileStats small { font-size: .85em; font-weight: 400; color: #655241; overflow: hidden; text-overflow: ellipsis; }
#profilePoints { top: 51.2%; height: 4.25%; left: 47%; width: 39%; }
#profilePoints > div { grid-template-columns: 40% 1fr; }
#profileSkills {
  top: 87.2%; height: 5.2%; left: 45.8%; width: 50.8%;
  grid-template-columns: 1fr 1.4fr; gap: 6px; font-size: clamp(.69rem,2.4cqi,.86rem);
}
#profileSkills > div { grid-template-columns: auto minmax(0,1fr); gap: 4px; }
.profile-gear { position: absolute; inset: 0; pointer-events: none; }
.classic-paper dl > div, .classic-points dl > div, .profile-slot {
  width: var(--skin-width); height: var(--skin-height);
}
.profile-slot {
  pointer-events: auto;
  position: absolute;
  display: grid;
  place-items: center;
  background: #fff7e0b3;
  border: 0;
  border-radius: 4px;
  padding: 0;
  min-height: 0;
  font: 600 clamp(8px, 2cqi, 11px)/1 Consolas, monospace;
  overflow: hidden;
}
.profile-slot img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.profile-slot:has(img) { background: transparent; }
.profile-slot:is(:hover,:focus-visible) { outline: 2px solid #bd6721; }
.profile-outfit { grid-column: 1 / -1; width: 100%; }
.outfit-group:not(:has(button)) { display: none; }
.outfit-group h4 { margin: 6px 0 3px; font-size: .85rem; }
.outfit-group > div { display: flex; flex-wrap: wrap; gap: 3px; }
.outfit-group .profile-slot { position: static; width: 34px; height: 34px; border: 1px solid #c5b29f; }
@container profile-card (width > 373px) {
  [data-skin=modern] .profile-outfit { position: absolute; inset: 0; pointer-events: none; }
  [data-skin=modern] .outfit-group h4 { display: none; }
  [data-skin=modern] .outfit-group .profile-slot {
    position: absolute; width: var(--skin-width); height: var(--skin-height); border: 0;
  }
}
[data-skin=modern] .profile-actions { position: absolute; top: 70%; left: 3.6%; width: 38%; }
#roleDesk .profile-actions h3 { margin: 0 0 5px; color: #5c432f; font-size: .88rem; }
.profile-actions #assetActions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; }
.profile-actions button {
  min-height: 24px;
  padding: 3px 1px;
  border: 0;
  background: transparent url("/profile/action.png") center / 100% 100% no-repeat;
  color: #152b45;
  font-weight: 600;
  font-size: clamp(.78rem, 2.6cqi, .92rem);
}
.profile-actions button:enabled:hover { filter: brightness(1.12); }
.profile-actions button:disabled { opacity: .55; }
[data-skin=classic] .profile-composition {
  display: grid;
  grid-template-columns: minmax(0,210fr) minmax(0,243fr);
  gap: 6px;
  align-items: start;
}
.classic-paper { grid-row: span 2; }
.classic-paper dl > div, .classic-points dl > div {
  position: absolute; display: grid; align-items: center; min-width: 0;
}
.classic-paper dd, .classic-points dd {
  text-align: left; font: 600 clamp(.72rem, 2.6cqi, .93rem)/1.05 "Segoe UI",sans-serif;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
#profileDialog { width: min(590px, calc(100% - 24px)); }
#profileDialog h3 { margin: 12px 0 6px; }
#profileDialog .dialog-body > :first-child { margin-top: 0; }
#profileDialog #progressFields { grid-template-columns: repeat(auto-fit,minmax(min(8rem,100%),1fr)); }

@container profile-card (max-width: 373px) {
  .modern-paper {
    aspect-ratio: 308 / 412;
    max-width: 308px;
    margin-inline: auto;
    --paper: url("/profile/detail.png");
    --corner: 14%;
    --shoulder: 10%;
    --bottom: 100%;
  }
  .modern-paper dl { font-size: .88rem; }
  .modern-paper dl > div { grid-template-columns: 46% minmax(0,1fr); }
  #profileInfo, #profileStats { left: 8.8%; width: 82.5%; }
  #profileInfo { top: 13.1%; height: 44.17%; }
  #profileStats { top: 57.27%; height: 37.86%; }
  .modern-paper :is(#profilePoints,#profileSkills) { display: none; }
  [data-skin=modern] .profile-actions { position: static; width: auto; margin-top: 8px; }
  .profile-actions #assetActions { grid-template-columns: repeat(auto-fit,minmax(min(6rem,100%),1fr)); }
  [data-skin=classic] .profile-composition { grid-template-columns: 1fr; justify-items: center; }
  .classic-paper { grid-row: auto; width: min(210px,100%); }
  .classic-points { width: min(243px,100%); }
  .profile-actions { width: 100%; }
  .classic-paper dd,.classic-points dd { font-size: .85rem; }
}
.gear-clear-rows {display:grid;grid-template-columns:repeat(auto-fit,minmax(12em,1fr));gap:.35rem;max-height:55vh;overflow:auto;margin:.7rem 0}
.gear-clear-rows label {display:flex;align-items:center;gap:.4rem;padding:.35rem;border:1px solid #c8d6ca;border-radius:.3rem}
.gear-clear-rows img {width:30px;height:30px;object-fit:contain;image-rendering:pixelated}
.gear-clear-rows input {width:auto}
.clear-slot-list {max-height:48vh;overflow:auto}
.clear-slot-list p {margin:.4rem 0;padding-bottom:.35rem;border-bottom:1px solid #d3ddd5}
button.clear-danger {color:#9a2b22;border-color:#c69184}
