/* PDF Viewer web demo. System fonts only: the page loads nothing from other sites. */

:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-2: #f6f8fa;
    --text: #1b2330;
    --muted: #5b6676;
    --border: #d5dbe3;
    --accent: #0b6e7a;
    --accent-text: #ffffff;
    --accent-soft: #d8eef0;
    --focus: #1d63d8;
    --danger-bg: #fdecec;
    --danger-text: #8a1c1c;
    --notice-bg: #fff6dc;
    --notice-text: #5c4400;
    --hit: rgba(255, 196, 0, 0.38);
    --hit-current: rgba(255, 112, 0, 0.5);
    --selection: rgba(29, 99, 216, 0.3);
    --page-shadow: 0 1px 3px rgba(16, 24, 40, 0.14), 0 4px 14px rgba(16, 24, 40, 0.08);
    --canvas-bg: #ffffff;
    --radius: 8px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #12161c;
        --surface: #1b2129;
        --surface-2: #222a33;
        --text: #e6eaf0;
        --muted: #9aa5b4;
        --border: #313b47;
        --accent: #3fb6c2;
        --accent-text: #061317;
        --accent-soft: #163a3f;
        --focus: #7aa7ff;
        --danger-bg: #3a1a1a;
        --danger-text: #ffc9c9;
        --notice-bg: #3a3014;
        --notice-text: #ffe7a6;
        --hit: rgba(255, 196, 0, 0.42);
        --hit-current: rgba(255, 128, 0, 0.6);
        --selection: rgba(122, 167, 255, 0.45);
        --page-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 18px rgba(0, 0, 0, 0.35);
        --canvas-bg: #2a2f36;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #12161c;
    --surface: #1b2129;
    --surface-2: #222a33;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --border: #313b47;
    --accent: #3fb6c2;
    --accent-text: #061317;
    --accent-soft: #163a3f;
    --focus: #7aa7ff;
    --danger-bg: #3a1a1a;
    --danger-text: #ffc9c9;
    --notice-bg: #3a3014;
    --notice-text: #ffe7a6;
    --hit: rgba(255, 196, 0, 0.42);
    --hit-current: rgba(255, 128, 0, 0.6);
    --selection: rgba(122, 167, 255, 0.45);
    --page-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 6px 18px rgba(0, 0, 0, 0.35);
    --canvas-bg: #2a2f36;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;   /* no text inflation when a phone turns to landscape */
    text-size-adjust: 100%;
}

html, body {
    margin: 0;
    height: 100%;
    height: 100dvh;                   /* the visible height on phones, whose address bar comes and goes */
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }

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

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

.muted { color: var(--muted); }

#app { height: 100%; }

/* ------------------------------------------------------------ boot screen */

.boot {
    height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 16px; text-align: center;
}
.boot h1 { margin: 8px 0 0; font-size: 22px; }
.boot-mark { color: var(--accent); }
.boot-bar { width: min(320px, 80vw); height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.boot-bar-fill { height: 100%; width: var(--blazor-load-percentage, 0%); background: var(--accent); transition: width 0.2s; }
#boot-progress::after { content: var(--blazor-load-percentage-text, ""); }

#blazor-error-ui {
    display: none;
    position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 1000;
    padding: 12px 16px; border-radius: var(--radius);
    background: var(--danger-bg); color: var(--danger-text); box-shadow: var(--page-shadow);
}

/* ------------------------------------------------------------ layout */

.app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Notched phones (index.html has viewport-fit=cover): the bars keep their controls out of the
   safe-area insets; max() keeps the usual padding where there is no inset. */
:root {
    --inset-top: env(safe-area-inset-top, 0px);
    --inset-right: env(safe-area-inset-right, 0px);
    --inset-bottom: env(safe-area-inset-bottom, 0px);
    --inset-left: env(safe-area-inset-left, 0px);
}

.toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
    padding: max(6px, var(--inset-top)) max(12px, var(--inset-right)) 6px max(12px, var(--inset-left));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.toolbar { position: relative; }   /* holds the "More" menu and the .visually-hidden labels */
.toolbar .group { display: flex; align-items: center; gap: 4px; }
.toolbar .phone-only { display: none; }
.toolbar .group.end { margin-left: auto; }

