/* ── Layout ───────────────────────────────────────────────────────────────── */

.library-main {
  color: inherit;
}

.library-inner {
  max-width: 900px;
}

/* ── Header ───────────────────────────────────────────────────────────────── */

/* Title row + save count share one line; subtitle below (grid beats flex from catalog.css) */
.library-header.catalog-header-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.35rem;
  margin-bottom: 2rem;
}

.library-header .catalog-title {
  grid-column: 1;
  grid-row: 1;
  margin-bottom: 0;
  min-width: 0;
}

.library-header .library-save-count {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
}

.library-header .library-header-subtitle {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
}

/* Total saves - compact badge (circle + caption) */
.library-save-count {
  flex-shrink: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  margin: 0;
  padding: 0;
  text-align: center;
}

.library-save-count-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.85rem;
  min-height: 2.85rem;
  padding: 0 0.5rem;
  border-radius: 999px;
  box-sizing: border-box;
  background: linear-gradient(165deg, rgba(32, 30, 26, 0.95) 0%, rgba(18, 17, 15, 0.98) 100%);
  border: 1px solid rgba(200, 169, 110, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 2px 8px rgba(0, 0, 0, 0.35);
}

.library-save-count-value {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: #f2eee6;
  font-variant-numeric: tabular-nums;
}

/* Shimmer inside the badge while total is fetching */
#library-save-count-value.dt-val-loading {
  color: transparent;
  user-select: none;
  width: 1.45rem;
  min-width: 1.45rem;
  min-height: 0.72rem;
  border-radius: 3px;
  vertical-align: middle;
}

.library-save-count-label {
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(160, 150, 130, 0.85);
  max-width: 5.5rem;
}

/* Subtle tone shifts for non-supporter libraries that are filling up.
   Intentionally non-explicit (no copy, no icon) — just a warm tint cue. */
.library-save-count.is-tone-near .library-save-count-circle {
  border-color: rgba(212, 144, 10, 0.34);
  background: linear-gradient(165deg, rgba(36, 31, 24, 0.95) 0%, rgba(21, 18, 14, 0.98) 100%);
}
.library-save-count.is-tone-near .library-save-count-value {
  color: #ead7b0;
}

.library-save-count.is-tone-soft .library-save-count-circle {
  border-color: rgba(212, 144, 10, 0.45);
  background: linear-gradient(165deg, rgba(40, 32, 20, 0.95) 0%, rgba(24, 19, 12, 0.98) 100%);
}
.library-save-count.is-tone-soft .library-save-count-value {
  color: #f0d9a6;
}

.library-save-count.is-tone-warm .library-save-count-circle {
  border-color: rgba(212, 144, 10, 0.7);
  background: linear-gradient(165deg, rgba(54, 38, 18, 0.95) 0%, rgba(32, 22, 10, 0.98) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 2px 8px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(212, 144, 10, 0.08);
}
.library-save-count.is-tone-warm .library-save-count-value {
  color: #f3c97a;
}

.library-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

/* ── Library save nudge ───────────────────────────────────────────────────── */
/* Base = soft-promo CTA (10-20 saves, non-supporters). */
/* .is-over-limit = amber warning when >20 saves (all non-Pro users). */

.library-save-nudge {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 6px;
  background: rgba(59, 93, 156, 0.1);
  border: 1px solid rgba(59, 93, 156, 0.3);
}

.library-save-nudge-text {
  flex: 1;
  font-size: 0.82rem;
  color: rgba(200, 210, 240, 0.8);
  line-height: 1.4;
}

.library-save-nudge-cta {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #7fa8e8;
  text-decoration: none;
  white-space: nowrap;
}

.library-save-nudge-cta:hover {
  color: #a8c4f0;
}

.library-save-nudge.is-over-limit {
  background: rgba(212, 144, 10, 0.08);
  border-color: rgba(212, 144, 10, 0.34);
}

.library-save-nudge.is-over-limit .library-save-nudge-text {
  color: rgba(240, 217, 166, 0.92);
}

@media (max-width: 720px) {
  .library-save-nudge {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .library-save-nudge-text {
    flex: none;
    width: 100%;
    max-width: none;
  }

  .library-save-nudge-cta {
    align-self: flex-start;
  }
}

/* ── Legacy ───────────────────────────────────────────────────────────────── */

.library-kicker {
  margin: 0 0 4px;
  color: #555;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.library-title {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ebebeb;
}

.library-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: #555;
}

/* ── Filter bar (layout + spacing: `.catalog-filters` in catalog.css) ─────── */

/* Tuck controls + summary together; summary row carries spacing above type pills */
.library-filter-bar.catalog-filters {
  margin-bottom: 0.5rem;
}

/* Design type tabs - reuse `.profile-tabs` / `.profile-tab` from catalog.css (profile page) */
.library-design-type-tabs.profile-tabs {
  flex-wrap: wrap;
  row-gap: 0;
  margin: 0 auto 1.25rem;
  max-width: 900px;
}

/* Category colour on the active tab (replaces left border accent on each card) */
.library-design-type-tabs .profile-tab.is-active[data-filter-type="division"] {
  color: rgba(200, 169, 110, 0.98);
  border-bottom-color: rgba(196, 154, 85, 0.65);
}

.library-design-type-tabs .profile-tab.is-active[data-filter-type="tank"] {
  color: rgba(72, 178, 154, 0.98);
  border-bottom-color: rgba(52, 148, 124, 0.65);
}

.library-design-type-tabs .profile-tab.is-active[data-filter-type="ship"] {
  color: rgba(130, 165, 195, 0.98);
  border-bottom-color: rgba(110, 145, 175, 0.65);
}

.library-design-type-tabs .profile-tab.is-active[data-filter-type="research"] {
  color: rgba(120, 170, 220, 0.98);
  border-bottom-color: rgba(100, 150, 200, 0.65);
}

.library-design-type-tabs .profile-tab.is-active[data-filter-type="doctrine"] {
  color: rgba(170, 140, 210, 0.98);
  border-bottom-color: rgba(150, 120, 200, 0.65);
}

.library-design-type-tabs .profile-tab[data-filter-type="division"]:hover:not(.is-active) {
  color: rgba(196, 154, 85, 0.75);
}

.library-design-type-tabs .profile-tab[data-filter-type="tank"]:hover:not(.is-active) {
  color: rgba(52, 148, 124, 0.78);
}

.library-design-type-tabs .profile-tab[data-filter-type="ship"]:hover:not(.is-active) {
  color: rgba(110, 145, 175, 0.78);
}

.library-design-type-tabs .profile-tab[data-filter-type="research"]:hover:not(.is-active) {
  color: rgba(100, 150, 200, 0.78);
}

.library-design-type-tabs .profile-tab[data-filter-type="doctrine"]:hover:not(.is-active) {
  color: rgba(150, 120, 200, 0.78);
}

.library-muted {
  color: #6e6455;
  font-size: 0.8rem;
}

/* ── Designs list ─────────────────────────────────────────────────────────── */

.library-designs-grid {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Library list: compact rows; preview expands per row (see .library-row--compact-open) */
#library-designs-panel .library-designs-grid {
  gap: 0.45rem;
  min-width: 0;
  max-width: 968px;
}

#library-designs-panel .library-row {
  min-width: 0;
}

