:root {
  color-scheme: dark;
  --navy: #16242b;
  --blue: #f47a20;
  --pale: #eef5fa;
  --line: #c5d5e3;
  --zoom: 1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: #dfe9f1;
  color: var(--navy);
}

button, input { font: inherit; }

.action-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--blue);
  border-radius: 10px;
  padding: 0 14px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.action-link:focus-visible { outline: 3px solid #52a8f4; outline-offset: 2px; }

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 14px;
  background: #fff;
  color: var(--navy);
  font-weight: 700;
  cursor: pointer;
}

button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible { outline: 3px solid #52a8f4; outline-offset: 2px; }
button:disabled { opacity: .35; cursor: default; }

.topbar {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto 0;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: #fff;
  border-bottom: 3px solid var(--blue);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}

.brand { display: flex; align-items: center; min-width: 0; }
.brand strong { display: block; font-size: 21px; letter-spacing: .07em; line-height: 1; }
.brand strong::after { content: ""; display: block; width: 100%; height: 3px; margin-top: 6px; background: var(--blue); }
.brand small { display: block; margin-top: 6px; font-size: 10px; letter-spacing: .12em; color: #607487; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }

.viewer {
  position: fixed;
  inset: 68px 0 66px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y pinch-zoom;
  padding: 18px;
  display: grid;
  align-items: start;
  justify-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.96), transparent 42%),
    #dfe9f1;
}

.page-shell {
  position: relative;
  width: min(calc(100% * var(--zoom)), calc(1360px * var(--zoom)));
  min-width: min(calc(100% * var(--zoom)), calc(1360px * var(--zoom)));
  background: #fff;
  box-shadow: 0 18px 55px rgba(0,0,0,.5);
  border-radius: 3px;
  overflow: hidden;
}

.page-shell img { display: block; width: 100%; height: auto; user-select: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: #4b5f78; background: #edf3f8; font-weight: 700; }
.page-shell.ready .loading { display: none; }

.controls {
  position: fixed;
  z-index: 20;
  inset: auto 0 0 0;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px max(12px, env(safe-area-inset-right)) max(9px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-btn { width: 48px; padding: 0; font-size: 30px; line-height: 1; background: var(--blue); border-color: var(--blue); color: #fff; }
.page-control { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--navy); }
.page-control input {
  width: 62px;
  height: 42px;
  border: 1px solid #9db5ca;
  border-radius: 9px;
  background: #fff;
  color: var(--navy);
  text-align: center;
  font-weight: 800;
}
.divider { width: 1px; height: 30px; background: var(--line); margin: 0 2px; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 82px;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

body.focus-mode .topbar { height: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
body.focus-mode .brand,
body.focus-mode .pdf-link,
body.focus-mode #shareBtn,
body.focus-mode .controls { display: none; }
body.focus-mode .viewer {
  inset: 0;
  width: 100vw;
  height: 100dvh;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #07111c;
}
body.focus-mode .page-shell {
  width: calc(100% * var(--zoom));
  min-width: calc(100% * var(--zoom));
  box-shadow: none;
}
body.focus-mode #fullBtn {
  display: block;
  position: fixed;
  z-index: 50;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  min-height: 36px;
  background: rgba(8, 35, 63, .9);
  color: #fff;
  border-color: rgba(255,255,255,.35);
}

@media (max-width: 640px) {
  .topbar { height: 60px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand strong { font-size: 18px; }
  .brand small { font-size: 8px; }
  .top-actions button { min-height: 38px; padding: 0 10px; font-size: 13px; }
  .top-actions .action-link { min-height: 38px; padding: 0 10px; font-size: 13px; }
  .viewer { inset: 60px 0 64px; padding: 10px; }
  .controls { min-height: 64px; gap: 5px; }
  .controls button { min-height: 40px; padding: 0 10px; }
  .nav-btn { width: 42px; font-size: 27px; }
  .page-control { gap: 5px; font-size: 12px; }
  .page-control input { width: 50px; height: 40px; }
  .divider { display: none; }
}

@media (max-width: 390px) {
  .brand small { display: none; }
  .pdf-link { font-size: 0 !important; }
  .pdf-link::after { content: "PDF"; font-size: 11px; }
  #fullBtn { padding: 0 8px; font-size: 11px; }
  .controls { justify-content: space-between; }
  .controls button { padding: 0 8px; }
}
