html,
body,
#out {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    box-sizing: border-box;
}

/* Avalonia creates a full-viewport native host for browser text input. */
.avalonia-native-host {
    pointer-events: none !important;
    z-index: 1000 !important;
}

.avalonia-input-element {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

html.dts-keyboard-open,
body.dts-keyboard-open,
html.dts-keyboard-open #out {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

html.dts-keyboard-open #out {
    padding-bottom: 290px;
}

#out {
    transform: translateY(var(--dts-pan-y, 0px));
    transition: transform 220ms ease;
}

@media (max-width: 720px) {
    html,
    body {
        position: static;
        min-height: 100%;
        height: auto;
        overflow-y: auto;
        overflow-x: hidden;
    }

    #out {
        position: relative;
        inset: auto;
        width: 100%;
        min-height: 100vh;
        height: auto;
        overflow: visible;
        transform: none;
        transition: none;
    }

    html.dts-keyboard-open,
    body.dts-keyboard-open,
    html.dts-keyboard-open #out {
        overflow-y: visible !important;
    }

    html.dts-keyboard-open #out {
        padding-bottom: 0;
    }

    html.dts-keyboard-open #out {
        transform: translateY(var(--dts-pan-y, 0px));
    }

    #dts-simple-keyboard {
        position: static;
        width: 100%;
        box-sizing: border-box;
        z-index: auto;
        box-shadow: none;
    }
}

#dts-simple-keyboard {
    position: fixed;
    z-index: 3000;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    padding: 8px 6px max(8px, env(safe-area-inset-bottom));
    background: #dfe3ea;
    box-shadow: 0 -8px 24px rgba(20, 33, 61, .18);
}

#dts-simple-keyboard.is-open { display: block; }

@media (max-width: 720px) {
    #dts-simple-keyboard {
        position: static;
        width: 100%;
        box-sizing: border-box;
        z-index: auto;
        box-shadow: none;
    }

    #dts-simple-keyboard.is-open {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        z-index: 3000;
        box-shadow: 0 -8px 24px rgba(20, 33, 61, .18);
    }
}
#dts-simple-keyboard .simple-keyboard { max-width: 720px; margin: 0 auto; background: transparent; }
#dts-simple-keyboard .hg-button {
    min-height: clamp(42px, 9vw, 58px);
    border-radius: 6px;
    font-size: clamp(16px, 4vw, 22px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, .18);
}
@media (max-width: 720px) {
    #dts-simple-keyboard {
        background: #1f2028;
        padding: 10px 8px 14px;
    }

    #dts-simple-keyboard .simple-keyboard {
        max-width: 100%;
    }

    #dts-simple-keyboard .hg-row {
        gap: 5px;
        margin-bottom: 6px;
    }

    #dts-simple-keyboard .hg-button {
        min-height: 54px;
        border: 0;
        border-radius: 9px;
        color: #f4f3f8;
        background: #383842;
        box-shadow: 0 2px 0 #292a32;
        font-size: 28px;
        font-weight: 400;
    }

    #dts-simple-keyboard .hg-button[data-skbtn="{shift}"],
    #dts-simple-keyboard .hg-button[data-skbtn="{bksp}"],
    #dts-simple-keyboard .hg-button[data-skbtn="{enter}"],
    #dts-simple-keyboard .hg-button[data-skbtn="{numbers}"],
    #dts-simple-keyboard .hg-button[data-skbtn="{abc}"] {
        background: #4b4c68;
    }

    #dts-simple-keyboard .hg-button[data-skbtn="{space}"] {
        flex: 1 1 auto;
        min-width: 120px;
    }

    #dts-simple-keyboard .hg-button[data-skbtn="{emoji}"] {
        font-size: 31px;
    }

    #dts-simple-keyboard .hg-button[data-skbtn="{symbols}"],
    #dts-simple-keyboard .hg-button[data-skbtn="{symbols2}"] {
        white-space: pre-line;
        line-height: 1.05;
        font-size: 15px;
    }

    #dts-simple-keyboard .hg-button.hg-activeButton,
    #dts-simple-keyboard .hg-button:active {
        background: #60618a;
        transform: translateY(2px);
    }
}