#library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview {
  opacity: 0;
  flex: 0 0 0 !important;
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  max-height: 0;
  min-height: 0 !important;
  overflow: hidden;
  margin: 0 !important;
  padding-block: 0 !important;
  padding-inline: 0 !important;
  border-width: 0 !important;
  pointer-events: none;
  visibility: hidden;
  /* Close: no preview animation - card gap/padding/chrome transitions only. */
  transition: none;
}

/* Path-v2: resting transform so open can animate from below (close stays instant). */
#library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
  transform: translateY(1.35rem);
  transform-origin: top center;
}

#library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview {
  opacity: 1;
  flex: revert !important;
  width: revert !important;
  min-width: revert !important;
  max-width: revert !important;
  max-height: 2000px;
  min-height: unset;
  overflow: visible;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: revert;
  border-width: revert;
  border-style: revert;
  border-color: revert;
  pointer-events: auto;
  visibility: visible;
  transition:
    opacity 0.24s ease,
    max-height 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.28s ease,
    flex-basis 0.28s ease,
    padding 0.28s ease,
    margin 0.28s ease,
    border-width 0.28s ease,
    visibility 0s linear 0s;
}

/* Path-v2 open: slide up + fade (close still instant - see base closed preview). */
#library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
  transform: translateY(0);
  transform-origin: top center;
  max-height: min(33rem, 84vh);
  transition:
    opacity 0.3s cubic-bezier(0.33, 1, 0.68, 1) 0.05s,
    max-height 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    width 0s linear,
    flex-basis 0s linear,
    padding 0.34s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    margin 0.28s ease,
    border-width 0.28s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {
  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2,
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
    transform: none;
  }

  @media (max-width: 720px) {
    #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview,
    #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview {
      transform: none;
    }

    #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview {
      transition: opacity 0.15s ease, max-height 0.2s ease, visibility 0s linear 0s;
    }
  }
}

/* Module strips (tank + ship): natural grid height (no max-height — avoids squashed rows). Simple tank icon strip stays short. */
#library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--tank-modules,
#library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--ship-modules {
  max-height: none;
  min-height: 0;
  transition:
    opacity 0.22s ease 0.04s,
    max-height 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    width 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    flex-basis 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    padding 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    margin 0.28s ease,
    border-width 0.28s ease,
    visibility 0s linear 0s;
}

#library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--tank:not(.design-card-preview--tank-modules) {
  max-height: 9rem;
  min-height: 5.05rem;
  transition:
    opacity 0.22s ease 0.04s,
    max-height 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    width 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    flex-basis 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    padding 0.28s cubic-bezier(0.33, 1, 0.32, 1),
    margin 0.28s ease,
    border-width 0.28s ease,
    visibility 0s linear 0s;
}

#library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview.design-card-preview--tank-modules,
#library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview.design-card-preview--ship-modules,
#library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview.design-card-preview--tank:not(.design-card-preview--tank-modules) {
  transition: none;
}

#library-designs-panel .library-design-card {
  --lib-card-pad-x: 0.72rem;
  --lib-card-pad-y: 0.42rem;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  transition: gap 0.28s ease, padding 0.28s ease, box-shadow 0.22s ease, border-radius 0.22s ease;
}

/* Doctrine/research rows: slightly longer card chrome to match path-v2 preview open. */
#library-designs-panel .library-row:has(> .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2) > .library-design-card {
  transition:
    gap 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.22s ease,
    border-radius 0.22s ease;
}

#library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card {
  cursor: pointer;
}

#library-designs-panel .library-row.library-row--compact-open > .library-design-card {
  cursor: default;
}

#library-designs-panel .library-design-card .design-card-body {
  flex: 1 1 auto;
  min-width: 0;
}

#library-designs-panel .library-design-card-icon-well {
  width: 44px;
  min-height: 2.75rem;
  align-self: center;
  border-radius: 4px;
}

#library-designs-panel .library-design-card-icon-img {
  width: 36px;
  height: 30px;
}

#library-designs-panel .library-design-card-icon-img--sm {
  width: 20px;
  height: 20px;
}

#library-designs-panel .library-design-card-icon-svg {
  width: 22px;
  height: 22px;
}

#library-designs-panel .library-design-card-body-main {
  gap: 0.28rem;
}

#library-designs-panel .library-design-card-tags-section {
  margin-top: 0.12rem;
}

#library-designs-panel .library-design-card-title.design-card-title {
  font-size: 0.86rem;
}

#library-designs-panel .library-design-card-toolbar {
  flex: 0 1 auto;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  align-self: center;
}

#library-designs-panel .library-design-card-toolbar-start:empty {
  display: none;
}

#library-designs-panel .library-design-card-toolbar-btn {
  padding: 0.28rem 0.52rem;
  font-size: 0.62rem;
}

#library-designs-panel .library-row-more-btn {
  width: 1.85rem;
  height: 1.85rem;
}

/* One row opened: comfortable-style card + preview for that item only */
#library-designs-panel .library-row.library-row--compact-open > .library-design-card {
  --lib-card-pad-x: 1.08rem;
  --lib-card-pad-y: 0.83rem;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 0.74rem 0.98rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  min-width: 0;
  box-sizing: border-box;
}

#library-designs-panel .library-row.library-row--compact-open > .library-design-card.design-card--tank {
  padding: var(--lib-card-pad-y) var(--lib-card-pad-x);
}

#library-designs-panel .library-row.library-row--compact-open > .library-design-card .design-card-body {
  flex: 1 1 0;
  min-width: 0;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-icon-well {
  width: 65px;
  min-height: 4.9rem;
  align-self: stretch;
  border-radius: 5px;
}

