body {
  margin: 0 auto;
  background: no-repeat center center fixed;
  background-size: cover;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  color: white;
  padding: 40px 20px;
  overflow-x: hidden !important;
}

* {
  box-sizing: border-box;
}

.lib-wrapper {
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 0 0 80px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.lib-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(25, 25, 25, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 24px 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.lib-back {
  font-size: 12px;
  color: #888;
  text-decoration: none;
  letter-spacing: 1px;
  transition: color 0.2s;
  width: fit-content;
}

.lib-back:hover {
  color: var(--accent);
}

.lib-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(36px, 8vw, 64px);
  font-weight: 600;
  margin: 0;
  letter-spacing: -1px;
  line-height: 1;
}

.lib-sub {
  font-size: 12px;
  color: #666;
  margin: 0;
  letter-spacing: 1px;
}

.lib-topbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(25, 25, 25, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 24px 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  justify-content: center;
}

.lib-filter {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: rgba(22, 22, 22, 0.6);
  border: 1px solid rgba(255,255,255,0.06);
  color: #999;
  padding: 7px 16px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}

.lib-filter:hover {
  color: white;
  border-color: rgba(255,255,255,0.15);
}

.lib-filter.active {
  background: var(--accent);
  color: black;
  border-color: transparent;
  font-weight: 500;
}

.lib-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lib-card {
  background: rgba(25, 25, 25, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeIn 0.4s ease both;
  position: relative;
}

.lib-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
}

.lib-card.type-hidden,
.lib-card.status-hidden,
.lib-card.page-hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lib-inner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  padding: 14px;
  overflow: hidden;
  position: relative;
  transition: transform 0.2s ease, background 0.2s ease, background-image 0.4s ease;
}

.lib-inner:hover {
  transform: scale(1.02);
  background: rgba(0,0,0,0.4);
}

.lib-inner.synopsis-expanded {
  background: rgba(0,0,0,0.25);
  clip-path: inset(0 round 12px);
}

.lib-inner.synopsis-expanded::before {
  content: '';
  position: absolute;
  inset: -80px;
  border-radius: 32px;
  background-image: var(--cover-url);
  background-size: cover;
  background-position: top center;
  filter: blur(12px);
  opacity: 0.9;
  z-index: 0;
  transition: opacity 0.4s ease;
}

.lib-inner::before {
  content: '';
  position: absolute;
  inset: -80px;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.lib-inner.synopsis-expanded::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 0;
  border-radius: 12px;
}

.lib-inner.synopsis-expanded .lib-info,
.lib-inner.synopsis-expanded .lib-cover {
  position: relative;
  z-index: 1;
}

.lib-cover {
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  transition: opacity 0.3s ease, width 0.3s ease;
}

.lib-cover.cover-hidden {
  opacity: 0;
  width: 0;
  margin: 0;
  padding: 0;
  transition: all 0.3s ease;
}

.lib-cover.square { width: 125px; height: 125px; }
.lib-cover.portrait { aspect-ratio: 460/650; height: 200px; }

.lib-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lib-name {
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  height: 20 !important;
  color: white;
}

.lib-author {
  font-size: 13px;
  color: #aaa;
  line-height: 1.35;
}

.lib-meta {
  font-size: 11px;
  color: #777;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.lib-tag {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 4px;
}

.lib-synopsis {
  font-size: 12px;
  color: #999;
  line-height: 1.45;
  margin-top: 2px;
  max-height: 83px;
  overflow: hidden;
  position: relative;
  transition: max-height, grid-template-rows 0.35s ease;
  display: grid;
  grid-template-rows: 60px;
}

.lib-synopsis.expanded {
  max-height: 600px;
  grid-template-rows: 1fr;
}