@media (max-width: 720px) {
    #dts-simple-keyboard.emoji-open .simple-keyboard,
    #dts-simple-keyboard.emoji-open #dts-keyboard-toggle { display: none; }
    #dts-emoji-panel { display: block; height: 360px; overflow: hidden; color: #eeeef5; background: #1f2028; }
    .dts-emoji-toolbar { display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 14px; color: #d9d8e8; background: #191a21; font-size: 22px; }
    .dts-emoji-toolbar button, .dts-emoji-search { border: 0; border-radius: 28px; color: #eeeef5; background: #2a2b35; font-size: 24px; }
    .dts-emoji-toolbar button { width: 48px; height: 44px; }
    .dts-emoji-search { flex: 1; padding: 10px 16px; text-align: left; font-size: 18px; }
    .dts-emoji-toolbar b { color: #b8aaff; }
    .dts-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; height: 296px; overflow-y: auto; padding: 12px 8px; }
    .dts-emoji-grid button { min-width: 0; height: 58px; border: 0; color: #fff; background: transparent; font-size: 35px; }
}

.dts-key-preview {
    position: fixed;
    z-index: 4000;
    width: 56px;
    height: 64px;
    display: grid;
    place-items: center;
    color: #17233d;
    background: #fff;
    border: 1px solid #c1cbe0;
    border-radius: 12px 12px 8px 8px;
    box-shadow: 0 8px 18px rgba(20, 33, 61, .25);
    font-size: 28px;
    font-weight: 600;
    pointer-events: none;
}

.dts-key-alternates {
    position: fixed;
    z-index: 4001;
    display: flex;
    gap: 3px;
    padding: 5px;
    border: 1px solid #c1cbe0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(20, 33, 61, .25);
}

.dts-key-alternates button {
    min-width: 38px;
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: #f1f4fa;
    color: #17233d;
    font-size: 20px;
}

#dts-keyboard-toggle {
    display: block;
    width: 56px;
    height: 22px;
    margin: -4px auto 3px;
    border: 0;
    border-radius: 12px;
    color: #53627b;
    background: #c8ced9;
    font-size: 15px;
    line-height: 18px;
}

@media (max-width: 720px) and (max-height: 720px) {
    #dts-simple-keyboard {
        padding: 5px 5px 7px;
    }

    #dts-simple-keyboard .hg-row {
        gap: 3px;
        margin-bottom: 3px;
    }

    #dts-simple-keyboard .hg-button {
        min-height: 38px;
        border-radius: 6px;
        font-size: 20px;
    }

    #dts-simple-keyboard .hg-button[data-skbtn="{space}"] {
        min-width: 80px;
    }

    html.dts-keyboard-open #out {
        transform: translateY(var(--dts-pan-y, 0px));
    }
}

@media (max-width: 339px) and (max-height: 600px) {
    html.dts-keyboard-open #out {
        transform: translateY(var(--dts-pan-y, 0px));
    }
}

#dts-splash {
    position: fixed;
    z-index: 10;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    overflow: hidden;
    color: #14213d;
    background: radial-gradient(circle at 50% 32%, #ffffff 0%, #f5f8ff 46%, #e8eefb 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
    opacity: 1;
    transition: opacity 420ms ease, visibility 420ms ease;
}

#dts-splash.is-hidden {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
}

