.portrait { overflow: hidden; vertical-align: middle; background: #e4edf3; }
.portrait svg { display: block; width: 100%; height: 100%; }
.portrait-initial { color: #58758b; }
.header-avatar-button { display: inline-flex; padding: 0; border-radius: 50%; background: none; flex-shrink: 0; }
.header-avatar-button .portrait { width: 36px; height: 36px; }
.header-avatar-button:hover { box-shadow: 0 0 0 3px #e8eef2; }
.account-identity { display: flex; align-items: center; gap: 8px; min-width: 0; }
.profile-avatar-row { display: flex; align-items: center; gap: 16px; padding: 16px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--wash); }
.profile-avatar-row .portrait { width: 64px; height: 64px; }
.profile-avatar-row p { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.person-heading .portrait { width: 42px; height: 42px; }
.avatar-dialog { padding: 0; border: 1px solid #e2e8ec; border-radius: 24px; width: min(900px, calc(100vw - 40px)); max-width: none; max-height: min(850px, calc(100dvh - 48px)); color: var(--ink); background: white; box-shadow: 0 24px 90px #26374429; }
.avatar-dialog::backdrop { background: #28374466; backdrop-filter: blur(5px); }
.avatar-dialog[open] { display: flex; flex-direction: column; }
.avatar-editor-heading { padding: 25px 30px 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.avatar-eyebrow { font-size: 10px; color: #8398a6; letter-spacing: .18em; margin-bottom: 5px; }
.avatar-editor-heading h2 { font-size: 25px; letter-spacing: .04em; }
.avatar-intro { margin-top: 5px; font-size: 12px; color: #7b8b97; }
.avatar-editor-body { display: grid; grid-template-columns: 285px minmax(0,1fr); min-height: 0; overflow: hidden; }
.avatar-preview-panel { padding: 32px 24px; background: #f4f7f9; text-align: center; border-right: 1px solid var(--line); }
.avatar-stage { position: relative; padding: 18px 6px 24px; }
.avatar-large { width: 208px; max-width: 100%; aspect-ratio: 1; margin: auto; overflow: hidden; border-radius: 50%; box-shadow: 0 9px 0 #dbe5eb66, 0 0 0 9px #ffffff; }
.avatar-large svg { display: block; width: 100%; height: 100%; }
.avatar-stage-spark { position: absolute; top: 1px; right: 5px; color: #a3b7c3; font-size: 29px; }
.avatar-stage-dot { position: absolute; bottom: 15px; left: 5px; width: 9px; height: 9px; border: 2px solid #bbccd6; border-radius: 50%; }
.avatar-preview-name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; margin-top: 13px; }
.avatar-preview-caption { font-size: 11px; color: #8a99a4; margin-top: 3px; }
.avatar-tools { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 24px 0; }
.avatar-tools .button { padding: 9px 16px; font-size: 12px; background: white; }
.avatar-size-preview { display: flex; align-items: center; justify-content: center; gap: 9px; border-top: 1px dashed #dbe4ea; padding-top: 20px; font-size: 11px; text-align: left; }
.avatar-size-preview > span:first-child { color: #8a99a4; white-space: nowrap; }
#avatar-mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 85px; }
.avatar-wardrobe { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.avatar-tabs { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); padding: 16px 20px 0; gap: 5px; flex-shrink: 0; border-bottom: 1px solid var(--line); }
.avatar-tab { padding: 9px 2px 12px; background: transparent; color: #80919d; font-size: 12px; border-bottom: 3px solid transparent; border-radius: 10px 10px 0 0; }
.avatar-tab > svg { display: block; width: 24px; height: 24px; margin: 0 auto 5px; }
.avatar-tab[aria-pressed="true"] { color: #46677e; background: #f0f5f8; border-bottom-color: #7695aa; font-weight: 600; }
.avatar-options { padding: 22px 24px 26px; overflow-y: auto; min-height: 0; height: 400px; overscroll-behavior: contain; scrollbar-width: thin; }
.avatar-option-section + .avatar-option-section { margin-top: 24px; }
.avatar-option-section h3 { font-size: 13px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; }
.avatar-option-section h3 > span { font-weight: 400; font-size: 11px; color: #8a99a4; }
.avatar-choice-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.avatar-choice { border: 2px solid #edf1f3; border-radius: 12px; background: #fafbfc; padding: 6px 5px 5px; min-width: 0; position: relative; }
.avatar-choice-picture { display: block; max-width: 71px; margin: auto; aspect-ratio: 1; border-radius: 9px; overflow: hidden; }
.avatar-choice-picture svg { width: 100%; height: 100%; display: block; }
.avatar-choice-label { display: block; font-size: 10px; color: #667d8d; margin-top: 5px; white-space: nowrap; }
.avatar-choice:hover { background: #edf3f7; }
.avatar-choice[aria-pressed="true"] { border-color: #6e90a8; background: #edf3f7; }
.avatar-choice[aria-pressed="true"]::after { content: '✓'; position: absolute; right: 3px; top: 3px; color: white; background: #6e90a8; font-size: 9px; width: 16px; height: 16px; border-radius: 50%; }
.avatar-swatches { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.avatar-swatch { padding: 5px 3px; background: none; border: 2px solid transparent; border-radius: 10px; }
.avatar-color-dot { display: block; width: 32px; height: 32px; margin: auto; border-radius: 50%; box-shadow: inset 0 0 0 1px #0000000d; }
.avatar-swatch[aria-pressed="true"] { border-color: #6e90a8; background: #f0f5f8; }
.avatar-swatch[aria-pressed="true"] .avatar-color-dot::after { content: '✓'; color: #fff; text-shadow: 0 1px 3px #283744; line-height: 32px; }
.avatar-editor-footer { padding: 18px 26px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-shrink: 0; }
.avatar-save-status { font-size: 11px; color: #8596a2; }
.avatar-editor-footer .form-error { margin: 0; font-size: 12px; max-width: 350px; }
.avatar-editor-footer .form-error:empty { display: none; }
.avatar-footer-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.avatar-footer-actions .button { padding: 10px 17px; font-size: 12px; white-space: nowrap; }
@media (max-width: 640px) {
  .account-identity { gap: 5px; }
  .header-avatar-button .portrait { width: 30px; height: 30px; }
  .avatar-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 20px); border-radius: 18px; }
  .avatar-editor-heading { padding: 16px 18px 12px; }
  .avatar-editor-heading h2 { font-size: 20px; }
  .avatar-eyebrow { font-size: 9px; }
  .avatar-intro { font-size: 10px; }
  .avatar-editor-body { display: flex; flex-direction: column; }
  .avatar-preview-panel { position: relative; display: grid; grid-template-columns: 114px minmax(0,1fr); align-items: center; padding: 14px 20px; gap: 0 16px; text-align: left; border-right: 0; border-bottom: 1px solid var(--line); flex-shrink: 0; }
  .avatar-stage { padding: 6px; grid-row: 1 / 4; }
  .avatar-large { width: 102px; box-shadow: 0 4px 0 #dbe5eb66, 0 0 0 5px white; }
  .avatar-stage-spark, .avatar-stage-dot, .avatar-size-preview { display: none; }
  .avatar-preview-name { font-size: 15px; margin: 0; align-self: end; }
  .avatar-preview-caption { font-size: 10px; }
  .avatar-tools { margin: 6px 0 0; justify-content: flex-start; gap: 12px; align-self: start; }
  .avatar-tools .button { padding: 6px 10px; font-size: 10px; }
  .avatar-tools .text-button { font-size: 11px; }
  .avatar-tabs { padding: 8px 10px 0; gap: 2px; }
  .avatar-tab { padding: 5px 1px 8px; font-size: 11px; }
  .avatar-tab > svg { width: 20px; height: 20px; margin-bottom: 4px; }
  .avatar-options { padding: 16px 14px; height: 300px; }
  .avatar-choice-grid { gap: 6px; }
  .avatar-choice { padding: 4px 3px; border-radius: 10px; }
  .avatar-choice-label { font-size: 9px; }
  .avatar-option-section + .avatar-option-section { margin-top: 18px; }
  .avatar-editor-footer { padding: 12px 15px; flex-direction: column; align-items: stretch; gap: 8px; }
  .avatar-footer-actions { justify-content: flex-end; }
  #avatar-reset { margin-right: auto; }
  .avatar-save-status { font-size: 10px; }
  .avatar-footer-actions .button { padding: 9px 14px; }
}
@media (max-height: 560px) and (min-width: 641px) {
  .avatar-preview-panel { padding: 12px 24px; }
  .avatar-large { width: 140px; }
  .avatar-size-preview, .avatar-preview-caption { display: none; }
  .avatar-tools { margin: 10px 0; }
  .avatar-editor-heading { padding: 12px 24px; }
}

.avatar-gender-bar { display: flex; align-items: center; gap: 13px; padding: 16px 24px 0; flex-shrink: 0; }
.avatar-gender-label { font-size: 11px; color: #8496a2; white-space: nowrap; }
.avatar-gender-options { display: flex; gap: 8px; }
.avatar-gender { display: flex; align-items: center; gap: 5px; padding: 6px 13px; border: 1.5px solid transparent; border-radius: 10px; font-size: 12px; }
.avatar-gender > span { font-size: 18px; line-height: 1.2; font-weight: 700; }
.avatar-gender.male { background: #eef5fb; color: #5282a9; border-color: #dfeaf3; }
.avatar-gender.female { background: #fcf0f4; color: #bc8097; border-color: #f0dee6; }
.avatar-gender.male[aria-pressed="true"] { background: #638bad; color: white; border-color: #638bad; box-shadow: 0 3px 0 #50718e; }
.avatar-gender.female[aria-pressed="true"] { background: #c48ba3; color: white; border-color: #c48ba3; box-shadow: 0 3px 0 #a97087; }
#avatar-wardrobe-count { margin-left: auto; color: #8b9da9; font-size: 10px; white-space: nowrap; }
@media (max-width: 640px) {
  .avatar-gender-bar { gap: 8px; padding: 10px 14px 4px; }
  .avatar-gender-options { gap: 7px; }
  .avatar-gender { padding: 5px 10px; font-size: 11px; }
  .avatar-gender > span { font-size: 17px; }
  #avatar-wardrobe-count { font-size: 9px; }
}
@media (max-height: 600px) {
  .avatar-intro { display: none; }
  .avatar-gender-bar { padding-top: 7px; }
  .avatar-tabs { padding-top: 4px; }
}

@media (max-width: 480px) {
  .site-header { flex-wrap: wrap; row-gap: 14px; }
  .site-header .header-right { margin-left: auto; }
  .history-shell .brand { display: none; }
}

/* Identity portraits stay beside names, leaving reading and action areas intact. */
.group-card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.group-avatar-stack { display: inline-flex; align-items: center; flex-shrink: 0; }
.portrait-group-card, .group-avatar-more { width: 32px; height: 32px; border: 2px solid white; flex-shrink: 0; font-size: 11px; }
.group-avatar-stack > * + * { margin-left: -9px; }
.group-avatar-more { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #edf2f5; color: #617e91; font-size: 10px; font-weight: 600; }
.history-entry-meta { align-items: center; }
.portrait-history { width: 24px; height: 24px; font-size: 10px; flex-shrink: 0; }
.history-author { color: #5d778a; }
.person-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.person-label > :last-child { min-width: 0; overflow-wrap: anywhere; }
.portrait-journal, .portrait-social { width: 32px; height: 32px; font-size: 13px; flex-shrink: 0; }
.portrait-comment { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
.social-person { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 130px; }
.social-copy .social-inviter { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.portrait-inviter { width: 24px; height: 24px; font-size: 10px; flex-shrink: 0; }
.notification-actor { display: flex; align-items: center; gap: 9px; min-width: 0; }
.notification-actor strong { min-width: 0; }
.portrait-notification { width: 28px; height: 28px; font-size: 11px; flex-shrink: 0; }
@media (max-width: 480px) {
  .person-label { gap: 6px; }
  .social-person { gap: 8px; }
  .social-row .social-actions { margin-left: auto; }
}
