:root {
  color-scheme: light;
  --ink: #17332f;
  --muted: #6c7f79;
  --accent: #176856;
  --accent-soft: #e8f2ec;
  --line: #dbe3dc;
  --surface: #f6f7f3;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--surface);
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .4; }
button:focus-visible, input:focus-visible { outline: 3px solid #64b6a0; outline-offset: 3px; }
button svg { flex-shrink: 0; }
.viewer-app { width: min(100%, 1120px); margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
.document-header { padding-bottom: 22px; }
.eyebrow { display: flex; align-items: center; gap: 9px; font-size: 10px; font-weight: 700; letter-spacing: .15em; color: var(--muted); }
.eyebrow-dot { width: 3px; height: 3px; border-radius: 50%; background: #93a59d; }
h1 { margin: 13px 0 14px; max-width: 920px; font-size: clamp(20px, 3vw, 29px); line-height: 1.3; font-weight: 650; overflow-wrap: anywhere; }
.access-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--accent); }
.access-mark { display: inline-flex; }
.expiry-label { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.privacy-note { margin: 6px 0 0 22px; font-size: 12px; color: var(--muted); }
.reader { -webkit-user-select: none; user-select: none; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fafbf8; color: var(--ink); }
.icon-button:hover:not(:disabled), .go-button:hover:not(:disabled) { background: var(--accent-soft); }
.page-form { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 13px; }
.page-form input { width: 62px; height: 36px; padding: 6px; text-align: center; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; -moz-appearance: textfield; appearance: textfield; -webkit-user-select: text; user-select: text; font-variant-numeric: tabular-nums; background: #fff; }
.page-form input::-webkit-inner-spin-button, .page-form input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.page-total { white-space: nowrap; }
.go-button { height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 7px; background: #fafbf8; color: var(--ink); font-size: 12px; }
.view-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 15px 0 10px; min-height: 36px; }
.view-label { color: var(--muted); font-size: 12px; }
.view-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.text-button { border: 0; background: transparent; color: var(--accent); font-size: 12px; line-height: 1.4; padding: 8px 0; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.zoom-button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #c8dcd1; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 12px; padding: 8px 11px; min-height: 36px; }
.zoom-button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: white; }
.selection-help { margin: 0 0 10px; padding: 10px 12px; background: #e8f2ec; border-radius: 8px; font-size: 12px; line-height: 1.5; color: #245b4b; }
.page-frame { position: relative; min-height: 280px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #e9ece5; box-shadow: inset 0 1px 5px #17332f05; padding: 12px; text-align: center; }
.page-surface { position: relative; max-width: 100%; margin: 0 auto; background: white; box-shadow: 0 3px 18px #17332f12; }
canvas { width: 100%; height: auto; display: block; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.page-surface.selecting { cursor: crosshair; touch-action: none; }
.page-surface.selecting canvas { touch-action: none; }
.selection-box { position: absolute; pointer-events: none; border: 2px solid #176856; background: #17685625; box-shadow: 0 0 0 1px #fff8; }
.loading-state { min-height: 256px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.spinner { width: 23px; height: 23px; border: 2px solid #c6d5cb; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.reader-hint { margin: 10px 2px 0; font-size: 11px; line-height: 1.55; color: var(--muted); }
.notice { margin: 0 0 18px; padding: 13px 15px; color: #81492c; border: 1px solid #ead3bf; border-radius: 10px; background: #fff3e7; font-size: 13px; line-height: 1.55; }
.viewer-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 20px 2px 0; font-size: 11px; color: var(--muted); }
.close-button { padding-left: 14px; flex-shrink: 0; }
.print-note { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 520px) {
  .viewer-app { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .document-header { padding-left: 4px; padding-right: 4px; }
  h1 { font-size: 21px; }
  .page-toolbar { padding: 8px; gap: 6px; }
  .icon-button { width: 36px; height: 38px; }
  .page-form { gap: 6px; font-size: 12px; }
  .page-form input { width: 50px; }
  .go-button { padding: 0 8px; font-size: 11px; }
  .view-toolbar { align-items: flex-start; }
  .view-label { padding-top: 11px; }
  .view-actions { flex-wrap: wrap; gap: 5px 10px; }
  .zoom-button { font-size: 11px; padding: 8px; }
  .page-frame { padding: 5px; border-radius: 9px; }
}
@media (max-width: 340px) {
  .page-form label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .page-form { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
@media print { .viewer-app { display: none !important; } .print-note { display: block; padding: 30px; } }