/* Templates / tank / ship: center icon vs preview; doctrine & research (path-v2) keep stretch + top align. */
#library-designs-panel
  .library-row.library-row--compact-open:not(:has(> .library-design-card > .design-card-preview.design-card-preview--path-v2))
  .library-design-card-icon-well {
  align-self: center;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-icon-img {
  width: 50px;
  height: 42px;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-icon-img--sm {
  width: 24px;
  height: 24px;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-icon-svg {
  width: 28px;
  height: 28px;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-body-main {
  gap: 0.5rem;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-tags-section {
  margin-top: 0.38rem;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-title.design-card-title {
  font-size: 0.98rem;
}

#library-designs-panel .library-row.library-row--compact-open > .library-design-card > .library-design-card-toolbar {
  flex: 1 1 100%;
  width: 100%;
  max-width: none;
  min-width: 0;
  align-self: stretch;
  margin: 0.15rem calc(-1 * var(--lib-card-pad-x)) calc(-1 * var(--lib-card-pad-y));
  padding: 0.65rem var(--lib-card-pad-x);
  background: rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(233, 220, 199, 0.06);
  border-radius: 0 0 6px 6px;
}

#library-designs-panel .library-row.library-row--compact-open .library-design-card-toolbar-btn {
  padding: 0.32rem 0.65rem;
  font-size: 0.68rem;
}

#library-designs-panel .library-row.library-row--compact-open .library-row-more-btn {
  width: 2rem;
  height: 2rem;
}

@media (min-width: 721px) {
  /* Division / tank / ship: vertically center header block with sidebar preview. */
  #library-designs-panel
    .library-row.library-row--compact-open:not(:has(> .library-design-card > .design-card-preview.design-card-preview--path-v2))
    > .library-design-card {
    align-items: center;
  }

  /* Doctrine / research (path-v2): top-align - tall carousel + full-width preview read better from the top. */
  #library-designs-panel
    .library-row.library-row--compact-open:has(> .library-design-card > .design-card-preview.design-card-preview--path-v2)
    > .library-design-card {
    align-items: flex-start;
  }

  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview {
    flex: 0 1 264px !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: min(264px, 100%) !important;
    padding: 0.52rem;
    box-sizing: border-box;
  }

  /* Ship preview has more cols than tank; scale width so cells stay the same physical size (tank = 264px / 6 cols). */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--ship-modules {
    flex: 0 1 calc(264px * var(--ship-preview-cols, 7) / 6) !important;
    max-width: min(calc(264px * var(--ship-preview-cols, 7) / 6), 100%) !important;
  }

  #library-designs-panel
    .library-row.library-row--compact-open:has(> .library-design-card > .design-card-preview.design-card-preview--path-v2)
    > .library-design-card
    > .design-card-preview {
    align-self: flex-start;
  }

  /* Doctrine/research (path-v2 + carousel) are authored for ~280px; narrow sidebar clipped them - own full row under title. */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: none !important;
    padding: 0.55rem 0.64rem 0.5rem;
    gap: 0.42rem;
  }

  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--path:not(.design-card-preview--path-v2) {
    min-height: 4.5rem;
    padding: 0.56rem 0.65rem;
    gap: 0.32rem 0.42rem;
  }

  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.library-path-carousel .library-path-carousel-shell,
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.library-path-carousel .library-path-carousel-track {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  /* Compact list: wrap so a full-width preview slot can sit under the title row with max-height:0 when closed */
  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card .design-card-body {
    flex: 1 1 0;
    min-width: 0;
    order: 1;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card .library-design-card-title.design-card-title {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .library-design-card-toolbar {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    align-self: center;
    justify-content: flex-end;
    order: 2;
    padding-top: 0;
    margin-top: 0;
    border-top: none;
  }

  /*
   * Closed preview: match research/doctrine (path-v2) — collapse vertically on a full-width
   * row instead of width:0 “slide from the side”. Same translateY cue as path-v2 on open/close.
   */
  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    max-height: 0 !important;
    min-height: 0 !important;
    order: 3;
    opacity: 0;
    transform: translateY(0.85rem);
    transform-origin: top center;
    overflow: hidden;
    margin: 0 !important;
    padding-block: 0 !important;
    padding-inline: 0 !important;
    border-width: 0 !important;
    pointer-events: none;
    visibility: hidden;
    transition: none;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
    transform: translateY(1.35rem);
  }

  /* Expanded card: keep comfortable mobile (wrap + full-width toolbar strip) */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Expanded: same visual order as DOM — body row, full-width preview, full-width toolbar strip on the right */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-body {
    order: 1;
  }

  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .library-design-card-toolbar {
    justify-content: flex-end;
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
    min-width: 0;
    align-self: stretch;
    box-sizing: border-box;
    margin: 0.15rem calc(-1 * var(--lib-card-pad-x)) calc(-1 * var(--lib-card-pad-y));
    padding: 0.65rem var(--lib-card-pad-x);
    padding-top: 0.45rem;
    border-top: 1px solid rgba(233, 220, 199, 0.07);
  }

  /*
   * Expanded preview on mobile: full-width row below the title block.
   * Resets catalog's <560px `order: -1` rule (which pushes preview to top of card).
   * Height + translateY + opacity (same family as path-v2), not width/flex-basis peel from the side.
   */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview {
    order: 2;
    flex: 0 0 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(40rem, 88vh);
    box-sizing: border-box;
    transform: translateY(0);
    transition:
      opacity 0.3s cubic-bezier(0.33, 1, 0.68, 1) 0.05s,
      max-height 0.42s cubic-bezier(0.22, 1, 0.36, 1),
      padding 0.34s cubic-bezier(0.25, 0.46, 0.45, 0.94),
      margin 0.28s ease,
      border-width 0.28s ease,
      transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0s linear 0s;
  }

  /* Module strips (tank + ship): natural grid height. Capping max-height squashes
   * the 2-row aspect-ratio cells and they visually overlap. Simple tank icon strip
   * (no module grid) keeps the short band. */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--tank-modules,
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--ship-modules {
    max-height: none;
    min-height: 0;
  }

  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--tank:not(.design-card-preview--tank-modules) {
    max-height: 7.5rem;
    min-height: 4.5rem;
  }

  /* Doctrine/research carousel: shorter cap on mobile (avoid swallowing the viewport) */
  #library-designs-panel .library-row.library-row--compact-open > .library-design-card > .design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
    max-height: min(28rem, 68vh);
  }

  /* Icon-well: stay centered with title on mobile expanded (no full-height stretch — keeps the top row tight) */
  #library-designs-panel .library-row.library-row--compact-open .library-design-card-icon-well {
    align-self: center;
    min-height: 0;
  }

  /* Design type tabs: single scrollable row on mobile */
  .library-design-type-tabs.profile-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .library-design-type-tabs.profile-tabs::-webkit-scrollbar {
    display: none;
  }

  .library-design-type-tabs .profile-tab {
    flex: 0 0 auto;
  }
}

/* ── Row (wraps a catalog-style .design-card; see landing.css) ───────────── */

.library-row {
  position: relative;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  transition: opacity 0.25s ease, filter 0.25s ease;
}

/* Dim all other rows when one is expanded */
.library-designs-grid:has(.library-row.is-expanded) .library-row:not(.is-expanded) {
  opacity: 0.38;
  filter: brightness(0.65);
}

.library-row.is-expanded > .library-design-card {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* Library cards: same tokens as catalog .design-card; mobile stacks, desktop centers body vs preview */
.library-design-card {
  --lib-card-pad-x: 1.15rem;
  --lib-card-pad-y: 0.95rem;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  width: 100%;
  box-sizing: border-box;
  padding: var(--lib-card-pad-y) var(--lib-card-pad-x);
  gap: 0.85rem 1.15rem;
}

/* Match catalog desktop: body + preview vertically centered on the same row */
@media (min-width: 721px) {
  .library-design-card {
    align-items: center;
  }

  .library-design-card > .design-card-preview {
    align-self: center;
  }
}

/* Drop catalog’s extra tank vertical padding - Library uses one density for all kinds */
.library-design-card.design-card--tank {
  padding: var(--lib-card-pad-y) var(--lib-card-pad-x);
}

.library-design-card .design-card-body {
  flex: 1 1 220px;
  min-width: min(100%, 220px);
}

.library-design-card > .design-card-preview {
  margin-top: 0;
}

/* Research / doctrine: chip strip (Library list preview) */
.design-card-preview.design-card-preview--path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  gap: 0.35rem 0.45rem;
  width: 280px;
  min-height: 4.75rem;
  padding: 0.65rem 0.75rem;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.design-card-preview.design-card-preview--path.design-card-preview--path-v2 {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  align-content: stretch;
  gap: 0.45rem;
  padding: 0.55rem 0.6rem;
}

/* Keep path / pyramid previews in a fixed sidebar column (catalog + library), not full-bleed when the card wraps */
.design-card > .design-card-preview.design-card-preview--path-v2,
.design-card > .design-card-preview.design-card-preview--doctrine-pyramid,
.design-card > .design-card-preview.design-card-preview--research-pyramid {
  flex: 0 0 auto;
  width: 280px;
  max-width: min(280px, 100%);
  box-sizing: border-box;
}

.library-research-track-count {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #c49a55;
  text-align: right;
}

.library-research-tech-areas {
  max-height: 7.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 154, 85, 0.3) transparent;
}

.library-research-sp-specs {
  max-height: 6rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 154, 85, 0.3) transparent;
}

.library-path-preview-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.library-path-summary-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.58rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8f846f;
  padding: 0.16rem 0.38rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.library-path-preview-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.4rem;
}