.brand { font-weight: 650; white-space: nowrap; margin: 0 4px; }
.brand-tag {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 999px; vertical-align: 2px;
}

.privacy-bar {
    margin: 0; padding: 4px max(12px, var(--inset-right)) 4px max(12px, var(--inset-left));
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--muted);
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.privacy-bar .icon { width: 16px; height: 16px; color: var(--accent); flex: none; }

.body { display: flex; flex: 1; min-height: 0; position: relative; }

.pages {
    flex: 1; min-width: 0;
    overflow: auto;
    padding: 16px max(16px, var(--inset-right)) 16px max(16px, var(--inset-left));
    display: flex; flex-direction: column; align-items: safe center; gap: 16px;
    outline: none;
}
.pages:has(.welcome) { justify-content: flex-start; }

.page {
    position: relative; flex: none;
    background: var(--canvas-bg);
    box-shadow: var(--page-shadow);
}
.page.drawn { background: #fff; }
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hit {
    position: absolute;
    background: var(--hit);
    mix-blend-mode: multiply;
    border-radius: 2px;
    pointer-events: none;
}
.hit.current { background: var(--hit-current); outline: 2px solid rgba(255, 112, 0, 0.9); outline-offset: 1px; }
/* Night pages are mostly black: multiply would hide the highlight there. */
.pages.night .hit { mix-blend-mode: screen; }
.pages.night .page.drawn { background: #000; }

/* Text selection: the engine finds the characters, so the page is not selectable by the browser. */
.page { cursor: text; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y pinch-zoom; }
.sel {
    position: absolute;
    background: var(--selection);
    mix-blend-mode: multiply;
    pointer-events: none;
}
.pages.night .sel { mix-blend-mode: screen; }

/* Two columns: pages side by side, in rows. */
.pages.two-column {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: safe center;
    align-content: start;
    align-items: start;
}

/* Thumbnails in the side panel. */
.thumbs { list-style: none; margin: 0; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.thumb {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px; border: 2px solid transparent; border-radius: var(--radius);
    background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.thumb:hover { background: var(--surface-2); }
.thumb.current { border-color: var(--accent); background: var(--accent-soft); }
.thumb-page { position: relative; display: block; background: #fff; box-shadow: var(--page-shadow); }
.thumb-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.thumb-number { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ embedded (pdfviewer-embed.js) */

.embedded .file-title { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.embed-wait { margin: auto; padding: 24px; color: var(--muted); }
html.embed .boot h1, html.embed .boot .muted { display: none; }
/* In line: the frame grows with the document and the host page scrolls. */
html.embed-inline, html.embed-inline body, html.embed-inline #app, html.embed-inline .app { height: auto; }
html.embed-inline .body { display: block; }
html.embed-inline .pages { overflow: visible; }
html.embed-inline .boot { min-height: 240px; }

.statusbar {
    display: flex; gap: 16px; align-items: center;
    padding: 4px max(12px, var(--inset-right)) max(4px, var(--inset-bottom)) max(12px, var(--inset-left)); min-height: 28px;
    font-size: 12.5px; color: var(--muted);
    background: var(--surface); border-top: 1px solid var(--border);
    white-space: nowrap; overflow: hidden;
}
.status-file { max-width: 30%; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.status-main { overflow: hidden; text-overflow: ellipsis; }
.status-perf { margin-left: auto; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ controls */

button, input, select { font: inherit; color: inherit; }

.button, .icon-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--border); background: var(--surface);
    border-radius: 6px; cursor: pointer;
}
.button { padding: 5px 10px; min-height: 32px; }
.button.quiet { border-color: transparent; }
.button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.button.large { padding: 10px 18px; font-size: 15px; min-height: 44px; }
.icon-button { width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent; }
.button:hover, .icon-button:hover { background: var(--surface-2); border-color: var(--border); }
.button.primary:hover { background: var(--accent); filter: brightness(1.08); }
.icon-button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button:disabled:hover { background: transparent; border-color: transparent; }
.icon { flex: none; }

.page-box { display: inline-flex; align-items: center; gap: 6px; }
.page-box input {
    width: 3.6em; text-align: center; padding: 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
.zoom-select { padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }

.search-box {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); padding: 0 8px;
}
.search-box .icon { width: 16px; height: 16px; color: var(--muted); }
.search-box input { border: 0; background: transparent; padding: 5px 0; width: 11em; outline: none; }
.search-box:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.search-count { min-width: 6.5em; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; cursor: pointer; padding: 0 4px; }

/* ------------------------------------------------------------ banners */

.banner {
    display: flex; align-items: center; gap: 10px;
    padding: 8px max(12px, var(--inset-right)) 8px max(12px, var(--inset-left)); border-bottom: 1px solid var(--border);
}
.banner p { margin: 0; flex: 1; }
.banner.error { background: var(--danger-bg); color: var(--danger-text); }
.banner.notice { background: var(--notice-bg); color: var(--notice-text); }
.banner .icon-button { color: inherit; }

/* ------------------------------------------------------------ side panel */

.sidebar {
    width: 280px; flex: none;
    display: flex; flex-direction: column; min-height: 0;
    padding-left: var(--inset-left);
    background: var(--surface); border-right: 1px solid var(--border);
}
.sidebar-backdrop { display: none; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tabs button {
    flex: 1; padding: 8px; border: 0; background: transparent; cursor: pointer;
    border-bottom: 2px solid transparent; color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.panel { overflow: auto; flex: 1; padding: 6px; }
.empty { padding: 8px; }

.outline, .outline ul { list-style: none; margin: 0; padding: 0; }
.outline ul { padding-left: 14px; }
.outline-entry {
    display: flex; width: 100%; gap: 8px; align-items: baseline; text-align: left;
    padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
}
.outline-entry:hover { background: var(--surface-2); }
.outline-entry.current { background: var(--accent-soft); }
.outline-entry.disabled { color: var(--muted); cursor: default; }
.outline-title { flex: 1; }
.outline-page { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.results { list-style: none; margin: 0; padding: 0; }
.result {
    display: block; width: 100%; text-align: left;
    padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
}
.result:hover { background: var(--surface-2); }
.result.current { background: var(--accent-soft); }
.result-page { display: block; font-size: 11.5px; color: var(--muted); }
.result-text { font-size: 13px; overflow-wrap: anywhere; }
.result mark { background: var(--hit); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ------------------------------------------------------------ welcome */

.welcome { max-width: 880px; width: 100%; padding: 32px 8px 48px; text-align: center; }
.welcome h1 { font-size: clamp(24px, 4vw, 34px); line-height: 1.2; margin: 8px 0 12px; }
.welcome .lead { font-size: 16px; color: var(--muted); max-width: 640px; margin: 0 auto 24px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 8px; }
.facts {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px;
    margin-top: 32px; text-align: left;
}
.facts > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.facts h2 { font-size: 15px; margin: 0 0 6px; }
.facts p { margin: 0; color: var(--muted); }
.loading { display: inline-flex; align-items: center; gap: 8px; }
.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ drop overlay and dialogs */

.drop-overlay {
    display: none; position: fixed; inset: 0; z-index: 50;
    align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    border: 3px dashed var(--accent);
    pointer-events: none;
}
.drop-overlay > div {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 20px; border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--page-shadow); font-size: 16px; font-weight: 600;
}
body.dropping .drop-overlay { display: flex; }

.dialog-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 60; }
.dialog {
    position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto;
    overscroll-behavior: contain;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--page-shadow);
    padding: 16px 20px 20px;
}
.dialog header { display: flex; align-items: center; justify-content: space-between; }
.dialog h2 { font-size: 16px; margin: 8px 0; }
.shortcuts { width: 100%; border-collapse: collapse; }
.shortcuts td { padding: 4px 0; vertical-align: top; }
.shortcuts td:first-child { white-space: nowrap; padding-right: 16px; }
.font-notices { margin: 0 0 8px; padding-left: 18px; columns: 2 16em; column-gap: 24px; }
.font-notices li { break-inside: avoid; }
kbd {
    font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
    padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2);
}
.field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.field input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* The custom stamp dialog */
.stamp-dialog h3 { font-size: 14px; margin: 16px 0 6px; }
.stamp-page { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.stamp-page input { width: 4.5em; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); color: var(--text); }
.stamp-preview {
    display: block; max-width: 280px; max-height: 200px; margin: 8px 0;
    border: 1px solid var(--border); background: #fff;
}
.stamp-dialog .problem { padding: 6px 10px; border-radius: 6px; background: var(--danger-bg); color: var(--danger-text); }
.saved-stamps { list-style: none; margin: 0 0 12px; padding: 0; max-height: 180px; overflow-y: auto; }
.saved-stamps li { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.saved-stamps .muted { flex: 1; font-size: 12px; }
.link-button { border: 0; background: none; padding: 4px 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; text-decoration: underline; }

/* ------------------------------------------------------------ narrow screens */

@media (max-width: 760px) {
    .toolbar { gap: 4px 6px; padding: 6px 8px; }
    .toolbar .label { display: none; }
    .brand { display: none; }
    /* The toolbar is one row: see "phone toolbar" at the end of this file. */
    .search-box { flex: 1; }
    .search-box input { width: 100%; min-width: 0; }
    .search-count { min-width: 0; }
    .icon-button { width: 36px; height: 36px; }
    .privacy-bar { font-size: 11.5px; }
    /* The side panel is a drawer over the pages, below the toolbars: the toolbar's panel button
       stays in view to close it, and so does a tap beside it (.sidebar-backdrop) or Esc. */
    .sidebar {
        position: absolute; z-index: 40; top: 0; bottom: 0; left: 0;
        width: min(320px, 85vw); box-shadow: var(--page-shadow);
    }
    .sidebar-backdrop {
        display: block; position: absolute; inset: 0; z-index: 39;
        background: rgba(0, 0, 0, 0.35);
    }
    .status-perf { display: none; }
    .status-file { max-width: 55%; }
    .pages { padding: 8px max(8px, var(--inset-right)) 8px max(8px, var(--inset-left)); gap: 8px; }
    .dialog { padding: 12px 16px 16px; }
    .shortcuts td:first-child { white-space: normal; padding-right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* Annotation tools (Viewer.Annotations.cs): a second toolbar, overlays on the pages. */
.annot-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
    padding: 4px max(12px, var(--inset-right)) 4px max(12px, var(--inset-left));
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.annot-toolbar .group { display: flex; align-items: center; gap: 2px; }
.annot-toolbar .swatches, .annot-toolbar .shape-style { gap: 6px; }
.swatch {
    width: 20px; height: 20px; padding: 0; border-radius: 50%;
    border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); cursor: pointer;
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); }
.swatch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.pages[data-tool="note"] .page, .pages[data-tool="freetext"] .page, .pages[data-tool="callout"] .page, .pages[data-tool="ink"] .page,
.pages[data-tool="square"] .page, .pages[data-tool="circle"] .page, .pages[data-tool="line"] .page, .pages[data-tool="arrow"] .page,
.pages[data-tool="polygon"] .page, .pages[data-tool="polyline"] .page, .pages[data-tool="stamp"] .page,
.pages[data-tool="customstamp"] .page { cursor: crosshair; }
/* Touch: with the Select tool a finger scrolls and zooms the pages (above). With any other tool the
   viewer takes the finger to draw, place or mark text (viewer.js), so the browser does not scroll,
   zoom or show its long-press menu on the page; two fingers scroll the pages. With the Select
   tool a finger drags the selected annotation and a callout's anchor. */
.pages:not([data-tool="select"]) .page { touch-action: none; -webkit-touch-callout: none; }
/* A pen (data-input: set by viewer.js when a pen hovers or presses) selects text with the Select
   tool instead of scrolling; a finger scrolls again once the pen has left the pages. */
.pages[data-input="pen"] .page { touch-action: none; }
.annot-hit.selected { touch-action: none; }
/* Links on a page: a pointer and the target as a tooltip; Tab reaches them, Enter follows them. */
.link-hit { position: absolute; cursor: pointer; border-radius: 2px; }
.link-hit:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.pages:not([data-tool="select"]) .link-hit { pointer-events: none; }
.link-url { overflow-wrap: anywhere; font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; max-height: 8em; overflow: auto; }
.annot-hit {
    position: absolute; border-radius: 2px; cursor: move;
    outline: 1px solid transparent; outline-offset: 1px;
}
.annot-hit:hover { outline-color: var(--accent); }
.annot-hit.selected { outline: 2px dashed var(--accent); outline-offset: 2px; }
.annot-hit.passive { pointer-events: none; }
/* A callout's anchor: the selected callout's handle (drag to move the spot it points to), and the spot the callout tool took. */
.callout-anchor, .callout-mark, .vertex-handle {
    position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; box-sizing: border-box;
    background: var(--surface, #fff); border: 2px solid var(--accent);
}
.callout-anchor { cursor: grab; touch-action: none; z-index: 2; }
.callout-anchor::after { content: ""; position: absolute; inset: -8px; } /* a larger target than it looks */
/* A selected line's, polygon's or polyline's points: drag one to move only that point (viewer.js). */
.vertex-handle { width: 12px; height: 12px; margin: -6px 0 0 -6px; cursor: move; touch-action: none; z-index: 2; }
.vertex-handle::after { content: ""; position: absolute; inset: -7px; }
.draw-preview.vertex-preview * { stroke-dasharray: none; stroke-linejoin: round; }
.callout-mark { pointer-events: none; background: var(--accent); }
/* A polygon or polyline drawn with a finger: its first and last points, where a tap ends it. */
.poly-end {
    position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; box-sizing: border-box;
    background: var(--surface, #fff); border: 2px solid var(--accent); pointer-events: none;
}
/* A finger: each annotation and a callout's anchor is a target of at least 44 x 44 CSS pixels; they
   look the same. data-input="touch": the last press was a finger (viewer.js), also on a screen whose
   main pointer is a mouse. An attribute, not a class: Blazor rewrites the pages' class. */
.pages[data-input="touch"] .annot-hit::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
}
.pages[data-input="touch"] .callout-anchor::after, .pages[data-input="touch"] .vertex-handle::after { inset: -16px; }
.draw-preview { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.draw-preview * { fill: none; stroke: var(--accent); stroke-width: 2px; vector-effect: non-scaling-stroke; stroke-dasharray: 4 3; }
.draw-preview polyline { stroke-dasharray: none; stroke-linecap: round; stroke-linejoin: round; }

.annot-editor {
    position: absolute; z-index: 3; width: 240px; margin-top: 6px;
    display: flex; flex-direction: column; gap: 6px; padding: 8px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    cursor: auto;
}
.annot-editor textarea { font: inherit; font-size: 13.5px; resize: vertical; padding: 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.annot-editor-actions { display: flex; justify-content: flex-end; gap: 6px; }
.comments .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
/* A thread: the replies under the comment they answer, indented by their level (set on the item). */
.comments .reply-form { display: flex; flex-direction: column; gap: 6px; padding: 4px 8px 8px 14px; }
.comments .reply-form textarea { font: inherit; font-size: 13px; resize: vertical; padding: 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.comments .reply-form .button { align-self: flex-end; }
.annot-toolbar select { font: inherit; font-size: 13px; padding: 2px 4px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

/* Form fields: the page shows the field's appearance; the input shows its text only while it has the focus. */
.form-field {
    position: absolute; z-index: 2; margin: 0; padding: 0 2px;
    font-family: Arial, "Liberation Sans", Helvetica, sans-serif; line-height: 1.15;
    background: rgba(29, 99, 216, 0.10); color: transparent; caret-color: #000;
    border: 1px solid rgba(29, 99, 216, 0.35); border-radius: 0; cursor: text;
}
.form-field:hover { background: rgba(29, 99, 216, 0.16); }
.form-field:focus { background: #fff; color: #000; outline: 2px solid var(--focus); outline-offset: 0; }
textarea.form-field { resize: none; overflow: hidden; }
.form-field.toggle { cursor: pointer; background: rgba(29, 99, 216, 0.08); }
.form-field.choice { cursor: pointer; appearance: none; color: transparent; }
.form-field.choice:focus { color: #000; }
.form-field.choice option { color: #000; background: #fff; }

/* ------------------------------------------------------------ phones and short screens */

/* After the annotation toolbar's own rules, so these win. The tools stay on one row that scrolls
   sideways inside itself: a wider row made the whole page wider than a phone's screen. */
@media (max-width: 760px), (max-height: 500px) {
    .annot-toolbar {
        position: relative;   /* contains the absolutely placed .visually-hidden labels */
        flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
        scrollbar-width: thin; gap: 4px 10px;
    }
    .annot-toolbar > .group { flex: none; }
    /* With a document open the pages need the height; the start page says the same thing. */
    .app:has(.page) .privacy-bar { display: none; }
}

/* A phone held sideways: the main toolbar is one row too, so the pages keep some height. */
@media (max-height: 500px) and (min-width: 761px) {
    .toolbar {
        position: relative;   /* else its .visually-hidden labels, scrolled past the edge, widen the page */
        flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
    }
    .toolbar > .group { flex: none; }
    .toolbar .label, .brand { display: none; }
}

/* Touch screens: controls at least 44 x 44 CSS pixels. */
@media (pointer: coarse) {
    .icon-button { width: 44px; height: 44px; }
    .button { min-height: 44px; }
    .page-box input, .zoom-select, .search-box, .annot-toolbar select, .field input { min-height: 44px; }
    /* Fields at 16 px: iOS Safari zooms the page in when a smaller field gets the focus. */
    .app :is(input, select, textarea):not(.form-field) { font-size: 16px; }
    .check { min-height: 44px; padding: 0 8px; }
    .check input { width: 20px; height: 20px; }
    .tabs button, .outline-entry, .result { min-height: 44px; }
    .outline-entry { align-items: center; }
    /* The colour dots keep their size; an invisible ring makes each a 44 px target. */
    .annot-toolbar .swatches { gap: 20px; padding: 0 10px; }
    .swatch { position: relative; width: 24px; height: 24px; }
    .swatch::after { content: ""; position: absolute; inset: -12px; border-radius: 50%; }
    .dialog-actions .button, .annot-editor-actions .button { min-width: 44px; }
    /* As .pages[data-input="touch"] above: annotations, a callout's anchor and a shape's points are 44 px targets. */
    .annot-hit::after {
        content: ""; position: absolute; left: 50%; top: 50%;
        width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
    }
    .callout-anchor::after { inset: -15px; }
    .vertex-handle::after { inset: -16px; }
}

/* ------------------------------------------------------------ phone toolbar */

/* One row: side panel, open, page number, zoom, search and "More". The page and zoom steppers
   and the tour go (scrolling, the zoom list and the menu do their work); the search field opens
   into the row in place of the others; the end group's commands are in the "More" menu. */
@media (max-width: 760px) {
    .toolbar { flex-wrap: nowrap; gap: 0; padding-left: max(6px, var(--inset-left)); padding-right: max(6px, var(--inset-right)); }
    .toolbar > .group { flex: none; gap: 0; }
    .toolbar .phone-only { display: inline-flex; }
    .toolbar .group.end, .toolbar .page-step, .toolbar .zoom-step, .toolbar .tour-button, .toolbar .group.search { display: none; }
    .toolbar .button { min-width: 44px; padding-inline: 10px; }
    .toolbar .page-box { gap: 4px; padding: 0 4px; }
    .toolbar .page-box input { width: 2.8em; }
    /* The zoom list gives way first when the row is short of room ("of 128"). */
    .toolbar > .group:has(.zoom-select) { flex: 0 1 auto; min-width: 0; }
    .toolbar > .group:has(.zoom-select) > label { display: flex; min-width: 0; }
    .zoom-select { width: 6.6em; min-width: 0; max-width: 100%; }
    .phone-actions { margin-left: auto; }

    .toolbar.search-open > .group:not(.search) { display: none; }
    .toolbar.search-open > .group.search { display: flex; flex: 1 1 auto; min-width: 0; gap: 2px; }
    .search-count { font-size: 12px; white-space: nowrap; padding: 0 4px; }
    .search-count:empty { padding: 0; }
    .check { padding: 0 4px; }
}

.more-menu {
    position: absolute; z-index: 46; top: calc(100% - 2px); right: max(6px, var(--inset-right));
    min-width: 220px; max-width: calc(100vw - 12px);
    display: flex; flex-direction: column; padding: 4px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.menu-backdrop { position: fixed; inset: 0; z-index: 45; }
.menu-item {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
    border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-item[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.menu-item[aria-checked="true"]::after { content: "\2713"; margin-left: auto; }
