/* Match the game's detail panel: portrait, tabs, affinities, base bars. */
.homunculus-picker-search-row {display:grid;grid-template-columns:minmax(0,1fr) minmax(130px,180px);gap:12px;margin-bottom:12px}
.homunculus-picker-search-row>.homunculus-picker-search,.homunculus-picker-race {display:flex;flex-direction:column;gap:6px;min-width:0;margin:0;font-size:12px}
.homunculus-picker-search-row input,.homunculus-picker-race select {width:100%;min-width:0;min-height:44px;box-sizing:border-box}
@media(max-width:680px){.homunculus-picker-search-row {grid-template-columns:minmax(0,1fr) 140px;gap:8px}.homunculus-picker-race select {font-size:16px}}
@media(max-width:360px){.homunculus-picker-search-row {grid-template-columns:minmax(0,1fr) 130px}}
.homunculus-choice-metric {display:flex;flex-direction:column;align-items:center;gap:2px;max-width:100%;color:#d8cee5;font-size:11px;line-height:1.35;overflow-wrap:anywhere}
.homunculus-choice-metric strong {color:#f8cf7d;font-size:14px;font-variant-numeric:tabular-nums;line-height:1.4}
.homunculus-choice-metric strong.is-unavailable {color:#beb4d0;font-size:12px;font-weight:400}
.homunculus-picker-conditions {margin:0;padding:0;border:0}
.homunculus-picker-conditions>summary,.homunculus-condition-done {display:none}
.homunculus-condition-active[hidden],.homunculus-picker-basis[hidden] {display:none!important}
dialog.homunculus-picker.is-preview,.party-page dialog.homunculus-picker.is-preview {width:720px;height:min(840px,calc(100dvh - 32px));padding:18px;background:#1f1b2b;color:#f5f0ff;border-color:#7e7191;color-scheme:dark}
.is-preview .homunculus-picker-header {position:static;margin:0 0 12px;padding:0;background:#1f1b2b;color:#f5f0ff}
.is-preview .homunculus-picker-header h2 {font-size:20px;color:#f5f0ff}
.is-preview .homunculus-picker-close,.is-preview .homunculus-preview-back,.is-preview .homunculus-preview-retry {background:#12101b;color:#f5f0ff;border-color:#7e7191}
.is-preview .homunculus-picker-close:hover,.is-preview .homunculus-preview-back:hover {background:#3f354e}
.is-preview .homunculus-preview {display:flex;flex:1;flex-direction:column;overflow:hidden;padding:0;scrollbar-gutter:auto;min-height:0}
.homunculus-preview-intro {display:flex;flex-direction:column;align-items:center;gap:4px;margin:0 0 12px;padding:8px;border:1px solid #374151;border-radius:7px;background:#12101b;flex-shrink:0}
.homunculus-preview-portrait {display:grid;place-items:center;position:relative;overflow:hidden;flex-shrink:0;width:128px;height:116px}
.homunculus-preview-portrait img {position:absolute;inset:0;width:100%;height:100%;object-fit:contain;padding:4px}
.profile-portrait-fallback {display:grid;place-items:center;min-width:64px;min-height:64px;border:1px solid #4b415c;border-radius:8px;color:#d8cee5;background:#292236;font-size:24px;font-weight:700}
.profile-portrait-fallback[hidden] {display:none!important}
.profile-comparison-note {flex-shrink:0;padding:0 2px 10px;color:#c7bbd6;font-size:11px;line-height:1.6}
.profile-comparison-note p {display:flex;justify-content:space-between;gap:4px 12px;flex-wrap:wrap;margin:0 0 3px;color:#f1e9fa;font-size:12px}
.profile-comparison-note small {font-size:11px}
.homunculus-preview-rank {display:flex;align-items:center;gap:8px;margin:2px 0 4px;font-size:11px;color:#beb4d0;line-height:1.5}
.homunculus-preview-rank strong {background:#f5b346;color:#23180c;border-radius:4px;padding:2px 10px;font-size:14px}
.profile-races {display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:5px 8px;max-width:100%;font-size:12px;line-height:1.5}
.profile-race-label,.profile-race-empty {color:#beb4d0}
.profile-race-list {display:flex;justify-content:center;flex-wrap:wrap;gap:5px;min-width:0;max-width:100%;list-style:none;margin:0;padding:0}
.profile-race-list li {margin:0;padding:2px 8px;border:1px solid #61576e;border-radius:4px;background:#292236;color:#f5f0ff;overflow-wrap:anywhere}
.profile-tabs {display:flex;gap:4px;flex-shrink:0}
.profile-tabs button {min-height:42px;padding:9px 18px;border:1px solid #374151;border-bottom:0;border-radius:5px 5px 0 0;background:#12101b;color:#beb4d0;font-size:13px;font-weight:650}
.profile-tabs button[aria-selected=true] {background:#2a2436;color:#c79af0;border-color:#6b607c}
.profile-tabs button span {font-size:11px;margin-left:5px;color:#beb4d0}
.profile-tab-body {flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:12px;background:#2a2436;border:1px solid #6b607c;border-radius:0 6px 6px 6px;scrollbar-color:#7e7191 #1f1b2b;scrollbar-gutter:stable}
.profile-tab-body [hidden] {display:none!important}
.profile-affinities {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin-bottom:12px}
.profile-game-panel {min-width:0;border:1px solid #374151;border-radius:7px;background:#12101b;padding:12px}
.homunculus-preview .profile-game-panel h3 {display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 0 10px;font-size:15px;font-weight:700;color:#f5f0ff;line-height:1.4}
.profile-info {display:grid;place-items:center;width:16px;height:16px;border:1px solid #7e7191;border-radius:50%;font-size:10px;line-height:1;color:#beb4d0;font-weight:400;cursor:help}
.profile-affinity-list {margin:0;font-size:13px;line-height:1.6;font-variant-numeric:tabular-nums}
.profile-affinity-list>div {display:flex;justify-content:space-between;align-items:baseline;gap:8px;margin:3px 0}
.profile-affinity-list dt {min-width:0;overflow-wrap:anywhere;color:#f5f0ff}
.profile-affinity-list dd {margin:0;white-space:nowrap;font-weight:600}
.affinity-good {color:#4ade80}.affinity-bad {color:#f87171}.affinity-boost {color:#f5b346}.affinity-immune {color:#22d3ee}.affinity-neutral {color:#beb4d0}
.profile-empty {text-align:center;color:#9c93aa;font-size:12px;margin:12px 0}
.profile-base-bars {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px 16px}
.profile-stat-row {display:flex;align-items:center;gap:8px;min-width:0}
.profile-stat-label {font-size:13px;font-weight:700;width:32px;flex-shrink:0;text-align:right}
.stat-hp .profile-stat-label {color:#4ade80}.stat-atk .profile-stat-label {color:#f87171}.stat-mtk .profile-stat-label {color:#c084fc}.stat-def .profile-stat-label {color:#60a5fa}.stat-mdf .profile-stat-label {color:#2dd4bf}.stat-spd .profile-stat-label {color:#facc15}
.profile-stat-meter {flex:1;position:relative;height:22px;min-width:0;overflow:hidden;background:#1f2937;border-radius:3px}
.profile-stat-meter svg {display:block;width:100%;height:100%}
.profile-promotion-fill {fill:#818cf8}
.profile-stat-value {position:absolute;inset:0;display:flex;align-items:center;justify-content:flex-end;padding-right:6px;font-size:12px;font-weight:700;font-variant-numeric:tabular-nums;color:#fff;text-shadow:0 1px 2px #000,0 0 3px #000;white-space:nowrap}
.profile-stat-value small {font-size:10px}.profile-stat-value small span {color:#c7d2fe}
.profile-promotion-key {display:flex;align-items:center;gap:6px;justify-content:flex-end;font-size:10px;color:#beb4d0;margin:10px 0 0}
.profile-promotion-key>span {width:10px;height:10px;background:#818cf8;border-radius:2px}
.profile-footnote {font-size:11px;line-height:1.7;color:#beb4d0;margin:10px 2px 0}
.profile-game-skills {display:flex;flex-direction:column;gap:8px}
.profile-game-skills details {border:1px solid #4b5563;border-radius:5px;background:#211b2c;overflow:hidden}
.profile-game-skills summary {display:flex;align-items:center;gap:8px;min-height:46px;padding:9px;cursor:pointer;list-style:none}
.profile-game-skills summary::-webkit-details-marker {display:none}
.profile-game-skills summary::after {content:none;display:none}
.profile-game-skills summary:hover {background:#3f354e}
.profile-game-skills summary>strong {flex:1;min-width:0;font-size:13px;font-weight:650;color:#f5f0ff;overflow-wrap:anywhere}
.profile-skill-badge {font-size:10px;line-height:1.4;font-weight:600;padding:3px 5px;border:1px solid;border-radius:3px;white-space:nowrap}
.profile-skill-badge.skill-attack {background:#78350f80;border-color:#92400e;color:#fcd34d}
.profile-skill-badge.skill-active {background:#7f1d1d80;border-color:#991b1b;color:#fca5a5}
.profile-skill-badge.skill-passive {background:#1e3a8a80;border-color:#2563eb;color:#93c5fd}
.profile-rank6-skill {font-size:10px;color:#c79af0;white-space:nowrap}
.profile-skill-chevron {color:#beb4d0;font-size:16px;font-weight:700;flex-shrink:0}
.profile-game-skills details[open] .profile-skill-chevron {transform:rotate(180deg)}
.profile-skill-description {border-top:1px solid #4b5563;padding:10px 12px;background:#12101b;font-size:13px;line-height:1.8;color:#f5f0ff}
.profile-skill-description p {margin:0 0 8px;white-space:pre-line;overflow-wrap:anywhere}
.profile-skill-description small {font-size:10px;color:#beb4d0}
.profile-skill-description .profile-inactive {color:#fca5a5}
.profile-description-label {display:block;margin-bottom:5px;color:#beb4d0;font-size:11px}
.profile-official-number {color:#f8cf7d;font-weight:700;font-variant-numeric:tabular-nums}
.profile-innate-bonuses {margin-top:12px}
.homunculus-preview .profile-innate-bonuses h3 {flex-wrap:wrap;gap:4px 10px}
.profile-innate-bonuses h3 small {font-size:11px;color:#beb4d0;font-weight:400}
.profile-reflection-notes {font-size:12px;line-height:1.8;color:#beb4d0}
.profile-reflection-notes p {margin:0 0 8px}.profile-reflection-notes strong {font-weight:600;color:#f5f0ff}
.profile-bonus-skill {border-top:1px solid #3f354e;padding-top:12px;margin-top:12px}
.profile-bonus-skill h4 {display:flex;flex-wrap:wrap;align-items:center;gap:5px 10px;font-size:13px;line-height:1.6;margin:0 0 8px;color:#e3c3ff}
.profile-bonus-list {list-style:none;margin:0;padding:0;display:grid;gap:9px}
.profile-bonus-list li {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:1px 12px;align-items:baseline;font-size:12px;line-height:1.6;margin:0}
.profile-bonus-list li>span {overflow-wrap:anywhere}
.profile-bonus-list li>strong {font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}
.profile-bonus-positive {color:#86efac}.profile-bonus-negative {color:#fca5a5}
.profile-bonus-reflection {grid-column:1/-1;color:#beb4d0;font-size:10px}
.profile-aura-note {display:block;font-size:10px;color:#beb4d0}
.profile-bonus-excluded,.profile-bonus-conditional {font-size:11px;line-height:1.8;margin:8px 0 0;color:#f0cc88}
.profile-bonus-description {margin-top:5px}
.profile-bonus-description summary {min-height:44px;display:flex;align-items:center;font-size:12px;color:#c79af0;cursor:pointer}
.profile-bonus-description summary::after {content:'＋';margin-left:7px}.profile-bonus-description[open] summary::after {content:'−'}
.profile-bonus-description p {margin:0 0 7px;font-size:13px;line-height:1.9;white-space:pre-line;overflow-wrap:anywhere;color:#f5f0ff}
.homunculus-preview-actions {display:flex;justify-content:space-between;gap:12px;flex-shrink:0;padding-top:12px;margin-top:12px;border-top:1px solid #4b5563}
.homunculus-preview-actions button {min-height:46px;padding:10px 18px;font-size:14px}
.is-preview .homunculus-preview-confirm {background:#f5b346;color:#23180c;border-color:#f5b346;font-weight:700}
.is-preview .homunculus-preview-confirm:hover {background:#f9c567}
.is-preview button:focus-visible,.is-preview summary:focus-visible,.profile-info:focus-visible {outline:2px solid #c79af0;outline-offset:2px}
.homunculus-preview-retry {align-self:flex-start;min-height:40px;flex-shrink:0;margin-bottom:10px}
.is-readonly .homunculus-preview-confirm {display:none!important}
.is-readonly .homunculus-preview-actions {justify-content:flex-end}
/* One persistent species card and one level/rank entry in either editor. */
#character-card {gap:12px;align-items:center;flex-wrap:nowrap}
#character-card-open {min-width:0;max-width:480px;flex:1 1 220px;padding:8px 12px;gap:10px}
#character-card-open .homunculus-portrait {width:56px;height:64px;flex:0 0 56px}
#character-card .character-card-copy {gap:3px}
#character-card .character-card-name {font-size:16px;line-height:1.4}
#character-card .character-card-meta {font-size:11px}
#character-card .character-card-action {font-size:12px}
.character-card-actions {display:flex;flex-direction:column;gap:4px;flex:0 0 auto}
.character-card-actions[hidden] {display:none!important}
.character-card-actions button {min-height:36px;padding:7px 10px;white-space:nowrap;font-size:12px}
#character-settings.character-advanced-settings>summary {display:none!important}
#character-settings.character-advanced-settings:not([open]) {display:none}
#character-settings.character-advanced-settings[open] {display:block;flex-basis:100%;min-width:0;margin:0}
#character-settings.character-advanced-settings[open]>.character-picker {padding-top:4px}
#character-settings.character-advanced-settings .character-picker>[hidden] {display:none!important}
.embedded-party #character-card {gap:8px;align-items:center}
.embedded-party #character-card-open {flex:1 1 150px;max-width:none;padding:7px 9px;gap:8px}
.embedded-party #character-card-open .homunculus-portrait {width:48px;height:56px;flex-basis:48px}
@media(max-width:680px){
  .homunculus-picker-conditions {margin:0 0 10px;border:1px solid #7e7191;border-radius:4px;background:#211b2c}
  .homunculus-picker-conditions>summary {display:flex;align-items:center;gap:4px 10px;flex-wrap:wrap;min-height:44px;padding:10px 12px;color:#e3c3ff;font-size:12px;line-height:1.5;cursor:pointer;list-style:none}
  .homunculus-picker-conditions>summary::-webkit-details-marker {display:none}
  .homunculus-picker-conditions>summary::after {margin-left:auto}
  .homunculus-condition-active {flex:1 1 120px;min-width:0;color:#d8cee5;font-size:11px;overflow-wrap:anywhere}
  .homunculus-picker-conditions[open] {padding:0 10px 10px}
  .homunculus-picker-conditions[open]>summary {margin:0 -10px 10px;border-bottom:1px solid #4b415c}
  .homunculus-condition-done {display:block;width:100%;min-height:44px;margin-top:8px;font-size:12px}
  .homunculus-picker-conditions>summary:focus-visible {outline:2px solid #c79af0;outline-offset:2px}
  dialog.homunculus-picker.is-preview,.party-page dialog.homunculus-picker.is-preview {width:calc(100vw - 16px);max-width:calc(100vw - 16px);height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);padding:12px}
  .is-preview .homunculus-picker-header h2 {font-size:17px}
  .homunculus-preview-intro {padding:5px;margin-bottom:10px}
  .homunculus-preview-portrait {width:108px;height:90px}
  .profile-tab-body {padding:9px;scrollbar-gutter:auto}
  .profile-affinities {gap:8px;margin-bottom:10px}
  .profile-game-panel {padding:10px}
  .profile-affinity-list {font-size:12px}
  .profile-base-bars {grid-template-columns:1fr;gap:8px}
  .profile-game-skills summary {gap:7px}
  .profile-game-skills .profile-rank6-skill {font-size:9px}
  .homunculus-preview-actions {gap:8px;margin-top:9px;padding-top:10px}
  .homunculus-preview-actions button {padding:10px 12px;font-size:13px}
  .homunculus-picker-sort select {font-size:16px;min-width:0;max-width:100%}
  #character-card {gap:8px}
  #character-card-open {min-width:0;width:auto;padding:8px;gap:8px}
  #character-card-open .homunculus-portrait {width:50px;height:60px;flex-basis:50px}
  #character-card .character-card-name {font-size:15px}
  #character-card .character-card-actions button {min-height:44px;padding:7px 8px;font-size:11px}
}
/* Keep the cosmetic action attached to the portrait, including embedded editors. */
.character-card-identity {position:relative;flex:1 1 220px;min-width:0;max-width:480px}
#character-card .character-card-identity #character-card-open {width:100%;max-width:none;min-width:0}
#character-card .character-card-identity.has-skins #character-card-open {padding:4px 8px;gap:10px}
#character-card .character-card-identity.has-skins #character-card-open .homunculus-portrait {width:66px;height:106px;flex:0 0 66px}
#character-card .character-card-identity.has-skins .homunculus-portrait img {height:76px;top:0;bottom:auto}
#character-skin-open {position:absolute;left:8px;bottom:0;display:flex;align-items:center;justify-content:center;gap:3px;min-height:36px;width:72px;padding:4px;border:1px solid #b18ad0;border-radius:8px;background:#382747;color:#f3dfff;font-size:11px;line-height:1.2;box-shadow:0 2px 5px #0005}
#character-skin-open[hidden] {display:none!important}
#character-skin-open:hover {background:#533667;border-color:#e0b6ff}
#character-skin-open:focus-visible,.character-skin-dialog button:focus-visible {outline:2px solid #e0b6ff;outline-offset:3px}
dialog.character-skin-dialog {width:480px;max-width:calc(100% - 24px);max-height:calc(100dvh - 24px);box-sizing:border-box;padding:18px;overflow:auto;border:1px solid #7e7191;border-radius:10px;background:#1f1b2b;color:#f5f0ff}
.character-skin-dialog::backdrop {background:#080610b3}
.character-skin-dialog>header {display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.character-skin-dialog h2 {margin:0;font-size:18px;line-height:1.5;overflow-wrap:anywhere}
.character-skin-dialog>header button {flex-shrink:0;min-height:44px;padding:8px 12px}
.character-skin-choices {display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:10px}
.character-skin-choices>button {display:flex;flex-direction:column;align-items:center;gap:6px;min-width:0;padding:10px 6px;border:1px solid #6d617a;border-radius:8px;background:#14111e;color:#f5f0ff;font-size:12px;white-space:normal;overflow-wrap:anywhere}
.character-skin-choices>button:hover {background:#30233e;border-color:#d2a3f4}
.character-skin-choices>button[aria-pressed=true] {border:2px solid #c79af0;padding:9px 5px;background:#352442}
.character-skin-preview {position:relative;display:grid;place-items:center;width:100%;height:112px;flex:0 0 112px;overflow:hidden;color:#beb4d0}
.character-skin-preview img {position:absolute;inset:0;width:100%;height:100%;object-fit:contain}
.character-skin-status {color:#c79af0;font-size:11px}
.character-skin-error {color:#fca5a5;font-size:13px}
body.game-ui #character-card.has-member-name .character-card-identity {display:grid;grid-template-columns:80px minmax(0,1fr);gap:10px;align-items:center;max-width:none;flex:1}
body.game-ui #character-card.has-member-name #character-card-open {padding:4px;justify-content:center;background:transparent;border-color:transparent}
body.game-ui #character-card.has-member-name .member-card-portrait {position:relative;display:block;min-width:0}
body.game-ui #character-card.has-member-name .character-card-copy {min-width:0;gap:2px}
body.game-ui #character-card.has-member-name .member-card-heading {display:flex;align-items:center;gap:8px;min-width:0}
body.game-ui #character-card.has-member-name .character-card-name {min-width:0;overflow-wrap:anywhere;font-size:15px}
body.game-ui #character-card.has-member-name #character-card-rename {flex-shrink:0;min-height:44px;padding:6px 8px;font-size:12px;white-space:nowrap}
body.game-ui #character-card.has-member-name .character-card-actions {display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;gap:4px 12px;margin:0;padding:0}
body.game-ui #character-card.has-member-name .character-card-actions button {min-height:44px;padding:4px 0;font-size:12px;flex:none}
body.game-ui #character-card.has-member-name #character-skin-open {left:4px;width:72px}
@media(max-width:680px){#character-skin-open {min-height:44px;bottom:0;width:68px;font-size:10px}#character-card .character-card-identity.has-skins #character-card-open .homunculus-portrait {height:116px}.character-skin-dialog h2 {font-size:16px}}
