:root {
  --library-panel:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    radial-gradient(circle at 0% 0%, rgba(var(--page-accent-1-rgb), 0.16), transparent 38%),
    radial-gradient(circle at 100% 0%, rgba(var(--page-accent-2-rgb), 0.12), transparent 40%),
    linear-gradient(180deg, rgba(12, 17, 25, 0.96), rgba(6, 10, 16, 0.93));
  --library-panel-border: 1px solid rgba(255, 255, 255, 0.1);
  --library-panel-shadow: 0 26px 60px rgba(1, 5, 12, 0.34);
  --library-text-soft: rgba(222, 229, 236, 0.78);
  --library-text-faint: rgba(197, 208, 220, 0.58);
  --library-wood-top: #6b4d33;
  --library-wood-bottom: #2a1b11;
  --library-wood-edge: rgba(219, 176, 126, 0.24);
}

.library-page {
  width: min(100%, 84rem);
  margin: 0 auto;
  display: grid;
  gap: 1rem;
  padding: 0.15rem 0 2.6rem;
}

.library-hero,
.library-toolbar,
.library-stat,
.library-stacks,
.library-desk,
.library-empty,
.library-search input,
.library-sort select {
  border: var(--library-panel-border);
  border-radius: 1.55rem;
  background: var(--library-panel);
  box-shadow: var(--library-panel-shadow);
  -webkit-backdrop-filter: blur(20px) saturate(155%);
  backdrop-filter: blur(20px) saturate(155%);
}

.library-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.92fr);
  gap: 1rem;
  padding: 1.15rem;
}

.library-hero__copy {
  display: grid;
  gap: 0.82rem;
  align-content: start;
}

.library-kicker,
.library-stat__label,
.library-search__label,
.library-sort span,
.library-volume__index,
.library-desk__eyebrow,
.library-desk__label {
  margin: 0;
  color: rgba(227, 214, 188, 0.72);
  font: 700 0.72rem/1 "Space Grotesk", "Inter", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.library-hero__copy h1,
.library-empty h2,
.library-volume__title,
.library-desk h2 {
  margin: 0;
  color: #f8fbfd;
  font-family: "Space Grotesk", "Inter", sans-serif;
}

.library-hero__copy h1 {
  max-width: 11ch;
  font-size: clamp(2.15rem, 3.6vw, 3.45rem);
  line-height: 0.97;
  letter-spacing: -0.05em;
}

.library-copy,
.library-results-head__copy,
.library-desk__copy,
.library-desk__hint,
.library-files__empty,
.library-empty p {
  margin: 0;
  color: var(--library-text-soft);
  line-height: 1.65;
}

.library-hero__actions,
.library-empty__actions,
.library-desk__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.library-stats {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.library-stat {
  display: grid;
  gap: 0.35rem;
  padding: 0.95rem;
  align-content: end;
  min-height: 7rem;
}

.library-stat strong {
  color: #fff7ec;
  font: 700 1.58rem/1 "Space Grotesk", "Inter", sans-serif;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.9rem;
  padding: 0.95rem;
  align-items: end;
}

.library-search,
.library-sort {
  display: grid;
  gap: 0.46rem;
}

.library-search input,
.library-sort select {
  width: 100%;
  min-height: 3.25rem;
  padding: 0.82rem 1rem;
  color: #f7fafc;
  background:
    linear-gradient(180deg, rgba(20, 26, 37, 0.98), rgba(9, 13, 20, 0.96)),
    radial-gradient(circle at 100% 0%, rgba(var(--page-accent-1-rgb), 0.12), transparent 48%);
}

.library-search input::placeholder {
  color: rgba(201, 212, 223, 0.46);
}

.library-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.library-filter {
  min-height: 3.1rem;
  padding: 0.7rem 0.96rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)),
    rgba(12, 16, 24, 0.82);
  color: rgba(236, 242, 247, 0.88);
  font: 700 0.84rem/1 "Space Grotesk", "Inter", sans-serif;
  transition:
    transform 0.22s ease,
    border-color 0.22s ease,
    background 0.22s ease,
    box-shadow 0.22s ease;
}

.library-filter:hover,
.library-filter:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(var(--page-accent-1-rgb), 0.34);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(16, 22, 31, 0.88);
}