/* Multi-section path preview: carousel (swipe viewport + arrows + dots) */
.library-path-carousel {
  gap: 0.4rem;
}

.library-path-carousel-shell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.library-path-carousel-nav {
  flex: 0 0 1.65rem;
  width: 1.65rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  background: rgba(22, 22, 22, 0.9);
  color: #aaa08d;
  font-size: 1.15rem;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.library-path-carousel-nav:hover:not(:disabled) {
  border-color: rgba(196, 154, 85, 0.45);
  color: #d8c89a;
  background: rgba(34, 32, 28, 0.95);
}

.library-path-carousel-nav:disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.library-path-carousel-viewport {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: rgba(196, 154, 85, 0.25) transparent;
}

.library-path-carousel-viewport::-webkit-scrollbar {
  height: 4px;
}

.library-path-carousel-viewport::-webkit-scrollbar-thumb {
  background: rgba(196, 154, 85, 0.25);
  border-radius: 999px;
}

.library-path-carousel-track {
  display: flex;
  flex-flow: row nowrap;
  gap: 0;
  align-items: stretch;
}

.library-path-carousel-slide {
  flex: 0 0 100%;
  box-sizing: border-box;
  min-width: 100%;
  max-width: 100%;
  scroll-snap-align: start;
}

.library-path-carousel-dots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.1rem;
}

.library-path-carousel-dot {
  margin: 0;
  padding: 0;
  width: 0.45rem;
  height: 0.45rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.12s ease;
}

.library-path-carousel-dot:hover {
  background: rgba(255, 255, 255, 0.22);
}

.library-path-carousel-dot.is-active {
  background: rgba(196, 154, 85, 0.85);
  transform: scale(1.2);
}

.library-path-preview-group {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
  padding: 0.32rem 0.38rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.library-path-preview-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.library-path-preview-group-title {
  min-width: 0;
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #978a73;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-path-preview-group-count {
  flex-shrink: 0;
  font-size: 0.58rem;
  color: #7f7566;
}

.library-path-preview-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.22rem 0.26rem;
}

