/* PDF Editor - layout & viewer internals.
 * Colors/typography come from the site's Tailwind tokens in the markup; this
 * file only covers what utilities can't express (virtualized viewer chrome,
 * thumbnails, dialogs, spinner). Theme-aware via the site's `.dark` class.
 *
 * NOTE: this stylesheet loads AFTER styles.css. Any rule here that sets
 * `display` on a class which is also toggled with Tailwind's `.hidden` MUST
 * use :where() (zero specificity) so `.hidden` always wins - same pattern as
 * the .material-symbols-outlined rule in partials/head.ejs. */

/* -- Workspace ---------------------------------------------------------- */

#pdf-editor-root { min-height: 720px; }
#pdf-editor-root:fullscreen { border-radius: 0; min-height: 100vh; }
.pdf-workspace { flex: 1 1 auto; min-height: 560px; height: calc(100vh - 240px); }
#pdf-editor-root:fullscreen .pdf-workspace { height: calc(100vh - 56px); }
#pdf-editor-root.pdf-empty { min-height: auto; }
#pdf-editor-root.pdf-empty .pdf-workspace { height: auto; min-height: 400px; }
#pdf-editor-root.pdf-empty #upload-overlay { background-color: transparent !important; }
#pdf-editor-root.pdf-empty .pdf-toolbar,
#pdf-editor-root.pdf-empty .thumb-panel { display: none !important; }

/* -- Toolbar buttons ----------------------------------------------------- */

