:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  color: #dfe1e5;
  background: #17181a;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #1c1d20;
  border-bottom: 1px solid #303136;
}

.toolbar {
  max-width: 1080px;
  min-height: 86px;
  margin: 0 auto;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.catalog-title { display: flex; align-items: center; gap: 13px; min-width: 0; }
.document-icon { flex-shrink: 0; color: #b8a36d; }
h1 { font-size: 17px; line-height: 1.4; font-weight: 550; letter-spacing: .04em; margin: 0; }
.catalog-title p { margin: 5px 0 0; font-size: 11px; line-height: 1.5; color: #a2a5ac; }
.actions { display: flex; gap: 9px; flex-shrink: 0; }

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid #404956;
  border-radius: 5px;
  background: transparent;
  color: #b6cef1;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.action:hover { border-color: #7399c9; background: #252c36; }
:focus-visible { outline: 2px solid #8dbdff; outline-offset: 5px; }
.reader { width: min(100% - 56px, 960px); margin: 0 auto; }
.reader-info { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 24px 0 16px; color: #a2a5ad; font-size: 11px; line-height: 1.6; letter-spacing: .02em; }
.reader-info > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.status-dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: #b8a36d; }
.catalog-page { margin: 0 0 24px; }
.page-image { display: block; background: #fff; cursor: zoom-in; box-shadow: 0 4px 24px #0002; }
.page-image picture { display: block; }
.page-image img { display: block; width: 100%; height: auto; color: #172333; background: #fff; }
.catalog-page figcaption { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 10px; line-height: 1.6; color: #979aa2; }
.page-number { font-variant-numeric: tabular-nums; letter-spacing: .08em; }
.page-image:hover { outline: 1px solid #52565d; }
.reader-footer { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 4px 0 36px; }
.reader-footer p { color: #a2a5ad; font-size: 11px; }
.footer-line { width: 42px; height: 1px; background: #3a3c41; }
.toast, .share-fallback { position: fixed; z-index: 20; bottom: 24px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); border: 1px solid #4a5260; border-radius: 8px; padding: 13px 20px; background: #2b3038; color: #f2f4f8; box-shadow: 0 8px 32px #0005; font-size: 13px; line-height: 1.6; text-align: center; }
.share-fallback { width: min(460px, 100% - 32px); }
.share-fallback label { display: block; margin-bottom: 8px; }
.share-fallback input { display: block; width: 100%; padding: 10px; border: 1px solid #606b7c; border-radius: 4px; background: #17181a; color: #fff; font: inherit; }

@media (max-width: 640px) {
  .toolbar { min-height: 0; padding: 14px 16px; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
  .catalog-title { gap: 10px; flex: 1 1 100%; }
  h1 { font-size: 15px; letter-spacing: .02em; }
  .catalog-title p { font-size: 10px; margin-top: 3px; }
  .document-icon { width: 23px; height: 27px; }
  .actions { width: 100%; gap: 8px; }
  .action { flex: 1; min-height: 40px; font-size: 12px; padding: 9px 12px; }
  .reader { width: calc(100% - 20px); }
  .reader-info { padding: 17px 2px 12px; font-size: 10px; flex-wrap: wrap; gap: 5px 12px; }
  .catalog-page { margin-bottom: 17px; }
  .catalog-page figcaption { margin: 8px 2px 0; }
  .reader-footer { padding-bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .action { transition: none; }
}

@media print {
  :root { color-scheme: light; background: #fff; }
  .site-header, .reader-info, figcaption, .reader-footer, .toast, .share-fallback { display: none !important; }
  .reader { width: 100%; margin: 0; }
  .catalog-page { margin: 0; break-after: page; }
  .catalog-page:last-of-type { break-after: auto; }
  .page-image { box-shadow: none; }
  @page { size: A4; margin: 0; }
}
