/* Shared touch keyboard. It is mounted only while a writable field is active. */
.sb-keyboard[hidden], .sb-keyboard [hidden] { display:none !important; }
.sb-keyboard {
    position:fixed; z-index:2147483000; left:50%; bottom:var(--sb-visible-bottom, 0px);
    transform:translateX(-50%); width:min(100%, 1040px); max-height:48dvh; overflow:auto;
    padding:10px 12px max(12px, env(safe-area-inset-bottom)); border:1px solid var(--border-subtle, #cbd5e1);
    border-radius:18px 18px 0 0; background:var(--bg-surface, var(--mob-bg-surface, #f8fafc));
    color:var(--text-primary, var(--mob-text-primary, #0f172a)); box-shadow:0 -10px 35px #0003;
    font-family:inherit; user-select:none; -webkit-user-select:none; touch-action:manipulation;
    box-sizing:border-box;
}
.sb-keyboard[data-placement="top"] { top:var(--sb-visible-top, 0px); bottom:auto; border-radius:0 0 18px 18px; box-shadow:0 10px 35px #0003; }
.sb-keyboard:not([data-mode="text"]) { width:min(100%, 460px); }
.sb-keyboard-header { display:flex; align-items:center; gap:12px; margin-bottom:8px; }
.sb-keyboard-title { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:13px; }
.sb-keyboard-number { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; text-align:right; font:700 22px/1.2 ui-monospace, monospace; }
.sb-keyboard-rows { display:flex; flex-direction:column; gap:6px; }
.sb-key-row { display:flex; justify-content:center; gap:6px; }
.sb-key {
    display:inline-flex; align-items:center; justify-content:center; flex:1 1 0;
    min-width:0; min-height:44px; padding:8px 4px; margin:0; border:1px solid var(--border-subtle, #cbd5e1);
    border-radius:9px; background:var(--bg-field, var(--mob-bg-field, #fff)); color:inherit;
    font-family:inherit; font-size:19px; font-weight:600; line-height:1.1;
    box-shadow:0 2px 0 #0002; cursor:pointer; -webkit-tap-highlight-color:transparent;
}
.sb-key:active { transform:translateY(1px); box-shadow:none; background:var(--brand-tint-bg, #e2e8f0); }
.sb-key:focus-visible { outline:3px solid var(--brand-500, #6366f1); outline-offset:1px; }
.sb-key-done, .sb-key-next, .sb-key-enter {
    flex:1.5; background:var(--brand-500, var(--mob-brand-500, #475569)); color:var(--brand-ink, #fff);
    font-size:14px; font-weight:800;
}
.sb-key-done { flex:0 0 auto; min-width:70px; min-height:36px; }
.sb-key-space { flex:5; font-size:14px; }
.sb-key-symbols { flex:2; font-size:12px; }
.sb-key-shift, .sb-key-backspace { flex:1.5; }
.sb-key-shift[aria-pressed="true"] { background:var(--brand-500, #475569); color:var(--brand-ink, #fff); }
@media(max-width:600px) {
    .sb-keyboard { padding:8px 5px max(8px, env(safe-area-inset-bottom)); border-radius:12px 12px 0 0; }
    .sb-key-row, .sb-keyboard-rows { gap:4px; }
    .sb-key { min-height:42px; font-size:17px; border-radius:6px; }
    .sb-key-symbols { font-size:10px; }
    .sb-key-space, .sb-key-next, .sb-key-enter { font-size:12px; }
}
@media(max-height:550px) {
    .sb-keyboard { max-height:46dvh; }
    .sb-key { min-height:32px; padding:5px 3px; }
    .sb-keyboard-header { margin-bottom:5px; }
}
@media print { .sb-keyboard { display:none !important; } }

/* Fit text and numeric modes to the visible viewport, including landscape and zoom. */
.sb-keyboard{left:var(--sb-keyboard-left,50%);width:min(1040px,100%,var(--sb-keyboard-visible-width,100vw));max-height:var(--sb-keyboard-max-height,65dvh);overflow-x:hidden;overscroll-behavior:contain}
.sb-keyboard:not([data-mode=text]){width:min(460px,100%,var(--sb-keyboard-visible-width,100vw))}
.sb-keyboard .sb-key{min-height:var(--sb-key-height,44px);height:var(--sb-key-height,44px);padding:3px 2px;font-size:var(--sb-key-font,19px)}
.sb-keyboard .sb-key-done{height:30px;min-height:30px;font-size:12px;min-width:58px}
.sb-keyboard :is(.sb-key-symbols,.sb-key-space,.sb-key-next,.sb-key-enter){font-size:clamp(10px,var(--sb-key-font,14px),14px)}
.sb-keyboard-rows,.sb-key-row{gap:4px}
.sb-keyboard-title{font-size:12px}.sb-keyboard-number{font-size:18px}
@media(max-height:500px){.sb-keyboard{padding:5px 6px max(5px,env(safe-area-inset-bottom))}.sb-keyboard-header{gap:6px;margin-bottom:4px}}
@media(max-width:380px){.sb-keyboard{padding-left:3px;padding-right:3px}.sb-key-row{gap:2px}.sb-keyboard .sb-key{border-radius:5px}.sb-keyboard .sb-key-symbols{font-size:9px}}