.library-filter.is-active {
  border-color: rgba(var(--page-accent-1-rgb), 0.4);
  background:
    linear-gradient(135deg, rgba(var(--page-accent-1-rgb), 0.2), rgba(var(--page-accent-2-rgb), 0.18)),
    linear-gradient(180deg, rgba(17, 22, 31, 0.94), rgba(8, 12, 18, 0.9));
  color: #fff;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.library-sort {
  min-width: 14.5rem;
}

.library-results-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
}

.library-results-head__count {
  margin: 0;
  color: #fff7ee;
  font: 700 1rem/1.1 "Space Grotesk", "Inter", sans-serif;
}

.library-stacks {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11.8rem, 1fr));
  gap: 1rem 0.95rem;
  padding: 1.15rem 1rem 1.4rem;
  overflow: hidden;
}

.library-stacks::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 8%, rgba(var(--page-accent-1-rgb), 0.12), transparent 28%),
    radial-gradient(circle at 90% 10%, rgba(var(--page-accent-2-rgb), 0.1), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 16%);
  opacity: 0.8;
}

.library-volume-card {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding-bottom: 1.1rem;
  align-self: end;
}

.library-volume-card[hidden] {
  display: none !important;
}

.library-volume-card::after {
  content: "";
  position: absolute;
  left: -0.4rem;
  right: -0.4rem;
  bottom: 0;
  height: 1.08rem;
  border-radius: 0.9rem;
  border: 1px solid rgba(255, 232, 205, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, var(--library-wood-top), var(--library-wood-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 22px rgba(0, 0, 0, 0.2);
}

.library-volume {
  --volume-a-rgb: 123, 95, 65;
  --volume-b-rgb: 84, 116, 101;
  position: relative;
  display: grid;
  align-content: start;
  gap: 0.56rem;
  width: 100%;
  min-height: 14.8rem;
  padding: 1rem 1rem 1.2rem 1.05rem;
  border-radius: 1.35rem 1rem 1rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)),
    linear-gradient(135deg, rgba(var(--volume-a-rgb), 0.24), rgba(var(--volume-b-rgb), 0.16)),
    linear-gradient(180deg, rgba(19, 25, 35, 0.98), rgba(10, 14, 21, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset -1rem 0 1.8rem rgba(0, 0, 0, 0.14),
    0 18px 28px rgba(2, 6, 14, 0.24);
  color: #f7f9fb;
  text-align: left;
  transition:
    transform 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    background 0.22s ease;
  overflow: hidden;
}

.library-volume::before {
  content: "";
  position: absolute;
  inset: 0.6rem auto 0.6rem 0.48rem;
  width: 0.26rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(var(--volume-a-rgb), 0.95), rgba(var(--volume-b-rgb), 0.9));
  box-shadow: 0 0 18px rgba(var(--volume-a-rgb), 0.18);
}

.library-volume::after {
  content: "";
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  bottom: 0.55rem;
  width: 0.85rem;
  border-radius: 0.72rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    linear-gradient(180deg, rgba(234, 225, 210, 0.18), rgba(193, 182, 166, 0.08));
  opacity: 0.8;
}

.library-volume:hover,
.library-volume:focus-visible,
.library-volume-card.is-selected .library-volume {
  transform: translateY(-0.3rem);
  border-color: rgba(var(--volume-a-rgb), 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset -1rem 0 1.8rem rgba(0, 0, 0, 0.16),
    0 24px 34px rgba(2, 6, 14, 0.28),
    0 0 0 1px rgba(var(--volume-a-rgb), 0.12);
}

.library-volume-card.is-selected::after {
  border-color: rgba(var(--page-accent-1-rgb), 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 12px 24px rgba(0, 0, 0, 0.22),
    0 0 18px rgba(var(--page-accent-1-rgb), 0.12);
}

.library-volume-card:nth-child(4n + 1) .library-volume {
  --volume-a-rgb: 122, 91, 60;
  --volume-b-rgb: 88, 116, 98;
}

.library-volume-card:nth-child(4n + 2) .library-volume {
  --volume-a-rgb: 90, 110, 130;
  --volume-b-rgb: 110, 94, 66;
}

.library-volume-card:nth-child(4n + 3) .library-volume {
  --volume-a-rgb: 92, 78, 126;
  --volume-b-rgb: 78, 118, 122;
}

.library-volume-card:nth-child(4n + 4) .library-volume {
  --volume-a-rgb: 114, 78, 92;
  --volume-b-rgb: 128, 106, 64;
}

.library-volume__title {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 0.9rem);
  margin-top: 0.15rem;
  font-size: 1.28rem;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.library-volume__note {
  position: relative;
  z-index: 1;
  color: rgba(230, 237, 244, 0.72);
  font-size: 0.84rem;
  line-height: 1.42;
}

.library-volume__status {
  position: relative;
  z-index: 1;
  align-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 1.95rem;
  margin-top: auto;
  padding: 0.32rem 0.66rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(251, 248, 241, 0.9);
  font: 700 0.7rem/1 "Space Grotesk", "Inter", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.library-badge,
.library-kind-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.9rem;
  padding: 0.28rem 0.66rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(12, 16, 24, 0.72);
  color: rgba(244, 248, 251, 0.86);
  font: 700 0.72rem/1 "Space Grotesk", "Inter", sans-serif;
  letter-spacing: 0.04em;
}

.library-badge.is-shared {
  border-color: rgba(var(--page-accent-2-rgb), 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(var(--page-accent-2-rgb), 0.12);
  color: #f0faf6;
}

.library-desk {
  padding: 1.1rem;
  scroll-margin-top: 5.6rem;
}

.library-desk__inner {
  min-height: 19rem;
}

.library-desk__frame {
  display: grid;
  gap: 1rem;
}

.library-desk__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
}

.library-desk__title-block {
  display: grid;
  gap: 0.42rem;
}

.library-desk h2 {
  font-size: clamp(1.75rem, 2vw, 2.45rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.library-desk__side {
  display: flex;
  justify-content: flex-end;
}

.library-badges--desk {
  justify-content: flex-end;
}

.library-desk__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.library-desk__metrics span {
  display: inline-flex;
  align-items: center;
  min-height: 2.2rem;
  padding: 0.45rem 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(10, 14, 21, 0.76);
  color: rgba(241, 245, 248, 0.88);
  font: 700 0.76rem/1 "Space Grotesk", "Inter", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-kind-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.library-desk__files {
  display: grid;
  gap: 0.8rem;
}

.library-desk__files-head {
  display: grid;
  gap: 0.18rem;
}

.library-desk__file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 0.62rem;
}

.library-desk__file-list li {
  min-width: 0;
  padding: 0.72rem 0.8rem;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    rgba(9, 13, 20, 0.76);
  color: rgba(244, 248, 251, 0.9);
  font: 500 0.9rem/1.45 "Inter", sans-serif;
  word-break: break-word;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.library-empty {
  display: grid;
  gap: 0.8rem;
  padding: 1.2rem;
}

.library-empty--filtered {
  text-align: center;
  place-items: center;
}

.library-empty--initial {
  min-height: 16rem;
  align-content: center;
}

@media (max-width: 1100px) {
  .library-hero {
    grid-template-columns: 1fr;
  }

  .library-toolbar {
    grid-template-columns: 1fr;
  }

  .library-sort {
    min-width: 0;
  }

  .library-results-head,
  .library-desk__head {
    grid-template-columns: 1fr;
  }

  .library-desk__side,
  .library-badges--desk {
    justify-content: flex-start;
  }
}

@media (max-width: 767.98px) {
  .library-page {
    gap: 0.85rem;
    padding-bottom: 1.6rem;
  }

  .library-hero,
  .library-toolbar,
  .library-stat,
  .library-stacks,
  .library-desk,
  .library-empty,
  .library-search input,
  .library-sort select {
    border-radius: 1.2rem;
  }

  .library-hero,
  .library-toolbar,
  .library-desk,
  .library-empty {
    padding: 1rem;
  }

  .library-stats {
    grid-template-columns: 1fr;
  }

  .library-results-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .library-stacks {
    grid-template-columns: repeat(auto-fit, minmax(10.3rem, 1fr));
    padding: 0.95rem 0.85rem 1.2rem;
  }

  .library-volume {
    min-height: 13.5rem;
    padding: 0.9rem 0.9rem 1.05rem 0.96rem;
  }

  .library-volume__title {
    font-size: 1.14rem;
  }

  .library-desk__file-list {
    grid-template-columns: 1fr;
  }

  .library-hero__actions,
  .library-desk__actions,
  .library-empty__actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
