.library-dialog { width: min(700px, calc(100vw - 32px)); max-height: min(850px, calc(100dvh - 48px)); margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: 0 24px 90px #0008; overflow: hidden; }
.library-dialog[open] { display: flex; flex-direction: column; }
.library-dialog::backdrop { background: #07080bbf; }
.library-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.library-dialog-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.library-close { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.library-close:hover { background: var(--panel-2); color: var(--text); }
.library-detail-body, .library-manager-body { padding: 24px; overflow-y: auto; overscroll-behavior-y: contain; min-height: 0; }
.library-profile { display: flex; align-items: flex-start; gap: 22px; }
.library-profile > .library-detail-cover { width: 210px; max-width: 100%; flex: 0 0 210px; border-radius: 10px; }
.library-profile > .library-avatar { height: auto; aspect-ratio: 3 / 4; object-fit: cover; background: var(--panel-2); }
.library-profile-copy { min-width: 0; flex: 1; }
.library-profile-copy h1 { margin: 3px 0 10px; font-size: 25px; line-height: 1.4; letter-spacing: -.6px; overflow-wrap: anywhere; }
.library-tagline { margin: 0 0 12px; font-size: 14px; color: #d0d2da; line-height: 1.7; overflow-wrap: anywhere; }
.library-meta { color: var(--muted); font-size: 12px; line-height: 1.6; }
.library-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.library-tag { border: 1px solid #41434c; border-radius: 6px; padding: 5px 8px; background: transparent; color: #c9cbd4; font: inherit; font-size: 12px; cursor: pointer; }
.library-tag:hover { border-color: var(--accent); color: var(--accent); }
.library-text-section { margin-top: 26px; }
.library-text-section h3, .library-manager-body h3, .library-text-section > label { display: block; margin: 0 0 10px; color: var(--text); font-size: 14px; font-weight: 600; }
.library-prose { margin: 0; font-size: 14px; color: #c5c8d2; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.library-preview-text.library-expandable:not(.library-expanded) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.library-preview-toggle { border: 0; padding: 7px 0; background: transparent; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.library-preview-toggle[hidden] { display: none; }
.library-preview-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.library-select { width: 100%; padding: 10px 12px; margin-bottom: 12px; border: 1px solid #41434c; border-radius: 7px; color: var(--text); background: var(--bg); font: inherit; font-size: 14px; }
.library-scene-preview-wrap { padding: 14px; background: var(--bg); border-radius: 8px; }
.library-guide { padding: 10px 0; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }
.library-detail-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 24px; }
.library-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 12px; border: 1px solid #42444e; border-radius: 7px; background: #24262e; color: var(--text); font: inherit; font-size: 13px; text-decoration: none; cursor: pointer; }
.library-button:hover { border-color: #777b86; background: #30333d; }
.library-button:disabled { opacity: .45; cursor: not-allowed; }
.library-primary { color: #271612; border-color: var(--accent); background: var(--accent); font-weight: 650; }
.library-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.library-detail-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--panel); flex-shrink: 0; }
.library-detail-actions .library-button { min-height: 44px; }
.library-tabs { display: flex; gap: 5px; padding: 14px 22px 0; flex-shrink: 0; }
.library-tab { border: 0; border-radius: 6px; padding: 9px 12px; color: var(--muted); background: transparent; font: inherit; font-size: 13px; cursor: pointer; }
.library-tab.active { background: #30313a; color: var(--text); }
.library-empty { margin: 0; padding: 28px 24px; color: var(--muted); font-size: 14px; line-height: 1.8; }
.library-new { margin-bottom: 14px; }
.library-card-row { display: flex; align-items: center; gap: 14px; padding: 13px 0; width: 100%; border: 0; border-bottom: 1px solid var(--border); color: var(--text); background: transparent; text-align: left; font: inherit; cursor: pointer; }
.library-card-row:hover .library-card-copy strong { color: var(--accent-2); }
.library-card-row .library-avatar { width: 52px; height: 62px; flex-shrink: 0; object-fit: cover; border-radius: 6px; }
.library-card-copy { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.library-card-copy strong { font-size: 14px; line-height: 1.5; }
.library-card-copy small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-row-arrow { color: var(--muted); font-size: 22px; }
.library-file { display: block; width: 100%; margin-top: 24px; color: var(--muted); font: inherit; font-size: 13px; }
.library-file::file-selector-button { margin-right: 12px; padding: 12px; background: var(--panel-2); color: var(--text); border: 1px solid #4a4c57; border-radius: 7px; cursor: pointer; }
.library-toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 120; max-width: min(540px, calc(100vw - 32px)); padding: 12px 18px; border: 1px solid #626570; border-radius: 9px; color: var(--text); background: #2b2d35; font-size: 13px; line-height: 1.6; box-shadow: 0 8px 35px #0006; pointer-events: none; }
.library-copy-field { width: 100%; margin-top: 16px; padding: 12px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.library-account-entry { padding-block: 14px; font-size: 13px; }
.library-version-dialog { width: min(540px, calc(100vw - 24px)); }
.library-button:focus-visible, .library-tag:focus-visible, .library-close:focus-visible, .library-tab:focus-visible, .library-card-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 700px) {
  .library-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 24px); border-radius: 12px; }
  .library-dialog-head { padding: 12px 16px; }
  .library-detail-body, .library-manager-body { padding: 18px 16px; }
  .library-profile { gap: 15px; }
  .library-profile > .library-detail-cover { width: 180px; flex-basis: 180px; }
  .library-profile-copy h1 { font-size: 20px; margin-top: 0; }
  .library-tagline { font-size: 13px; }
  .library-detail-actions { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .library-detail-actions .library-button { flex: 1; white-space: nowrap; }
  .library-tabs { padding-inline: 16px; }
  .library-tab { padding-inline: 10px; }
  .library-select { font-size: 16px; }
}
@media (max-width: 520px) {
  .library-profile { flex-direction: column; gap: 18px; }
  .library-profile > .library-detail-cover { width: 200px; flex: none; align-self: center; }
  .library-profile-copy { width: 100%; }
}