.library-path-preview-chip {
  display: inline-block;
  max-width: 100%;
  font-size: 0.62rem;
  line-height: 1.3;
  color: #c4bcb0;
  padding: 0.22rem 0.5rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.library-path-preview-more {
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6e685c;
  padding: 0.15rem 0.1rem;
}

/* Doctrine card preview: three slides (land / naval / SF) with pyramid layout */
.library-doctrine-pillar {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
  padding: 0.35rem 0.4rem 0.45rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 6.5rem;
  box-sizing: border-box;
}

.library-doctrine-pillar-title {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: #a89878;
}

.library-doctrine-pyramid {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.library-doctrine-pyramid-apex {
  text-align: center;
  margin: 0 auto;
  width: 100%;
  max-width: 88%;
  padding: 0.32rem 0.45rem 0.38rem;
  border-radius: 3px 3px 2px 2px;
  background: linear-gradient(180deg, rgba(196, 154, 85, 0.12) 0%, rgba(0, 0, 0, 0.2) 100%);
  border: 1px solid rgba(196, 154, 85, 0.22);
  clip-path: polygon(6% 0, 94% 0, 100% 100%, 0 100%);
}

.library-doctrine-pyramid-caption {
  display: block;
  font-size: 0.52rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #7f7566;
  margin-bottom: 0.2rem;
}

.library-doctrine-pyramid-value {
  font-size: 0.66rem;
  line-height: 1.25;
  color: #d8d2c4;
  font-weight: 600;
}

.library-doctrine-pyramid-value--empty {
  color: #5c574d;
  font-weight: 400;
}

.library-doctrine-pyramid-base {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.library-doctrine-track-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 0.35rem;
  align-items: center;
  font-size: 0.6rem;
  line-height: 1.25;
  padding: 0.22rem 0.32rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.library-doctrine-track-name {
  color: #8f846f;
  font-size: 0.56rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.library-doctrine-track-pick {
  color: #c9c2b5;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-doctrine-track-pick--empty {
  color: #5a554c;
  font-style: italic;
  text-align: right;
  font-weight: 400;
}

.library-doctrine-pillar--sf .library-doctrine-sf-hint {
  margin: -0.15rem 0 0.25rem;
  font-size: 0.54rem;
  color: #6e685c;
  text-align: center;
}

.library-doctrine-sf-trees {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.library-doctrine-sf-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.62rem;
  padding: 0.28rem 0.38rem;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.library-doctrine-sf-name {
  color: #a89f90;
  letter-spacing: 0.02em;
}

.library-doctrine-sf-count {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #c49a55;
  min-width: 1.25rem;
  text-align: right;
}

/* Body: icon + copy */
.library-design-card .library-design-card-body {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.9rem;
}

.library-design-card-icon-well {
  flex-shrink: 0;
  width: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 5.25rem;
  background: linear-gradient(165deg, rgba(22, 22, 22, 1) 0%, rgba(12, 12, 12, 1) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  box-sizing: border-box;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.library-design-card-icon-img {
  width: 48px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
}

.library-design-card-icon-img--sm {
  width: 20px;
  height: 20px;
  filter: brightness(0.75);
  object-fit: contain;
  image-rendering: auto;
}

.library-design-card-icon-svg {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  fill: none;
  stroke: #7a7368;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.library-design-card-body-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.library-design-card-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.library-design-card-type.design-card-type {
  margin: 0;
  letter-spacing: 0.08em;
}

.library-design-card-title.design-card-title {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.3;
  color: #e4e0d8;
}

.library-design-card-tags-section {
  margin-top: 0.38rem;
}

.library-design-card-tags-row.design-card-tags {
  gap: 0.3rem;
}

/* Match catalog .design-card-tag (landing.css); tags are <button> - reset UA / inherited font. */
.library-design-card .library-design-card-tags-row.design-card-tags .design-card-tag.library-design-card-tag {
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: normal;
  text-transform: none;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

.library-design-card-toolbar {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-sizing: border-box;
  width: 100%;
  margin: 0.15rem calc(-1 * var(--lib-card-pad-x)) calc(-1 * var(--lib-card-pad-y));
  padding: 0.65rem var(--lib-card-pad-x);
  background: rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(233, 220, 199, 0.06);
  border-radius: 0 0 6px 6px;
}

.library-design-card-toolbar-start {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  min-width: 0;
}

.library-design-card-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin-left: auto;
}

/* Library row footer: one visual language (panel buttons + square more) */
.library-design-card-toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.32rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(26, 26, 26, 0.95);
  color: #a09888;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.library-design-card-toolbar-btn--details:hover {
  border-color: rgba(196, 154, 85, 0.4);
  color: #d8c89a;
  background: rgba(34, 32, 24, 0.9);
}

.library-design-card-toolbar-btn--load {
  border-color: rgba(196, 154, 85, 0.38);
  color: #c9a86a;
}

.library-design-card-toolbar-btn--load:hover {
  border-color: rgba(212, 176, 108, 0.65);
  color: #ecd9a8;
  background: rgba(38, 34, 26, 0.92);
}

/* Wide cards: spacing only (tag chip size matches catalog at all breakpoints) */
@media (min-width: 721px) {
  .library-design-card-tags-section {
    margin-top: 0.32rem;
  }

  .library-design-card-body-main {
    gap: 0.42rem;
  }
}

@media (max-width: 720px) {
  .library-design-card {
    flex-direction: column;
    align-items: stretch;
  }

  .library-design-card .design-card-body {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Full-width preview strip (no centered narrow column) */
  .library-design-card > .design-card-preview {
    width: 100% !important;
    max-width: 100% !important;
    align-self: stretch;
    box-sizing: border-box;
  }

  .library-design-card-toolbar {
    flex-wrap: wrap;
  }
}

/* Match catalog narrow cards (landing.css ~560px): grid spans full card width, preview first */
@media (max-width: 560px) {
  .library-design-card {
    padding: 0;
    gap: 0;
    overflow: hidden;
  }

  .library-design-card.design-card--tank {
    padding: 0;
  }

  .library-design-card > .design-card-preview {
    order: -1;
    width: 100% !important;
    max-width: 100% !important;
    flex-shrink: 1;
    margin: 0;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #1e1e1e;
    background: rgba(0, 0, 0, 0.15);
  }

  .library-design-card > .design-card-preview.design-card-preview--tank-modules,
  .library-design-card > .design-card-preview.design-card-preview--ship-modules,
  .library-design-card > .design-card-preview.design-card-preview--tank {
    width: 100% !important;
    max-width: 100% !important;
  }

  .library-design-card .design-card-body {
    padding: 0.75rem 1rem;
  }

  .library-design-card-toolbar {
    margin: 0;
    padding: 0.65rem 1rem;
    border-radius: 0;
  }

  .library-design-card .library-design-card-title.design-card-title {
    font-size: 0.875rem;
  }
}

@media (max-width: 560px) {
  #library-designs-panel .library-design-card {
    padding: var(--lib-card-pad-y) var(--lib-card-pad-x);
    gap: 0.5rem 0.6rem;
    overflow: visible;
  }

  #library-designs-panel .library-design-card.design-card--tank {
    padding: var(--lib-card-pad-y) var(--lib-card-pad-x);
  }

  #library-designs-panel .library-design-card .design-card-body {
    padding: 0;
  }

  /* Inline toolbar on compact rows; expanded card keeps strip spacing from base open rules */
  #library-designs-panel .library-row:not(.library-row--compact-open) > .library-design-card > .library-design-card-toolbar {
    padding: 0;
  }
}

.library-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.library-row-tag {
  display: inline-flex;
  align-items: center;
  max-width: 140px;
  padding: 2px 6px;
  border: 1px solid rgba(196, 154, 85, 0.28);
  border-radius: 999px;
  background: rgba(196, 154, 85, 0.08);
  color: #c9b58a;
  font-size: 0.68rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.library-row-tag:hover {
  filter: brightness(1.08);
}

/* Quick filters: tags that appear in the current type tab (counts = designs in this category) */
.library-tag-strip-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  margin-bottom: 0.7rem;
  max-width: 968px;
  margin-left: auto;
  margin-right: auto;
}

.library-tag-strip-heading {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.library-tag-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  align-items: center;
}

.library-tag-strip-chip {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(200, 169, 110, 0.28);
  background: rgba(22, 20, 18, 0.92);
  color: #c4b8a4;
  font-family: inherit;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.library-tag-strip-chip:hover {
  border-color: rgba(200, 169, 110, 0.48);
  color: #e8dcc8;
  background: rgba(200, 169, 110, 0.07);
}

.library-tag-strip-chip.is-active {
  border-color: rgba(200, 169, 110, 0.65);
  background: rgba(200, 169, 110, 0.14);
  color: #f2ead8;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.library-tag-strip-count {
  margin-left: 0.38rem;
  padding: 0.06rem 0.28rem;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: rgba(180, 165, 140, 0.88);
  background: rgba(0, 0, 0, 0.28);
}

.library-tag-strip-chip.is-active .library-tag-strip-count {
  color: rgba(240, 232, 216, 0.9);
  background: rgba(0, 0, 0, 0.35);
}

.library-tag-strip-wrap[hidden] {
  display: none;
}

.library-tag-filter-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 0.75rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Author display:flex wins over UA [hidden] - hide explicitly when no tag filter */
.library-tag-filter-row[hidden] {
  display: none;
}

.library-active-tag-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.library-tag-filter-chip {
  gap: 4px;
}

.library-tag-filter-clear-x {
  margin-left: 2px;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.75;
}

.library-tag-filter-clear-all {
  background: none;
  border: none;
  color: var(--hoi4-muted, #888);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.library-tag-filter-clear-all:hover {
  color: var(--hoi4-text, #ddd);
}

.library-row-extra-template {
  padding: 12px 0;
}

.library-row-extra-template + .library-row-extra-template {
  border-top: 1px solid #2a2a2a;
}

.library-row-extra-template-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7a7265;
  margin-bottom: 8px;
}

/* More options - same footprint as toolbar text buttons */
.library-row-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(26, 26, 26, 0.95);
  color: #9a9080;
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  flex-shrink: 0;
  box-sizing: border-box;
}

.library-row-more-btn:hover {
  border-color: rgba(196, 154, 85, 0.4);
  color: #d0c4a8;
  background: rgba(34, 32, 24, 0.9);
}

/* Floating dropdown - position: absolute on body, escapes overflow:hidden on rows */
.library-row-more-menu {
  position: absolute;
  min-width: 160px;
  background: #161616;
  border: 1px solid #262626;
  border-radius: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 500;
  overflow: hidden;
  padding: 3px 0;
}

.library-row-more-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.5rem 0.85rem;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  color: #888;
  text-decoration: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  box-sizing: border-box;
}

.library-row-more-item:hover {
  background: #1e1e1e;
  color: #d0d0d0;
}

.library-row-more-item--danger {
  color: #8a4a4a;
}

.library-row-more-item--danger:hover {
  background: #1a1010;
  color: #c07070;
}


/* ── Row expanded content ─────────────────────────────────────────────────── */

/* Grid trick: 0fr → 1fr animates height without knowing the content size */
.library-row-content[hidden] {
  display: none;
}

.library-row-content {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  background: #181818;
  border: 1px solid #1e1e1e;
  border-top: none;
  border-radius: 0 0 6px 6px;
  margin-top: -1px;
  box-sizing: border-box;
}

.library-row.is-expanded .library-row-content {
  grid-template-rows: 1fr;
}

/* Inner: slide up + fade in, matching tank designer's inline editor feel */
.library-row-content-inner {
  overflow: hidden;
  min-height: 0;
  max-width: 960px;
  transform: translateY(10px);
  opacity: 0;
  transition:
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.32s ease;
}

.library-row.is-expanded .library-row-content-inner {
  transform: translateY(0);
  opacity: 1;
}

/* Flatten nested card wrappers inside expanded panel */
.library-row-content .td-share-card,
.library-row-content .design-template-card {
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  background: transparent;
  max-width: none;
  width: 100%;
}

.library-row-content .td-share-card-header,
.library-row-content .design-template-header {
  display: none;
}

/* Separator between multiple division templates */
.library-row-content .design-template-card + .design-template-card {
  border-top: 1px solid #242424;
}

/* Research/Doctrine inline path view */
.library-row-path {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 14px 1.1rem;
}

/* Research path: tabbed tree-section view */
.library-research-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid rgba(233, 220, 199, 0.08);
  padding-bottom: 6px;
}

.library-research-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid rgba(233, 220, 199, 0.1);
  background: rgba(233, 220, 199, 0.04);
  color: #a09486;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.library-research-tab:hover {
  border-color: rgba(196, 154, 85, 0.4);
  background: rgba(196, 154, 85, 0.1);
  color: #d8c89a;
}

.library-research-tab strong {
  font-weight: 600;
  color: #6a6050;
  font-size: 0.72rem;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}

.library-research-tab.is-active {
  border-color: rgba(196, 154, 85, 0.6);
  background: rgba(196, 154, 85, 0.15);
  color: #f2d79f;
  font-weight: 500;
}

.library-research-tab.is-active strong {
  color: #d8c89a;
  background: rgba(0, 0, 0, 0.3);
}

.library-research-panels {
  display: block;
}

.library-research-panel {
  display: none;
}

.library-research-panel.is-active {
  display: block;
}

.library-research-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-research-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 96px;
  padding: 8px 6px;
  background: #2a4633;
  border: 1px solid #4e7e5f;
  border-radius: 4px;
  color: #a0d0b2;
  font-size: 0.72rem;
  text-align: center;
}

