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.silos-keyboard-open,
body.silos-keyboard-open,
html.silos-keyboard-open #out {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

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

#out {
    transform: translateY(var(--silos-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.silos-keyboard-open,
    body.silos-keyboard-open,
    html.silos-keyboard-open #out {
        overflow-y: visible !important;
    }

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

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

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

#silos-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);
}

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

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

    #silos-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);
    }
}
#silos-simple-keyboard .simple-keyboard { max-width: 720px; margin: 0 auto; background: transparent; }
#silos-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) {
    #silos-simple-keyboard {
        background: #1f2028;
        padding: 10px 8px 14px;
    }

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

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

    #silos-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;
    }

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

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

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

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

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

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

.silos-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;
}

.silos-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);
}

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

#silos-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) {
    #silos-simple-keyboard {
        padding: 5px 5px 7px;
    }

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

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

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

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

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

#silos-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;
}

#silos-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(84vw, 320px); height: 160px; }
.inventory-track { position: absolute; top: 94px; left: 10%; width: 80%; height: 4px; border-radius: 99px; background: #cbd8f1; }
.inventory-track::before, .inventory-track::after { content: ''; position: absolute; top: -5px; width: 14px; height: 14px; border: 3px solid #2457d6; border-radius: 50%; background: #fff; }
.inventory-track::before { left: -2px; } .inventory-track::after { right: -2px; }
.inventory-scan { position: absolute; top: 27px; left: 31%; width: 3px; height: 98px; border-radius: 99px; background: #3d7cff; box-shadow: 0 0 18px #3d7cff99; animation: inventory-scan 2.2s ease-in-out infinite; }
.inventory-package { position: absolute; top: 51px; display: grid; place-items: center; width: 52px; height: 42px; border: 2px solid #2457d6; border-radius: 8px; color: #2457d6; background: #eef3ff; box-shadow: 0 8px 18px #28447722; font-size: .58rem; font-weight: 850; letter-spacing: .08em; animation: package-flow 3.6s linear infinite; }
.inventory-package::before { content: ''; position: absolute; top: -8px; left: 9px; width: 30px; height: 8px; border: 2px solid #2457d6; border-bottom: 0; border-radius: 6px 6px 0 0; }
.package-one { animation-delay: 0s; } .package-two { animation-delay: -1.2s; } .package-three { animation-delay: -2.4s; }
.inventory-node { position: absolute; top: 87px; width: 18px; height: 18px; border: 3px solid #cbd8f1; border-radius: 50%; background: #fff; animation: node-check 2.2s ease-in-out infinite; }
.inventory-node span { display: block; width: 6px; height: 6px; margin: 3px; border-radius: 50%; background: #2457d6; }
.node-receive { left: 8%; animation-delay: 0s; } .node-check { left: 47%; animation-delay: .25s; } .node-store { right: 8%; animation-delay: .5s; }
.inventory-label { position: absolute; top: 119px; color: #60708f; font-size: .55rem; font-weight: 800; letter-spacing: .12em; }
.label-receive { left: 3%; } .label-check { left: 43%; } .label-store { right: 2%; }
.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; }

@keyframes inventory-scan { 0%, 100% { transform: translateX(0); opacity: .35; } 50% { transform: translateX(122px); opacity: 1; } }
@keyframes package-flow { 0% { left: 7%; opacity: 0; transform: translateY(0) rotate(-4deg); } 12% { opacity: 1; } 48% { transform: translateY(-10px) rotate(3deg); } 84% { opacity: 1; } 100% { left: 77%; opacity: 0; transform: translateY(0) rotate(-3deg); } }
@keyframes node-check { 0%, 100% { border-color: #cbd8f1; transform: scale(1); } 45%, 65% { border-color: #2457d6; box-shadow: 0 0 0 7px #2457d61c; transform: scale(1.12); } }
@keyframes progress-sweep { 0% { margin-left: -42%; } 50%, 100% { margin-left: 110%; } }

@media (prefers-color-scheme: dark) {
    #silos-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) {
    #silos-splash { gap: 18px; }
    .splash-visual { transform: scale(.88); }
    .splash-copy h1 { font-size: 1rem; }
}

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

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

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

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

@media (max-width: 480px) {
    .silos-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; }
}
