:root {
  --bg: #f3f4f6;
  --bar: #ffffff;
  --line: #e3e5e9;
  --text: #16181d;
  --muted: #5d6470;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --btn: #ffffff;
  --btn-hover: #f1f3f6;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 10px 30px rgb(16 24 40 / 10%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --bar: #1c1f26;
    --line: #2b2f38;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --accent: #5b82ef;
    --btn: #23262e;
    --btn-hover: #2b2f39;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 12px 32px rgb(0 0 0 / 45%);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  padding: 14px max(16px, calc((100% - 960px) / 2));
  background: var(--bar);
  border-bottom: 1px solid var(--line);
}
.who h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; display: flex; gap: 8px; flex-wrap: wrap; }
.updated::before { content: "·"; margin-right: 8px; }
.updated a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 2px; }
.updated a:hover { color: var(--text); }

.actions { display: flex; gap: 8px; }
.btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--btn);
  color: var(--text);
  font-weight: 550;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:focus-visible, #viewerContainer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* PDF.js requires an absolutely positioned scroll container. */
.stage { position: relative; flex: 1; min-height: 0; }
#viewerContainer { position: absolute; inset: 0; overflow: auto; }
.pdfViewer.removePageBorders .page {
  margin: 28px auto;
  border: 0;
  border-radius: 3px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.pdfViewer .page { background: #fff; }

.status {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}
.status[hidden] { display: none; }
.status a { color: var(--accent); }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

@media (max-width: 560px) {
  .bar { padding: 12px 16px; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; justify-content: center; }
  .pdfViewer.removePageBorders .page { margin: 12px auto; border-radius: 2px; }
}
