.sphv-viewer,
.sphv-viewer * {
  box-sizing: border-box;
}

.sphv-viewer {
  --sphv-bg: #0b1220;
  --sphv-panel: rgba(14, 22, 38, 0.84);
  --sphv-panel-2: rgba(255, 255, 255, 0.06);
  --sphv-border: rgba(255, 255, 255, 0.09);
  --sphv-text: #eff6ff;
  --sphv-muted: #94a3b8;
  --sphv-accent: #60a5fa;
  --sphv-success: #22c55e;
  position: relative;
  width: 100%;
  max-width: none;
  margin: 18px auto;
  color: var(--sphv-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sphv-viewer.sphv-stretch {
  width: min(calc(100vw - 20px), 1680px);
  max-width: min(calc(100vw - 20px), 1680px);
  margin-left: 50%;
  transform: translateX(-50%);
}

.sphv-shell {
  background:
    radial-gradient(circle at top left, rgba(96,165,250,.20), transparent 28%),
    radial-gradient(circle at top right, rgba(34,197,94,.12), transparent 22%),
    linear-gradient(180deg, #0f172a 0%, #0b1220 100%);
  border: 1px solid var(--sphv-border);
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(2, 6, 23, .45);
  overflow: hidden;
}

.sphv-toolbar,
.sphv-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--sphv-border);
  backdrop-filter: blur(14px);
}

.sphv-toolbar {
  background: rgba(15, 23, 42, 0.56);
}

.sphv-meta-bar {
  background: rgba(255,255,255,0.03);
  color: var(--sphv-muted);
  font-size: 13px;
}

.sphv-toolbar-left,
.sphv-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.sphv-toolbar-right {
  justify-content: flex-end;
}

.sphv-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.sphv-title-wrap > div:last-child {
  min-width: 0;
}

.sphv-file-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #22c55e);
  box-shadow: 0 0 0 6px rgba(255,255,255,0.06);
}

.sphv-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.22;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  word-break: normal;
  text-wrap: balance;
}

.sphv-subtitle {
  color: var(--sphv-muted);
  font-size: 12px;
}

.sphv-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: #fff;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
  font-size: 14px;
  line-height: 1;
}

.sphv-btn:hover,
.sphv-btn:focus-visible {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.22);
  transform: translateY(-1px);
  color: #fff;
}

.sphv-btn.is-active {
  background: linear-gradient(135deg, rgba(96,165,250,.26), rgba(34,197,94,.18));
  border-color: rgba(96,165,250,.45);
}

.sphv-body {
  display: grid;
  min-height: 72vh;
}

.sphv-body.has-thumbs {
  grid-template-columns: 170px minmax(0, 1fr);
}

.sphv-body.no-thumbs {
  grid-template-columns: minmax(0, 1fr);
}

.sphv-thumbs {
  border-right: 1px solid var(--sphv-border);
  padding: 16px 10px;
  overflow: auto;
  background: rgba(8, 13, 23, 0.55);
}

.sphv-thumbs:empty {
  display: none;
}

.sphv-body.no-thumbs .sphv-thumbs,
.sphv-viewer.sphv-thumbs-hidden .sphv-thumbs {
  display: none;
}

.sphv-viewer.sphv-thumbs-hidden .sphv-body.has-thumbs {
  grid-template-columns: minmax(0, 1fr);
}

.sphv-thumb {
  display: block;
  width: 100%;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  padding: 8px;
  background: rgba(255,255,255,.03);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s ease;
}

.sphv-thumb:hover,
.sphv-thumb.is-active {
  border-color: rgba(96,165,250,.58);
  transform: translateY(-1px);
}

.sphv-thumb canvas,
.sphv-thumb .sphv-thumb-placeholder {
  width: 100%;
  display: block;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}

.sphv-thumb-num {
  display: block;
  text-align: center;
  margin-top: 8px;
  color: var(--sphv-muted);
  font-size: 12px;
}

.sphv-main {
  min-width: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.03) 0%, rgba(255,255,255,.01) 100%);
}

.sphv-pages,
.sphv-text-mode {
  padding: 16px;
}

