.zh-local-keyboard[hidden]{ display:none !important; }
.zh-local-keyboard{ position:fixed; left:0; right:0; bottom:0; z-index:1100; padding:8px max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); background:#eaf0e8; color:#262c26; border-top:1px solid #cbd8c9; box-shadow:0 -3px 16px rgba(0,0,0,.15); max-height:100vh; max-height:100dvh; overflow:auto; }
.zh-local-keyboard-head{ display:flex; align-items:flex-end; gap:8px; margin-bottom:4px; }
.zh-local-keyboard-head label{ flex:1; min-width:0; margin:0; font-size:14px; }
.zh-local-keyboard-head label span{ display:block; margin-bottom:3px; }
.zh-local-keyboard-head input{ width:100%; height:36px; padding:8px 12px; color:#262c26; background:#fff; border:1px solid #b8c6b5; border-radius:6px; font-size:16px; }
.zh-local-keyboard button{ min-height:36px; min-width:44px; border:1px solid #cbd3c8; border-radius:6px; padding:4px 8px; color:#262c26; background:#fff; font-size:16px; touch-action:manipulation; }
.zh-local-keyboard button:active{ background:#d8e8d3; transform:translateY(1px); }
.zh-local-keyboard button:focus-visible{ outline:2px solid #278e32; outline-offset:1px; }
.zh-local-keyboard button[data-action="done"]{ background:#ff8a00; color:#fff; border-color:#ff8a00; }
.zh-local-keyboard-keys{ display:flex; flex-direction:column; gap:4px; }
.zh-local-keyboard-row{ display:flex; gap:4px; }
.zh-local-keyboard-row button{ flex:1; padding:3px 2px; }
.zh-local-keyboard-row button[data-key=" "]{ flex:2; }
.zh-local-keyboard{
 left:auto; right:max(6px,env(safe-area-inset-right)); bottom:max(6px,env(safe-area-inset-bottom));
 width:520px; max-width:calc(100vw - 12px); padding:6px;
 border:1px solid #cbd8c9; border-radius:9px;
}
.zh-local-keyboard.zh-local-keyboard-numeric{ width:320px; }
.zh-local-keyboard-head{ gap:5px; }
.zh-local-keyboard-head label span{ overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:13px; }
.zh-local-keyboard-head input{ height:34px; padding:5px 8px; }
.zh-local-keyboard button{ min-width:0; min-height:34px; padding:4px 7px; }
.zh-local-keyboard-row{ gap:4px; }
.zh-local-keyboard-row button{ flex:1 1 0; min-width:0; height:34px; padding:3px 0; }
.zh-local-keyboard-row button[data-key=" "]{ flex:2 1 0; }
.zh-local-keyboard button[data-action="back"]{ background:#d5d8dc; border-color:#b7bec5; color:#293038; }
.zh-local-keyboard button[data-action="back"]:active{ background:#bfc5cc; }
@media (any-pointer:coarse) and (orientation:portrait) and (max-width:600px){.zh-local-keyboard,.zh-local-keyboard.zh-local-keyboard-numeric{
  left:50%; right:auto; transform:translateX(-50%); width:520px; max-width:calc(100vw - 16px);
 }
.zh-local-keyboard.zh-local-keyboard-numeric{ width:320px; }
.zh-local-keyboard-row{ gap:3px; }
.zh-local-keyboard-row button{ min-height:38px; height:38px; }}
.zh-local-keyboard{ z-index:1200; }
.zh-local-keyboard-head label{position:relative}
.zh-local-keyboard-head input{caret-color:transparent}
.zh-local-keyboard-head .zh-keyboard-caret{position:absolute;display:block;width:2px;height:20px;background:#d84646;pointer-events:none;animation:zh-keyboard-caret-blink 1s step-end infinite;z-index:1}
@keyframes zh-keyboard-caret-blink{0%,100%{opacity:1}50%{opacity:0}}
@media(prefers-reduced-motion:reduce){.zh-local-keyboard-head .zh-keyboard-caret{animation:none}}
.zh-local-keyboard,.zh-local-keyboard *{box-sizing:border-box}
.zh-local-keyboard button{text-align:center;white-space:nowrap;line-height:1.2;font-family:Ubuntu,Arial,sans-serif}
.zh-place-dialog.zh-city-keyboard-open{max-height:max(80px,calc(100dvh - var(--zh-city-keyboard-height,230px) - 20px));margin-top:10px;margin-bottom:0}

/* Landscape city search stays on the left, with keyboard over the right side. */
@media(any-pointer:coarse) and (orientation:landscape) and (max-width:1366px) and (max-height:600px){
 .zh-place-dialog.zh-city-keyboard-open{left:max(6px,env(safe-area-inset-left));right:auto;top:max(6px,env(safe-area-inset-top));bottom:auto;width:calc(100vw - 12px);max-width:calc(100vw - 12px);max-height:calc(100dvh - 12px);margin:0;padding:12px;box-sizing:border-box;overflow:auto}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-results{width:var(--zh-city-result-width,30vw);max-width:100%;min-width:120px}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-results>button{width:100%;overflow-wrap:anywhere}
 .zh-place-dialog.zh-city-keyboard-open>.zh-place-status,.zh-place-dialog.zh-city-keyboard-open>.zh-place-help,.zh-place-dialog.zh-city-keyboard-open>[data-place-regions]{max-width:var(--zh-city-result-width,30vw)}
 .zh-place-dialog.zh-city-keyboard-open .zh-local-keyboard{left:auto;right:max(6px,env(safe-area-inset-right));bottom:max(6px,env(safe-area-inset-bottom));transform:none;width:min(520px,64vw);max-width:calc(100vw - 12px);background:rgba(234,240,232,.90);z-index:1200}
}

/* Three visible case modes and a distinct latched Caps state. */
.zh-local-keyboard button[data-action="shift"]{display:flex;align-items:center;justify-content:center;gap:3px;font-size:12px;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:none}
.zh-local-keyboard [data-case-symbol]{opacity:.45;line-height:1}
.zh-local-keyboard [data-case-symbol].is-active{opacity:1;font-weight:700;text-decoration:underline;text-underline-offset:3px}
.zh-local-keyboard button[data-case-mode="once"]{background:#d8e8d3;border-color:#96b98c}
.zh-local-keyboard button[data-case-mode="locked"]{background:#3c8139;color:#fff;border-color:#286025;box-shadow:inset 0 2px 5px #0004;transform:translateY(1px)}
.zh-local-keyboard .zh-local-keyboard-head button[data-action="back"]{min-width:44px;font-size:21px}
.zh-local-keyboard-row button[data-action="cancel"]{flex:1.25 1 0;font-size:12px;padding:3px 1px}

/* Same compact text keyboard geometry in both phone orientations. */
#zh-local-keyboard-title{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(any-pointer:coarse){
 .zh-local-keyboard:not(.zh-local-keyboard-numeric),.zh-place-dialog.zh-city-keyboard-open .zh-local-keyboard:not(.zh-local-keyboard-numeric){width:var(--zh-phone-keyboard-width,calc(100vmin - 16px));max-width:calc(100vw - 16px);padding:6px;border-radius:9px}
 .zh-local-keyboard .zh-local-keyboard-head{gap:5px;margin-bottom:4px}
 .zh-local-keyboard .zh-local-keyboard-head input{height:36px;min-height:36px;padding:5px 8px;font-size:16px}
 .zh-local-keyboard .zh-local-keyboard-head button{height:36px;min-height:36px;padding:4px 7px}
 .zh-local-keyboard .zh-local-keyboard-keys{gap:3px}
 .zh-local-keyboard .zh-local-keyboard-row{gap:3px}
 .zh-local-keyboard .zh-local-keyboard-row button{height:38px;min-height:38px;padding:3px 0}
}

/* Equal header controls; Backspace supports a stationary long press. */
.zh-local-keyboard .zh-local-keyboard-head button:is([data-action="done"],[data-action="back"]){flex:0 0 76px;width:76px;min-width:76px;max-width:76px;height:36px;min-height:36px;padding:4px 6px;font-size:14px;line-height:1.2}
.zh-local-keyboard .zh-local-keyboard-head button[data-action="back"]{font-size:21px;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:none}
.zh-local-keyboard button[data-action="back"].is-repeating{background:#bfc5cc;box-shadow:inset 0 2px 4px #0003;transform:translateY(1px)}

/* One case glyph; latched capitals use the same fill as a pressed letter key. */
.zh-local-keyboard button[data-action="shift"]{font-size:16px;font-weight:500;text-decoration:none}
.zh-local-keyboard button[data-case-mode="locked"]{background:#d8e8d3;color:#262c26;border-color:#cbd3c8;box-shadow:none;transform:translateY(1px);text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:4px}
.zh-local-keyboard button{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}

/* Outline / solid / underlined solid Shift; equal utility keys and larger spacebar. */
.zh-local-keyboard button[data-action="shift"] svg{display:block;width:22px;height:26px;pointer-events:none}
.zh-local-keyboard button[data-case-mode="locked"]{text-decoration:none;background:#d8e8d3;color:#262c26;border-color:#cbd3c8;box-shadow:inset 0 1px 3px #0002;transform:translateY(1px)}
.zh-local-keyboard .zh-local-keyboard-row:last-child>button{flex:1 1 0;min-width:0}
.zh-local-keyboard .zh-local-keyboard-row:last-child>button[data-key=" "]{flex:2.4 1 0}
.zh-local-keyboard .zh-local-keyboard-row:last-child>button[data-action="symbols"]{font-size:13px}
.zh-local-keyboard .zh-local-keyboard-row:last-child>button[data-action="collapse"]{font-size:17px}
.zh-local-keyboard.zh-keyboard-collapsed{background:transparent!important;border-color:transparent;box-shadow:none;pointer-events:none}
.zh-local-keyboard.zh-keyboard-collapsed .zh-local-keyboard-head,.zh-local-keyboard.zh-keyboard-collapsed .zh-local-keyboard-keys>.zh-local-keyboard-row:not(:last-child),.zh-local-keyboard.zh-keyboard-collapsed .zh-local-keyboard-row:last-child>button:not([data-action="collapse"]){display:none}
.zh-local-keyboard.zh-keyboard-collapsed .zh-local-keyboard-row:last-child{justify-content:flex-end}
.zh-local-keyboard.zh-keyboard-collapsed .zh-local-keyboard-row:last-child>button[data-action="collapse"]{flex:0 0 var(--zh-collapse-key-width,52px);width:var(--zh-collapse-key-width,52px);pointer-events:auto;box-shadow:0 2px 8px #0002}

/* Shared JS blink clock keeps the source-field and keyboard carets in phase. */
.zh-keyboard-source-wrap{display:block;position:relative;width:100%;margin:0;padding:0}
.zh-keyboard-source-wrap .zh-source-caret{display:block;position:absolute;width:2px;height:20px;background:#d84646;pointer-events:none;z-index:2;animation:none}
.zh-keyboard-source-wrap .zh-source-caret[hidden]{display:none!important}
.zh-keyboard-source-wrap.zh-keyboard-source-active input{caret-color:transparent}
.zh-local-keyboard-head .zh-keyboard-caret{animation:none!important}

/* Landscape city entry matches the visible result-list width left of the keyboard. */
@media(any-pointer:coarse) and (orientation:landscape) and (max-width:1366px) and (max-height:600px){
 .zh-place-dialog.zh-city-keyboard-open>.zh-keyboard-source-wrap{width:var(--zh-city-result-width,30vw);max-width:100%;min-width:120px}
 .zh-place-dialog.zh-city-keyboard-open>.zh-keyboard-source-wrap #zh-place-query{width:100%;box-sizing:border-box;background:#fff}
}

/* Fixed city entry with an independent result scroller in landscape. */
.zh-place-scroll-rail{display:none;pointer-events:none}.zh-place-scroll-rail[hidden]{display:none!important}
@media(any-pointer:coarse) and (orientation:landscape) and (max-width:1366px) and (max-height:600px){
 .zh-place-dialog[open],.zh-place-dialog[open].zh-city-keyboard-open{display:flex;flex-direction:column;max-height:calc(100dvh - 12px);overflow:hidden}
 .zh-place-dialog>.zh-place-heading,.zh-place-dialog>label,.zh-place-dialog>.zh-keyboard-source-wrap,.zh-place-dialog>#zh-place-query{flex:0 0 auto}
 .zh-place-dialog>.zh-place-scroll{position:relative;flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;box-sizing:border-box;padding-right:7px;scrollbar-width:none}
 .zh-place-dialog>.zh-place-scroll::-webkit-scrollbar{display:none}
 .zh-place-dialog.zh-city-keyboard-open>.zh-place-scroll{width:calc(var(--zh-city-result-width,30vw) + 7px);max-width:100%}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-scroll .zh-place-results{width:auto;max-width:100%;min-width:0}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-scroll .zh-place-status,.zh-place-dialog.zh-city-keyboard-open .zh-place-scroll .zh-place-help,.zh-place-dialog.zh-city-keyboard-open .zh-place-scroll>[data-place-regions]{max-width:100%}
 .zh-place-dialog .zh-place-scroll-rail:not([hidden]){display:block;position:absolute;width:4px;border-radius:3px;background:#e5eddf;z-index:5}
 .zh-place-scroll-rail>span{position:absolute;top:0;left:0;display:block;width:4px;border-radius:3px;background:#96b98c}
}

/* Entire landscape city dialog ends at the keyboard, not at viewport midpoint. */
@media(any-pointer:coarse) and (orientation:landscape) and (max-width:1366px) and (max-height:600px){
 .zh-place-dialog[open].zh-city-keyboard-open{left:max(0px,env(safe-area-inset-left));right:auto;top:max(6px,env(safe-area-inset-top));margin:0;width:var(--zh-city-panel-width,calc(100vw - 100vmin));max-width:calc(100vw - 12px);height:calc(100dvh - 12px);max-height:calc(100dvh - 12px);padding:12px;overflow:hidden}
 .zh-place-dialog.zh-city-keyboard-open>.zh-place-heading{min-width:0;display:block}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-heading h2{font-size:18px;line-height:1.2;margin:0 0 10px;overflow-wrap:anywhere}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-heading>[data-place-close]{position:fixed;right:max(6px,env(safe-area-inset-right));top:max(6px,env(safe-area-inset-top));z-index:1201;width:44px;height:44px;padding:0;text-align:center;box-shadow:0 2px 8px #0002}
 .zh-place-dialog.zh-city-keyboard-open>label{overflow-wrap:anywhere}
 .zh-place-dialog.zh-city-keyboard-open>.zh-keyboard-source-wrap{min-width:0;max-width:100%}
 .zh-place-dialog.zh-city-keyboard-open>.zh-place-scroll{width:100%;max-width:100%}
 .zh-place-dialog.zh-city-keyboard-open .zh-place-scroll>[data-place-regions]{max-width:100%;overflow-wrap:anywhere}
}

/* Scroll the whole landscape city column; keep only close and keyboard fixed. */
.zh-place-dialog .zh-place-heading>[data-place-close]{display:inline-flex;align-items:center;justify-content:center;padding:0;width:44px;height:44px;box-sizing:border-box;text-align:center;line-height:1}
@media(any-pointer:coarse) and (orientation:landscape) and (max-width:1366px) and (max-height:600px){
 .zh-place-dialog[open],.zh-place-dialog[open].zh-city-keyboard-open{display:block;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;scrollbar-width:none}
 .zh-place-dialog[open]::-webkit-scrollbar{display:none}
 .zh-place-dialog>.zh-place-scroll{display:block;flex:none;overflow:visible;min-height:0;padding-right:7px}
 .zh-place-dialog .zh-place-heading>[data-place-close]{position:fixed;right:max(6px,env(safe-area-inset-right));top:max(6px,env(safe-area-inset-top));z-index:1201;box-shadow:0 2px 8px #0002}
}

/* Every local-keyboard field has a paired caret without changing its layout. */
.zh-keyboard-source-host{position:relative}
.zh-keyboard-source-host>.zh-source-caret{display:block;position:absolute;width:2px;height:20px;background:#d84646;pointer-events:none;z-index:2;animation:none}
.zh-keyboard-source-host>.zh-source-caret[hidden]{display:none!important}
.zh-keyboard-source-host.zh-keyboard-source-active input{caret-color:transparent}
