.library-panel {
  position: fixed;
  right: 96px;
  top: 112px;
  z-index: 42;
  width: min(360px, calc(100vw - 120px));
  max-height: calc(100vh - 150px);
  display: none;
  overflow: hidden;
  border: 1px solid rgba(101, 255, 216, 0.18);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(9, 22, 29, 0.96), rgba(5, 12, 17, 0.96)),
    rgba(7, 13, 18, 0.94);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(16px);
  color: #dffcf4;
}

.library-panel--open {
  display: block;
}

.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(101, 255, 216, 0.12);
  cursor: move;
}

.library-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.library-title {
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #88f6d1;
}

.library-subtitle {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(223, 252, 244, 0.58);
}

.library-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.library-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  padding: 3px;
  border: 1px solid rgba(101, 255, 216, 0.18);
  background: rgba(16, 37, 48, 0.9);
  cursor: pointer;
}

.library-toggle::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(177, 255, 235, 0.95);
  box-shadow: 0 0 18px rgba(108, 255, 220, 0.32);
  transform: translateX(0);
  transition: transform 160ms ease;
}

.library-toggle.is-on {
  background: linear-gradient(135deg, rgba(31, 144, 109, 0.95), rgba(50, 209, 171, 0.88));
}

.library-toggle.is-on::after {
  transform: translateX(19px);
}

.library-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #dffcf4;
  cursor: pointer;
  font-size: 18px;
}

.library-body {
  max-height: calc(100vh - 240px);
  overflow: auto;
  padding: 16px 18px 20px;
}

.library-section {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.library-section-title {
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(123, 242, 210, 0.82);
  font-weight: 700;
}

.library-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-action-row {
  display: flex;
  gap: 8px;
}

.library-chip {
  appearance: none;
  border: 1px solid rgba(101, 255, 216, 0.18);
  border-radius: 999px;
  background: rgba(15, 35, 44, 0.9);
  color: #dffcf4;
  cursor: pointer;
  padding: 9px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.library-chip.is-active {
  border-color: rgba(107, 255, 221, 0.7);
  background: linear-gradient(135deg, rgba(33, 103, 91, 0.95), rgba(42, 171, 140, 0.86));
  color: #041311;
  font-weight: 700;
}

.library-action {
  appearance: none;
  border: 1px solid rgba(101, 255, 216, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(14, 34, 43, 0.88);
  color: #dffcf4;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
}

.library-action--secondary {
  background: rgba(10, 25, 32, 0.88);
  color: rgba(223, 252, 244, 0.88);
}

.library-action.is-placing {
  border-color: rgba(255, 233, 126, 0.68);
  background: linear-gradient(135deg, rgba(161, 125, 41, 0.92), rgba(231, 188, 77, 0.82));
  color: #1c1404;
}

.library-upload {
  display: grid;
  gap: 10px;
}

.library-upload input[type="file"] {
  width: 100%;
  font: inherit;
  color: rgba(223, 252, 244, 0.86);
}

.library-note {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(223, 252, 244, 0.68);
}

.library-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.library-card {
  appearance: none;
  border: 1px solid rgba(101, 255, 216, 0.15);
  border-radius: 18px;
  background: rgba(14, 28, 36, 0.9);
  color: inherit;
  cursor: pointer;
  padding: 10px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.library-card.is-active {
  border-color: rgba(115, 255, 224, 0.72);
  box-shadow: inset 0 0 0 1px rgba(115, 255, 224, 0.24);
}

.library-card-preview {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 18%, rgba(96, 255, 216, 0.32), transparent 38%),
    linear-gradient(160deg, rgba(19, 48, 59, 0.96), rgba(8, 18, 24, 0.98));
  display: grid;
  place-items: center;
}

.library-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-card-preview--asset {
  padding: 8px;
  background:
    radial-gradient(circle at 28% 20%, rgba(115, 255, 223, 0.22), transparent 34%),
    radial-gradient(circle at 76% 76%, rgba(108, 175, 255, 0.18), transparent 28%),
    linear-gradient(160deg, rgba(16, 42, 51, 0.98), rgba(6, 13, 18, 0.98));
}

.library-card-preview--asset img {
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.42));
}

.library-card-icon {
  width: 66%;
  height: 66%;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 32%, rgba(174, 255, 235, 0.7), transparent 34%),
    linear-gradient(160deg, rgba(45, 97, 86, 0.96), rgba(13, 30, 31, 0.98));
  position: relative;
}

.library-card-icon::before,
.library-card-icon::after {
  content: "";
  position: absolute;
  border-radius: 6px;
}

.library-card-icon--forest::before {
  inset: 18% 28% 24% 28%;
  clip-path: polygon(50% 0%, 100% 62%, 76% 62%, 92% 100%, 8% 100%, 24% 62%, 0% 62%);
  background: linear-gradient(180deg, rgba(126, 255, 173, 0.95), rgba(34, 93, 55, 0.98));
}

.library-card-icon--forest::after {
  left: 42%;
  right: 42%;
  bottom: 10%;
  top: 58%;
  background: rgba(87, 55, 30, 0.92);
}

.library-card-icon--city::before {
  left: 18%;
  right: 18%;
  bottom: 18%;
  top: 28%;
  background:
    linear-gradient(90deg, rgba(77, 246, 255, 0.32) 0 15%, transparent 15% 28%, rgba(77, 246, 255, 0.24) 28% 40%, transparent 40% 58%, rgba(77, 246, 255, 0.22) 58% 75%, transparent 75% 100%),
    linear-gradient(180deg, rgba(140, 170, 192, 0.95), rgba(36, 48, 65, 0.98));
  box-shadow:
    -18px 18px 0 -6px rgba(40, 55, 74, 0.94),
    18px 8px 0 -4px rgba(53, 68, 91, 0.94);
}

