:root{
  --rainbow: linear-gradient(90deg,
    #ff0040, #ff8a00, #ffe600, #31d843,
    #1ecde1, #7b61ff, #ff2bd6, #ff0040
  );
}

/* page wrapper */
.frag-page {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 34px 0 60px;

  --rb-fill: rgba(255,255,255,.86);
  --rb-speed: 20s;
}

.frag-hero { margin-bottom: 20px; }
.frag-title { font-size: clamp(28px, 3.2vw, 44px); margin: 0 0 8px; }
.frag-sub { margin: 0 0 18px; line-height: 1.6; opacity: 0.85; max-width: 70ch; }

/* controls */
.frag-controls {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.frag-filters, .frag-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* buttons */
.chip{
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .2px;
  color: #000;

  background:
    linear-gradient(0deg, rgba(255,255,255,.86), rgba(255,255,255,.86)) padding-box,
    var(--rainbow) border-box;
  background-size: 100% 100%, 400% 400%;
  border: 2px solid transparent;
  animation: rainbow-flow 24s linear infinite;

  transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
  box-shadow: 0 8px 18px rgba(0,0,0,.08);
}

.chip:hover{
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 12px 26px rgba(0,0,0,.10);
}

.chip.is-active{
  background:
    linear-gradient(0deg, rgba(255,255,255,.94), rgba(255,255,255,.94)) padding-box,
    var(--rainbow) border-box;
}

.chip-ghost{
  background:
    linear-gradient(0deg, rgba(255,255,255,.60), rgba(255,255,255,.60)) padding-box,
    var(--rainbow) border-box;
  opacity: .95;
}

/* grid */
.frag-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  margin-top: 18px;
}

/* card base */
.frag-card{
  grid-column: span 4;
  border-radius: 16px;
  overflow: hidden;

  background:
    linear-gradient(0deg, rgba(255,255,255,.88), rgba(255,255,255,.88)) padding-box,
    var(--rainbow) border-box;
  background-size: 100% 100%, 400% 400%;
  border: 2px solid transparent;
  animation: rainbow-flow 22s linear infinite;

  box-shadow: 0 10px 24px rgba(0,0,0,.09);
  transition: transform .14s ease, box-shadow .14s ease, filter .14s ease;
}

.frag-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 16px 38px rgba(0,0,0,.12);
  filter: saturate(1.05);
}

.frag-open { display: block; color: inherit; text-decoration: none; }
.frag-open-text { width: 100%; text-align: left; border: 0; background: transparent; padding: 0; cursor: pointer; }

/* media area */
.frag-media{
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;

  /* Slight inner panel contrast */
  background: rgba(255,255,255,.72);
  border-bottom: 1px solid rgba(0,0,0,.06);
}

.frag-img{
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 12px;

  background: #fff;
  box-shadow: 0 8px 18px rgba(0,0,0,.08);
}

.frag-meta{
  padding: 12px 14px 14px;
  display: grid;
  gap: 4px;
}

.frag-name{ font-weight: 900; }
.frag-tag{ font-weight: 400; opacity: 0.65; font-size: 0.92rem; }

/* card flavors */
.frag-paper .frag-media{ background: rgba(255,255,255,.78); }
.frag-photo .frag-img{ background: transparent; box-shadow: none; }

/* pastel border */
.frag-modal{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}
.frag-modal.is-open { display: block; }

.frag-modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
}

.frag-modal-panel{
  position: relative;
  width: min(980px, 92vw);
  margin: 5vh auto;
  border-radius: 18px;
  overflow: hidden;

  background:
    linear-gradient(0deg, rgba(255,255,255,.94), rgba(255,255,255,.94)) padding-box,
    var(--rainbow) border-box;
  background-size: 100% 100%, 400% 400%;
  border: 2px solid transparent;
  animation: rainbow-flow 26s linear infinite;

  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}

.frag-modal-close{
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 30px;
  line-height: 1;
  border: 0;
  background: transparent;
  cursor: pointer;
  opacity: 0.7;
}
.frag-modal-close:hover { opacity: 1; }

.frag-modal-head{
  padding: 16px 18px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  background: rgba(255,255,255,.70);
}

.frag-modal-title{ font-weight: 1000; font-size: 1.15rem; }
.frag-modal-sub{ opacity: 0.75; margin-top: 4px; }

.frag-modal-body{
  padding: 16px 18px 18px;
  max-height: 72vh;
  overflow: auto;
  background: rgba(255,255,255,.72);
}

.frag-modal-body img{
  width: 100%;
  height: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
}

.frag-modal-body .modal-text{
  white-space: pre-wrap;
  font-size: 1.05rem;
  line-height: 1.7;
}

/* keyframes */
@keyframes rainbow-flow{
  0%   { background-position: 0% 50%, 0% 50%; }
  100% { background-position: 0% 50%, 100% 50%; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .frag-card,
  .chip,
  .frag-modal-panel{
    animation: none !important;
    background-position: 0 50%, 0 50%;
  }
}