.splash-brand { display: flex; align-items: center; gap: 10px; letter-spacing: .16em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: #fff; background: #2457d6; box-shadow: 0 9px 24px #2457d633; font-size: 1.25rem; font-weight: 800; }
.brand-name { color: #17346f; font-size: 1.15rem; font-weight: 800; }
.splash-visual { position: relative; width: min(76vw, 270px); height: 150px; }
.splash-variant { position: absolute; inset: 0; }
.splash-pages, .splash-stack, .splash-workflow, .splash-filing, .splash-stamps { display: none; }
html[data-splash-variant="pages"] .splash-pages,
html[data-splash-variant="stack"] .splash-stack,
html[data-splash-variant="workflow"] .splash-workflow,
html[data-splash-variant="filing"] .splash-filing,
html[data-splash-variant="stamps"] .splash-stamps { display: block !important; }
.splash-copy { text-align: center; }
.splash-copy h1 { margin: 0; color: #14213d; font-size: clamp(1.05rem, 3vw, 1.4rem); font-weight: 750; }
.splash-copy p { margin: 8px 0 0; color: #60708f; font-size: .92rem; }
.splash-progress { width: min(54vw, 160px); height: 4px; overflow: hidden; border-radius: 999px; background: #d6e0f4; }
.splash-progress span { display: block; width: 42%; height: 100%; border-radius: inherit; background: #2457d6; animation: progress-sweep 1.7s ease-in-out infinite; }

.page, .stack-sheet { position: absolute; left: 50%; width: 100px; height: 126px; border: 1px solid #c8d4ed; border-radius: 7px; background: #fff; box-shadow: 0 12px 24px #28447722; transform-origin: 50% 100%; }
.page::after, .stack-sheet::after { content: ''; position: absolute; top: 24px; left: 18px; width: 62px; height: 4px; border-radius: 4px; background: #d8e2f5; box-shadow: 0 14px #e4ebf8, 0 28px #e4ebf8; }
.page-back { transform: translateX(-50%) rotate(-11deg) translateY(12px); }
.page-middle { transform: translateX(-50%) rotate(7deg) translateY(6px); }
.page-front { display: grid; place-items: center; color: #2457d6; font-size: 1.1rem; font-weight: 800; animation: page-flip 2.8s ease-in-out infinite; }
.page-front span { position: relative; z-index: 1; margin-top: -56px; }
.stack-sheet { height: 105px; top: 18px; }
.stack-back { transform: translateX(-50%) rotate(-8deg) translateY(12px); }
.stack-middle { transform: translateX(-50%) rotate(6deg) translateY(6px); }
.stack-front { display: grid; place-items: center; color: #2457d6; font-size: .65rem; font-weight: 800; letter-spacing: .12em; animation: stack-lift 2.4s ease-in-out infinite; }
.stack-front span { margin-top: 58px; }

.workflow-line { position: absolute; top: 54px; left: 10%; width: 80%; height: 3px; background: #c9d7f1; }
.workflow-line span { display: block; width: 30%; height: 100%; background: #2457d6; animation: workflow-progress 2.4s ease-in-out infinite; }
.workflow-nodes { position: absolute; inset: 39px 0 auto; display: flex; justify-content: space-between; }
.workflow-nodes i { display: grid; place-items: center; width: 31px; height: 31px; border: 3px solid #c9d7f1; border-radius: 50%; color: #647594; background: #f5f8ff; font-size: 0; font-style: normal; }
.workflow-nodes i::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #2457d6; }
.workflow-nodes i:nth-child(2) { animation: node-pulse 2.4s .3s infinite; }

.folder { position: absolute; top: 38px; left: 50%; width: 150px; height: 86px; border-radius: 7px; background: #f4c96b; box-shadow: 0 14px 24px #84631e2b; transform: translateX(-50%); }
.folder-tab { position: absolute; top: -12px; left: 13px; width: 54px; height: 20px; border-radius: 6px 6px 0 0; background: #f4c96b; }
.folder-label { position: absolute; inset: 33px 0 auto; color: #765719; text-align: center; font-size: .65rem; font-weight: 800; letter-spacing: .14em; }
.filing-page { position: absolute; top: 20px; left: 50%; display: grid; place-items: center; width: 86px; height: 105px; border: 1px solid #c8d4ed; border-radius: 5px; color: #2457d6; background: #fff; box-shadow: 0 8px 16px #28447722; font-size: .8rem; font-weight: 800; transform: translateX(-50%) rotate(-4deg); animation: filing-slide 2.4s ease-in-out infinite; }

.stamp-page { position: absolute; top: 15px; left: 50%; width: 100px; height: 126px; border: 1px solid #c8d4ed; border-radius: 7px; background: #fff; transform: translateX(-50%) rotate(-5deg); }
.stamp { position: absolute; padding: 7px 10px; border: 2px solid; border-radius: 4px; font-size: .6rem; font-weight: 900; letter-spacing: .08em; transform: rotate(-13deg); }
.stamp-received { top: 47px; left: calc(50% - 72px); color: #2f8f68; border-color: #2f8f68; animation: stamp-in 2.5s ease-in-out infinite; }
.stamp-review { top: 82px; left: calc(50% - 23px); color: #2457d6; border-color: #2457d6; animation: stamp-in 2.5s .7s ease-in-out infinite; }

@keyframes page-flip { 0%, 65%, 100% { transform: translateX(-50%) rotate(0); } 18% { transform: translateX(-50%) rotateY(70deg) rotate(5deg); } 38% { transform: translateX(-50%) rotateY(0) rotate(-4deg); } }
@keyframes stack-lift { 0%, 100% { transform: translateX(-50%) translateY(0) rotate(0); } 45% { transform: translateX(-50%) translateY(-14px) rotate(2deg); } }
@keyframes workflow-progress { 0% { transform: translateX(0); } 70%, 100% { transform: translateX(235%); } }
@keyframes node-pulse { 0%, 100% { border-color: #c9d7f1; } 35%, 65% { border-color: #2457d6; box-shadow: 0 0 0 7px #2457d61c; } }
@keyframes filing-slide { 0%, 100% { transform: translateX(-50%) translateY(0) rotate(-4deg); } 45% { transform: translateX(-50%) translateY(18px) rotate(0); } }
@keyframes stamp-in { 0%, 100% { opacity: .35; transform: rotate(-13deg) scale(.92); } 35%, 65% { opacity: 1; transform: rotate(-13deg) scale(1); } }
@keyframes progress-sweep { 0% { margin-left: -42%; } 50%, 100% { margin-left: 110%; } }

@media (prefers-color-scheme: dark) {
    #dts-splash { color: #edf3ff; background: radial-gradient(circle at 50% 30%, #243967 0%, #101a31 72%); }
    .brand-name, .splash-copy h1 { color: #edf3ff; }
    .splash-copy p { color: #aebddd; }
    .splash-progress { background: #354b78; }
    .page, .stack-sheet, .stamp-page, .filing-page { border-color: #506797; background: #f7faff; }
    .workflow-nodes i { background: #182747; }
}

@media (max-width: 480px) {
    #dts-splash { gap: 18px; }
    .splash-visual { transform: scale(.88); }
    .splash-copy h1 { font-size: 1rem; }
}

@media (max-width: 480px) and (max-height: 800px) {
    .dts-native-login {
        top: 53%;
        width: min(340px, calc(100vw - 32px));
        gap: 10px;
    }

    .dts-native-login label {
        gap: 4px;
        font-size: 10px;
    }

    .dts-native-login input {
        min-height: 42px;
        padding: 8px 11px;
    }

    .dts-native-login button {
        min-height: 42px;
    }
}

@media (max-width: 480px) {
    .dts-native-login {
        width: min(340px, calc(100vw - 32px));
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
