/* Library object collection; original editor ownership stays unchanged. */
[data-library-view][hidden], [data-library-active="true"] .golden-workspace,
[data-library-active="true"] .workspace-launcher { display: none !important; }
[data-library-editor="true"] .golden-heading,
[data-library-editor="true"] .golden-context,
[data-library-editor="true"] .stage-path,
[data-library-editor="true"] .workspace-launcher { display: none !important; }

.golden-shell[data-library-editor="true"] .tool-workspace:not([hidden]) { display: block; }
.golden-shell[data-library-editor="true"] .golden-workspace { display: block; max-width: none; }
[data-library-editor="true"] [data-workspace-tool="code"],
[data-library-editor="true"] [data-tool-expand] { display: none; }
[data-library-active="true"] [data-persistence],
[data-library-editor="true"] [data-persistence] { display: none; }
/* Object shapes retain the selected wireframe; shared semantic tokens own style. */
.library { color:var(--color-text); font:1rem/1.55 var(--font-reading); padding-block:var(--space-6); container-type:inline-size; }
.shell-destination:has(.library) { background:var(--color-canvas); }
[data-library-view] { background:var(--color-canvas); }
[data-library-view] > .library { padding:var(--space-6) var(--space-7); }
.library h1,.library h2,.library h4 { line-height:1.2; }
.library h1 { font:600 clamp(1.65rem,3vw,2.65rem)/1.05 var(--font-display); letter-spacing:-.025em; margin:0 0 .75rem; }
.library h1:focus { outline:none; }
.library h2 { font-size:20px; margin:0; }
.library p { margin:.5rem 0; }
.library button,.library input,.library select { font:inherit; color:inherit; }
.library button,.library select { min-height:44px; border:1px solid var(--color-rule); border-radius:var(--radius-control); background:var(--color-sheet-raised); padding:8px 16px; cursor:pointer; }
.library button:disabled { cursor:wait; opacity:.7; }
.library button:focus-visible,.library input:focus-visible,.library select:focus-visible,.library-preview:focus-visible { outline:3px solid var(--color-focus); outline-offset:3px; }
.library .library-primary { background:var(--color-nav); color:var(--color-text-on-dark); }
.library-top { display:flex; justify-content:space-between; gap:1rem; align-items:flex-start; }
.library-top p { color:var(--color-text-muted); }
.library .library-link { flex-shrink:0; background:transparent; font-size:.875rem; }
.library-toolbar { display:flex; align-items:center; gap:var(--space-4); margin:var(--space-5) 0 0; }
.library-form { display:flex; flex:1; min-width:0; position:relative; align-items:center; gap:var(--space-2); padding:4px 4px 4px 46px; border:1px solid var(--color-rule-strong); border-radius:var(--radius-control); background:var(--color-sheet-raised); }
.library-search-icon { position:absolute; left:16px; width:18px; height:18px; fill:none; stroke:var(--color-text-muted); stroke-width:1.5; }
.library-field { flex:1; min-width:0; }
.library-field label { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.library-field input { width:100%; min-height:44px; min-width:0; background:transparent; border:0; padding:8px 0; }
.library-field input::placeholder { color:var(--color-text-muted); opacity:1; }
.library-sort { display:flex; gap:var(--space-2); align-items:center; font-size:.875rem; }
.library-sort select { max-width:100%; }
#library-scope { color:var(--color-text-muted); font-size:.875rem; margin:var(--space-2) 0 var(--space-4); }
.library-materials { display:flex; flex-wrap:wrap; align-items:center; gap:10px; margin-bottom:20px; }
.library-materials button { display:inline-flex; align-items:center; gap:var(--space-2); background:transparent; border-color:transparent; }
.library-materials button[aria-pressed=true] { background:var(--color-sheet-raised); border-color:var(--color-rule-strong); }
.library-materials svg,.library-mark svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.5; }
.library-current { margin-left:auto; color:var(--color-text-muted); font-size:.75rem; }
.library-filters { display:flex; justify-content:space-between; gap:10px; padding-bottom:20px; border-bottom:1px solid var(--color-rule); }
.library-views { display:flex; gap:var(--space-2); }
.library-body { margin-top:22px; }
.library-section-heading,.library-group-heading { display:flex; justify-content:space-between; gap:12px; align-items:baseline; margin-bottom:20px; }
.library-section-heading h2 { font-size:15px; }
.library-count,.library-group-heading>span { color:var(--color-text-muted); font-size:.75rem; }
.library-grid { display:grid; grid-template-columns:minmax(0,1fr); gap:var(--space-5); }
@container (min-width:620px) { .library-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@container (min-width:1000px) { .library-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
.library .library-item { position:relative; display:flex; flex-direction:column; align-items:stretch; gap:0; min-width:0; min-height:224px; padding:var(--space-5); text-align:left; border:1px solid var(--color-rule); background:var(--color-sheet-raised); border-radius:var(--radius-control); overflow-wrap:anywhere; }
.library .library-note { background:var(--color-sheet); border-radius:2px; }
.library-note::before { content:''; position:absolute; top:-1px; right:-1px; width:28px; height:28px; background:var(--color-canvas); clip-path:polygon(0 0,100% 0,100% 100%); pointer-events:none; }
.library-note::after { content:''; position:absolute; top:0; right:0; width:27px; height:27px; background:var(--color-rule); clip-path:polygon(0 0,0 100%,100% 100%); pointer-events:none; }
.library-item:hover { border-color:var(--color-rule-strong); }
.library .library-selected { outline:2px solid var(--color-focus); outline-offset:3px; }
.library-type { display:flex; gap:var(--space-2); align-items:center; color:var(--color-text-muted); font-size:.75rem; font-weight:700; margin-bottom:var(--space-4); }
.library-mark { width:25px; height:25px; border-radius:2px; background:var(--color-canvas); display:grid; place-items:center; }
.library-note .library-type { color:var(--color-reasoning); }
.library-note .library-mark { background:var(--color-rule); }
.library-item strong { font-size:18px; line-height:1.4; margin-bottom:8px; }
.library-excerpt { white-space:pre-wrap; overflow-wrap:anywhere; font-size:.875rem; }
.library-item .library-excerpt { color:var(--color-text-muted); display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.library-row-meta { display:flex; justify-content:space-between; align-items:flex-end; gap:12px; margin-top:auto; padding-top:14px; border-top:1px solid var(--color-rule); font-size:.75rem; color:var(--color-text-muted); }
.library-row-meta>span { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.library-row-meta time { flex-shrink:0; }
.library-item>.library-excerpt { margin-bottom:22px; }
.library-canvas { display:block; background:var(--color-canvas); border:1px solid var(--color-rule); border-radius:2px; margin:2px 0 14px; min-height:88px; }
.library-canvas svg { display:block; width:100%; height:88px; }
.library-canvas rect { fill:var(--color-sheet-raised); stroke:var(--color-rule-strong); stroke-width:.7; }
.library-canvas text { fill:var(--color-text-muted); font:9px var(--font-reading); }
.library-board-empty { display:block; padding:24px 12px; color:var(--color-text-muted); font-size:.75rem; text-align:center; }
.library-status { padding:32px 0; }
.library-group,.library-phase { margin-top:28px; }
.library-project { font-size:14px; color:var(--color-reasoning); margin:20px 0 12px; }
.library-lesson { margin:20px 0; }
.library-lesson h4 { margin:0; font-size:17px; }
.library-preview { color:var(--color-text); background:var(--color-sheet-raised); border:1px solid var(--color-rule); border-radius:var(--radius-sheet); padding:var(--space-6); width:min(44rem,calc(100% - 32px)); max-height:calc(100svh - 32px); overflow:auto; box-sizing:border-box; }
.library-preview::backdrop { background:var(--color-overlay); }
.library-preview h2 { font:600 1.65rem/1.15 var(--font-display); clear:both; margin:16px 0; overflow-wrap:anywhere; }
.library-close { float:right; }
.library-meta { color:var(--color-text-muted); font-size:.75rem; padding-top:12px; }
.library-source { margin:20px 0; font-size:.875rem; }
.library dt { color:var(--color-text-muted); }
.library dd { margin:4px 0 0; overflow-wrap:anywhere; }
.library-record { display:flex; gap:24px; font-size:.75rem; }
.library-tags { display:flex; flex-wrap:wrap; gap:var(--space-2); padding:0; list-style:none; font-size:.75rem; }
.library-tags li { border:1px solid var(--color-rule); border-radius:var(--radius-pill,999px); padding:4px 10px; }
@media(max-width:660px) { [data-library-view]>.library { padding:24px 18px; } .library { padding-block:24px; } .library-top { flex-wrap:wrap; } .library h1 { font-size:30px; } .library-toolbar { flex-direction:column; align-items:stretch; } .library-sort { align-self:flex-start; } .library-current { flex-basis:100%; margin-left:0; } .library-filters { flex-wrap:wrap; } .library .library-item { min-height:224px; padding:18px; } .library-form { padding-left:36px; } .library-search-icon { left:10px; } .library-form .library-primary { padding-inline:10px; } .library-preview { padding:var(--space-5); } }
.shell-destination:has(.library) main { background:var(--color-canvas); }
.library-section-heading h2 { font:700 .875rem/1.3 var(--font-reading); }

.library-note strong { font-family:var(--font-display); font-size:1.1875rem; font-weight:600; }
.library .library-primary:hover { background:var(--color-nav-deep); }

/* Keep related controls together and let saved material lead the page. */
.library-controls { display:flex; flex-wrap:wrap; gap:var(--space-3) var(--space-5); align-items:center; justify-content:space-between; }
.library-materials { margin:0; gap:var(--space-1); }
.library-filters { padding:0; border:0; align-items:center; justify-content:flex-start; gap:var(--space-3); }
.library-views { gap:0; }
.library-views button { border-radius:0; margin-left:-1px; padding-inline:var(--space-3); font-size:.875rem; }
.library-views button:first-child { margin-left:0; border-radius:var(--radius-control) 0 0 var(--radius-control); }
.library-views button:last-child { border-radius:0 var(--radius-control) var(--radius-control) 0; }
.library-views button[aria-pressed=true] { background:var(--color-sheet); color:var(--color-text); font-weight:700; border-color:var(--color-rule-strong); position:relative; }
.library-filters > button { background:transparent; border-color:transparent; color:var(--color-text-muted); font-size:.875rem; padding-inline:var(--space-2); }
.library-filters > button:hover { color:var(--color-text); text-decoration:underline; text-underline-offset:.2em; }
.library-body { border-top:1px solid var(--color-rule); padding-top:var(--space-5); margin-top:var(--space-4); }
.library-section-heading { margin-bottom:var(--space-4); }
.library-summary { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:baseline; gap:var(--space-2) var(--space-4); }
.library-summary .library-current { margin:0; }
.library-summary .library-count { margin:0; }
.library-type { margin-bottom:var(--space-3); }
.library-item strong { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; font-weight:600; }
.library-item .library-excerpt { -webkit-line-clamp:4; }
.library-item .library-row-meta { padding-top:var(--space-3); }
@container(max-width:700px) { .library-controls { gap:var(--space-2); } .library-section-heading { align-items:flex-start; } .library-summary { flex-direction:column; align-items:flex-end; gap:var(--space-1); } }
@media(max-width:660px) { .library-top .library-link { min-height:44px; } .library-toolbar { margin-top:var(--space-4); gap:var(--space-2); } .library-controls { gap:var(--space-2); } .library-body { padding-top:var(--space-4); } .library-grid { gap:var(--space-4); } }

/* The selected R02 reference keeps search, sort and material tabs above cards. */
.library-visually-hidden { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.library-toolbar { gap:var(--space-2); }
.library-form { padding-right:var(--space-4); border-color:var(--color-rule); }
.library-sort { flex-shrink:0; }
.library-materials button,.library-materials button[aria-pressed=true] { background:transparent; border-color:transparent; }
.library-materials button[aria-pressed=true] { background:var(--color-sheet-raised); border-color:var(--color-rule); font-weight:700; }
.library-controls { margin-top:var(--space-3); }
.library-body { margin-top:var(--space-4); padding-top:var(--space-4); }
.library-collection-footer { display:flex; align-items:flex-start; justify-content:space-between; gap:var(--space-4); border-top:1px solid var(--color-rule); margin-top:var(--space-6); padding-top:var(--space-3); }
.library-collection-footer .library-link { border-color:transparent; padding-inline:0; color:var(--color-text-muted); text-decoration:underline; text-underline-offset:.25em; }
.library-options { min-width:0; }
.library-options summary { display:flex; align-items:center; gap:var(--space-2); min-height:44px; color:var(--color-text-muted); cursor:pointer; font-size:.875rem; list-style:none; }
.library-options summary::-webkit-details-marker { display:none; }
.library-options summary::after { content:'⌄'; }
.library-options[open] summary::after { content:'⌃'; }
.library-options summary:focus-visible { outline:2px solid var(--color-focus); outline-offset:4px; }
.library-options .library-filters { margin-top:var(--space-3); flex-wrap:wrap; }
.library-options #library-scope { margin-bottom:0; }
@container(min-width:800px) { .library-grid { grid-template-columns:repeat(3,minmax(0,1fr)); } }
@media(max-width:660px) { .library-controls>.library-current { flex-basis:auto; margin-left:auto; } .library-collection-footer { flex-wrap:wrap; } }

.library-skeleton-card { display:flex; flex-direction:column; gap:16px; box-sizing:border-box; min-width:0; min-height:282px; padding:24px; border:1px solid var(--color-rule); border-radius:var(--radius-control); background:var(--color-sheet-raised); }
.library-skeleton-line { display:block; height:12px; border-radius:2px; background:var(--color-rule); opacity:.65; }
.library-skeleton-label { width:28%; height:20px; }
.library-skeleton-title { width:78%; height:20px; }
.library-skeleton-short { width:58%; }
.library-skeleton-meta { margin-top:auto; border-top:1px solid var(--color-rule); padding-top:16px; }
.library-skeleton-meta .library-skeleton-line { width:60%; }
.library-loading-heading { margin:0; color:var(--color-text-muted); font-size:.875rem; }

/* Match the shared missing-content indicator; no motion for reduced-motion users. */
.library-grid[aria-hidden="true"]{animation:library-loading-breathe 1.8s ease-in-out infinite}
@keyframes library-loading-breathe{50%{opacity:.55}}
@media(prefers-reduced-motion:reduce){.library-grid[aria-hidden="true"]{animation:none}}
@media print{.library-grid[aria-hidden="true"]{display:none}}
