:root {
  color-scheme: light;
  --ink: #12232d;
  --muted: #61727b;
  --blueprint: #102b3f;
  --blueprint-raised: #183d56;
  --signal: #25c2b4;
  --signal-dark: #087f78;
  --paper: #ffffff;
  --mat: #dce7eb;
  --line: #b7c8cf;
  --focus: #f4bc42;
  --danger: #a53737;
  --toolbar-height: 4.25rem;
  --sidebar-width: 14rem;
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: var(--mat);
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.reader {
  display: grid;
  grid-template:
    "toolbar toolbar" var(--toolbar-height)
    "sidebar stage" calc(100dvh - var(--toolbar-height))
    / 0 minmax(0, 1fr);
  min-height: 100dvh;
  transition: grid-template-columns 180ms ease;
}

.reader.sidebar-open {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.toolbar {
  z-index: 20;
  grid-area: toolbar;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: 0 1rem;
  color: #f5fbfd;
  background: var(--blueprint);
  border-bottom: 3px solid var(--signal);
  box-shadow: 0 2px 10px rgb(18 35 45 / 18%);
}

.identity {
  min-width: 14rem;
  margin-right: auto;
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  color: var(--blueprint);
  font-size: 1.25rem;
  font-weight: 800;
  background: var(--signal);
  clip-path: polygon(0 0, 100% 0, 88% 100%, 12% 100%);
}

.brand-copy {
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 0.93rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy span {
  margin-top: 0.2rem;
  color: #b8d0da;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.reader-controls,
.control-group,
.display-controls {
  display: flex;
  align-items: center;
}

.reader-controls {
  min-width: 0;
  gap: 0.65rem;
}

.control-group,
.display-controls {
  gap: 0.25rem;
}

.control,
.text-control {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  color: #eaf5f8;
  background: transparent;
  cursor: pointer;
}

.control {
  display: grid;
  place-items: center;
  padding: 0.65rem;
}

.control svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: currentColor;
}

.text-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.control:hover,
.text-control:hover,
.control[aria-pressed="true"] {
  color: #ffffff;
  background: var(--blueprint-raised);
  border-color: #35627a;
}

.control:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.page-position {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  color: #a9c4cf;
  font-size: 0.8rem;
}

#page-input {
  width: 3.25rem;
  height: 2.25rem;
  padding: 0.3rem;
  color: #ffffff;
  text-align: center;
  background: #0a202f;
  border: 1px solid #31566b;
  border-radius: 0.25rem;
}

#zoom-value {
  min-width: 3.2rem;
  color: #bfd2da;
  font-size: 0.75rem;
  text-align: center;
}

.download-link {
  color: #092b2a;
  background: var(--signal);
}

.download-link:hover {
  color: #071f1e;
  background: #52d3c8;
  border-color: #52d3c8;
}

.sidebar {
  z-index: 15;
  grid-area: sidebar;
  min-width: 0;
  overflow: hidden;
  background: #f6fafb;
  border-right: 1px solid var(--line);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--sidebar-width);
  min-height: 4.5rem;
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading > div {
  display: grid;
}

.sidebar-heading strong {
  font-size: 0.86rem;
}

.sidebar-heading span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.sidebar .control {
  color: var(--ink);
}

.thumbnail-list {
  width: var(--sidebar-width);
  height: calc(100% - 4.5rem);
  padding: 0.75rem;
  overflow: auto;
  scrollbar-color: #91a9b3 transparent;
}

.thumbnail-button {
  display: grid;
  width: 100%;
  margin: 0 0 0.8rem;
  padding: 0.45rem;
  color: var(--muted);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 0.25rem;
  cursor: pointer;
}

.thumbnail-button:hover {
  color: var(--ink);
  background: #e7eff2;
}

.thumbnail-button[aria-current="page"] {
  color: var(--ink);
  background: #d8f2ef;
  border-color: var(--signal-dark);
}

.thumbnail-button canvas {
  display: block;
  width: 100%;
  height: auto;
  background: white;
  box-shadow: 0 1px 4px rgb(16 43 63 / 18%);
}

.thumbnail-button span {
  padding-top: 0.4rem;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.sidebar-backdrop {
  display: none;
}

.document-stage {
  position: relative;
  grid-area: stage;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--mat);
}

.stage-grid {
  position: fixed;
  inset: var(--toolbar-height) 0 0;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    linear-gradient(rgb(16 43 63 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(16 43 63 / 5%) 1px, transparent 1px);
  background-size: 24px 24px;
}

.canvas-frame {
  position: relative;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  padding: 2rem;
}

#document-canvas {
  display: block;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0.3rem 1.7rem rgb(16 43 63 / 22%);
}

.loading-panel,
.error-panel {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(30rem, calc(100% - 2rem));
  transform: translate(-50%, -50%);
  background: #f8fbfc;
  border: 1px solid #9fb5be;
  border-left: 5px solid var(--signal-dark);
  box-shadow: 0 0.7rem 2rem rgb(16 43 63 / 15%);
}

.loading-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.2rem;
  align-items: center;
  padding: 1.35rem;
}

