/* The touch handler requests one page per swipe. Do not race native momentum. */
#library[data-view="channels"] { touch-action: pan-y pinch-zoom; }
#library[data-view="channels"][data-page-slide] { scroll-snap-type: none; }

/* Organizer is a native system screen, not an overlay on the grid. */
.wii-grid-organizer {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  max-width: 100%;
}
.wii-grid-organizer-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(220px, 2fr);
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #cedae1;
}
.wii-grid-organizer-name { min-width: 0; overflow-wrap: anywhere; }
.wii-grid-organizer-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; }
.wii-grid-organizer-controls .wii-btn { min-height: 44px; min-width: 44px; padding: 8px 10px; font: inherit; font-size: .9em; white-space: normal; }
.wii-grid-organizer-controls .wii-btn:disabled { opacity: .42; }
.wii-grid-destination { grid-column: 1 / -1; box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; overflow: hidden; padding: 8px; border: 1px solid #afc5d2; border-radius: 10px; background: #fff; color: inherit; font: inherit; font-size: .9em; }
.wii-grid-organizer-controls [data-grid-move="destination"] { grid-column: 1 / -1; }
.wii-grid-status { min-height: 1.5em; color: #37728c; }
@media (max-width: 560px) {
  .wii-grid-organizer-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
}
#library[data-view="channels"] .cover,
#library[data-view="channels"] .wii-author-channel { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#library[data-grid-organizing] .cover,
#library[data-grid-organizing] .wii-author-channel { cursor: grab; }
#library[data-grid-dragging] .cover,
#library[data-grid-dragging] .wii-author-channel { cursor: grabbing; transform: none !important; }
#library[data-view="channels"] .wii-grid-drag-source {
  border-color: #26b9e8 !important;
  box-shadow: inset 0 0 0 2px #e8faff, 0 0 0 2px rgba(38, 185, 232, .28) !important;
}
#library[data-view="channels"] .wii-grid-drop-target:not(.wii-grid-drag-source) {
  border-color: #009ac8 !important;
  box-shadow: inset 0 0 0 3px rgba(225, 249, 255, .8) !important;
}