.library-research-node-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.library-research-node-icon img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.library-research-node-label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.2;
  word-break: break-word;
}

.library-research-node-sub {
  font-size: 0.62rem;
  font-weight: 500;
  color: rgba(160, 208, 178, 0.85);
  line-height: 1.15;
  max-width: 100%;
}

.library-doctrine-grand-grid {
  margin-bottom: 12px;
}

.library-doctrine-sf-heading {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6e6455;
}

.library-doctrine-sf-heading:not(:first-child) {
  margin-top: 14px;
}

/* Major doctrine blocks (Land / Special Forces) under expanded row */
.library-doctrine-sf-heading.library-doctrine-section-heading {
  margin-top: 14px;
}

.library-row-path--doctrine > .library-doctrine-sf-heading.library-doctrine-section-heading:first-child {
  margin-top: 0;
}

.library-doctrine-grand-grid + .library-doctrine-sf-heading.library-doctrine-section-heading {
  margin-top: 12px;
}

.library-row-loading {
  padding: 1.5rem;
  color: #6a6050;
  font-size: 0.85rem;
  text-align: center;
  border: 1px dashed rgba(196, 162, 98, 0.18);
}

/* ── Row inline action buttons - mirrors dx-create-variant-btn ────────────── */

.library-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Primary "Load" button - teal for tanks (mirrors designer), gold otherwise */
.library-card-load {
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 0.02em;
  background: rgba(52, 148, 124, 0.08);
  border: 1px solid rgba(52, 148, 124, 0.28);
  color: rgba(52, 148, 124, 0.9);
  border-radius: 2px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.library-card-load:hover {
  background: rgba(52, 148, 124, 0.15);
  border-color: rgba(52, 148, 124, 0.55);
  color: rgba(52, 148, 124, 1);
}

/* Secondary action buttons */
.library-card-btn {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0.01em;
  border: 1px solid #2e2e2e;
  background: #1c1c1c;
  color: #666;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.library-card-btn:hover {
  border-color: #3a3a3a;
  background: #222;
  color: #999;
}

.library-card-btn.is-danger {
  border-color: #3d2c2c;
  background: #261e1e;
  color: #9a6868;
}

.library-card-btn.is-danger:hover {
  border-color: #4a2020;
  background: #1e1010;
  color: #c07070;
}

.library-card-spacer { flex: 1; }

.library-card-post-link {
  padding: 3px 8px;
  font-size: 10px;
  font-family: inherit;
  letter-spacing: 0.01em;
  border: 1px solid #2a2a2a;
  background: transparent;
  color: #555;
  border-radius: 2px;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.library-card-post-link:hover {
  color: #888;
  border-color: #3a3a3a;
}

/* ── Research / Doctrine modal views ──────────────────────────────────────── */

.library-path-modal-section {
  margin-bottom: 1.5rem;
}

.library-path-modal-section:last-child {
  margin-bottom: 0;
}

.library-path-section-label {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #8f8070;
}

.library-path-tech-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.library-path-tech-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(196, 162, 98, 0.16);
  background: rgba(196, 162, 98, 0.05);
  font-size: 0.8rem;
  color: #c8b890;
  min-width: 0;
}

.library-path-tech-item img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.library-path-doctrine-tree {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.library-path-doctrine-grand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid rgba(196, 162, 98, 0.25);
  background: rgba(196, 162, 98, 0.08);
  color: #e8d09a;
  font-size: 0.9rem;
  font-weight: 600;
}

.library-path-doctrine-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(233, 220, 199, 0.1);
  background: rgba(233, 220, 199, 0.03);
  font-size: 0.82rem;
  color: #b0a488;
}

