    html {
        width: 100%;
        height: 100%;
        overflow: clip;
        overscroll-behavior: none;
    }

    /* === SECURITY: Prevent selection & copy === */
    body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
    input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; }

    /*
     * Keep the two workspace columns anchored inside the viewport. Unlike
     * `overflow: hidden`, `overflow: clip` cannot be scrolled by focus
     * restoration when a deep form control or permission prompt is used.
     * The editor body and preview remain the only scroll owners.
     */
    #consentWorkspace {
        min-width: 0;
        min-height: 0;
        overflow: clip !important;
        overscroll-behavior: none;
    }
    #editorPanel,
    #previewPanel {
        min-width: 0;
        min-height: 0;
        height: 100%;
    }
    #editorPanel { overflow: clip !important; }
    #editorPanel > .flex-1.overflow-y-auto {
        min-height: 0;
        overscroll-behavior: contain;
    }
    #previewPanel { overscroll-behavior: contain; }

    .consent-brand {
        min-width: 0;
        color: inherit;
        text-decoration: none;
    }
    .consent-brand:focus-visible,
    .consent-platform-links a:focus-visible,
    .consent-action-navigation a:focus-visible,
    .consent-action-navigation button:focus-visible {
        outline: 3px solid #fff;
        outline-offset: 2px;
    }
    .consent-platform-links {
        display: none;
        align-items: center;
        gap: 4px;
        margin-inline: auto;
        padding: 4px;
        border: 1px solid #1e3a5f;
        border-radius: 12px;
        background: #0d1830;
    }
    .consent-platform-links a,
    .consent-platform-links span {
        display: inline-flex;
        min-height: 40px;
        align-items: center;
        padding: 7px 12px;
        border-radius: 9px;
        color: #cbd5e1;
        font-size: 12px;
        font-weight: 700;
        text-decoration: none;
    }
    .consent-platform-links a:hover { color: #fff; background: #132441; }
    .consent-platform-links span {
        color: #080c24;
        background: #f5a623;
    }

    .consent-history-actions button {
        min-height: 34px;
        padding: 6px 10px;
        border: 1px solid #253551;
        border-radius: 8px;
        background: #111d33;
        color: #cbd5e1;
        font-size: 10px;
        font-weight: 800;
    }
    .consent-history-actions button:hover { border-color: #f5a623; color: #fff; }
    .consent-history-actions button.text-red-400 { border-color: rgba(248, 113, 113, .32); color: #fca5a5; }
    [data-save-state="error"] { color: #fda4af !important; }
    [data-save-state="saving"] { color: #f8c15c !important; }
    .consent-storage-warning {
        position: fixed;
        z-index: 80;
        top: 72px;
        left: 50%;
        display: none;
        width: min(calc(100% - 24px), 680px);
        padding: 10px 14px;
        transform: translateX(-50%);
        border: 1px solid rgba(251, 113, 133, .65);
        border-radius: 12px;
        background: #3b1019;
        box-shadow: 0 10px 28px rgba(0, 0, 0, .38);
        color: #ffe4e6;
        font-size: 12px;
        font-weight: 750;
        text-align: center;
    }
    body.consent-storage-error .consent-storage-warning { display: block; }

    .consent-feedback {
        position: fixed;
        z-index: 95;
        right: 18px;
        bottom: 18px;
        display: flex;
        width: fit-content;
        max-width: min(calc(100% - 36px), 380px);
        min-height: 40px;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        padding: 8px 12px;
        border: 1px solid rgba(96, 165, 250, .46);
        border-radius: 12px;
        background: rgba(10, 22, 40, .97);
        box-shadow: 0 10px 26px rgba(0, 0, 0, .42);
        color: #e5edf8;
        font-size: 11px;
        font-weight: 700;
        line-height: 1.35;
        text-align: left;
        pointer-events: none;
    }
    .consent-feedback[hidden] { display: none !important; }
    .consent-feedback-indicator {
        width: 14px;
        height: 14px;
        flex: 0 0 14px;
        border: 2px solid currentColor;
        border-radius: 999px;
    }
    .consent-feedback[data-feedback-state="working"] { border-color: rgba(248, 193, 92, .62); color: #fde68a; }
    .consent-feedback[data-feedback-state="working"] .consent-feedback-indicator {
        border-right-color: transparent;
        animation: consentSpin .7s linear infinite;
    }
    .consent-feedback[data-feedback-state="success"] { border-color: rgba(74, 222, 128, .56); color: #bbf7d0; }
    .consent-feedback[data-feedback-state="success"] .consent-feedback-indicator { background: #22c55e; box-shadow: inset 0 0 0 3px #0a1628; }
    .consent-feedback[data-feedback-state="warning"] { border-color: rgba(251, 191, 36, .65); color: #fde68a; }
    .consent-feedback[data-feedback-state="error"] { border-color: rgba(251, 113, 133, .72); background: rgba(59, 16, 25, .98); color: #ffe4e6; pointer-events: auto; }
    @keyframes consentSpin { to { transform: rotate(360deg); } }

    [data-consent-action].is-busy,
    [data-pwa-install].is-busy { position: relative; cursor: wait; color: transparent !important; }
    [data-consent-action].is-busy svg,
    [data-pwa-install].is-busy svg,
    [data-consent-action].is-busy span,
    [data-pwa-install].is-busy span { opacity: 0; }
    [data-consent-action].is-busy::after,
    [data-pwa-install].is-busy::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 18px;
        height: 18px;
        margin: -9px 0 0 -9px;
        border: 2px solid #f8c15c;
        border-right-color: transparent;
        border-radius: 999px;
        animation: consentSpin .7s linear infinite;
    }

    .consent-stamp-option {
        display: flex;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        transition: border-color .18s ease, background-color .18s ease, color .18s ease;
    }
    .consent-stamp-option.is-selected { border-color: #f5a623; background: rgba(245, 166, 35, .14); color: #f8c15c; }
    .consent-stamp-option.is-processing { box-shadow: 0 0 0 2px rgba(245, 166, 35, .2); }
    .consent-stamp-option:focus-within { outline: 3px solid #fff; outline-offset: 2px; }
    .consent-stamp-spinner {
        width: 14px;
        height: 14px;
        flex: 0 0 14px;
        border: 2px solid rgba(248, 193, 92, .35);
        border-top-color: #f8c15c;
        border-radius: 999px;
        animation: consentSpin .7s linear infinite;
    }
    .consent-stamp-feedback {
        min-height: 30px;
        margin: 0;
        padding: 7px 9px;
        border-radius: 8px;
        background: rgba(15, 28, 50, .7);
        color: #aebbd0;
        font-size: 10px;
        font-weight: 650;
        line-height: 1.4;
    }
    .consent-stamp-feedback[data-stamp-state="working"] { color: #fde68a; }
    .consent-stamp-feedback[data-stamp-state="success"] { color: #86efac; }
    .consent-stamp-feedback[data-stamp-state="warning"] { color: #fcd34d; }
    .consent-clinic-location-button { min-height: 44px; }

    @media (min-width: 1200px) {
        .consent-platform-links { display: flex; }
    }

    .consent-action-navigation { display: none; }

    @media (max-width: 1199.98px) {
        :root {
            --consent-dock-height: 70px;
            --consent-safe-bottom: env(safe-area-inset-bottom, 0px);
            --consent-dock-gap: 12px;
        }

        .consent-storage-warning { top: 62px; }
        .consent-feedback {
            right: 12px;
            bottom: calc(var(--consent-dock-height) + var(--consent-safe-bottom) + var(--consent-dock-gap) + 10px);
            max-width: min(calc(100% - 24px), 360px);
        }

        body.consent-menu-open { overscroll-behavior: contain; }
        #consentWorkspace {
            margin-bottom: calc(var(--consent-dock-height) + var(--consent-safe-bottom) + 22px);
            overflow: clip !important;
            overscroll-behavior: none;
        }
        #consentWorkspace #editorPanel,
        #consentWorkspace #previewPanel {
            position: absolute !important;
            inset: 0 !important;
            width: 100% !important;
            max-width: none !important;
        }
        #consentWorkspace #editorPanel.hidden,
        #consentWorkspace #previewPanel.hidden { display: none !important; }
        #editorPanel > div:first-child { display: flex !important; }
        #mobileBackBtn,
        .consent-floating-help,
        body > header .consent-header-output,
        body > header .consent-pwa-install { display: none !important; }

        .consent-action-navigation {
            display: block;
            position: fixed;
            inset: 0;
            z-index: 58;
            pointer-events: none;
        }
        .consent-action-navigation svg {
            width: 22px;
            height: 22px;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.8;
            stroke-linecap: round;
            stroke-linejoin: round;
        }
        .consent-action-dock {
            position: fixed;
            z-index: 62;
            right: 12px;
            bottom: calc(var(--consent-dock-gap) + var(--consent-safe-bottom));
            left: 12px;
            display: grid;
            grid-template-columns: repeat(5, minmax(0, 1fr));
            width: min(calc(100% - 24px), 720px);
            height: var(--consent-dock-height);
            margin-inline: auto;
            padding: 5px;
            border: 1px solid rgba(245, 166, 35, .3);
            border-radius: 22px;
            background: linear-gradient(160deg, rgba(17, 29, 53, .98), rgba(6, 12, 27, .99));
            box-shadow: 0 18px 45px rgba(0, 0, 0, .58), inset 0 1px rgba(255, 255, 255, .04);
            pointer-events: auto;
            -webkit-backdrop-filter: blur(18px);
            backdrop-filter: blur(18px);
        }
        .consent-dock-item {
            display: flex;
            min-width: 0;
            min-height: 58px;
            cursor: pointer;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            gap: 3px;
            padding: 4px 2px;
            border: 0;
            border-radius: 16px;
            background: transparent;
            color: #aebbd0;
            font: inherit;
            font-size: 10px;
            font-weight: 700;
            line-height: 1;
            transition: color .2s ease, background-color .2s ease;
        }
        .consent-dock-item:hover { color: #fff; background: rgba(30, 58, 95, .48); }
        .consent-dock-item.is-active {
            color: #f8c15c;
            background: rgba(245, 166, 35, .12);
        }
        .consent-dock-item[disabled] { cursor: wait; opacity: .58; }
        .consent-history-actions button { min-height: 44px; padding-inline: 14px; }

        .consent-action-backdrop {
            position: fixed;
            z-index: 59;
            inset: 0;
            cursor: pointer;
            border: 0;
            background: rgba(2, 6, 18, .68);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transition: opacity .22s ease, visibility .22s ease;
        }
        .consent-action-backdrop.is-open {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
        }
        .consent-action-sheet {
            position: fixed;
            z-index: 61;
            right: 12px;
            bottom: calc(var(--consent-dock-height) + var(--consent-safe-bottom) + 6px);
            left: 12px;
            display: flex;
            width: min(calc(100% - 24px), 720px);
            max-height: calc(100dvh - var(--consent-dock-height) - var(--consent-safe-bottom) - 28px);
            margin-inline: auto;
            flex-direction: column;
            overflow: hidden;
            border: 1px solid rgba(245, 166, 35, .3);
            border-radius: 24px 24px 18px 18px;
            background: linear-gradient(165deg, #121f38, #070d1d 72%);
            box-shadow: 0 -20px 55px rgba(0, 0, 0, .62);
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transform: translateY(24px);
            transition: transform .24s ease-out, opacity .2s ease, visibility .24s ease;
        }
        .consent-action-sheet.is-open {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transform: translateY(0);
        }
        .consent-sheet-handle {
            width: 44px;
            height: 4px;
            margin: 9px auto 2px;
            flex: 0 0 auto;
            border-radius: 999px;
            background: rgba(203, 213, 225, .46);
        }
        .consent-sheet-header {
            display: flex;
            min-height: 62px;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 10px 14px 12px;
            border-bottom: 1px solid rgba(148, 163, 184, .15);
        }
        .consent-sheet-header > div { display: grid; gap: 3px; }
        .consent-sheet-header strong { color: #fff; font-size: 17px; }
        .consent-sheet-header span { color: #70db9b; font-size: 11px; font-weight: 700; }
        .consent-sheet-header span.is-saving { color: #f8c15c; }
        .consent-sheet-header span.is-error { color: #fda4af; }
        .consent-sheet-close {
            display: inline-flex;
            width: 44px;
            height: 44px;
            cursor: pointer;
            align-items: center;
            justify-content: center;
            flex: 0 0 44px;
            border: 1px solid rgba(148, 163, 184, .25);
            border-radius: 13px;
            background: rgba(15, 23, 42, .76);
            color: #fff;
        }
        .consent-sheet-scroll {
            overflow-y: auto;
            overscroll-behavior: contain;
            padding: 4px 14px 18px;
            -webkit-overflow-scrolling: touch;
        }
        .consent-sheet-section {
            padding: 14px 0;
            border-bottom: 1px solid rgba(148, 163, 184, .12);
        }
        .consent-sheet-section:last-child { border-bottom: 0; }
        .consent-sheet-section h2 {
            margin: 0 0 9px;
            color: #9baac0;
            font-size: 10px;
            font-weight: 800;
            letter-spacing: .09em;
            text-transform: uppercase;
        }
        .consent-sheet-grid {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 8px;
        }
        .consent-sheet-grid button,
        .consent-sheet-list button,
        .consent-pwa-install-sheet {
            display: flex;
            min-height: 48px;
            cursor: pointer;
            align-items: center;
            gap: 10px;
            padding: 9px 11px;
            border: 1px solid rgba(148, 163, 184, .18);
            border-radius: 13px;
            background: rgba(15, 28, 50, .78);
            color: #e5edf8;
            font: inherit;
            font-size: 12px;
            font-weight: 700;
            text-align: left;
            transition: border-color .2s ease, background-color .2s ease, color .2s ease;
        }
        .consent-sheet-grid button:hover,
        .consent-sheet-list button:hover,
        .consent-pwa-install-sheet:hover {
            border-color: rgba(245, 166, 35, .48);
            background: rgba(30, 58, 95, .62);
            color: #fff;
        }
        .consent-sheet-grid button svg,
        .consent-sheet-list button svg { flex: 0 0 22px; color: #f8c15c; }
        .consent-sheet-grid button span,
        .consent-sheet-list button span {
            min-width: 0;
            overflow-wrap: anywhere;
            white-space: normal;
            line-height: 1.25;
        }
        .consent-sheet-list { display: grid; gap: 8px; }
        .consent-sheet-list button { width: 100%; }
        .consent-sheet-list [hidden] { display: none !important; }
        .consent-sheet-platforms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
        .consent-sheet-platforms a {
            display: flex;
            min-height: 44px;
            align-items: center;
            justify-content: center;
            border: 1px solid rgba(148, 163, 184, .18);
            border-radius: 12px;
            background: rgba(15, 28, 50, .6);
            color: #cbd5e1;
            font-size: 12px;
            font-weight: 700;
            text-decoration: none;
        }
        .consent-sheet-platforms a:hover { border-color: rgba(245, 166, 35, .48); color: #f8c15c; }
        .consent-sheet-danger { display: grid; gap: 8px; }
        .consent-sheet-danger h2 { margin-bottom: 1px; }
        .consent-sheet-danger button {
            min-height: 44px;
            cursor: pointer;
            border: 1px solid rgba(244, 63, 94, .28);
            border-radius: 12px;
            background: rgba(127, 29, 29, .15);
            color: #fda4af;
            font: inherit;
            font-size: 12px;
            font-weight: 750;
        }

        @media (min-width: 700px) {
            .consent-sheet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
        }
        @media (max-width: 420px) {
            .consent-action-dock { right: 8px; left: 8px; width: calc(100% - 16px); }
            .consent-action-sheet { right: 8px; left: 8px; width: calc(100% - 16px); }
            .consent-dock-item { font-size: 9px; }
            .consent-action-navigation svg { width: 20px; height: 20px; }
        }
        @media (prefers-reduced-motion: reduce) {
            .consent-action-navigation *,
            .consent-action-navigation *::before,
            .consent-action-navigation *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
            .consent-feedback-indicator,
            .consent-stamp-spinner,
            [data-consent-action].is-busy::after,
            [data-pwa-install].is-busy::after { animation-duration: 1.6s !important; }
        }
    }

    .consent-pwa-install {
        display: inline-flex;
        min-height: 44px;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        padding: 0.45rem 0.7rem;
        border: 1px solid rgba(245, 166, 35, 0.55);
        border-radius: 0.5rem;
        background: rgba(245, 166, 35, 0.1);
        color: #f8c15c;
        font-size: 0.75rem;
        font-weight: 700;
        line-height: 1;
        white-space: nowrap;
    }
    .consent-pwa-install[hidden] { display: none !important; }
    .consent-pwa-install:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
    @media (max-width: 639.98px) {
        .consent-pwa-install span { display: none; }
        .consent-pwa-install { width: 44px; flex: 0 0 44px; padding: 0; }
        body > header { padding-inline: 8px !important; gap: 6px; }
        body > header > .consent-brand { flex: 0 0 72px; min-width: 0; gap: 0; }
        body > header > .consent-brand img { width: 72px; height: auto; }
        body > header > .consent-brand > div { display: none; }
        body > header > div:last-child { flex: 1 1 auto; min-width: 0; gap: 4px !important; }
        body > header button[onclick="handleDownload()"],
        body > header button[onclick="handlePrint()"] {
            width: 44px;
            height: 44px;
            flex: 0 0 44px;
            justify-content: center;
            padding: 0 !important;
        }
    }
    
    /* UI Scrollbar */
    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: #0A1628; }
    ::-webkit-scrollbar-thumb { background: #1E3A5F; border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: #2a4a7a; }
    ::selection { background: #1E3A5F; color: #F5A623; }
    input::placeholder, textarea::placeholder { color: #475569 !important; opacity: 1; }

    /* A4 Paper Preview with Glassmorphism */
    .a4-paper {
        box-sizing: border-box !important;
        display: flex;
        flex-direction: column;
        width: 210mm;
        min-height: 297mm;
        background: white;
        box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(30, 58, 95, 0.1);
        margin: 0 auto;
        position: relative;
        padding: 15mm;
        color: #1e293b;
        font-family: 'Noto Serif', serif;
        transform-origin: top center;
        transition: transform 0.2s, box-shadow 0.3s;
        line-height: 1.5;
        border-radius: 2px;
    }
    .a4-paper:hover {
        box-shadow: 0 25px 70px -12px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(30, 58, 95, 0.15);
    }

    /* Watermark */
    .watermark {
        position: absolute;
        top: 50%; left: 50%;
        transform: translate(-50%, -50%) rotate(-45deg);
        font-size: 8rem;
        font-weight: 900;
        color: rgba(0,0,0,0.02);
        pointer-events: none;
        white-space: nowrap;
        text-transform: uppercase;
        z-index: 0;
    }

    /* Signature Canvas */
    canvas.signature-pad {
        border-bottom: 2px solid #000;
        cursor: crosshair;
        background: rgba(240, 240, 240, 0.5);
        touch-action: none; 
    }

    /* Page-safe consent content. These rules are shared by preview, print, and PDF. */
    .consent-multi-summary {
        margin-bottom: 4mm;
        break-after: avoid-page;
        page-break-after: avoid;
    }
    .consent-treatment-block {
        box-sizing: border-box;
        margin: 0 0 4mm;
        padding: 3.5mm;
        border: 1px solid #cbd5e1;
        border-left: 1mm solid #2563eb;
        border-radius: 2mm;
        background: #fff;
        break-inside: avoid-page;
        page-break-inside: avoid;
    }
    .consent-treatment-heading {
        margin-bottom: 2mm;
        padding-bottom: 1.5mm;
        border-bottom: 1px solid #dbeafe;
        break-after: avoid-page;
        page-break-after: avoid;
    }
    .consent-treatment-grid,
    .consent-single-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 4mm;
        align-items: start;
    }
    .consent-treatment-grid.is-bilingual,
    .consent-single-grid.is-bilingual,
    .consent-legal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .consent-treatment-grid .english-version,
    .consent-single-grid .english-version {
        min-width: 0;
    }
    .consent-treatment-grid .translated-version,
    .consent-single-grid .translated-version {
        min-width: 0;
        padding: 2mm;
        border-left: 1px solid #cbd5e1;
        border-radius: 1mm;
        background: #f8fafc;
    }
    .consent-keep-together {
        break-inside: avoid-page;
        page-break-inside: avoid;
    }
    .consent-pdf-source {
        border-radius: 0 !important;
        overflow: visible !important;
    }

    /* Explicit paged consent output shared by Download PDF and native Print. */
    .consent-output-document {
        box-sizing: border-box;
        width: 210mm;
        margin: 0;
        padding: 0;
        color: #172033;
        background: #fff;
        font-family: 'Noto Serif', 'Noto Sans Devanagari', serif;
    }
    .consent-output-render-host {
        position: fixed;
        z-index: 0;
        top: -10000px;
        left: 0;
        width: 210mm;
        visibility: visible;
        pointer-events: none;
    }
    .consent-output-document.is-pdf-rendering {
        position: static;
        z-index: auto;
        top: auto;
        left: auto;
        display: block;
        visibility: visible;
    }
    .consent-output-document.is-native-printing {
        position: fixed;
        z-index: 0;
        top: -10000px;
        left: 0;
        visibility: visible;
        pointer-events: none;
    }
    .consent-output-page {
        box-sizing: border-box;
        position: relative;
        width: 210mm;
        height: 296.8mm;
        min-height: 296.8mm;
        margin: 0;
        padding: 9mm 11mm 10mm;
        overflow: hidden;
        color: #172033;
        background: #fff;
        break-after: page;
        page-break-after: always;
    }
    .consent-output-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
    .consent-output-page-frame {
        position: absolute;
        z-index: 0;
        inset: 5mm;
        border: 0.35mm solid #475569;
        pointer-events: none;
    }
    .consent-output-page-inner {
        position: relative;
        z-index: 1;
        display: flex;
        flex-direction: column;
        gap: 1.7mm;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    .consent-output-document-type {
        color: #475569;
        font: 700 6.5px/1.2 Inter, sans-serif;
        letter-spacing: 0.12em;
        text-align: center;
    }
    .consent-output-header > div {
        margin: 0 !important;
        padding-bottom: 2.5mm !important;
    }
    .consent-output-header h1 {
        margin: 0 !important;
        font-size: 17px !important;
        line-height: 1.05 !important;
    }
    .consent-output-header img {
        width: 13mm !important;
        height: 13mm !important;
    }
    .consent-output-title {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 1.8mm;
        margin-bottom: 1.5mm;
    }
    .consent-output-title > div {
        margin: 0 !important;
        width: 100%;
    }
    .consent-output-title h2 {
        margin: 0 !important;
        padding-bottom: 0.8mm;
        font-size: 14px !important;
        line-height: 1.45 !important;
    }
    .consent-output-page-context {
        margin-top: 0;
        color: #1e3a5f;
        font: 800 7.5px/1.25 Inter, sans-serif;
        letter-spacing: 0.05em;
        text-align: center;
        text-transform: uppercase;
    }
    .consent-output-patient-summary {
        display: flex;
        flex-wrap: wrap;
        gap: 1.2mm 5mm;
        box-sizing: border-box;
        padding: 1.8mm 2.5mm;
        border: 1px solid #bfdbfe;
        border-radius: 1.2mm;
        color: #334155;
        background: #eff6ff;
        font: 7.5px/1.3 Inter, sans-serif;
    }
    .consent-output-treatment {
        display: flex;
        flex-direction: column;
        gap: 2mm;
        color: #1e293b;
        font-size: 9.3px;
        line-height: 1.35;
    }
    .consent-output-treatment > .consent-treatment-block,
    .consent-output-treatment .consent-treatment-block {
        margin: 0 !important;
        padding: 2.8mm !important;
        border-color: #94a3b8;
        border-left-color: #2563eb;
        border-radius: 1.5mm;
    }
    .consent-output-treatment > #pContent,
    .consent-output-treatment > div {
        margin: 0 !important;
    }
    .consent-output-treatment p {
        margin-top: 0 !important;
        margin-bottom: 1.15mm !important;
    }
    .consent-output-treatment p:last-child {
        margin-bottom: 0 !important;
    }
    .consent-output-treatment .consent-treatment-heading {
        margin-bottom: 1.7mm;
        padding-bottom: 1.2mm;
        font-size: 8px;
    }
    .consent-output-treatment .consent-treatment-grid,
    .consent-output-treatment .consent-single-grid {
        gap: 3mm;
    }
    .consent-output-treatment .translated-version {
        padding: 1.6mm;
    }
    .consent-output-legal {
        margin-top: auto;
        padding-top: 1.8mm;
        border-top: 0.3mm dashed #94a3b8;
    }
    .consent-output-legal > div {
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
    }
    .consent-output-legal .consent-legal-grid {
        gap: 3mm !important;
    }
    .consent-output-legal p {
        margin: 0 0 0.7mm !important;
        font-size: 6.7px !important;
        line-height: 1.2 !important;
    }
    .consent-output-legal ul {
        margin: 0 !important;
        padding-left: 3mm !important;
        font-size: 5.9px !important;
        line-height: 1.25 !important;
    }
    .consent-output-legal li {
        margin-bottom: 0.45mm;
    }
    .consent-output-auth {
        padding-top: 1.5mm;
        border-top: 0.25mm solid #cbd5e1;
    }
    .consent-output-auth-grid {
        display: grid;
        grid-template-columns: 1.05fr 0.9fr 1fr;
        gap: 2mm;
        align-items: stretch;
    }
    .consent-output-auth-cell {
        box-sizing: border-box;
        min-width: 0;
        min-height: 23mm;
        padding: 1.5mm;
        border: 0.25mm solid #94a3b8;
        border-radius: 1.2mm;
        background: #fff;
        text-align: center;
    }
    .consent-output-auth-label {
        margin-bottom: 1mm;
        color: #334155;
        font: 800 6.2px/1.2 Inter, sans-serif;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }
    .consent-output-signature-image {
        display: block;
        width: auto;
        max-width: 100%;
        height: 12mm;
        margin: 0 auto 0.8mm;
        object-fit: contain;
    }
    .consent-output-unsigned {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 12mm;
        margin-bottom: 0.8mm;
        border-bottom: 0.25mm solid #64748b;
        color: #991b1b;
        font: 800 6.4px/1.2 Inter, sans-serif;
    }
    .consent-output-auth-detail {
        color: #64748b;
        font: 5.5px/1.2 'Courier New', monospace;
    }
    .consent-output-seal .digital-seal {
        box-sizing: border-box;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 1mm !important;
        box-shadow: none !important;
    }
    .consent-output-seal .seal-header {
        font-size: 5.6px !important;
    }
    .consent-output-seal .seal-body,
    .consent-output-seal .seal-footer {
        font-size: 5.1px !important;
        line-height: 1.18 !important;
    }
    .consent-output-seal-fallback {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 15mm;
        border: 0.25mm dashed #64748b;
        color: #475569;
        font: 5.5px/1.35 'Courier New', monospace;
    }
    .consent-output-doctor-mark {
        display: flex;
        align-items: flex-end;
        justify-content: center;
        height: 11mm;
        color: #0f172a;
        font-size: 18px;
        line-height: 1;
    }
    .consent-output-sign-line {
        width: 90%;
        margin: 0 auto 1mm;
        border-top: 0.25mm solid #334155;
    }
    .consent-output-page-acknowledgement {
        margin: 1mm 0 0;
        color: #475569;
        font: 5.5px/1.25 Inter, sans-serif;
        text-align: center;
    }
    .consent-output-page-footer {
        display: grid;
        grid-template-columns: 0.85fr 1.35fr 1fr 1.2fr auto;
        gap: 2mm;
        align-items: center;
        margin-top: 0.5mm;
        padding-top: 1mm;
        border-top: 0.25mm solid #64748b;
        color: #475569;
        font: 5.8px/1.2 'Courier New', monospace;
    }
    .consent-output-brand {
        color: #b45309;
        font-weight: 900;
        letter-spacing: 0.03em;
    }
    .consent-output-page-footer span:last-child {
        font-weight: 800;
        text-align: right;
    }
    .consent-output-page.is-compact .consent-output-page-inner {
        gap: 1.25mm;
    }
    .consent-output-page.is-compact .consent-output-treatment {
        font-size: 8.2px;
        line-height: 1.28;
    }
    .consent-output-page.is-compact .consent-output-legal ul {
        font-size: 5.4px !important;
    }
    .consent-output-page.is-compact .consent-output-auth-cell {
        min-height: 20mm;
    }
    .consent-output-page.is-ultra-compact .consent-output-treatment {
        font-size: 7.4px;
        line-height: 1.22;
    }
    .consent-output-page.is-ultra-compact .consent-output-legal ul {
        font-size: 5px !important;
        line-height: 1.16 !important;
    }
    .consent-output-page.is-ultra-compact .consent-output-auth-cell {
        min-height: 18mm;
    }

    /* Legacy preview-only print rules are intentionally disabled. */
    @media print and (max-width: 0px) {
        @page { margin: 14mm 15mm 18mm; size: A4 portrait; }
        html,
        body {
            width: auto !important;
            min-height: 0 !important;
            height: auto !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
            background: #fff !important;
            -webkit-print-color-adjust: exact;
            print-color-adjust: exact;
        }
        body {
            display: block !important;
        }
        
        body > * {
            display: none !important;
        }
        body > #consentWorkspace {
            position: static !important;
            inset: auto !important;
            display: block !important;
            width: auto !important;
            height: auto !important;
            min-height: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
        }
        #consentWorkspace > * {
            display: none !important;
        }
        #consentWorkspace > #previewPanel,
        #consentWorkspace #previewPanel.hidden {
            position: static !important;
            inset: auto !important;
            display: block !important;
            width: auto !important;
            height: auto !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
        }
        #previewPanel > * {
            display: none !important;
        }

        #previewPanel > #printArea {
            box-sizing: border-box !important;
            position: relative !important;
            inset: auto !important;
            display: block !important;
            width: auto !important;
            max-width: none !important;
            height: auto !important;
            min-height: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
            box-shadow: none !important;
            transform: none !important;
            visibility: visible !important;
            background: #fff !important;
            border-radius: 0 !important;
        }
        #printArea,
        #printArea * {
            visibility: visible !important;
        }
        #printArea .no-print {
            display: none !important;
        }
        #printArea::before {
            content: '';
            position: fixed;
            z-index: 9998;
            top: 5mm;
            right: 5mm;
            bottom: 5mm;
            left: 5mm;
            border: 0.3mm solid #64748b;
            pointer-events: none;
        }
        #printArea::after {
            content: 'Consent ID: ' attr(data-consent-id) ' | Medico-Legal Document';
            position: fixed;
            z-index: 9999;
            right: 10mm;
            bottom: 7mm;
            left: 10mm;
            color: #475569;
            font: 7.5pt/1.2 'Courier New', monospace;
            letter-spacing: 0.1pt;
            pointer-events: none;
        }
        .consent-treatment-block,
        .consent-keep-together {
            break-inside: avoid-page !important;
            page-break-inside: avoid !important;
        }
    }

    /* Native print uses the same explicit A4 pages as Download PDF. */
    @media print {
        @page { size: A4 portrait; margin: 0; }
        html,
        body {
            width: 210mm !important;
            min-width: 210mm !important;
            max-width: 210mm !important;
            min-height: 0 !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
            background: #fff !important;
        }
        body.consent-native-print-active > * {
            display: none !important;
        }
        body.consent-native-print-active > #consentWorkspace,
        body.consent-native-print-active > .consent-output-document.is-pdf-rendering {
            display: none !important;
        }
        body.consent-native-print-active > .consent-output-document.is-native-printing {
            position: static !important;
            z-index: auto !important;
            top: auto !important;
            left: auto !important;
            display: block !important;
            width: 210mm !important;
            margin: 0 !important;
            padding: 0 !important;
            overflow: visible !important;
            visibility: visible !important;
            background: #fff !important;
        }
        body.consent-native-print-active > .consent-output-document.is-native-printing,
        body.consent-native-print-active > .consent-output-document.is-native-printing * {
            visibility: visible !important;
            -webkit-print-color-adjust: exact !important;
            print-color-adjust: exact !important;
        }
        body.consent-native-print-active > .consent-output-document.is-native-printing .consent-output-page {
            display: block !important;
            width: 210mm !important;
            height: 297mm !important;
            min-height: 297mm !important;
            max-height: 297mm !important;
            margin: 0 !important;
            overflow: hidden !important;
            break-after: page !important;
            page-break-after: always !important;
        }
        body.consent-native-print-active > .consent-output-document.is-native-printing .consent-output-page:last-child {
            break-after: auto !important;
            page-break-after: auto !important;
        }
    }
    
    /* 1. Desktop split workspace (1200px to 1280px) */
    @media (max-width: 1280px) and (min-width: 1200px) {
        .a4-paper { 
            transform: scale(0.75); 
            margin-bottom: -25%; 
        }
    }

    /* Full-width preview for large tablets. */
    @media (max-width: 1199.98px) and (min-width: 1025px) {
        #previewPanel { padding: 1rem; }
        .a4-paper {
            transform: scale(1);
            transform-origin: top center;
            margin-bottom: 0;
        }
    }
    
    /* 2. Tablets (iPad Portrait & Landscape - 768px to 1024px) */
    @media (max-width: 1024px) and (min-width: 768px) {
        #previewPanel { padding: 1rem; }
        .a4-paper { 
            transform: scale(0.82);
            transform-origin: top center;
            margin-bottom: -18%;
        }
    }
    
    /* 3. Mobile Phones (Under 768px) */
    @media (max-width: 767px) {
        #previewPanel {
            display: block !important; 
            overflow-x: hidden;
            width: 100%;
            padding: 0;
        }
        #consentWorkspace #previewPanel.hidden { display: none !important; }
        .a4-paper { 
            transform: scale(0.42); /* Slightly smaller to fit all phone screens */
            transform-origin: top center;
            position: relative;
            left: 50%;
            margin-left: -105mm; /* Exactly half of 210mm to center it */
            margin-top: 15px; 
            margin-bottom: -135%; 
            box-shadow: 0 10px 20px rgba(0,0,0,0.15);
        }
    }
    /* Tooth Button Reset */
    .tooth-btn:focus { outline: none; }
    .tooth-btn:active { transform: scale(0.95); }
    .tooth-btn.selected { background: #1E3A5F; color: #F5A623; }
    /* === NEW DIGITAL LEGAL SEAL === */
.digital-seal {
    font-family: 'Courier New', Courier, monospace; /* Technical Font */
    color: #1e3a8a; /* Medical/Legal Blue (Slate-900 or Blue-900) */
    border: 1px solid #1e3a8a;
    padding: 4px;
    background: rgba(255, 255, 255, 0.85); /* Slight transparency */
    width: 190px;
    max-width: 100%;
    text-align: left;
    position: relative;
    z-index: 0; /* Sits behind the signature line */
    /* Subtle Guilloche pattern simulation */
    background-image: repeating-linear-gradient(135deg, transparent, transparent 2px, rgba(30, 58, 138, 0.05) 2px, rgba(30, 58, 138, 0.05) 4px);
    box-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

.seal-header {
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
    border-bottom: 1px solid #1e3a8a;
    padding-bottom: 2px;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
}

.seal-body {
    font-size: 7px;
    line-height: 1.2;
    font-weight: 600;
    color: #334155;
}

.seal-location-address {
    margin-top: 2px;
    line-height: 1.18;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.seal-attribution {
    margin-top: 1px;
    font-size: 5.5px;
    font-weight: 500;
    color: #64748b;
}

.seal-footer {
    font-size: 6px;
    margin-top: 2px;
    padding-top: 2px;
    border-top: 1px dotted #94a3b8;
    color: #64748b;
    text-align: right;
}
    /* Fix for Login Overlay */
    .fixed.inset-0 {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
    }
    /* Slim Scrollbar for Vision Panel */
.vision-scrollbar {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}
.vision-scrollbar::-webkit-scrollbar {
    width: 4px;
}
.vision-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.vision-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1; /* Slate-300 */
    border-radius: 10px;
}
.vision-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; /* Slate-400 */
}

#desktopNotice {
    animation: slideInBottom 0.8s ease-out forwards;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
}

@keyframes slideInBottom {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Hide scrollbar during loading */
body.loading-active {
    overflow: hidden !important;
}
</style>
<style>
    /* === 🌟 APP-STYLE TOUR WALKTHROUGH === */
    .tour-overlay {
        position: fixed; inset: 0; z-index: 99998;
        background: rgba(10, 22, 40, 0.75);
        pointer-events: all;
    }
    .tour-card {
        position: fixed; z-index: 100000;
        background: linear-gradient(145deg, #1a2744, #0d1b33);
        border: 1px solid rgba(30, 58, 95, 0.6);
        border-radius: 20px;
        box-shadow: 0 25px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(245, 166, 35, 0.1) inset;
        width: min(92vw, 380px);
        max-height: 80vh;
        overflow: hidden;
        transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
        font-family: 'Inter', system-ui, sans-serif;
    }
    .tour-card-header {
        padding: 18px 20px 12px;
        border-bottom: 1px solid rgba(30, 58, 95, 0.4);
        position: relative;
    }
    .tour-step-badge {
        display: inline-flex; align-items: center; gap: 6px;
        background: rgba(245, 166, 35, 0.15);
        border: 1px solid rgba(245, 166, 35, 0.3);
        color: #F5A623;
        padding: 3px 10px;
        border-radius: 20px;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.5px;
    }
    .tour-progress-bar {
        height: 3px;
        background: rgba(30, 58, 95, 0.4);
        border-radius: 2px;
        margin-top: 10px;
        overflow: hidden;
    }
    .tour-progress-fill {
        height: 100%;
        background: linear-gradient(90deg, #F5A623, #f7b83d);
        border-radius: 2px;
        transition: width 0.4s ease;
    }
    .tour-card-body {
        padding: 16px 20px;
        overflow-y: auto;
        max-height: 45vh;
    }
    .tour-card-body::-webkit-scrollbar { width: 3px; }
    .tour-card-body::-webkit-scrollbar-track { background: transparent; }
    .tour-card-body::-webkit-scrollbar-thumb { background: rgba(245,166,35,0.3); border-radius: 2px; }
    .tour-title {
        font-size: 16px;
        font-weight: 800;
        color: #fff;
        margin-bottom: 8px;
        line-height: 1.3;
    }
    .tour-en {
        display: block;
        font-size: 13px;
        color: #cbd5e1;
        line-height: 1.6;
        margin-bottom: 8px;
    }
    .tour-hi {
        display: block;
        font-size: 12px;
        color: #94a3b8;
        background: rgba(30, 58, 95, 0.3);
        padding: 10px 12px;
        border-radius: 10px;
        border-left: 3px solid #F5A623;
        font-family: 'Noto Sans Devanagari', sans-serif;
        line-height: 1.5;
    }
    .tour-card-footer {
        padding: 12px 20px 16px;
        border-top: 1px solid rgba(30, 58, 95, 0.4);
        display: flex;
        gap: 10px;
        justify-content: space-between;
    }
    .tour-btn {
        border: none;
        border-radius: 12px;
        padding: 10px 18px;
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.15s;
        display: flex; align-items: center; gap: 6px;
        justify-content: center;
    }
    .tour-btn:active { transform: scale(0.96); }
    .tour-btn-prev {
        background: rgba(30, 58, 95, 0.4);
        color: #94a3b8;
        flex: 0.4;
    }
    .tour-btn-prev:hover { background: rgba(30, 58, 95, 0.6); }
    .tour-btn-next {
        background: linear-gradient(135deg, #1E3A5F, #2a4a7a);
        color: #fff;
        flex: 1;
        box-shadow: 0 4px 12px rgba(30, 58, 95, 0.4);
    }
    .tour-btn-next:hover { background: linear-gradient(135deg, #2a4a7a, #3a5a8a); }
    .tour-btn-done {
        background: linear-gradient(135deg, #F5A623, #d48f1c);
        color: #0A1628;
        flex: 1;
        box-shadow: 0 4px 12px rgba(245, 166, 35, 0.3);
    }
    .tour-highlight {
        position: relative;
        z-index: 100001 !important;
        box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.5), 0 0 30px rgba(245, 166, 35, 0.2);
        border-radius: 4px;
        transition: box-shadow 0.3s;
    }
    .tour-arrow {
        position: fixed; z-index: 100001;
        width: 0; height: 0;
        border-left: 12px solid transparent;
        border-right: 12px solid transparent;
        border-bottom: 14px solid #1a2744;
        filter: drop-shadow(0 -2px 4px rgba(0,0,0,0.2));
    }
    @keyframes tourPulse {
        0%, 100% { box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.5), 0 0 30px rgba(245, 166, 35, 0.2); }
        50% { box-shadow: 0 0 0 6px rgba(245, 166, 35, 0.7), 0 0 40px rgba(245, 166, 35, 0.3); }
    }
    .tour-highlight-pulse { animation: tourPulse 1.5s ease-in-out infinite; }
    @media (max-width: 767px) {
        .tour-card {
            width: 92vw;
            left: 4vw !important;
            right: 4vw !important;
            top: auto !important;
            bottom: 16px !important;
            transform: none !important;
            border-radius: 16px;
            max-height: 60vh;
        }
        .tour-arrow { display: none; }
        .tour-card-body { max-height: 35vh; }
    }
    @media (min-width: 768px) and (max-width: 1023px) {
        .tour-card { width: min(80vw, 420px); }
    }
    .tour-close-btn {
        position: absolute; top: 12px; right: 14px;
        background: rgba(255,255,255,0.08);
        border: none; border-radius: 50%;
        width: 28px; height: 28px;
        color: #94a3b8; font-size: 16px;
        display: flex; align-items: center; justify-content: center;
        cursor: pointer; transition: all 0.2s;
    }
    .tour-close-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