.pdf-tbtn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    min-width: 36px; height: 36px; padding: 0 6px; border-radius: 10px;
    color: #5c5c50; transition: background-color .15s, color .15s;
}
.pdf-tbtn:hover { background: #f4f4e6; color: #1c1c0d; }
.pdf-tbtn:disabled { opacity: .35; pointer-events: none; }
.pdf-tbtn .material-symbols-outlined { font-size: 20px; }
.pdf-tbtn-labeled { padding: 0 10px; }
.pdf-tlabel { font-size: .8rem; font-weight: 600; }
@media (max-width: 640px) { .pdf-tlabel { display: none; } }
.pdf-tsep { width: 1px; height: 20px; background: #e4e4e0; margin: 0 4px; }

.dark .pdf-tbtn { color: #a1a1aa; }
.dark .pdf-tbtn:hover { background: #27272a; color: #fff; }
.dark .pdf-tsep { background: #3f3f46; }

/* -- Touch devices: bigger tap targets (44px min, per platform guidelines) -- */
@media (pointer: coarse) {
    .pdf-tbtn { min-width: 44px; height: 44px; border-radius: 12px; }
    .pdf-tbtn .material-symbols-outlined { font-size: 22px; }
    .pdf-tsep { height: 26px; }
    .anno-handle { width: 22px; height: 22px; }
    .anno-color-input { width: 36px; height: 36px; }
}

/* -- Thumbnail panel ------------------------------------------------------ */

.thumb-panel { width: 13rem; flex-shrink: 0; overflow: hidden; display: flex; }
.thumb-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 1023px) {
    .thumb-panel {
        position: absolute; left: 0; top: 0; bottom: 0; z-index: 20;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: 0 4px 20px -2px rgba(0,0,0,.15);
    }
    .thumb-panel.thumb-panel-open { transform: translateX(0); }
}

.thumb-item {
    position: relative; border-radius: 12px; padding: 8px; cursor: pointer;
    border: 2px solid transparent; background: transparent;
    transition: border-color .15s, background-color .15s;
}
.thumb-item:hover { background: #f4f4e6; }
.dark .thumb-item:hover { background: #27272a; }
.thumb-item.thumb-active { border-color: #f9f506; }
.thumb-item.thumb-dragging { opacity: .4; }
.thumb-item.thumb-dropline { box-shadow: 0 -3px 0 0 #f9f506; }

.thumb-canvas-slot {
    width: 100%; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden;
    background: #fff; border: 1px solid #e4e4e0;
    display: flex; align-items: center; justify-content: center;
}
.dark .thumb-canvas-slot { background: #18181b; border-color: #3f3f46; }
.thumb-canvas-slot img { max-width: 100%; max-height: 100%; object-fit: contain; }

.thumb-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; min-height: 24px; }
.thumb-no { font-size: .72rem; font-weight: 700; color: #5c5c50; }
.dark .thumb-no { color: #a1a1aa; }
.thumb-menu { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.thumb-item:hover .thumb-menu, .thumb-item:focus-within .thumb-menu { opacity: 1; }
.thumb-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 6px; color: #5c5c50;
}
.thumb-btn:hover { background: #e4e4e0; color: #1c1c0d; }
.dark .thumb-btn { color: #a1a1aa; }
.dark .thumb-btn:hover { background: #3f3f46; color: #fff; }
.thumb-btn .material-symbols-outlined { font-size: 16px; }
.thumb-btn[data-act="delete"]:hover { color: #dc2626; }

/* -- Viewer --------------------------------------------------------------- */

.viewer-scroll {
    overflow: auto; overscroll-behavior: contain;
    background: #ececdf;
    scroll-behavior: auto;
    /* Mobile: one-finger pan stays native; two-finger pinch reaches the JS
       pinch-zoom handler instead of triggering browser page zoom. */
    touch-action: pan-x pan-y;
}
.dark .viewer-scroll { background: #0f0f11; }
.viewer-scroll:focus-visible { outline: 2px solid #f9f506; outline-offset: -2px; }

.viewer-pages {
    display: flex; flex-direction: column; align-items: center;
    gap: 24px; padding: 24px 16px; min-height: 100%;
}

.pdfv-page {
    position: relative; background: #fff; flex-shrink: 0;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, .12);
    border-radius: 2px;
}
.dark .pdfv-page { background: #2a2a2e; box-shadow: 0 4px 24px -2px rgba(0,0,0,.5); }
.pdfv-page.pdfv-hidden { display: none; }
.pdfv-canvas { display: block; }

.pdfv-badge {
    position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
    font-size: .7rem; font-weight: 600; color: #5c5c50; pointer-events: none;
}
.dark .pdfv-badge { color: #71717a; }

/* Loading shimmer on unrendered placeholders */
.pdfv-page:not(.pdfv-rendered)::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(0,0,0,.04) 50%, transparent 70%);
    background-size: 200% 100%;
    animation: pdfv-shimmer 1.4s linear infinite;
}
.dark .pdfv-page:not(.pdfv-rendered)::after {
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.05) 50%, transparent 70%);
    background-size: 200% 100%;
}
@keyframes pdfv-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
    .pdfv-page:not(.pdfv-rendered)::after { animation: none; }
}

/* Single page mode */
.viewer-scroll.pdfv-single .viewer-pages { justify-content: center; }

/* Search highlights */
.pdfv-hl-layer { position: absolute; inset: 0; pointer-events: none; }
.pdfv-hl {
    position: absolute; background: rgba(249, 245, 6, .4);
    border-radius: 2px; mix-blend-mode: multiply;
}
.dark .pdfv-hl { mix-blend-mode: screen; background: rgba(249, 245, 6, .28); }
.pdfv-hl-active { outline: 2px solid #9a7b00; background: rgba(249, 245, 6, .65); }

/* -- Upload drop state ----------------------------------------------------- */

#drop-card.drop-hot { border-color: #f9f506; }

/* -- Dialogs / toast / spinner ---------------------------------------------- */

/* display lives in a zero-specificity :where() so Tailwind's `.hidden`
   (same single-class specificity, earlier in load order) always wins.
   Without this, both dialogs rendered OPEN on page load. */
:where(.pdf-dialog-backdrop) { display: flex; }
.pdf-dialog-backdrop.hidden { display: none; }
.pdf-dialog-backdrop {
    position: fixed; inset: 0; z-index: 60;
    align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .45); padding: 16px;
}
.pdf-dialog {
    width: 100%; max-width: 26rem; border-radius: 1rem; padding: 20px 22px;
    box-shadow: 0 12px 48px -8px rgba(0, 0, 0, .35);
}
.pdf-dialog--wide { max-width: 40rem; max-height: 90vh; overflow-y: auto; }
.pdf-radio { display: flex; align-items: center; gap: 10px; font-size: .875rem; cursor: pointer; }

/* -- Header/footer style library ------------------------------------------- */

.hf-preset-grid {
    display: flex; flex-direction: row; overflow-x: auto; gap: 10px;
    padding-bottom: 4px; scrollbar-width: thin;
}
.hf-preset-card {
    display: block; flex: 0 0 auto; width: 160px; text-align: left; cursor: pointer;
    border: 1.5px solid #e4e4e0; border-radius: .6rem; padding: 6px;
    background: transparent; transition: border-color .15s;
}
.dark .hf-preset-card { border-color: #3f3f46; }
.hf-preset-card:hover { border-color: #9a7b00; }
.hf-preset-card.hf-preset-active { border-color: #9a7b00; box-shadow: 0 0 0 1px #9a7b00; }
.dark .hf-preset-card:hover, .dark .hf-preset-card.hf-preset-active { border-color: #f9f506; }
.dark .hf-preset-card.hf-preset-active { box-shadow: 0 0 0 1px #f9f506; }
.hf-preset-name { font-size: .72rem; font-weight: 600; margin-top: 5px; opacity: .8; }

.hf-preview {
    display: block; width: 100%; overflow: hidden; white-space: nowrap;
    text-overflow: ellipsis; border-radius: .25rem; background: #fff;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.hf-preview-live { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }

.hf-controls {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px 14px;
}
.hf-ctl { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .78rem; font-weight: 600; }
.hf-ctl > span { flex-shrink: 0; opacity: .8; }
.hf-input {
    min-width: 0; flex: 1; font-size: .8rem; padding: 3px 6px;
    border-radius: .375rem; border: 1px solid #e4e4e0; background: transparent;
}
.dark .hf-input { border-color: #3f3f46; background: #18181b; }
.hf-color { width: 34px; height: 24px; padding: 0; border: 1px solid #e4e4e0; border-radius: .3rem; background: none; cursor: pointer; }
.dark .hf-color { border-color: #3f3f46; }
.hf-range { flex: 1; min-width: 0; accent-color: #9a7b00; }
.dark .hf-range { accent-color: #f9f506; }
.hf-seg { display: inline-flex; border: 1px solid #e4e4e0; border-radius: .375rem; overflow: hidden; }
.dark .hf-seg { border-color: #3f3f46; }
.hfs-align-btn { display: inline-flex; align-items: center; padding: 2px 7px; cursor: pointer; background: transparent; }
.hfs-align-btn .material-symbols-outlined { font-size: 16px; }
.hfs-align-btn + .hfs-align-btn { border-left: 1px solid #e4e4e0; }
.dark .hfs-align-btn + .hfs-align-btn { border-left-color: #3f3f46; }
.hfs-align-btn.hfs-align-active { background: rgba(154, 123, 0, .18); }
.dark .hfs-align-btn.hfs-align-active { background: rgba(249, 245, 6, .18); }

.hfs-layout-btn {
    display: inline-flex; align-items: center; padding: 2px 9px;
    cursor: pointer; background: transparent; font-size: .72rem; font-weight: 600;
}
.hfs-layout-btn + .hfs-layout-btn { border-left: 1px solid #e4e4e0; }
.dark .hfs-layout-btn + .hfs-layout-btn { border-left-color: #3f3f46; }
.hfs-layout-btn.hfs-layout-active { background: rgba(154, 123, 0, .18); }
.dark .hfs-layout-btn.hfs-layout-active { background: rgba(249, 245, 6, .18); }

/* Three-zone preview row (Left & Right mode) */
.hf-preview-row { display: flex; width: 100%; }
.hf-preview-zone { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.pdf-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    z-index: 70; max-width: 90vw;
    background: #1c1c0d; color: #fff; font-size: .85rem; font-weight: 600;
    padding: 10px 18px; border-radius: 9999px;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, .3);
}
.dark .pdf-toast { background: #f8f8f5; color: #1c1c0d; }
.pdf-toast.hidden { display: none; }
.pdf-toast-error { background: #dc2626 !important; color: #fff !important; }

.pdf-spinner {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid rgba(154, 123, 0, .25); border-top-color: #9a7b00;
    animation: pdfv-spin .8s linear infinite;
}
.dark .pdf-spinner { border-color: rgba(249, 245, 6, .2); border-top-color: #f9f506; }
@keyframes pdfv-spin { to { transform: rotate(360deg); } }

/* Engine badge states */
#engine-badge.engine-wasm { color: #9a7b00; border-color: rgba(154, 123, 0, .4); }
.dark #engine-badge.engine-wasm { color: #f9f506; border-color: rgba(249, 245, 6, .35); }
#engine-badge.engine-missing { color: #dc2626; border-color: rgba(220, 38, 38, .4); }
.dark #engine-badge.engine-missing { color: #f87171; border-color: rgba(248, 113, 113, .35); }

/* -- Annotation layers (Milestone 2) ---------------------------------------- */

#pdf-editor-root.pdf-empty #anno-bar { visibility: hidden; }

.anno-svg, .anno-html { position: absolute; inset: 0; }
.anno-svg { pointer-events: none; }
.anno-svg .anno-obj { pointer-events: stroke; }
.anno-html { pointer-events: none; }
.anno-html > * { pointer-events: auto; }

/* tool-dependent hit behavior: only select/eraser need object hits */
[data-anno-tool="pen"] .anno-svg .anno-obj,
[data-anno-tool="marker"] .anno-svg .anno-obj,
[data-anno-tool="highlighter"] .anno-svg .anno-obj,
[data-anno-tool="rect"] .anno-svg .anno-obj,
[data-anno-tool="ellipse"] .anno-svg .anno-obj,
[data-anno-tool="line"] .anno-svg .anno-obj,
[data-anno-tool="arrow"] .anno-svg .anno-obj { pointer-events: none; }

[data-anno-tool="pen"] .pdfv-page, [data-anno-tool="marker"] .pdfv-page,
[data-anno-tool="highlighter"] .pdfv-page, [data-anno-tool="rect"] .pdfv-page,
[data-anno-tool="ellipse"] .pdfv-page, [data-anno-tool="line"] .pdfv-page,
[data-anno-tool="arrow"] .pdfv-page { cursor: crosshair; touch-action: none; }
[data-anno-tool="text"] .pdfv-page, [data-anno-tool="note"] .pdfv-page { cursor: text; }
[data-anno-tool="image"] .pdfv-page { cursor: copy; }
[data-anno-tool="eraser"] .pdfv-page { cursor: alias; }

.anno-svg .anno-selected { filter: drop-shadow(0 0 2px #9a7b00); }

.anno-text {
    position: absolute; min-width: 10px; white-space: pre-wrap;
    line-height: 1.25; font-family: Helvetica, Arial, sans-serif;
    cursor: move; outline: none; max-width: 90%;
}
.anno-text.anno-selected { outline: 1.5px dashed #9a7b00; outline-offset: 2px; }
.anno-text.anno-editing { outline: 1.5px solid #9a7b00; cursor: text; background: rgba(249,245,6,.08); }
.anno-note {
    background: #fef69e; border: 1px solid #d4c33a; border-radius: 4px;
    padding: 4px 6px; color: #1c1c0d !important;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.anno-img { position: absolute; cursor: move; }
.anno-img.anno-selected { outline: 2px dashed #9a7b00; outline-offset: 1px; }
.anno-handle {
    position: absolute; width: 14px; height: 14px; border-radius: 50%;
    background: #f9f506; border: 2px solid #9a7b00; cursor: nwse-resize; z-index: 5;
}

.anno-color-input {
    width: 28px; height: 28px; padding: 0; border: 1px solid #e4e4e0;
    border-radius: 8px; background: transparent; cursor: pointer;
}
.dark .anno-color-input { border-color: #3f3f46; }

.pdf-tbtn.anno-tool-active { background: #f9f506; color: #1c1c0d; }
.dark .pdf-tbtn.anno-tool-active { background: #f9f506; color: #1c1c0d; }

/* -- Text markup hotspots (underline / strikeout / highlight) --------------- */

.anno-edit-layer { position: absolute; inset: 0; pointer-events: none; }
.anno-edit-layer .anno-hotspot {
    position: absolute; pointer-events: auto; cursor: text;
    border-radius: 2px; outline: 1.5px dashed transparent;
    transition: outline-color .12s, background-color .12s;
}
.anno-edit-layer .anno-hotspot:hover {
    outline-color: #9a7b00; background: rgba(249, 245, 6, .12);
}
.dark .anno-edit-layer .anno-hotspot:hover {
    outline-color: #f9f506; background: rgba(249, 245, 6, .10);
}

/* -- Acrobat-style text edit mode (textedit-mode.js) ------------------------ */

/* Per-page layer with always-visible boundary frames around every detected
   paragraph block while the edittext tool is active. */
.tem-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.tem-block {
    position: absolute; pointer-events: auto; cursor: text;
    box-sizing: border-box; border-radius: 2px;
    border: 1px dashed rgba(120, 120, 110, .55);
    transition: border-color .12s, background-color .12s;
}
.tem-block:hover {
    border-color: #9a7b00; background: rgba(249, 245, 6, .10);
}
.tem-block.tem-dragging {
    border: 1.5px solid #9a7b00; background: rgba(249, 245, 6, .06);
    cursor: grabbing; z-index: 6;
}
.dark .tem-block { border-color: rgba(200, 200, 190, .45); }
.dark .tem-block:hover { border-color: #f9f506; background: rgba(249, 245, 6, .08); }
.dark .tem-block.tem-dragging { border-color: #f9f506; }

/* -- Smart layout: hover-detect, paragraph edit, guides, overflow ----------- */

/* Hover indicator over a detected paragraph block (select/default tool). It is
   click-through so the page's dblclick still fires to enter edit mode. */
.anno-text-hover {
    position: absolute; pointer-events: none; z-index: 2;
    border-radius: 3px; box-sizing: border-box;
    outline: 1.5px dashed #9a7b00;
    background: rgba(249, 245, 6, .10);
    transition: background-color .1s;
}
.dark .anno-text-hover { outline-color: #f9f506; background: rgba(249, 245, 6, .08); }
.pdfv-page.anno-text-hovering { cursor: text; }

/* ── Opaque mask: hides original canvas glyphs while editing ────────────────
   Background color is set dynamically by JS (sampled from the actual PDF page
   canvas) via inline style.  Fallback is white / dark-mode grey so the old
   text NEVER shows through even if the JS sampling fails. */
.anno-edit-mask {
    position: absolute; z-index: 5; pointer-events: none;
    box-sizing: border-box;
    background: var(--mask-bg, #fff);
}
.dark .anno-edit-mask { background: var(--mask-bg, #2a2a2e); }

/* ── Adobe Acrobat-style paragraph editor ───────────────────────────────────
   Sits above the mask. Font/size/color/alignment set via inline styles by
   textedit-mode.js to match the PDF's own text metrics exactly. Every
   browser-default contentEditable style is stripped. */
.anno-text.anno-block-edit {
    /* Strip every browser default */
    background: transparent !important;
    border: 1px solid #3B82F6;
    outline: none !important;
    box-shadow: none !important;
    resize: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* Layout */
    white-space: pre-wrap; word-wrap: break-word;
    padding: 0; margin: 0; box-sizing: border-box;
    overflow: hidden;
    z-index: 6;

    /* Remove browser focus ring */
    -webkit-tap-highlight-color: transparent;
}
.anno-text.anno-block-edit:focus {
    outline: none !important;
    box-shadow: none !important;
    border-color: #3B82F6;
}
.dark .anno-text.anno-block-edit { border-color: #60a5fa; }
.dark .anno-text.anno-block-edit:focus { border-color: #60a5fa; }
.anno-block-edit.anno-overflow { border-color: #e02424; }
.anno-block-edit.anno-committing { opacity: .6; pointer-events: none; }

/* Suppress all contentEditable browser chrome (spell-check decorations,
   drag handles, selection background) inside the block editor. */
.anno-block-edit::selection { background: rgba(59, 130, 246, .25); }
.anno-block-edit::-moz-selection { background: rgba(59, 130, 246, .25); }
.anno-block-edit *::selection { background: rgba(59, 130, 246, .25); }

/* Overflow warning chip shown above the editor. */
.anno-overflow-warn {
    position: absolute; z-index: 8; pointer-events: none;
    background: #e02424; color: #fff; font-size: 11px; line-height: 1.4;
    padding: 1px 7px; border-radius: 6px; white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

/* ── Adobe Acrobat-style resize handles (corners + edge midpoints) ────────── */
.anno-edit-handle {
    position: absolute; z-index: 8; pointer-events: none;
    width: 8px; height: 8px; border-radius: 50%;
    background: #fff; border: 1.5px solid #3B82F6;
    box-shadow: 0 0 0 1px rgba(0,0,0,.06);
    transform: translate(-50%, -50%);
}
.dark .anno-edit-handle { background: #1e1e22; border-color: #60a5fa; }

/* Alignment / boundary guide lines drawn while dragging. */
.anno-guide-layer {
    position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: visible;
}
.anno-guide-line {
    stroke: #e0249b; stroke-width: 1; stroke-dasharray: 4 3; opacity: .9;
    shape-rendering: crispEdges;
}

/* -- TRUE existing-image editing -------------------------------------------- */

.imged-layer { position: absolute; inset: 0; pointer-events: none; }
.imged-box {
    position: absolute; pointer-events: auto; cursor: move;
    outline: 1.5px dashed #9a7b00; outline-offset: 1px;
    transition: outline-color .12s, background-color .12s;
}
.imged-box:hover { outline-color: #f9f506; background: rgba(249,245,6,.07); }
.imged-box.imged-selected { outline: 2px solid #9a7b00; }
.imged-handle {
    position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px;
    border-radius: 50%; background: #f9f506; border: 2px solid #9a7b00;
    cursor: nwse-resize;
}
.imged-bar {
    position: absolute; display: flex; gap: 2px; padding: 2px; z-index: 6;
    background: #1c1c0d; border-radius: 8px; pointer-events: auto;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.imged-bar button {
    display: inline-flex; width: 26px; height: 26px; align-items: center;
    justify-content: center; color: #fff; border-radius: 6px;
}
.imged-bar button:hover { background: #3f3f46; }
.imged-bar .material-symbols-outlined { font-size: 16px; }
.dark .imged-bar { background: #f8f8f5; }
.dark .imged-bar button { color: #1c1c0d; }
.dark .imged-bar button:hover { background: #e4e4e0; }

/* -- Forms mode (Milestone 5) ------------------------------------------------ */

.form-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.form-layer .form-widget {
    position: absolute; pointer-events: auto; box-sizing: border-box;
    border: 1.5px solid rgba(37, 99, 235, .55); border-radius: 2px;
    /* near-opaque: the canvas underneath also paints the filled value
       (annotationMode ENABLE) — a translucent input would double-show it */
    background: rgba(244, 248, 255, .94); color: #111;
    font-family: Helvetica, Arial, sans-serif; padding: 0 3px;
}
.form-layer .form-widget:focus {
    outline: none; border-color: #2563eb; background: #fff;
}
.form-layer textarea.form-widget { resize: none; padding-top: 2px; line-height: 1.2; }
.form-layer .form-widget-checkbox,
.form-layer .form-widget-radio { accent-color: #2563eb; margin: 0; }
.form-layer select.form-widget { padding-right: 18px; }
.dark .form-layer .form-widget { color: #111; background: rgba(244, 248, 255, .94); }

.forms-creating .pdfv-page { cursor: crosshair; }
.form-drag-box {
    position: absolute; z-index: 6; pointer-events: none;
    border: 1.5px dashed #2563eb; background: rgba(59, 130, 246, .12);
}

/* -- Sign dialog (Milestone 5) ----------------------------------------------- */

.sign-tab-active { background: #f9f506; border-color: #9a7b00 !important; color: #1c1c0d; }
.sign-canvas {
    display: block; height: 160px; border-radius: 10px; touch-action: none;
    border: 1.5px dashed #c9c9c2; background: #fff; cursor: crosshair;
}
.dark .sign-canvas { border-color: #52525b; background: #fafaf9; }
.sign-type-preview {
    min-height: 72px; display: flex; align-items: center; justify-content: center;
    font-size: 34px; border-radius: 10px; border: 1.5px dashed #c9c9c2;
    background: #fff; color: #1a1a2e; overflow: hidden; padding: 0 12px;
}
.dark .sign-type-preview { border-color: #52525b; background: #fafaf9; }
.sign-saved-cell {
    position: relative; width: 96px; height: 44px; border-radius: 8px;
    border: 1px solid #e4e4e0; background: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.dark .sign-saved-cell { border-color: #3f3f46; background: #fafaf9; }
.sign-saved-cell img { max-width: 90%; max-height: 85%; object-fit: contain; }
.sign-saved-cell:hover { border-color: #9a7b00; }
.sign-saved-del {
    position: absolute; top: -1px; right: 2px; font-size: 14px; line-height: 1;
    color: #6b7280; padding: 2px;
}
.sign-saved-del:hover { color: #dc2626; }