.library-path-doctrine-choice .library-path-doctrine-path {
  font-size: 0.72rem;
  color: #6e6455;
  margin-left: auto;
}

.library-path-empty {
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed rgba(196, 162, 98, 0.2);
  color: #6e6455;
  font-size: 0.85rem;
}

/* ── Compositions panel ───────────────────────────────────────────────────── */

.library-compositions-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.library-compositions-title {
  margin: 0 0 0.3rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  color: #f4e5c7;
}

.library-compositions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.library-composition-card {
  padding: 1.1rem;
  border: 1px solid rgba(196, 162, 98, 0.15);
  background: rgba(12, 15, 16, 0.85);
}

.library-composition-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0.75rem;
}

.library-composition-card h3 {
  margin: 0 0 4px;
  color: #f3dfb9;
  font-size: 1rem;
}

.library-composition-card p {
  margin: 0;
  color: #7a7060;
  font-size: 0.82rem;
}

.library-composition-count {
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1px solid rgba(196, 162, 98, 0.2);
  color: #d8c39a;
  font-size: 0.76rem;
  white-space: nowrap;
}

.library-composition-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.library-composition-tags span {
  padding: 3px 7px;
  border: 1px solid rgba(196, 162, 98, 0.18);
  color: #9a8e78;
  font-size: 0.72rem;
}

.library-composition-items {
  display: grid;
  gap: 6px;
  margin-bottom: 0.9rem;
}

.library-composition-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
  color: #b0a488;
}

.library-composition-item strong {
  color: #c8b890;
}

.library-composition-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */

.library-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.7);
}

.library-modal-overlay[hidden] {
  display: none;
}

.library-modal {
  width: min(760px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  border: 1px solid rgba(196, 162, 98, 0.22);
  border-top: 3px solid #8a6228;
  background: #131517;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75);
  border-radius: 3px;
}

.library-modal--danger .library-modal {
  border-top-color: #9a4a4a;
  border-color: rgba(154, 74, 74, 0.35);
  max-width: 420px;
}

.library-modal--sm .library-modal {
  max-width: 420px;
}

.library-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  background: linear-gradient(180deg, #1a1814 0%, #131210 100%);
  border-bottom: 1px solid #252218;
}

.library-modal-header h2 {
  margin: 0;
  color: #ece6d8;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.library-modal-body {
  padding: 20px 20px 22px;
}

/* ── Shared form / button styles ──────────────────────────────────────────── */

.library-form {
  display: grid;
  gap: 16px;
}

.library-form label {
  display: grid;
  gap: 7px;
  color: #c8b890;
  font-size: 0.85rem;
}

.library-form input,
.library-form textarea {
  border: 1px solid rgba(196, 162, 98, 0.22);
  background: rgba(0, 0, 0, 0.28);
  color: #eadfc9;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.875rem;
}

.library-form input:focus,
.library-form textarea:focus {
  outline: none;
  border-color: rgba(196, 162, 98, 0.55);
}

.library-form-context {
  margin: 0;
  color: #c49a55;
  font-weight: 700;
  font-size: 0.875rem;
}

.library-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.library-design-picker {
  display: grid;
  gap: 6px;
}

.library-picker-row {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto 68px minmax(110px, 160px);
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.82rem;
  color: #b0a488;
  cursor: pointer;
}

.library-picker-row:hover {
  background: rgba(255, 255, 255, 0.055);
}

.library-picker-type {
  color: #6e6455;
  font-size: 0.78rem;
}

.library-picker-qty,
.library-picker-role {
  border: 1px solid rgba(196, 162, 98, 0.18);
  background: rgba(0, 0, 0, 0.22);
  color: #d8cbb0;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 0.8rem;
}

/* Rename / tag modals */
.library-rename-body,
.library-tag-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-rename-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #c8b890;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.library-rename-input {
  width: 100%;
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(196, 162, 98, 0.22);
  border-radius: 2px;
  color: #eadfc9;
  font-family: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.library-rename-input:focus {
  border-color: rgba(196, 162, 98, 0.55);
}

.library-rename-error {
  margin: 0;
  font-size: 0.8rem;
  color: #c07070;
}

.library-current-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 24px;
  align-items: center;
}