.loading-mark {
  display: grid;
  width: 3.4rem;
  height: 3.4rem;
  place-items: center;
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--blueprint);
}

.loading-panel strong {
  font-size: 1rem;
}

.loading-panel p {
  margin: 0.25rem 0 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.loading-panel progress {
  width: 100%;
  height: 0.4rem;
  accent-color: var(--signal-dark);
}

.error-panel {
  padding: 1.5rem;
  border-left-color: var(--danger);
}

.error-code {
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.error-panel h1 {
  margin: 0.45rem 0 0.5rem;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  line-height: 1.2;
}

.error-panel p {
  max-width: 48ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.2rem;
}

.error-actions button,
.error-actions a {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  color: var(--blueprint);
  font-weight: 700;
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--blueprint);
  border-radius: 0.3rem;
  cursor: pointer;
}

.error-actions .primary-action {
  color: #ffffff;
  background: var(--blueprint);
}

.noscript-message {
  position: fixed;
  z-index: 100;
  inset: auto 1rem 1rem;
  margin: 0;
  padding: 1rem;
  color: #ffffff;
  background: var(--danger);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .identity {
    min-width: 0;
  }

  .brand-copy span,
  .zoom-controls,
  #fit-page {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --toolbar-height: 3.75rem;
  }

  .reader,
  .reader.sidebar-open {
    grid-template:
      "toolbar" var(--toolbar-height)
      "stage" calc(100dvh - var(--toolbar-height))
      / minmax(0, 1fr);
  }

  .toolbar {
    gap: 0.35rem;
    padding: 0 0.45rem;
  }

  .brand-mark {
    width: 2rem;
    height: 2rem;
  }

  .brand-copy {
    display: none;
  }

  .reader-controls {
    flex: 1;
    justify-content: flex-end;
    gap: 0.2rem;
  }

  .display-controls .text-control,
  .display-controls #fullscreen {
    display: none;
  }

  .control {
    min-width: 2.55rem;
    min-height: 2.55rem;
    padding: 0.55rem;
  }

  #page-input {
    width: 2.7rem;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    top: var(--toolbar-height);
    bottom: 0;
    left: 0;
    width: min(82vw, var(--sidebar-width));
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .reader.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 35;
    inset: var(--toolbar-height) 0 0;
    width: 100%;
    height: auto;
    padding: 0;
    background: rgb(7 24 35 / 56%);
    border: 0;
  }

  .reader.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .canvas-frame {
    padding: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .toolbar,
  .sidebar,
  .sidebar-backdrop,
  .stage-grid,
  .loading-panel,
  .error-panel {
    display: none !important;
  }

  html,
  body,
  .reader,
  .document-stage,
  .canvas-frame {
    display: block;
    width: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: #ffffff;
  }

  .canvas-frame {
    padding: 0;
  }

  #document-canvas {
    max-width: 100%;
    box-shadow: none;
  }
}
