/* 角色库。颜色取 ui-kit.css 的共用配色（PD-CLIENT-014），兜底值是原来的浅色 */
.character-library {
    --lib-panel: var(--y-surface, #fffaf8);
    --lib-text: var(--y-text, #3b2a2e);
    --lib-accent: var(--y-primary, #c96c8a);
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--lib-text);
}
.library-head { display: flex; align-items: center; flex-shrink: 0; gap: 12px; padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px; background: var(--lib-panel); border-bottom: 1px solid var(--line); }
.library-head h1 { margin: 0; font-size: 18px; font-weight: 600; }
.library-head .library-count { margin-left: auto; font-size: 13px; color: var(--sub); }
.library-back { border: 0; background: none; color: inherit; width: 40px; height: 40px; font-size: 36px; line-height: 1; border-radius: 10px; }
.library-browse { flex: 1; overflow-y: auto; padding: 28px max(20px, calc((100vw - 1160px) / 2)) calc(28px + env(safe-area-inset-bottom, 0px)); }
.library-intro h2 { margin: 0 0 8px; font-size: 26px; }
.library-intro p, .library-status { margin: 0 0 20px; color: var(--sub); font-size: 14px; }
.library-search { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--lib-panel); }
.library-search span { flex-shrink: 0; white-space: nowrap; color: var(--sub); font-size: 13px; }
.library-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: inherit; font: inherit; }
.library-status { margin: 14px 0; min-height: 20px; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
/* 按维度分组（PD-DIM-010）：独立角色之后显示「什么是维度」，每组一个组头和背景介绍 */
.library-about { margin: 0 0 24px; padding: 14px 16px; border-radius: 14px; background: var(--y-primary-soft, rgba(201, 108, 138, .12)); }
.library-about strong { display: block; margin-bottom: 4px; font-size: 15px; }
.library-about p { margin: 0; font-size: 14px; line-height: 1.7; }
.library-section + .library-section, .library-section + .library-about { margin-top: 32px; }
.library-section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; }
.library-section-head h3 { margin: 0; font-size: 20px; }
.library-section-head span { color: var(--sub); font-size: 12px; }
.library-story { max-width: 780px; margin: 0 0 16px; color: var(--sub); font-size: 14px; line-height: 1.75; }
.library-card { min-width: 0; padding: 18px; background: var(--lib-panel); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; }
.library-preview { flex: 1; width: 100%; border: 0; padding: 0; color: inherit; background: none; text-align: center; }
.library-preview img { display: block; width: 112px; height: 112px; border-radius: 24px; margin: 0 auto 14px; object-fit: cover; background: var(--bg); }
.library-preview h3 { margin: 0 0 5px; font-size: 18px; }
.library-preview p { margin: 3px 0; color: var(--sub); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.library-job { min-height: 40px; }
.library-add, .library-retry, .add-character-entry { border: 0; border-radius: 10px; padding: 11px 14px; background: var(--y-primary-grad, var(--lib-accent, #c96c8a)); color: #fff; font: inherit; font-size: 14px; }
.library-card .library-add { width: 100%; margin-top: 16px; }
.library-add:disabled { background: var(--bg); color: var(--sub); cursor: default; }
/* 锁定的角色（PD-CHAR-009）：按钮写「未解锁」，资料下面一行小字说明 */
.library-add.is-locked::before { content: "🔒 "; }
.library-preview .library-lock { margin-top: 6px; color: var(--sub); font-size: 12px; }
.library-detail { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); }
.library-art { display: flex; align-items: center; justify-content: center; min-height: 350px; background: #1e1519; padding: 20px; }
.library-art img { display: block; width: 100%; height: calc(100dvh - 125px); object-fit: contain; }
.library-art p { color: #dcc8cd; text-align: center; }
.library-profile { align-self: center; padding: 40px; }
.library-profile h2 { margin: 0 0 12px; font-size: 30px; }
.library-profile p { color: var(--sub); line-height: 1.8; margin-bottom: 26px; }
.library-profile .library-add { min-width: 180px; }
.library-feedback { min-height: 44px; padding-top: 14px; font-size: 14px; color: var(--sub); }
/* 充值全部解锁与发帖单独解锁的说明（PD-CHAR-010、PD-ACT-001） */
.library-unlock[hidden], .library-unlock [hidden] { display: none !important; }
.library-unlock-how { white-space: pre-line; }
.library-unlock { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--y-primary-soft, rgba(201, 108, 138, .12)); }
.library-profile .library-unlock p { margin: 0 0 10px; font-size: 14px; line-height: 1.7; color: inherit; }
.library-unlock-caption { display: block; margin-bottom: 12px; padding: 8px 10px; border-radius: 8px; background: var(--card, #fff); font-size: 15px; font-weight: 600; user-select: all; word-break: break-all; }
.library-unlock-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.library-unlock-actions .library-copy { min-width: 120px; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--y-primary-grad, var(--lib-accent, #c96c8a)); color: #fff; font: inherit; font-size: 14px; cursor: pointer; }
.library-unlock-actions .library-group { color: var(--y-primary-text, #ad4f72); font-weight: 600; text-decoration: none; }
.library-unlock-actions .library-group[hidden] { display: none; }
.add-character-entry { margin: 6px 16px 12px; flex-shrink: 0; background: var(--y-primary-soft, rgba(201, 108, 138, .12)); color: var(--y-primary-text, #ad4f72); font-weight: 600; text-align: left; cursor: pointer; }
.add-character-entry:hover { filter: brightness(.97); }
.cell.add-character-cell { color: var(--y-primary-text, #ad4f72); font-weight: 600; }
.character-library button:focus-visible { outline: 3px solid var(--lib-accent); outline-offset: 3px; }
@media (max-width: 600px) {
    .library-head { padding-left: 8px; padding-right: 16px; gap: 4px; }
    .library-browse { padding: 22px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
    .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .library-card { padding: 16px 10px 12px; border-radius: 14px; }
    .library-preview img { width: 90px; height: 90px; border-radius: 20px; }
    .library-preview h3 { font-size: 17px; }
    .library-card .library-add { font-size: 13px; padding: 10px 4px; }
    .library-detail { display: block; }
    .library-art { min-height: 260px; padding: 12px; }
    .library-art img { height: 57dvh; }
    .library-profile { padding: 22px 22px calc(22px + env(safe-area-inset-bottom, 0px)); }
    .library-profile h2 { font-size: 24px; }
    .library-profile p { margin: 8px 0 16px; }
    .library-profile .library-add { width: 100%; }
}