.sphv-page-shell {
  position: relative;
  margin: 0 auto 18px;
  width: 100%;
}

.sphv-page {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .20);
}

.sphv-page-canvas {
  display: block;
  width: 100%;
  height: auto;
}

.sphv-page-placeholder {
  min-height: 320px;
  display: grid;
  place-items: center;
  color: #334155;
  background: linear-gradient(180deg, #fff 0%, #eef2f7 100%);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .18);
}

.sphv-page-meta {
  position: sticky;
  top: 12px;
  margin-bottom: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: #fff;
  background: rgba(15, 23, 42, .84);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  font-size: 12px;
}

.sphv-scan-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  padding: 8px 10px;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, .82);
  font-size: 12px;
}

.sphv-textLayer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.22;
  line-height: 1;
}

.sphv-textLayer :is(span, br) {
  color: transparent;
  position: absolute;
  white-space: pre;
  transform-origin: 0 0;
  cursor: text;
}

.sphv-textLayer span.markedContent {
  top: 0;
  height: 0;
}

.sphv-text-mode[hidden] {
  display: none !important;
}

.sphv-text-mode-page {
  width: min(100%, 980px);
  margin: 0 auto 18px;
  background: rgba(255,255,255,.98);
  color: #0f172a;
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .18);
}

.sphv-text-mode-page h3 {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.2;
}

.sphv-text-mode-page p {
  margin: 0 0 1em;
  font-size: 16px;
  line-height: 1.68;
  color: #1e293b;
}

.sphv-text-empty {
  width: min(100%, 980px);
  margin: 0 auto;
  text-align: center;
  padding: 30px 20px;
  border-radius: 18px;
  background: rgba(255,255,255,.96);
  color: #334155;
}

.sphv-loading,
.sphv-error {
  padding: 26px;
  text-align: center;
}

.sphv-error {
  border-radius: 16px;
  background: #fff5f5;
  color: #991b1b;
}

.sphv-pages[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .sphv-body.has-thumbs {
    grid-template-columns: minmax(0, 1fr);
  }

  .sphv-thumbs {
    display: none;
  }
}

@media (max-width: 782px) {
  .sphv-viewer.sphv-stretch {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
  }

  .sphv-toolbar,
  .sphv-meta-bar,
  .sphv-pages,
  .sphv-text-mode {
    padding-left: 12px;
    padding-right: 12px;
  }

  .sphv-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sphv-toolbar-left,
  .sphv-toolbar-right {
    width: 100%;
  }

  .sphv-shell {
    border-radius: 16px;
  }

  .sphv-title {
    font-size: 15px;
  }

  .sphv-btn {
    min-height: 38px;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    flex: 1 1 auto;
  }

  .sphv-page-placeholder {
    min-height: 220px;
  }
}


.sphv-btn.is-disabled,
.sphv-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
}

.sphv-native-wrap {
  padding: 14px;
}

.sphv-native-note {
  margin: 0 0 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(96, 165, 250, .10);
  border: 1px solid rgba(96, 165, 250, .24);
  color: #dbeafe;
  font-size: 14px;
}

.sphv-native-frame {
  display: block;
  width: 100%;
  min-height: 84vh;
  margin: 0;
  border: 0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(2, 6, 23, .18);
}

.sphv-ios-native .sphv-thumbs {
  display: none !important;
}

.sphv-ios-native .sphv-body.has-thumbs {
  grid-template-columns: minmax(0, 1fr);
}

.sphv-ios-native .sphv-btn.is-hidden-on-ios {
  display: none !important;
}

.sphv-ios-native .sphv-toolbar-right {
  gap: 8px;
}

.sphv-ios-native .sphv-toolbar-right .sphv-btn {
  flex: 0 0 auto;
}

@media (max-width: 767px) {
  .sphv-native-wrap,
  .sphv-pages,
  .sphv-text-mode {
    padding: 10px;
  }

  .sphv-native-frame {
    min-height: 76vh;
    border-radius: 14px;
  }

  .sphv-native-note {
    display: none;
  }
}