.library-tag-empty {
  color: #6f6657;
  font-size: 0.82rem;
}

/* Tag colors - preset tags only; custom tags stay neutral */

.library-tag-suggestions-label {
  display: block;
  margin-bottom: 0.35rem;
}

/* Neutralize publish-suggestion-chip.is-selected gold for all library chips,
   preset tag [data-tag] rules below override this for named tags */
.library-tag-suggestion.is-selected {
  color: #6e6456;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.library-tag-suggestion[data-tag="favorite"],
.library-row-tag[data-tag="favorite"],
.library-design-card-tag[data-tag="favorite"],
.library-tag-pill[data-tag="favorite"] { color: #d9b86c; border-color: rgba(217, 184, 108, 0.35); background: rgba(217, 184, 108, 0.08); }

.library-tag-suggestion[data-tag="current run"],
.library-row-tag[data-tag="current run"],
.library-design-card-tag[data-tag="current run"],
.library-tag-pill[data-tag="current run"] { color: #7fc99a; border-color: rgba(127, 201, 154, 0.3); background: rgba(127, 201, 154, 0.07); }

.library-tag-suggestion[data-tag="testing"],
.library-row-tag[data-tag="testing"],
.library-design-card-tag[data-tag="testing"],
.library-tag-pill[data-tag="testing"] { color: #8eb6d8; border-color: rgba(142, 182, 216, 0.3); background: rgba(142, 182, 216, 0.07); }

.library-tag-suggestion[data-tag="favorite"].is-selected,
.library-tag-suggestion[data-tag="current run"].is-selected,
.library-tag-suggestion[data-tag="testing"].is-selected {
  color: #6e6456;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

/* Active library tag filter (card pills + strip chip share logic in JS) */
#library-designs-panel .library-design-card-tag.design-card-tag.is-active {
  border-color: rgba(200, 169, 110, 0.65) !important;
  background: rgba(200, 169, 110, 0.16) !important;
  color: #f4ece0 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

/* Shared action row for small modals (rename + delete) */
.library-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.library-modal-actions .library-secondary-btn,
.library-modal-actions .library-primary-btn,
.library-modal-actions .library-danger-btn {
  flex: 1;
  justify-content: center;
}

/* Divider in the more-menu */
.library-row-more-divider {
  height: 1px;
  background: #242424;
  margin: 3px 0;
}

.library-confirm-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-confirm-message {
  margin: 0;
  font-size: 0.9rem;
  color: #e0d8c8;
  line-height: 1.5;
}

.library-confirm-message strong {
  color: #f0e6cc;
}

.library-confirm-warning {
  margin: 0;
  font-size: 0.8rem;
  color: #a09488;
}

.library-primary-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  background: #c49a55;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #171717;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.library-primary-btn:hover {
  background: #d4a860;
}

.library-danger-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  background: #7a2e2e;
  border: 1px solid rgba(154, 74, 74, 0.4);
  border-radius: 2px;
  color: #f0c0c0;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.library-danger-btn:hover {
  background: #8a3a3a;
}

.library-secondary-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border: 1px solid rgba(233, 220, 199, 0.18);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.04);
  color: #a09488;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}

.library-secondary-btn:hover {
  border-color: rgba(233, 220, 199, 0.32);
  color: #d8cbb0;
}

.library-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(233, 220, 199, 0.14);
  border-radius: 50%;
  background: transparent;
  color: #6e6455;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.library-icon-btn:hover {
  border-color: rgba(233, 220, 199, 0.3);
  color: #d8cbb0;
}

.library-empty {
  grid-column: 1 / -1;
  padding: 3rem 2rem;
  border: 1px dashed rgba(196, 162, 98, 0.22);
  color: #6e6455;
  text-align: center;
  font-size: 0.875rem;
}

.library-empty h3 {
  margin: 0 0 0.5rem;
  color: #9a8e78;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .library-main {
    padding: 1.5rem 1rem 3rem;
  }

  .library-header.catalog-header-with-action {
    margin-bottom: 1.5rem;
  }

  .library-header .library-header-subtitle {
    grid-column: 1 / -1;
  }

  .library-header-actions {
    flex-direction: row;
    justify-content: flex-start;
  }

  .library-picker-row {
    grid-template-columns: auto 1fr;
  }
}

@media (max-width: 560px) {
  .library-design-card-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .library-design-card-toolbar-start {
    flex-direction: column;
    align-items: flex-start;
  }

  .library-design-card-toolbar-actions {
    margin-left: 0;
    justify-content: flex-end;
  }

  .library-row-more-btn {
    flex-shrink: 0;
  }
}

/* Launch glyph hidden by default; promoted on narrow compact rows below. */
.library-design-card-toolbar-btn--load-icon {
  display: none;
}

/* Mobile: tighten compact-row buttons; swap the load label for an icon
   so the title gets more breathing room on narrow viewports. */
@media (max-width: 480px) {
  #library-designs-panel .library-row:not(.library-row--compact-open) .library-design-card-toolbar-btn--details {
    padding: 0.24rem 0.42rem;
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) .library-design-card-toolbar-btn--load {
    padding: 0.32rem;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) .library-design-card-toolbar-btn--load-label {
    display: none;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) .library-design-card-toolbar-btn--load-icon {
    display: inline-block;
  }

  #library-designs-panel .library-row:not(.library-row--compact-open) .library-row-more-btn {
    width: 1.6rem;
    height: 1.6rem;
  }
}

@media (max-width: 480px) {
  .library-composition-top,
  .library-compositions-header {
    flex-direction: column;
  }
}
