/* Collection dialog. Hidden legacy buttons retain the existing tested theme-switch behavior. */
html[data-skin] body .header-right .theme-picker.theme-library-source{display:none!important}
html[data-skin] body .header-right #theme-library-open{order:3;min-height:44px;padding:10px 20px;white-space:nowrap}
#theme-library,#library-bitmap-preview{width:min(1000px,calc(100vw - 24px));max-width:none;max-height:calc(100dvh - 24px);padding:0;background:var(--p-panel-flat,#11110e)!important;color:var(--p-ink,#f6eed8)!important;border:1px solid var(--p-rule,#b49657)!important;border-radius:10px!important;box-shadow:0 30px 100px #0009!important;overflow:auto}
#theme-library::backdrop,#library-bitmap-preview::backdrop{background:#080b08b8;backdrop-filter:blur(6px)}
.theme-library-shell{padding:24px}
#theme-library .theme-library-header{display:flex;justify-content:space-between;align-items:flex-start;gap:18px;border:0;padding:0;background:none;position:static}
#theme-library .library-kicker{margin:0 0 7px;font:700 10px/1.2 'Segoe UI',sans-serif;letter-spacing:.2em;color:var(--p-muted)!important}
#theme-library h2{margin:0;font:400 36px/1.1 Georgia,serif!important;color:var(--p-ink)!important;letter-spacing:0!important}
#theme-library h3{margin:8px 0;font:600 22px/1.15 Georgia,serif!important;color:var(--p-ink)!important}
#theme-library p{color:var(--p-muted)!important;font-family:'Segoe UI',sans-serif!important}
#theme-library .library-close,#library-bitmap-preview .library-close{width:44px;height:44px;flex-shrink:0;padding:0;border:1px solid var(--p-line);background:var(--p-inset);color:var(--p-ink);font:28px/1 sans-serif;border-radius:4px}
#theme-library .library-tabs{display:flex;gap:20px;margin:22px 0 0;border-bottom:1px solid var(--p-line)}
#theme-library .library-tabs button{padding:10px 0 13px;background:none;border:0;border-bottom:3px solid transparent;color:var(--p-muted);font:700 14px/1.3 'Segoe UI',sans-serif;min-height:44px;border-radius:0}
#theme-library .library-tabs [aria-selected="true"]{color:var(--p-ink);border-bottom-color:var(--p-rule)}
#theme-library [hidden]{display:none!important}
#theme-library .library-intro{margin:16px 0;font:14px/1.5 'Segoe UI',sans-serif}
.theme-library-grid,.skin-library-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
#theme-library .theme-option,#theme-library .skin-option{min-width:0;border:1px solid var(--p-line);background:var(--p-inset);border-radius:6px;overflow:hidden}
.theme-option-copy{padding:16px}
#theme-library .theme-option-copy p{font-size:13px;line-height:1.5;min-height:39px;margin:8px 0 16px}
.theme-scene{position:relative;display:grid;place-items:center;width:100%;height:165px;overflow:hidden;border:0;padding:0;background:#17291d}
.scene-marble{background:url('assets/marble-world-hd.webp') center/cover}
.scene-forest{background:url('assets/jungle-sanctuary.png') center/cover}
.scene-bitmap img{width:100%;height:100%;object-fit:cover;object-position:24% 50%}
.library-mini-board{display:grid;grid-template-columns:repeat(4,1fr);width:125px;height:125px;transform:rotate(-8deg);box-shadow:0 9px 25px #0008;outline:5px solid #d4b979;border:2px solid #373b31}
.library-mini-board>span{display:grid;place-items:center;position:relative;min-width:0}
.scene-marble .mini-light{background:#f6f4e9}.scene-marble .mini-dark{background:#70858e}
.scene-forest .mini-light{background:#e8dfc4}.scene-forest .mini-dark{background:#365f4c}
.scene-forest .library-mini-board{outline-color:#6b5033;border-color:#c5ad6a}
.library-piece{display:block;width:100%;height:100%;min-width:0}
.library-mini-board .library-piece{position:absolute;inset:-7px 0 0;height:39px;filter:drop-shadow(0 1px 1px #18151080)}
#theme-library .library-owned,#theme-library .library-premium{font:700 10px/1.4 'Segoe UI',sans-serif;letter-spacing:.1em;color:var(--p-label)}
#theme-library .library-premium{color:var(--p-ink)}
#theme-library .theme-option-copy button,#theme-library .skin-option button,#theme-library .library-reset{width:100%;min-height:44px;border:1px solid var(--p-rule);border-radius:3px;background:var(--p-panel-flat);color:var(--p-ink);font:600 13px/1.3 'Segoe UI',sans-serif;padding:9px}
#theme-library [aria-pressed="true"]{background:var(--p-cta)!important;color:var(--p-cta-ink)!important}
#theme-library .library-note{font-size:12px;margin:16px 0 0;line-height:1.4}
#theme-library .skin-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-top:18px;font:600 14px/1.4 'Segoe UI',sans-serif}
#theme-library select{max-width:60%;min-height:44px;padding:8px;border:1px solid var(--p-rule);border-radius:3px;background:var(--p-inset);color:var(--p-ink);font:14px 'Segoe UI',sans-serif}
.skin-option{padding:14px;text-align:center}
.skin-pair{height:128px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;border-radius:4px;background:linear-gradient(115deg,#d6ccb1 0 50%,#263d31 50%)}
#theme-library .skin-option h3{font-size:18px!important}
#theme-library .skin-option p{font-size:12px;line-height:1.5;min-height:36px}
#theme-library .library-shop{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:20px 0 12px;font:13px/1.4 'Segoe UI',sans-serif;color:var(--p-muted)}
#theme-library .library-shop button{padding:10px;min-height:44px;border:1px solid var(--p-line);background:transparent;color:var(--p-muted);font:12px 'Segoe UI',sans-serif;opacity:1;cursor:not-allowed}
#theme-library .library-reset{width:auto;background:transparent;border-color:var(--p-line)}
#theme-library .library-feedback{min-height:20px;font-size:13px;margin:12px 0 0}
#theme-library button:focus-visible,#theme-library select:focus-visible,#library-bitmap-preview button:focus-visible{outline:3px solid var(--p-rule);outline-offset:3px}
#library-bitmap-preview{width:min(1000px,calc(100vw - 24px));padding:16px;text-align:center}
#library-bitmap-preview img{display:block;width:100%;height:auto;max-height:65dvh;object-fit:contain;margin:12px 0}
#library-bitmap-preview .library-close{display:block;margin-left:auto}
#library-bitmap-preview h2,#library-bitmap-preview p{color:var(--p-ink)!important}
@media(max-width:650px){
 .theme-library-shell{padding:16px}#theme-library h2{font-size:29px!important}
 .theme-library-grid,.skin-library-grid{grid-template-columns:1fr;gap:12px}
 #theme-library .theme-option{display:grid;grid-template-columns:110px minmax(0,1fr)}
 .theme-scene{height:100%;min-height:160px}.theme-option-copy{padding:13px}
 .library-mini-board{width:92px;height:92px}.library-mini-board .library-piece{height:31px}
 #theme-library .theme-option-copy p{min-height:0;margin:7px 0 12px;font-size:12px}
 #theme-library h3{font-size:20px!important}.skin-option{display:grid;grid-template-columns:100px 1fr;column-gap:12px;padding:12px;text-align:left}
 .skin-pair{grid-row:1/4;height:122px;gap:0}.skin-option button{grid-column:2}
 #theme-library .skin-option p{min-height:0;margin:0 0 8px}
 #theme-library .skin-option h3{margin:0 0 6px}.library-shop{align-items:flex-start}
 html[data-skin] body .header-right #theme-library-open{flex:1 1 100%;text-align:center;padding:7px 12px}
}
@media(prefers-reduced-motion:reduce){#theme-library *, #library-bitmap-preview *{scroll-behavior:auto;transition:none!important}}
