/* Shared character archive and management library. */
.legacy-library-controls[hidden],.library-popover[hidden]{display:none!important}
.library-toolbar{display:flex;align-items:center;gap:14px;padding:20px 0 26px;position:relative;z-index:5;flex-wrap:wrap}
#librarySearchHost{flex:1 1 300px;min-width:190px}#librarySearchHost .search-box{width:100%;height:52px;border:1px solid #cfc8bf;border-radius:9px;background:#fff;box-shadow:none}#librarySearchHost .search-key{display:none}
#libraryBurstHost{display:flex;gap:7px}#libraryBurstHost button{width:48px;height:52px;border:1px solid #d0c9bf;border-radius:8px;background:#fff;font-size:23px;font-weight:900;color:#393732;cursor:pointer}#libraryBurstHost button[aria-pressed=true]{background:#b96929;color:#fff;border-color:#b96929}
.library-sort-host{position:relative}#librarySortTrigger{height:52px;min-width:150px;display:flex;align-items:center;justify-content:space-between;gap:23px;border:1px solid #cfc8bf;background:#fff;border-radius:9px;padding:0 16px;color:#34312c;cursor:pointer;font:inherit}#librarySortTrigger.has-filters{border-color:#b96929;box-shadow:inset 0 0 0 1px #b96929}
.library-popover{position:absolute;top:62px;right:0;width:355px;max-width:calc(100vw - 32px);padding:18px;max-height:72vh;overflow:auto;background:#252522;color:#f7f2e8;border:1px solid #51483b;border-radius:13px;box-shadow:0 18px 45px #201a1833;z-index:60}
.library-popover-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}.library-popover-heading button{background:none;border:0;color:#ddd;font-size:24px;cursor:pointer}.library-popover fieldset{border:0;border-top:1px solid #555047;margin:0 0 17px;padding:12px 0 0;min-width:0}.library-popover legend{padding-right:12px;color:#c6beb1;font-size:12px;font-weight:700}.library-filter-options{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}.library-filter-options button{border:1px solid #57544d;background:#3c3b36;color:#e9e5df;border-radius:6px;min-height:36px;padding:6px 3px;font:inherit;font-size:12px;cursor:pointer}.library-filter-options button[aria-pressed=true]{background:#c27d39;color:white;border-color:#e6aa62;box-shadow:inset 0 0 0 1px #e0a565}.library-filter-heading{display:block;font-size:14px;margin-bottom:14px}.library-sort-note{font-size:10px;line-height:1.6;color:#b9b2a7;margin:10px 0 0}.library-reset{width:100%;padding:10px;border-radius:6px;background:transparent;border:1px solid #78644b;color:#efd1a5;cursor:pointer}
#rosterSyncHost{margin-left:auto}#rosterSyncHost .sync-control{display:flex;gap:12px;align-items:center;background:#fff;border:1px solid #cfc8bf;border-radius:9px;padding:0 12px;height:52px;white-space:nowrap}#rosterSyncHost .sync-level{display:flex;align-items:center;gap:6px}#rosterSyncHost .sync-level>label,#rosterSyncHost .scope-badge{display:none}#rosterSyncHost input[type=number]{width:76px;height:32px;border:1px solid #d7d0c6;background:#f8f6f2;border-radius:6px;padding:5px 8px}#rosterSyncHost input[type=checkbox]{accent-color:#b96929}#rosterSyncHost .check-label{margin:0;gap:8px}
#characterGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(122px,1fr));gap:24px 17px;align-items:start}
#characterGrid .library-card{display:block;position:relative;padding:0;width:100%;overflow:hidden;border:1px solid #c3bbae;border-radius:15px;background:#faf8f3;box-shadow:0 3px 8px #3d322308;transition:border-color .16s,transform .16s;text-align:left;min-width:0;color:#302e29;cursor:pointer}
#characterGrid .library-card:hover{transform:translateY(-3px);border-color:#ac713b;box-shadow:0 7px 16px #3d32231a}#characterGrid article.library-card{cursor:default}#characterGrid article.library-card:hover{transform:none;box-shadow:0 3px 8px #3d322308}
#characterGrid .library-card .portrait-wrap{position:relative;aspect-ratio:0.73;height:auto;background:linear-gradient(145deg,#eee7dc,#ddd5c8);overflow:hidden;margin:0;border-radius:0}
#characterGrid .library-card .portrait-wrap>img{width:100%;height:100%;object-fit:cover;object-position:center 20%;display:block;padding-top:24px}
#characterGrid .library-card[data-owned=false] .portrait-wrap>img{filter:grayscale(1);opacity:.55}
.library-card-top{position:absolute;left:0;right:0;top:0;height:34px;border-bottom:1px solid #b9afa0;background:#f3eee5e8;display:flex;align-items:center;justify-content:space-between;padding-right:10px}
.library-brand{position:relative;width:53px;height:52px;align-self:flex-start;background:#ece3d3;clip-path:polygon(0 0,100% 0,0 100%);display:block}.library-brand:after{content:'';position:absolute;inset:0;background:linear-gradient(135deg,transparent 48%,#a99b85 49%,#a99b85 50%,transparent 51%);pointer-events:none}.library-brand img{position:absolute;left:8px;top:5px;width:23px;height:23px;object-fit:contain;filter:brightness(0);opacity:.85}.library-element{width:24px;height:27px;object-fit:contain}
.library-card-bottom{--library-corner-size:clamp(49px,7vw,64px);position:relative;display:flex;align-items:center;border-top:1px solid #b9afa0;background:#f7f3ec;min-height:44px;padding:0 calc(var(--library-corner-size) - 4px) 0 9px}
.library-card-bottom::before{content:'';position:absolute;right:0;bottom:0;width:var(--library-corner-size);aspect-ratio:1;background:linear-gradient(135deg,transparent 49%,#ad9d84 49.3%,#ad9d84 50.5%,#ece3d3 51%);pointer-events:none}
#characterGrid .library-card .card-name{font-size:11px;line-height:1.3;font-weight:650;white-space:normal;overflow:hidden;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;min-width:0;margin:0}
@media(max-width:360px){.library-card-bottom{--library-corner-size:46px}}
#characterGrid .library-card .card-power{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);padding:0;border:0;margin:-1px}
#characterGrid.show-power .library-card .card-power{position:static;width:auto;height:auto;clip-path:none;margin:0;padding:5px 8px;background:#f7f3ec;font-size:11px;flex-wrap:wrap;gap:3px}
#profileForm .power-preview output{display:block;padding:7px 0;font-size:18px;font-weight:700;font-variant-numeric:tabular-nums}
#characterGrid .virtual-character-entry{min-width:0;display:flex;flex-direction:column;gap:7px}#characterGrid .virtual-availability-toggle{font-size:11px;border-radius:7px;border:1px solid #d1c4b0;background:#f1e6d5;color:#775124;min-height:30px;cursor:pointer}#characterGrid .virtual-availability-toggle[aria-pressed=false]{color:#777;background:#eeece8;border-color:#ddd}
.catalog-mode .legend,.catalog-mode .roster-foot,.catalog-mode #scopeExplanation{display:none}.catalog-mode #rosterSyncHost{opacity:.55}.catalog-mode .library-card .portrait-wrap>img{filter:none!important;opacity:1!important}
.library-toolbar button:focus-visible,.library-card:focus-visible{outline:3px solid #b96929;outline-offset:3px}
@media(min-width:1600px){#characterGrid{grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:25px 20px}}
@media(max-width:700px){.library-toolbar{gap:9px;padding:12px 0 20px}#librarySearchHost{flex-basis:100%}#libraryBurstHost button{width:40px;height:44px;font-size:20px}#librarySortTrigger{height:44px;min-width:118px;gap:14px}#rosterSyncHost{flex-basis:100%;margin:0}#rosterSyncHost .sync-control{justify-content:space-between;height:46px}.library-popover{right:auto;left:-130px;top:52px;width:330px}#characterGrid{grid-template-columns:repeat(3,minmax(0,1fr));gap:17px 10px}#characterGrid .library-card{border-radius:11px}.library-card-bottom{padding-left:6px;min-height:42px}#characterGrid .library-card .card-name{font-size:10px}.library-card-top{padding-right:6px}.library-brand img{width:21px;height:21px}.library-element{width:22px;height:24px}}
@media(prefers-reduced-motion:reduce){#characterGrid .library-card{transition:none}}
#characterGrid .library-card .library-brand img{position:absolute;left:8px;top:5px;width:23px;height:23px;object-fit:contain;filter:brightness(0);opacity:.85;padding:0}
#characterGrid .library-card .library-element{position:static;width:24px;height:27px;object-fit:contain;filter:none;opacity:1;padding:0}
#librarySearchHost .search-box{max-width:none}#librarySearchHost .search-box input{width:100%;min-width:0}
@media(max-width:700px){#characterGrid .library-card .library-brand img{width:21px;height:21px}#characterGrid .library-card .library-element{width:22px;height:24px}}

.drawer-backdrop { background: #202b3d59; }
.drawer.profile-dialog {
  --dialog-padding: 26px;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100% - 32px));
  max-height: min(850px, calc(100vh - 32px));
  max-height: min(850px, calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid #d9e0e8;
  border-radius: 18px;
  box-shadow: 0 20px 70px #15223638;
}
.profile-dialog .drawer-header {
  position: relative;
  padding: 20px calc(var(--dialog-padding) + 43px) 20px var(--dialog-padding);
  border-color: #dfe5ed;
}
.profile-dialog .drawer-character { gap: 18px; margin: 0; }
.profile-dialog .drawer-portrait { width: 80px; height: 88px; border-radius: 10px; background: #f4efe7; }
.profile-dialog .profile-dialog-identity { min-width: 0; }
.profile-dialog .profile-dialog-scope { color: #596b80; font-size: 12px; font-weight: 600; }
.profile-dialog .drawer-character h2 { margin: 3px 0; color: #25364c; font-size: clamp(20px, 3vw, 26px); overflow-wrap: anywhere; }
.profile-dialog .drawer-character p { color: #506176; font-size: 13px; line-height: 1.45; }
.profile-dialog-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 9px; margin-top: 7px; }
.profile-dialog .drawer-status { margin: 0; font-size: 12px; color: #506176; }
.profile-dialog .drawer-status.saved { color: #854619; }
.profile-dialog .profile-dialog-close {
  position: absolute;
  inset: 16px 16px auto auto;
  width: 40px;
  height: 40px;
  color: #465c73;
  font-size: 25px;
}
.profile-dialog .profile-dialog-close:hover { background: #e8edf4; }
.profile-dialog .drawer-scroll {
  padding: 18px var(--dialog-padding) 22px;
  overscroll-behavior: contain;
}
.profile-dialog .drawer-info { color: #495d73; font-size: 13px; line-height: 1.55; }
.profile-dialog .drawer-info.virtual { color: #74502c; }
.profile-dialog .section-caption h3, .profile-dialog .form-section h3 { color: #25364c; font-size: 17px; }
.profile-dialog .form-section h3 { gap: 8px; flex-wrap: wrap; }
.profile-dialog .section-caption > span, .profile-dialog .form-section h3 span { color: #586b80; font-size: 12px; }
.profile-dialog .form-grid { gap: 14px 16px; }
.profile-dialog .form-field label { color: #43576d; font-weight: 600; font-size: 14px; }
.profile-dialog .form-field :is(input, select),
.profile-dialog .assign-controls select,
.profile-dialog .gear-editor :is(input, select) {
  height: 40px;
  padding: 7px 9px;
  border: 1px solid #cdd7e3;
  border-radius: 6px;
  color: #26394f;
  font-size: 15px;
}
.profile-dialog .assign-controls { align-items: stretch; }
.profile-dialog .assign-controls select { min-width: 0; }
.profile-dialog .assign-controls .secondary-button { font-size: 14px; font-weight: 700; }
.profile-dialog .small-note, .profile-dialog .field-note, .profile-dialog .sync-form-note { color: #53677d; font-size: 12px; line-height: 1.55; }
#profileForm .equipment-default-control { max-width: 360px; margin-bottom: 12px; }
#profileForm .gear-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
#profileForm .gear-grid .gear-editor { min-width: 0; margin: 0; }
#profileForm .gear-grid .gear-base { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#profileForm .gear-grid .gear-option { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
#profileForm .gear-grid select { min-width: 0; width: 100%; }
#profileForm .overload-totals { display: flex; flex-wrap: wrap; gap: 8px 12px; }
#profileForm .overload-totals div { display: flex; gap: 6px; padding: 5px 8px; border: 1px solid #e5ded3; border-radius: 5px; }
#profileForm .overload-totals dd { font-weight: 700; font-variant-numeric: tabular-nums; }
#profileForm .crit-summary { margin: 10px 0 0; }
#profileForm :disabled { background: #edf2f8; color: #64748b; }
#profileForm .applied-stats { margin-top: 14px; padding: 12px; border-radius: 6px; background: #f4f6f9; }
#profileForm .applied-stats h4 { margin: 0 0 8px; font-size: 13px; }
#profileForm .applied-stats h4 span { margin-left: 6px; font-size: 12px; color: #53677d; font-weight: 500; }
#profileForm .applied-stats dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
#profileForm .applied-stats dt { color: #53677d; font-size: 12px; }
#profileForm .applied-stats dd { margin: 2px 0 0; font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.profile-dialog .gear-editor { min-width: 0; margin: 0; }
.profile-dialog .gear-editor h4 { font-size: 15px; }
.profile-dialog .gear-number { font-size: 11px; }
.profile-dialog .gear-option { grid-template-columns: minmax(0, 1fr) 100px; }
.profile-dialog .percent-field input { padding-right: 25px; }
.profile-dialog .percent-field > span { top: 12px; font-size: 12px; color: #53677d; }
.profile-dialog .drawer-footer { padding: 12px var(--dialog-padding) 14px; background: #fcfbf8; }
.profile-dialog .save-context { font-size: 12px; color: #53677d; }
.profile-dialog .save-button, .profile-dialog .remove-profile { min-height: 42px; font-size: 14px; }
.profile-dialog .save-button { background: #a94b20; }
.profile-dialog .save-button:hover { background: #8c3e19; }
.profile-dialog .remove-profile { color: #506176; padding-inline: 12px; }
.profile-dialog .drawer-validation { font-size: 13px; }
.profile-dialog :is(button, input, select):focus-visible { outline: 2px solid #a94b20; outline-offset: 2px; }
@media (max-width: 640px) {
  .drawer.profile-dialog { --dialog-padding: 16px; width: calc(100% - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border-radius: 14px; }
  .profile-dialog .drawer-header { padding-block: 14px; }
  .profile-dialog .drawer-character { gap: 11px; }
  .profile-dialog .drawer-portrait { width: 58px; height: 68px; }
  .profile-dialog .profile-dialog-close { inset: 10px 10px auto auto; }
  #profileForm .gear-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-dialog .form-field :is(input, select), .profile-dialog .assign-controls select, .profile-dialog .gear-editor :is(input, select) { font-size: 16px; }
}
.growth-controls{display:flex;flex-wrap:wrap;align-items:center;gap:8px;min-width:0}
#rosterSyncHost:empty{display:none}
.research-control{position:relative;align-self:center}
.research-control summary{display:flex;align-items:center;gap:8px;min-height:33px;padding:6px 10px;border:1px solid #d7d0c6;border-radius:7px;background:#fff;color:#514638;cursor:pointer;font-weight:700;list-style:none;white-space:nowrap}
.research-control summary::after{content:"▾";font-size:10px}
.research-control[open] summary::after{content:"▴"}
.research-control summary:focus-visible{outline:2px solid #c9783c;outline-offset:3px}
#rosterSyncHost .research-control summary{min-height:52px;padding:0 12px}
#researchForm{position:absolute;z-index:22;top:calc(100% + 8px);right:0;width:min(365px,calc(100vw - 44px));background:#fff;padding:16px;border:1px solid #d7d0c6;border-radius:10px;box-shadow:0 8px 26px #33291d24}
#researchForm p{font-size:11px;line-height:1.65;color:#6c6258;margin-bottom:10px}
#researchForm fieldset{border:0;border-top:1px solid #e7e0d6;margin:0 0 10px;padding:8px 0 0;min-width:0}
#researchForm legend{font-weight:700;padding:0 7px 0 0}
#researchForm fieldset div{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px 10px}
#researchForm label{display:grid;gap:4px;color:#514638;font-size:11px;white-space:nowrap}
.research-control #researchForm input[type=number]{width:100%;height:34px;padding:5px 7px;font-size:12px}
#researchForm button{display:block;margin-left:auto}
.overload-heading{display:flex;align-items:center;gap:9px;margin:10px 0}
.overload-heading .field-note{font-size:11px;color:#6c6258}
#addOverloadOption,.overload-remove{display:grid;place-items:center;width:36px;height:36px;padding:0;font-size:20px;line-height:1}
#addOverloadOption:disabled{opacity:.45;cursor:default}
#overloadRows{display:grid;gap:7px}
.overload-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) 36px;gap:7px}
.overload-row select,.overload-row input{width:100%;height:36px;font-size:12px}
.overload-percent{position:relative;min-width:0}
.overload-percent input{padding-right:27px}
.overload-percent span{position:absolute;right:9px;top:50%;transform:translateY(-50%);color:#716658;pointer-events:none}
@media(max-width:700px){
  #rosterSyncHost .research-control summary{min-height:46px}
  #researchForm{position:static;margin-top:6px}
}
.linked-roster{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px 20px;margin:0 0 22px;padding:16px 20px;border:1px solid var(--border,#dbe2ed);border-radius:12px;background:#fff}
.linked-roster h2{font-size:16px;margin:0 0 5px}
.linked-roster p{color:#4e6684;margin:0;font-size:13px;line-height:1.55}
.linked-roster button{flex:none}
.linked-card-badge{position:absolute;right:7px;bottom:7px;border-radius:4px;padding:2px 6px;color:#fff;background:#304866;font-size:10px;font-weight:700;line-height:1.5}