/* Original abstract marks; existing poster pixels and Boo stay untouched. */
.wii-grid-identity { display: none; }
#library[data-view="channels"] .cover > .wii-grid-identity {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  opacity: .16;
  contain: paint;
}
.wii-grid-identity::before, .wii-grid-identity::after {
  content: '';
  position: absolute;
  pointer-events: none;
}
.wii-grid-identity[data-motif="color"]::before {
  inset: 13% 9% 18% 48%;
  border-radius: 50%;
  background: conic-gradient(from 30deg, #91c4df, #a9d7c3, #f0cd91, #d9a9bb, #91c4df);
  -webkit-mask-image: radial-gradient(ellipse, transparent 55%, #000 58%, #000 65%, transparent 68%);
  mask-image: radial-gradient(ellipse, transparent 55%, #000 58%, #000 65%, transparent 68%);
}
.wii-grid-identity[data-motif="color"]::after {
  inset: 21% 18% 26% 57%; border: 1px solid #fff; border-radius: 50%;
}
.wii-grid-identity[data-motif="vfx"]::before {
  inset: 16% 10%;
  background: linear-gradient(#e1f3fb, #e1f3fb);
  clip-path: polygon(0 0, 18% 0, 18% 2%, 1% 2%, 1% 20%, 0 20%, 0 0, 100% 0, 100% 20%, 99% 20%, 99% 2%, 82% 2%, 82% 0, 100% 0, 100% 100%, 82% 100%, 82% 98%, 99% 98%, 99% 80%, 100% 80%, 100% 100%, 0 100%, 0 80%, 1% 80%, 1% 98%, 18% 98%, 18% 100%, 0 100%);
}
.wii-grid-identity[data-motif="vfx"]::after {
  width: 16%; height: 24%; left: 63%; top: 28%;
  background: linear-gradient(90deg, transparent 48%, #d9f1fb 49%, #d9f1fb 51%, transparent 52%), linear-gradient(transparent 48%, #d9f1fb 49%, #d9f1fb 51%, transparent 52%);
}
.wii-grid-identity[data-motif="video"]::before {
  inset: 11% 12% 40% 63%; border-radius: 50%;
  background: radial-gradient(ellipse at 64% 34%, transparent 47%, #edcfad 49%, #edcfad 52%, transparent 54%);
}
.wii-grid-identity[data-motif="video"]::after {
  inset: 62% 9% 18% 9%;
  background: linear-gradient(165deg, transparent 46%, #e3d8cd 48%, transparent 50%);
}
.wii-grid-identity[data-motif="edit"]::before {
  inset: 47% 9% 17%;
  background: repeating-linear-gradient(90deg, #eed5b8 0 4%, transparent 4% 10%);
  clip-path: polygon(0 82%, 10% 82%, 10% 44%, 20% 44%, 20% 67%, 30% 67%, 30% 14%, 40% 14%, 40% 40%, 50% 40%, 50% 0, 60% 0, 60% 52%, 70% 52%, 70% 23%, 80% 23%, 80% 68%, 90% 68%, 90% 35%, 100% 35%, 100% 100%, 0 100%);
}
.wii-grid-identity[data-motif="edit"]::after {
  left: 9%; right: 9%; bottom: 14%; height: 1px; background: #f5e4ce;
}
.wii-grid-identity[data-motif="reels"]::before {
  inset: 12% 34%; border: 1px solid #e6edf2; border-radius: 8%;
  background: linear-gradient(transparent 81%, #e6edf2 82%, transparent 83%);
}
/* CSS owns motion; no timer or animation frame paints poster pixels. */
#library:not([data-grid-previews="on"]) .wii-grid-identity::before,
#library:not([data-grid-previews="on"]) .wii-grid-identity::after { animation: none !important; }
#library[data-grid-previews="off"] .wii-grid-identity,
#library[data-grid-previews="paused"] .wii-grid-identity { display: none !important; }
#library[data-grid-previews="on"] .wii-grid-identity[data-grid-preview="active"]::before {
  animation: wiiIdentityDrift 7.4s ease-in-out infinite alternate;
}
#library[data-grid-previews="on"] .wii-grid-identity[data-grid-preview="active"][data-motif="color"]::before { animation-name: wiiIdentityOrbit; animation-duration: 12s; }
#library[data-grid-previews="on"] .wii-grid-identity[data-grid-preview="active"][data-motif="vfx"]::before { animation-duration: 8.8s; }
#library[data-grid-previews="on"] .wii-grid-identity[data-grid-preview="active"][data-motif="edit"]::before { animation-name: wiiIdentityMeter; animation-duration: 3.8s; transform-origin: 50% 100%; }
#library[data-grid-previews="on"] .wii-grid-identity[data-grid-preview="active"][data-motif="reels"]::before { animation-duration: 6.6s; }
@keyframes wiiIdentityDrift { from { transform: translate(0, 0); opacity: .7; } to { transform: translate(1.2%, -1.8%); opacity: 1; } }
@keyframes wiiIdentityOrbit { from { transform: rotate(-9deg); } to { transform: rotate(9deg); } }
@keyframes wiiIdentityMeter { from { transform: scaleY(.9); opacity: .75; } to { transform: scaleY(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .wii-grid-identity::before, .wii-grid-identity::after { animation: none !important; }
}

.wii-grid-identity[data-motif="reels"]::after {
  inset: 20% 30%;
  background: repeating-linear-gradient(transparent 0 12%, #e4ebf0 12% 15%, transparent 15% 24%) left top / 4% 100% no-repeat, repeating-linear-gradient(transparent 0 12%, #e4ebf0 12% 15%, transparent 15% 24%) right top / 4% 100% no-repeat;
}
