.profile-form .form-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 15rem);
  align-items: center;
  gap: 12px 24px;
  overflow: visible;
  margin: 0 0 20px;
  padding: 0 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.profile-form .form-heading::after { content: none; }
.profile-form .form-heading h1 { font-family: var(--sans); }
.form-heading .character-name { max-width: none; margin: 0; }
.profile-form input:not([type]), .profile-form textarea { border-color: #adbec3; border-radius: 4px; background: #fdfefe; }

.character-studio {
  --studio-light: #f9fcfd;
  --studio-frost: #e4f1f4;
  --studio-edge: #b9ccd1;
  --studio-focus: #197783;
  display: grid;
  grid-template: "stage workbench" / minmax(240px, .92fr) minmax(0, 1.15fr);
  gap: 22px;
  align-items: start;
}

.character-stage {
  grid-area: stage;
  position: sticky;
  top: 12px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
}

.character-viewport {
  position: relative;
  padding: 4px;
  border: 1px solid var(--studio-edge);
  background: var(--studio-light);
}

.character-viewport::after {
  position: absolute;
  inset: 8px;
  border: 1px solid #ffffff75;
  pointer-events: none;
  content: "";
}

.character-stage .avatar-art { border: 0; border-radius: 0; }
.character-stage .avatar-art:where([data-renderer="3d"]) { cursor: grab; touch-action: pan-y; }
.character-stage .avatar-art.is-rotating { cursor: grabbing; }

.character-stage-controls, .character-playback, .character-turn, .character-motion, .character-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.character-stage-controls {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 9px 0 0;
}

.character-playback { flex-wrap: wrap; }
.character-turn, .character-motion { flex-basis: auto; }
.character-stage .studio-key {
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid var(--studio-edge);
  border-radius: 4px;
  background: var(--studio-light);
  box-shadow: 0 1px 0 #203e4a1a;
  color: var(--ink);
  font-size: .79rem;
  white-space: nowrap;
}

.character-stage .studio-key:hover { border-color: var(--studio-focus); background: var(--studio-frost); filter: none; }
.character-stage .studio-key[aria-pressed="true"] { border-color: var(--studio-focus); background: var(--studio-frost); box-shadow: inset 0 -2px var(--studio-focus); }
.character-stage .studio-key[aria-disabled="true"] { border-color: var(--line); background: transparent; box-shadow: none; color: var(--muted); cursor: default; }
.character-stage .studio-key.turn-button { width: 34px; padding: 2px; font-size: 1.17rem; }
.character-stage :focus-visible { outline-color: var(--studio-focus); }
.character-announcement { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.character-workbench {
  grid-area: workbench;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.character-categories {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0 3px;
  padding: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8fbfc8c;
}

.character-categories .character-category {
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 62px;
  padding: 5px 1px 7px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 -1px #cad8dc8a;
  color: var(--ink);
  font-size: .8rem;
  text-align: center;
}

.character-categories .character-category:hover,
.character-categories .character-category[aria-selected="true"] { background: var(--studio-frost); filter: none; }
.character-categories .character-category[aria-selected="true"] { box-shadow: inset 0 -3px var(--studio-focus); }
.character-categories .character-category:focus-visible { outline: 2px solid var(--studio-focus); outline-offset: -3px; }
.character-category .category-icon { width: 29px; height: 29px; padding: 2px; border: 0; border-radius: 0; background: transparent; }

.character-panel { min-width: 0; padding: 15px 0 0; }
.character-panel:focus-visible { outline: 2px solid var(--studio-focus); outline-offset: 3px; }
.character-panel h2 { margin: 0 0 12px; font: 750 1.22rem/1.15 var(--sans); }
.character-field { margin: 0 0 13px; }
.character-field legend, .character-slider { font-size: .86rem; }
.character-color-name { margin-left: 6px; color: var(--muted); }
.character-options { gap: 4px 7px; margin-top: 5px; }

.character-studio .character-chip {
  min-height: 40px;
  height: 100%;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: .81rem;
  line-height: 1.18;
  text-align: center;
}

.character-studio .character-option:hover .character-chip { border-color: var(--studio-edge); background: #f1f8f9; }
.character-studio .character-option input:checked + .character-chip {
  border-color: transparent;
  border-bottom-color: var(--studio-focus);
  background: var(--studio-frost);
  box-shadow: inset 0 -2px var(--studio-focus);
}

.character-studio .character-option input:focus-visible + .character-chip { outline: 2px solid var(--studio-focus); outline-offset: 1px; }
.character-studio .option-previews { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.character-studio .option-previews .character-chip { align-content: start; gap: 5px; padding: 3px 3px 7px; font-size: .75rem; }
.character-studio .option-previews .avatar-art { border-radius: 0; }
.character-studio .color-options { gap: 1px; }
.character-studio .color-options .character-chip { width: 41px; min-height: 41px; border-bottom-color: transparent; padding: 0; }
.character-studio .color-options .character-chip::before { width: 25px; height: 25px; }
.character-studio .color-options input:checked + .character-chip { border-color: var(--studio-focus); box-shadow: inset 0 0 0 1px var(--studio-focus); }

.character-studio .hairstyle-filters, .character-studio .wardrobe-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 0 3px;
  border-bottom: 1px solid var(--line);
}

.character-studio :is(.hairstyle-filter, .wardrobe-group) {
  min-width: 0;
  min-height: 37px;
  padding: 5px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: .79rem;
}

.character-studio :is(.hairstyle-filter, .wardrobe-group):hover { background: #f1f8f9; filter: none; }
.character-studio :is(.hairstyle-filter, .wardrobe-group)[aria-pressed="true"] { box-shadow: inset 0 -2px var(--studio-focus); color: var(--ink); }
.character-studio :is(.hairstyle-filter, .wardrobe-group):focus-visible { outline: 2px solid var(--studio-focus); outline-offset: -2px; }
.character-studio .wardrobe-groups { margin-bottom: 12px; }
.character-studio .tuning-grid { margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--line); }
.character-panel h2 + .tuning-grid { margin-top: 0; padding-top: 0; border: 0; }
.character-studio .character-slider input { accent-color: var(--studio-focus); }

.profile-form .form-fold {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.profile-form .form-fold:first-of-type { margin-top: 20px; }
.profile-form .form-fold + .form-fold { border-bottom: 1px solid var(--line); }
.profile-form .form-fold summary { min-height: 52px; gap: 10px; padding: 6px 9px; border-radius: 0; }
.profile-form .form-fold summary:hover { background: #f8fcfd; }
.profile-form .form-fold summary:focus-visible { outline-offset: -2px; }
.profile-form .form-fold summary::after { border-color: var(--accent); }
.profile-form .fold-icon { width: 29px; height: 29px; border-radius: 0; background: transparent; }
.profile-form .fold-icon-gift::after { top: 4px; left: 7px; }
.profile-form .fold-title { font-size: 1.03rem; font-weight: 700; }
.profile-form .fold-fields { padding: 5px 9px 15px; }
.profile-form .color-choice { border-radius: 3px; background: #f9fcfd; }
.profile-form .color-choice[aria-pressed="true"] { border-color: var(--accent); background: #e4f1f4; box-shadow: inset 0 -2px var(--accent); }
.profile-form .remove { margin: 10px 0 0; }
.profile-form-footer { background: #f5fafb; }

@media (max-width: 850px) {
  .character-stage-controls { justify-content: flex-start; }
}

@media (max-width: 730px) {
  .character-studio { grid-template: "stage" "workbench" / minmax(0, 1fr); gap: 10px; }
  .character-stage {
    top: 0;
    grid-template-columns: minmax(0, 204px) minmax(116px, 146px);
    justify-content: center;
    gap: 9px;
    padding: 7px 0 8px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
  }
  .character-stage-controls, .character-playback { display: grid; gap: 5px; padding: 0; }
  .character-stage-controls { align-content: center; justify-content: stretch; }
  .character-turn, .character-motion, .character-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .character-stage .studio-key { min-height: 37px; padding: 3px 4px; }
  .character-stage .studio-key.turn-button { width: 100%; }
  .character-categories .character-category { min-height: 52px; }
  .character-category .category-icon { width: 25px; height: 25px; }
  .character-categories .character-category, .character-studio .character-panel,
  .character-studio .character-panel :is(button, input, .character-option) { scroll-margin-top: 229px; }
}

@media (max-width: 510px) {
  .profile-form .form-heading { grid-template-columns: 1fr; gap: 9px; margin-bottom: 8px; padding-bottom: 11px; }
  .character-categories .character-category { font-size: .73rem; }
  .character-studio .character-panel { padding: 12px 0 0; }
  .character-studio .option-previews:has(> :nth-child(6):last-child) { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .character-studio .option-previews:has(> :nth-child(7):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 359px) {
  .character-categories { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .character-stage { grid-template-columns: minmax(0, 1fr) 116px; }
  .character-studio .option-previews:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-height: 550px) {
  .character-stage { position: static; }
  .character-categories .character-category, .character-studio .character-panel,
  .character-studio .character-panel :is(button, input, .character-option) { scroll-margin-top: 0; }
}