.lib-synopsis:not(.expanded) {
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.lib-synopsis-toggle {
  font-size: 11px;
  color: #666;
  cursor: pointer;
  margin-top: 4px;
  user-select: none;
}

.lib-synopsis-toggle:hover {
  color: #aaa;
}

.lib-synopsis-toggle.is-hidden {
  display: none;
}

.lib-bar-wrap {
  height: 3px;
  background: #1a1a1a;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 8px;
}

@media (max-width: 768px) {
  .lib-cover.landscape {
    width: 60px;
    height: 90px;
  }
}

.lib-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 10px;
}

.lib-percent {
  font-size: 10px;
  color: #666;
  margin-top: 4px;
  text-align: right;
}

.lib-note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.lib-note-label {
  font-size: 10px;
  color: #666;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.lib-note-text {
  font-size: 13px;
  color: #aaa;
  font-style: italic;
  line-height: 1.6;
}

.lib-type-badge {
  position: absolute;
  top: 0;
  left: 0;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #666;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 20px 0 8px 0;
}

.lib-status-badge {
  position: absolute;
  top: 0;
  right: 0;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #666;
  padding: 4px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 0 20px 0 8px;
}

.lib-status-badge.live {
  background: var(--accent);
  color: black;
}

.lib-status-badge.last {
  background: rgba(255,255,255,0.06);
  color: #666;
}

.maintenance {
  display: flex;
  letter-spacing: 0.5px;
  background: rgba(25, 25, 25, 0.7);
  backdrop-filter: blur(8px);
  border-radius: 20px;
  padding: 24px 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

#games-container,
#music-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lib-cover.landscape {
  width: 184px;
  height: 86px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.lib-rating {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.lib-repeat-count {
  margin-left: auto;
  font-size: 11px;
  color: #777;
  white-space: nowrap;
  letter-spacing: 0.4px;
}

.lib-rating-stars-wrap {
  position: relative;
  display: inline-block;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 1px;
  user-select: none;
}

.lib-stars-empty {
  color: #1a1a1a;
}

.lib-stars-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: hidden;
  white-space: nowrap;
  color: var(--accent);
}

.lib-rating-num {
  font-size: 11px;
  color: #777;
  white-space: nowrap;
  min-width: 45px;
}

.lib-pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.lib-page-btn {
  font-size: 11px;
  letter-spacing: 1px;
  background: rgba(22, 22, 22, 0.6);
  border: 1px solid rgba(255,255,255,0.06);
  color: #999;
  padding: 6px 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}

.lib-page-btn:hover {
  color: white;
  border-color: rgba(255,255,255,0.15);
}

.lib-page-btn.active {
  background: var(--accent);
  color: black;
  border-color: transparent;
}

.page-hidden {
  display: none !important;
}

.lib-divider {
  width: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0 4px;
  align-self: stretch;
}

.lib-sort,
.lib-status-filter {
  appearance: none;
  -webkit-appearance: none;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: rgba(22, 22, 22, 0.6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  border: 1px solid rgba(255,255,255,0.06);
  color: #999;
  padding: 7px 8px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: flex-end;
  padding-right: 32px;
  width: auto;
}

.lib-sort:hover,
.lib-status-filter:hover {
  color: white;
  border-color: rgba(255,255,255,0.15);
}

.lib-sort option,
.lib-status-filter option {
  background: #1a1a1a;
  color: white;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}

.lib-collection-badges {
  position: absolute;
  bottom: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.lib-collection-badge {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  padding: 3px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px 0 0 8px;
}

.lib-collection-badge:last-child {
  border-radius: 8px 0 20px 0;
}

@media (min-width: 768px) { .mobile-only {display: none} }
@media (max-width: 767px) { .desktop-only {display: none} }

.lib-note .note-body.open.needs-fade {
  -webkit-mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 75%, transparent 100%);
}

.lib-note .note-body.open.needs-fade.scrolled {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 75%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 75%, transparent 100%);
}

.lib-note .note-body.open.needs-fade.at-bottom,
.lib-note .note-body.open.needs-fade.scrolled.at-bottom {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, black 10%, black 100%);
}
