.spm-grid{display:grid;gap:24px;margin:32px 0 8px;min-width:0}.spm-grid--multiple{grid-template-columns:repeat(2,minmax(0,1fr))}.sdpfl-reading .spm-figure{margin:0;min-width:0;background:#fff;border:1px solid #ddd0ed;border-radius:20px;overflow:hidden;box-shadow:0 12px 35px #2710390d}.spm-open{position:relative;display:flex;align-items:center;justify-content:center;background:linear-gradient(145deg,#f5f0fb,#fdf9ff);padding:12px;min-height:150px;overflow:hidden}.sdpfl-reading .spm-open img{display:block;width:auto;max-width:100%;height:auto;max-height:560px;object-fit:contain;border-radius:9px;margin:0}.spm-action{position:absolute;right:14px;bottom:14px;display:inline-flex;align-items:center;gap:8px;padding:9px 13px;border:1px solid #ffffff80;border-radius:24px;background:#231331ee;color:#fff;font-size:12px;font-weight:700;line-height:1.4;box-shadow:0 4px 14px #1d102229}.sdpfl-reading .spm-figure figcaption{padding:17px 20px;font:inherit;font-size:13px;line-height:1.65;color:#51435e;border-top:1px solid #e9e0f0;margin:0}.spm-open:hover img{filter:brightness(1.025)}
.spm-open:focus-visible {
  outline: 3px solid #a32deb;
  outline-offset: -4px;
}

.spm-viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #100b18;
  color: #fff;
  overflow: hidden;
}

.spm-viewer::backdrop { background: #100b18f5; }

.spm-viewer[open] {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 68px;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
}

.spm-viewer-head {
  grid-area: 1 / 1 / 2 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: none;
  padding: 16px 24px;
  border-bottom: 1px solid #ffffff20;
}

.spm-viewer-title {
  margin-right: auto;
  font-size: 14px;
  letter-spacing: .03em;
}

.spm-viewer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 46px;
  padding: 10px;
  border: 1px solid #ffffff40;
  border-radius: 13px;
  background: #ffffff10;
  color: #fff;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.spm-viewer button:hover { background: #7423b5; }
.spm-viewer [hidden] { display: none !important; }
.spm-viewer :is(button, a):focus-visible { outline: 3px solid #ea9fff; outline-offset: 2px; }
.spm-viewer .spm-zoom { font-size: 12px; white-space: nowrap; }
.spm-stage, .spm-controls { display: contents; }
.spm-prev { grid-area: 2 / 1; place-self: center; }
.spm-next { grid-area: 2 / 3; place-self: center; }

.spm-screen {
  grid-area: 2 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 12px 0;
  overflow: auto;
  touch-action: pan-y;
}

.spm-screen :is(img, video) {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.spm-screen p { color: #fff; }
.spm-screen.is-zoomed { display: block; touch-action: pan-x pan-y; }
.spm-screen.is-zoomed img { max-width: none; max-height: none; margin: auto; }

.spm-viewer-caption {
  grid-area: 3 / 1 / 4 / -1;
  justify-self: center;
  max-width: 75ch;
  margin: 0;
  padding: 8px 24px;
  color: #ede1f7;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.spm-viewer .spm-original {
  grid-area: 4 / 1 / 5 / -1;
  justify-self: center;
  margin: 2px 0 10px;
  color: #ecd7ff;
  font-size: 13px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.spm-thumbs {
  grid-area: 5 / 1 / 6 / -1;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: safe center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 8px 20px max(16px, env(safe-area-inset-bottom));
}

.spm-thumbs button {
  width: 62px;
  min-width: 62px;
  height: 50px;
  flex: none;
  padding: 3px;
  border-radius: 9px;
}

.spm-thumbs img { width: 100%; height: 100%; object-fit: contain; }
.spm-thumbs button[aria-current=true] { border: 2px solid #f29eff; background: #5d13af; }
.spm-media-open { overflow: hidden !important; }

@media (min-width: 1200px) {
  .spm-gallery.spm-grid--multiple:has(> .spm-figure:nth-child(9)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

@media (max-width: 600px) {
  .spm-grid--multiple { grid-template-columns: 1fr; }
  .spm-grid { margin: 24px 0 4px; gap: 20px; }
  .spm-open { padding: 8px; }
  .sdpfl-reading .spm-figure figcaption { padding: 14px 16px; }
  .spm-action { right: 11px; bottom: 11px; font-size: 11px; }

  .spm-viewer[open] { display: flex; flex-direction: column; }
  .spm-viewer-head { padding: max(10px, env(safe-area-inset-top)) 12px 10px; gap: 8px; }
  .spm-viewer-title { font-size: 13px; }
  .spm-viewer .spm-zoom { padding-inline: 10px; }
  .spm-stage {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: safe center;
    gap: 10px;
    min-height: 0;
    padding: 8px max(8px, env(safe-area-inset-right)) 2px max(8px, env(safe-area-inset-left));
  }
  .spm-screen { flex: 0 1 auto; width: 100%; margin: 0; }
  .spm-screen.is-zoomed { flex: 1; }
  .spm-controls {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    align-items: center;
    gap: 10px;
    align-self: center;
    flex: none;
    width: min(100%, 360px);
  }
  .spm-prev { grid-area: 1 / 1; }
  .spm-next { grid-area: 1 / 3; }
  .spm-viewer .spm-original {
    grid-area: 1 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: stretch;
    gap: 6px;
    box-sizing: border-box;
    min-height: 46px;
    margin: 0;
    padding: 8px;
    border: 1px solid #c590ff;
    border-radius: 13px;
    background: #6323a6;
    color: #fff;
    font-weight: 700;
    text-decoration: none;
  }
  .spm-viewer .spm-original:hover { background: #7837c1; }
  .spm-viewer-caption { flex: none; max-height: 22dvh; overflow: auto; padding: 8px 14px; font-size: 12px; }
  .spm-thumbs { justify-content: flex-start; padding: 4px 10px max(8px, env(safe-area-inset-bottom)); }
  .spm-thumbs button { min-width: 53px; width: 53px; min-height: 44px; height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .spm-open img { transition: filter .18s ease; }
  .spm-viewer[open] { animation: spm-enter .14s ease; }
  @keyframes spm-enter { from { opacity: 0; } to { opacity: 1; } }
}
