:root {
  color-scheme: light;
  --teal: #173f46;
  --teal-soft: #315d64;
  --gold: #bd713a;
  --paper: #fffefb;
  --background: #e9eeec;
  --page-width: 980px;
  --page-scale: 1;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: #183b41;
  background: var(--background);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

.viewer-bar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(260px, 2fr) minmax(150px, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 12px clamp(16px, 4vw, 54px);
  border-bottom: 1px solid rgba(23, 63, 70, 0.14);
  background: rgba(255, 254, 251, 0.94);
  box-shadow: 0 8px 24px rgba(23, 63, 70, 0.08);
  backdrop-filter: blur(14px);
}

.back-link {
  width: fit-content;
  color: var(--teal);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible { color: var(--gold); }

.viewer-heading { min-width: 0; text-align: center; }

.viewer-kicker,
.viewer-count {
  margin: 0;
  color: #62787c;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.viewer-heading h1 {
  overflow: hidden;
  margin: 2px 0;
  color: var(--teal);
  font-size: clamp(16px, 2.2vw, 22px);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zoom-controls {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.zoom-controls button {
  min-width: 38px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(23, 63, 70, 0.2);
  border-radius: 8px;
  color: var(--teal);
  background: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.zoom-controls button:hover,
.zoom-controls button:focus-visible {
  border-color: var(--gold);
  color: var(--gold);
  outline: none;
}

.document-pages {
  width: min(calc(var(--page-width) * var(--page-scale)), calc(100vw - 28px));
  margin: 28px auto 70px;
  transition: width 180ms ease;
}

.document-page {
  position: relative;
  overflow: hidden;
  margin: 0 0 22px;
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(23, 63, 70, 0.12);
}

.document-page img {
  display: block;
  width: 100%;
  height: auto;
}

.document-pages.html-mode { --page-width: 860px; }

.html-document {
  padding: clamp(28px, 6vw, 72px);
  border-radius: 5px;
  color: #243d42;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(23, 63, 70, 0.12);
  font-size: 16px;
  line-height: 1.82;
}

.html-document .document-cover {
  display: block;
  width: min(100%, 680px);
  max-height: 360px;
  margin: 0 auto 42px;
  border: 1px solid rgba(23, 63, 70, 0.12);
  object-fit: contain;
  background: #fff;
}

.html-document p,
.html-document li {
  font-family: inherit !important;
  font-size: inherit !important;
}

.html-document p { margin: 0 0 0.82em !important; }
.html-document ul,
.html-document ol { margin: 0.2em 0 1.15em; padding-left: 1.5em; }
.html-document li { margin: 0.28em 0 !important; }
.html-document p:first-of-type {
  margin-bottom: 0.25em !important;
  color: var(--teal);
  font-size: clamp(24px, 3vw, 32px) !important;
  font-weight: 760;
  line-height: 1.32;
  text-align: center;
}
.html-document p:nth-of-type(2) {
  margin-bottom: 2.2em !important;
  color: #5b7478;
  font-size: 14px !important;
  text-align: center;
}
.html-document b { color: #173f46; }

.page-number {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(23, 63, 70, 0.72);
  font-size: 11px;
}

.single-image img { cursor: zoom-in; }

.video-shell {
  padding: clamp(12px, 2vw, 22px);
  border-radius: 8px;
  background: #102e34;
  box-shadow: 0 14px 38px rgba(16, 46, 52, 0.2);
}

.video-shell video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 150px);
  background: #000;
}

.loading-note,
.error-note {
  margin: 90px auto;
  color: #60777b;
  text-align: center;
}

@media (max-width: 680px) {
  .viewer-bar {
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 10px 14px;
  }

  .viewer-heading {
    grid-column: 1 / -1;
    grid-row: 1;
    padding: 0 52px;
  }

  .back-link { grid-column: 1; grid-row: 1; font-size: 13px; }
  .zoom-controls { grid-column: 2; grid-row: 1; }
  .zoom-controls button:first-child,
  .zoom-controls button:last-child { display: none; }
  .viewer-kicker { display: none; }
  .viewer-heading h1 { font-size: 15px; }
  .viewer-count { font-size: 10px; }
  .document-pages { margin-top: 14px; }
  .document-page { margin-bottom: 12px; border-radius: 2px; box-shadow: 0 6px 18px rgba(23, 63, 70, 0.1); }
  .html-document { padding: 26px 20px 42px; font-size: 15px; line-height: 1.72; }
  .html-document .document-cover { margin-bottom: 26px; }
}

@media print {
  .viewer-bar { position: static; box-shadow: none; }
  .back-link,
  .zoom-controls { display: none; }
  body { background: #fff; }
  .document-pages { width: 100%; margin: 0; }
  .document-page { break-after: page; margin: 0; box-shadow: none; }
  .page-number { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .document-pages { transition: none; }
}
