:root{color-scheme:light;font:14px/1.5 -apple-system,BlinkMacSystemFont,"Helvetica Neue","PingFang SC",sans-serif;color:#18212d;background:#f6f7fa;--blue:#145bc5;--line:#dce1e8}
*{box-sizing:border-box}
body{margin:0;min-height:100dvh}
main{max-width:900px;margin:auto;padding: max(20px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left))}
header,.brand,.heading,.controls{display:flex;align-items:center;gap:10px}
header,.heading{justify-content:space-between}
h1,h2,p{margin:0}
h1{font-size:24px;letter-spacing:-1px} h2,.field-title{font-size:16px;font-weight:650}
.mark{display:grid;place-items:center;width:38px;height:38px;border-radius:12px;color:white;background:#213956;font-size:25px}
button,input,textarea,select{font:inherit;color:inherit}
button{border:1px solid var(--line);border-radius:10px;background:white;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
button:focus-visible,textarea:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #5089cf;outline-offset:2px}
button:active:enabled{background:#e0eafb}button:disabled{cursor:default;color:#717b88}
.status{border-radius:24px;padding:7px 11px;color:#4c596b}.status[data-live=true]{color:#10734c;background:#e8f6ee;border-color:#c1e4d1}
.tabs{display:flex;padding:4px;margin:20px 0 14px;background:#e7eaf0;border-radius:13px;gap:2px}
.tabs button{border:0;background:transparent;flex:1;padding:8px}.tabs button[aria-pressed=true]{background:white;font-weight:650;box-shadow:0 1px 4px #23334c24}
#feedback{color:#536278;margin-bottom:14px;min-height:21px}
section{background:white;border:1px solid var(--line);border-radius:18px;padding:16px}
textarea,input,select{width:100%;border-radius:10px;border:1px solid var(--line);padding:10px;background:#fafbfd;font-size:16px}
textarea{margin:8px 0 12px;resize:vertical;min-height:64px}
.heading{margin:4px 0 12px}.heading span,.tile small{color:#5f6979}
.mods,.keyrow{display:flex;gap:4px}.mods{gap:6px;margin-bottom:12px}.mods button{flex:1;padding:8px 2px}
.mods button[aria-pressed=true]{background:#dfeeff;border-color:#86b3ef;color:#074893}
.tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:20px}
.tile{display:flex;align-items:center;justify-content:space-between;gap:4px;text-align:left;padding:12px 10px;min-height:52px}.tile small{font-size:12px}
.link{border:0;color:var(--blue);padding:6px 0;background:transparent}
.custom-row{display:flex;gap:6px;margin-bottom:6px}.custom-row .tile{flex:1}
dialog{border:1px solid var(--line);border-radius:18px;padding:20px;width:min(380px,92vw);box-shadow:0 14px 60px #13233c30}
dialog::backdrop{background:#1f2a3a50}dialog p,dialog label{display:block;margin:12px 0}dialog input,dialog select{margin-top:4px}
.controls{flex-wrap:wrap;justify-content:flex-end;margin-top:18px}.controls button,.custom-row>button:last-child{padding:8px 12px}
.primary{color:white;background:var(--blue)}
[hidden]{display:none!important}
.top-actions{display:flex;align-items:center;gap:5px}.bar-button{padding:6px 9px;color:var(--blue)}
#imeOpen,#padToggle,.compact,#expand{display:none}
#padToggle[aria-pressed=true]{background:#e2edff}
.keybed{width:100%;display:flex;gap:8px;padding:6px;border-radius:12px;background:#e5e9ef;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.main-block{flex:1;min-width:0;display:grid;grid-template-rows:.75fr repeat(5,1fr);gap:4px}
.physical-row{display:flex;gap:4px;min-height:0}
.physical-key{flex:1 1 0;min-width:0;min-height:0;height:100%;padding:3px 1px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;border-radius:5px;background:#fff;border:1px solid #ccd3de;border-bottom-color:#aab6c5;box-shadow:0 1px 0 #bcc6d2;color:#182433;line-height:1.05;touch-action:none;overflow:hidden}
.physical-key .legend{font-size:clamp(12px,1.85vw,18px)}
.physical-key small{font-size:clamp(9px,1.35vw,13px);font-weight:450;line-height:1.15}
.physical-key.pressed,.physical-key[aria-pressed=true]{color:#164e9c;background:#dceaff;border-color:#7ca3d6}
.physical-key.shifted .legend{color:#145bc5;font-weight:750}
.physical-key[data-key="space"]{flex:5.9}.physical-key[data-key="tab"],.physical-key[data-key="⌫"]{flex:1.55}
.physical-key[data-key="caps"]{flex:1.82}.physical-key[data-key="return"]{flex:2.02}
.row-4 .physical-key:first-child{flex:2.36}.row-4 .physical-key:last-child{flex:2.68}
.physical-key[data-key="command"]{flex:1.4}.row-0 .physical-key:first-child,.row-0 .physical-key:last-child{flex:1.28}
.row-0 .legend{font-size:clamp(10px,1.5vw,14px)}.row-5 .physical-key small{font-size:clamp(8px,1.15vw,11px)}
.arrow-cluster{flex:3.1;min-width:0;display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(2,minmax(0,1fr));gap:2px}
.arrow-cluster [data-key="←"]{grid-row:2;grid-column:1}.arrow-cluster [data-key="↑"]{grid-row:1;grid-column:2}.arrow-cluster [data-key="↓"]{grid-row:2;grid-column:2}.arrow-cluster [data-key="→"]{grid-row:2;grid-column:3}
.arrow-cluster .physical-key{padding:0}.arrow-cluster .legend{font-size:13px}
.numeric-block{display:none;grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:.75fr repeat(5,minmax(0,1fr));gap:3px;flex:0 0 21%;min-width:0}
.show-pad .numeric-block{display:grid}.numeric-block [data-key="num:0"]{grid-column:span 2}.numeric-block [data-key="num:enter"]{grid-row:span 2}
#keybed{height:clamp(220px,36vw,315px)}
#linkPair{margin-top:12px}#linkPair input{margin-bottom:5px}
.pair-photo{font-weight:600}.pair-photo input{font-size:14px;margin-top:4px}.controls button{min-height:38px}
#imeDialog #nativeInput{display:block}#imeDialog textarea{min-height:72px}
@media(orientation:portrait) and (max-width:600px){
  section{padding:11px}.compact{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}.compact button{min-height:44px;font-size:16px}
  #expand{display:block;margin-top:10px}#keybed{display:none}.expanded #keybed{display:flex;height:195px;padding:3px;gap:2px}
  .physical-row,.main-block{gap:2px}.physical-key{border-radius:3px}.physical-key small{font-size:7px}.keybed .legend{font-size:10px}
  .heading span{font-size:12px}
}
@media (orientation:landscape) and (max-height:650px),(orientation:landscape) and (pointer:coarse){
  body.keys-active{overscroll-behavior:none}
  .keys-active main{width:100%;max-width:none;height:100vh;height:100dvh;display:grid;grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto auto minmax(0,1fr);gap:4px;
    padding:max(4px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(5px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left))}
  .keys-active header{display:contents}.keys-active .brand{grid-column:1;grid-row:1;gap:5px}
  .keys-active h1{font-size:16px}.keys-active .mark{height:26px;width:26px;border-radius:7px;font-size:17px}
  .keys-active .tabs{grid-column:2;grid-row:1;align-self:center;justify-self:center;margin:0;padding:2px;border-radius:9px}
  .keys-active .tabs button{font-size:13px;white-space:nowrap;padding:4px 12px;border-radius:7px}
  .keys-active .top-actions{grid-column:3;grid-row:1;gap:4px}
  .keys-active .bar-button,.keys-active .status{font-size:12px;padding:5px 8px}
  .keys-active #imeOpen,.keys-active #padToggle{display:block}
  .keys-active #feedback{display:none;grid-column:1/-1;grid-row:2;min-height:0;margin:0;font-size:12px}
  .keys-active.show-note #feedback{display:block}
  .keys-active #keyboard{grid-column:1/-1;grid-row:3;min-height:0;display:flex;padding:0;border:0;background:transparent}
  .keys-active #keyboard>#nativeInput,.keys-active #keyboard>.heading,.keys-active #modifiers,.keys-active #compact,.keys-active #expand{display:none}
  .keys-active #keybed{display:flex;height:100%;padding:clamp(3px,1.5dvh,8px);border:1px solid #d4dbe4}
  .main-block,.physical-row{gap:clamp(2px,1.05dvh,6px)}.physical-key{border-radius:clamp(4px,.85vw,9px)}
  .row-0 .physical-key{background:#f5f7fa}
  .keybed .physical-key[aria-pressed=true],.keybed .physical-key.pressed{background:#dceaff}
  .physical-key[data-key="space"]::after{content:"";width:22%;height:2px;background:#d3dbe5;border-radius:4px;align-self:center}
}
@media(orientation:landscape) and (max-width:720px){.keys-active h1{display:none}.keys-active .tabs button{padding:3px 9px}.keys-active .bar-button,.keys-active .status{padding:4px 6px}.keys-active .physical-key small{font-size:8px}}
dialog{max-height:calc(100dvh - 20px);overflow:auto}