.library-card-icon--city::after {
  left: 26%;
  right: 26%;
  bottom: 12%;
  top: 76%;
  background: rgba(16, 22, 28, 0.9);
}

.library-card-meta {
  display: grid;
  gap: 3px;
}

.library-card-title {
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.library-card-copy {
  font-size: 11px;
  line-height: 1.35;
  color: rgba(223, 252, 244, 0.62);
}

.library-list {
  display: grid;
  gap: 8px;
  max-height: 210px;
  overflow: auto;
}

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.library-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(101, 255, 216, 0.14);
  background: rgba(12, 25, 33, 0.84);
}

.library-item.is-active {
  border-color: rgba(114, 255, 223, 0.65);
  box-shadow: inset 0 0 0 1px rgba(114, 255, 223, 0.22);
}

.library-item-main {
  display: grid;
  grid-template-columns: 52px;
  gap: 10px;
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.library-item-title,
.library-item-copy {
  display: none;
}

.library-item-preview {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(circle at 28% 20%, rgba(115, 255, 223, 0.22), transparent 34%),
    linear-gradient(160deg, rgba(16, 42, 51, 0.98), rgba(6, 13, 18, 0.98));
  grid-row: 1 / span 2;
}

.library-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-item-preview--asset img {
  object-fit: contain;
}

.library-item-preview--photo img {
  object-fit: cover;
}

.library-item-actions {
  display: flex;
  gap: 6px;
}

.library-mini {
  appearance: none;
  border: 1px solid rgba(101, 255, 216, 0.18);
  border-radius: 10px;
  background: rgba(17, 38, 47, 0.92);
  color: #dffcf4;
  cursor: pointer;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1;
}

.library-mini--danger {
  border-color: rgba(255, 118, 118, 0.28);
  color: #ffd7d7;
}

.library-item-toggle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(101, 255, 216, 0.22);
  background: rgba(17, 38, 47, 0.92);
  color: #dffcf4;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  padding: 0;
}

.library-item-toggle[aria-pressed="true"] {
  border-color: rgba(114, 255, 223, 0.72);
  background: linear-gradient(135deg, rgba(33, 103, 91, 0.95), rgba(42, 171, 140, 0.86));
  color: #041311;
}

.library-controls {
  display: grid;
  gap: 12px;
}

.library-selection-summary {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(123, 242, 210, 0.84);
  font-weight: 700;
}

body.library-edit-cleanview #module-galaxy-fx,
body.library-edit-cleanview #module-planet-fx,
body.library-edit-cleanview #module-reflections,
body.library-edit-cleanview #reflection-open-button,
body.library-edit-cleanview #photo-open-button,
body.library-edit-cleanview #reflection-trigger-orb,
body.library-edit-cleanview #photo-hover-label {
  display: none !important;
}

.library-control {
  display: grid;
  gap: 8px;
}

.library-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.library-control-row strong {
  color: rgba(223, 252, 244, 0.92);
}

.library-control-row span {
  color: rgba(123, 242, 210, 0.84);
  font-variant-numeric: tabular-nums;
}

.library-range {
  width: 100%;
}

.library-empty {
  padding: 14px;
  border-radius: 16px;
  border: 1px dashed rgba(101, 255, 216, 0.16);
  color: rgba(223, 252, 244, 0.58);
  font-size: 12px;
  line-height: 1.5;
}

.module-card-icon .lib-btn-icon {
  position: relative;
  width: 38px;
  height: 38px;
  display: inline-block;
  animation: lib-dock-float 5.8s ease-in-out infinite;
}

.lib-btn-orb,
.lib-btn-card,
.lib-btn-cube {
  position: absolute;
}

.lib-btn-orb {
  inset: 7px;
  border-radius: 999px;
  border: 1px solid rgba(113, 255, 223, 0.68);
  box-shadow: inset 0 0 18px rgba(89, 215, 194, 0.24);
  animation: lib-orb-breathe 4.4s ease-in-out infinite;
}

.lib-btn-card {
  width: 14px;
  height: 18px;
  left: 4px;
  top: 11px;
  border-radius: 5px;
  background: linear-gradient(160deg, rgba(233, 252, 255, 0.96), rgba(108, 227, 255, 0.72));
  transform: rotate(-16deg);
  box-shadow: 0 0 12px rgba(153, 242, 255, 0.25);
  animation: lib-card-drift 5s ease-in-out infinite;
}

.lib-btn-cube {
  width: 14px;
  height: 14px;
  right: 5px;
  bottom: 8px;
  border-radius: 4px;
  background: linear-gradient(160deg, rgba(126, 255, 177, 0.94), rgba(26, 112, 82, 0.92));
  box-shadow: 0 0 14px rgba(114, 255, 184, 0.26);
  animation: lib-cube-bob 4.2s ease-in-out infinite;
}

#module-library:hover .lib-btn-icon,
#module-library.is-active .lib-btn-icon {
  animation-duration: 3.9s;
}

@keyframes lib-dock-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}

@keyframes lib-orb-breathe {
  0%, 100% { transform: scale(0.98); box-shadow: inset 0 0 16px rgba(89, 215, 194, 0.2); }
  50% { transform: scale(1.04); box-shadow: inset 0 0 20px rgba(89, 215, 194, 0.32); }
}

@keyframes lib-card-drift {
  0%, 100% { transform: rotate(-16deg) translate(0, 0); }
  50% { transform: rotate(-12deg) translate(1.2px, -1px); }
}

@keyframes lib-cube-bob {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-1px, -1.4px) rotate(6deg); }
}
