html:has(#works-root) { background: var(--library-bg); }
.work-library { min-height: 100dvh; background: var(--library-bg, var(--apple-bg)); color: var(--apple-text); font-family: var(--font-body); }
.work-library * { box-sizing: border-box; }
.work-library a { color: inherit; text-decoration: none; }
.work-library button { font-family: inherit; cursor: pointer; }
.work-library :is(a, button):focus-visible { outline: 2px solid var(--apple-blue); outline-offset: 4px; }
.library-skip { position: fixed; top: 12px; left: 16px; z-index: 10; padding: 12px 16px; background: #1c1c1e; border: 1px solid var(--apple-hairline); border-radius: 8px; transform: translateY(-160%); }
.library-skip:focus { transform: translateY(0); }
.library-shell { width: min(1220px, calc(100% - 64px)); margin-inline: auto; }
.work-library main { padding-bottom: 48px; }
.library-topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 92px; border-bottom: 1px solid var(--apple-hairline-soft); }
.library-home { display: inline-flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 600; }
.library-home img { display: block; width: 36px; height: 36px; border: 1px solid var(--apple-hairline); border-radius: 50%; }
.library-actions { display: flex; align-items: center; gap: 24px; font-size: 12px; color: var(--apple-secondary); }
.library-actions > a { display: inline-flex; min-height: 44px; align-items: center; }
.library-language { min-width: 44px; min-height: 44px; padding: 0 10px; border: 1px solid var(--apple-hairline); border-radius: var(--portfolio-control-radius); background: transparent; color: var(--apple-text); font-size: 11px; }
.library-intro { padding: 52px 0 36px; }
.library-intro .page-title { margin: 0 0 var(--space-4); }
.library-intro > p:last-child { margin: 0; color: var(--apple-secondary); font-size: var(--type-supporting); line-height: 1.65; }
.library-filters { display: flex; flex-wrap: wrap; gap: 8px; }
/* Reserve the description lane even for "All": changing categories should
   not suddenly push the 3:4 cover grid down 35+ pixels. */
.library-category-note { min-height: 1.6em; margin: var(--space-4) 0 0; color: var(--apple-secondary); font-size: var(--type-caption); line-height: 1.6; }
.library-filters button { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; border: 1px solid var(--apple-hairline); border-radius: var(--portfolio-control-radius); background: transparent; color: var(--apple-secondary); font-size: 12px; transition: color var(--apple-duration-control) var(--apple-ease), background-color var(--apple-duration-control) var(--apple-ease), border-color var(--apple-duration-control) var(--apple-ease); }
.library-filter-count { color: var(--apple-tertiary); font: 10px var(--font-mono); }
.library-filter-short { display: none; }
.library-filters button[aria-pressed="true"] { background: var(--portfolio-tile-surface-hover); border-color: rgba(255,255,255,.28); color: var(--apple-text); }
.library-filters button:not([aria-pressed="true"]):hover { background: transparent; border-color: rgba(255,255,255,.28); color: var(--apple-text); }
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 24px; margin-top: 28px; }
.work-library .comet-archive__item { min-width: 0; }
.work-library .comet-archive__card { display: grid; width: 100%; height: 100%; min-width: 0; align-content: start; gap: 0; padding: 0; border: 0; background: transparent; color: var(--apple-text); text-align: left; }
.work-library .comet-archive__title { grid-row: 2; display: block; min-width: 0; min-height: 0; margin-top: var(--portfolio-work-title-gap); }
.work-library .comet-archive__image { position: relative; display: block; width: 100%; aspect-ratio: var(--portfolio-work-cover-ratio); overflow: hidden; border: 1px solid var(--portfolio-content-border); border-radius: var(--portfolio-content-radius); background: var(--comet-cover) center/cover no-repeat; box-shadow: var(--portfolio-content-shadow); }
.work-library .comet-archive__image::after { display: none; }
.work-library .comet-archive__image { grid-row: 1; background-size: var(--comet-cover-fit, cover); background-color: var(--portfolio-content-surface); }
.work-library .comet-archive__copy { grid-row: 3; display: block; margin-top: var(--portfolio-work-caption-gap); }
.work-library .comet-archive__details strong { display: block; max-width: none; text-align: left; }
.work-library .comet-archive__card:hover .comet-archive__image { transform: none; }
.library-empty { min-height: 300px; display: grid; align-content: center; justify-items: center; color: var(--apple-secondary); }
.library-empty p { font-size: 15px; }
.library-empty button { min-height: 44px; padding: 0 16px; border: 1px solid var(--apple-hairline); border-radius: var(--portfolio-control-radius); background: transparent; color: var(--apple-text); }
@media (min-width: 900px) { .library-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .library-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .library-shell { width: calc(100% - 32px); }
  .work-library main { padding-bottom: 32px; }
  .library-topbar { min-height: 76px; gap: 12px; }
  .library-actions { gap: 12px; font-size: 11px; }
  .library-home { gap: 8px; font-size: 13px; }
  .library-home img { width: 30px; height: 30px; }
  .library-intro { padding: 26px 0 28px; }
  .library-intro .page-title { margin-top: var(--space-3); }
  .library-intro > p:last-child { font-size: var(--type-supporting-mobile); }
  /* Two lines cover the longest EN description at narrow phone widths. */
  .library-category-note { font-size: var(--type-caption-mobile); min-height: 3.2em; }
  .library-filters { flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; }
  .library-filters button { position: relative; flex: 0 0 auto; justify-content: center; gap: 0; min-width: 44px; min-height: 44px; padding: 0 6px; border: 0; border-radius: 0; background: transparent; color: var(--apple-secondary); font-size: 13px; white-space: nowrap; }
  .library-filters .library-filter-label, .library-filters .library-filter-count { display: none; }
  .library-filter-short { display: inline; }
  .library-filters button[aria-pressed="true"], .library-filters button:hover { background: transparent; color: var(--apple-text); }
  .library-filters button[aria-pressed="true"]::after { content: ''; position: absolute; left: 2px; right: 2px; bottom: 4px; height: 1px; background: currentColor; }
  .library-filters button:focus-visible { outline-offset: -2px; }
  .library-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 14px; margin-top: 24px; }
}
/* Featured switches to the compact two-up card at 720px, not 760px.
   Match its card text rhythm even while the library toolbar is still compact. */
@media (max-width: 720px) {
  .work-library .comet-archive__title { margin-top: var(--portfolio-work-title-gap-mobile); }
  .work-library .comet-archive__copy { margin-top: var(--portfolio-work-caption-gap-mobile); }
}
@media (max-width: 349px) { .library-filters { display: grid; grid-template-columns: repeat(3, max-content); } }
@media (prefers-reduced-motion: reduce) { .library-filters button { transition: none; } }

/* Subtle locator for a work opened from the local Studio. */
.library-grid .comet-archive__card.library-preview-target{
  outline:2px solid #9ec7ec;outline-offset:5px;
  border-radius:18px;scroll-margin-top:110px;
}
