/* ===========================================================
   OSSim 内核 · 触屏模式样式（core/touch*.js）
   只在 html.ossim-touch 或 .ossim-tui* 下生效：电脑上（触屏模式未启用）不影响任何东西
   =========================================================== */
html.ossim-touch #ossim, html.ossim-touch #ossim * { touch-action: none !important; -webkit-touch-callout: none; }
html.ossim-touch #ossim .ossim-screen.ossim-touch-anim { transition: transform .22s ease; }

.ossim-tui {
  position: fixed; inset: 0; z-index: 2147483600; pointer-events: none;
  font: 13px/1.4 system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; color: #fff;
  -webkit-user-select: none; user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none;
}
.ossim-tui > * { pointer-events: auto; }
.ossim-tui > .tui-ring, .ossim-tui > .tui-ripple, .ossim-tui > .tui-zoom { pointer-events: none; }

/* ---------- 长按圆环 / 点按涟漪 / 缩放比例 ---------- */
.ossim-tui .tui-ring { position: fixed; width: 48px; height: 48px; opacity: 0; }
.ossim-tui .tui-ring.run { opacity: 1; }
.ossim-tui .tui-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ossim-tui .tui-ring circle { fill: none; stroke-width: 3.5; }
.ossim-tui .tui-ring .bg { stroke: rgba(0, 0, 0, .28); }
.ossim-tui .tui-ring .fg { stroke: #4ea1ff; stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 119.4; }
.ossim-tui .tui-ring.run .fg { stroke-dashoffset: 0; transition: stroke-dashoffset .39s linear; }
.ossim-tui .tui-ring.done { animation: ossim-tui-pop .3s ease-out forwards; }
@keyframes ossim-tui-pop { from { transform: scale(1); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.ossim-tui .tui-ripple {
  position: fixed; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 255, 255, .38); box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .25);
  animation: ossim-tui-ripple .4s ease-out forwards;
}
.ossim-tui .tui-ripple.two { background: rgba(78, 161, 255, .5); }
@keyframes ossim-tui-ripple { from { transform: scale(.3); opacity: .95; } to { transform: scale(1.15); opacity: 0; } }
.ossim-tui .tui-zoom {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); padding: 5px 13px; border-radius: 14px;
  background: rgba(20, 20, 22, .8); font-weight: 600; opacity: 0; transition: opacity .2s;
}
.ossim-tui .tui-zoom.show { opacity: 1; }

/* ---------- 悬浮球 ---------- */
.ossim-tui .tui-ball {
  position: fixed; left: 0; top: 0; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer;
  background: rgba(28, 30, 34, .62); box-shadow: 0 2px 10px rgba(0, 0, 0, .35), inset 0 0 0 1px rgba(255, 255, 255, .2);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: opacity .3s, background .2s, margin .25s;
}
.ossim-tui .tui-ball svg { width: 28px; height: 28px; }
.ossim-tui .tui-ball.anim { transition: transform .25s cubic-bezier(.2, .8, .3, 1), opacity .3s, background .2s, margin .25s; }
.ossim-tui .tui-ball.idle { opacity: .5; }
.ossim-tui .tui-ball.open { background: rgba(40, 110, 230, .9); opacity: 1; }
.ossim-tui .tui-ball.tucked { opacity: .45; margin-left: 30px; }
.ossim-tui .tui-ball.tucked.left { margin-left: -30px; }
.ossim-tui .tui-ball.mods { box-shadow: 0 0 0 2px #4ea1ff, 0 2px 10px rgba(0, 0, 0, .35); }
.ossim-tui .tui-badge {
  position: absolute; right: -3px; top: -3px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
  background: #ff9f0a; color: #111; font-size: 11px; font-weight: 700; display: none; align-items: center; justify-content: center;
}
.ossim-tui .tui-ball.right .tui-badge { display: flex; }

/* ---------- 面板 ---------- */
.ossim-tui .tui-panel {
  position: fixed; width: 240px; padding: 10px; border-radius: 16px;
  background: rgba(28, 30, 34, .92); box-shadow: 0 8px 30px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; transform: scale(.92); transition: opacity .15s, transform .15s;
}
.ossim-tui .tui-panel.show { opacity: 1; transform: none; }
.ossim-tui .tui-ph { display: flex; justify-content: space-between; padding: 2px 6px 8px; color: rgba(255, 255, 255, .7); font-size: 12px; }
.ossim-tui .tui-ph b { color: #fff; font-weight: 600; }
.ossim-tui .tui-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ossim-tui .tui-it {
  display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 68px; padding: 9px 2px 7px;
  border-radius: 11px; background: rgba(255, 255, 255, .07); text-align: center; font-size: 11px; line-height: 1.25; cursor: pointer;
}
.ossim-tui .tui-it svg { width: 24px; height: 24px; flex: none; }
.ossim-tui .tui-it.on { background: #2f7cf6; }
.ossim-tui .tui-it.down, .ossim-tui .tui-key.down, .ossim-tui .tui-x.down { background: rgba(255, 255, 255, .24); }

/* ---------- 快捷键面板 ---------- */
.ossim-tui .tui-sheet {
  position: fixed; left: 50%; bottom: 0; width: min(780px, 100%); max-height: 62%;
  display: flex; flex-direction: column; border-radius: 16px 16px 0 0;
  background: rgba(24, 26, 30, .96); box-shadow: 0 -6px 30px rgba(0, 0, 0, .45);
  transform: translate(-50%, 105%); transition: transform .2s ease-out; padding-bottom: env(safe-area-inset-bottom);
}
.ossim-tui .tui-sheet.show { transform: translate(-50%, 0); }
.ossim-tui .tui-sh-hd { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.ossim-tui .tui-sh-t { font-weight: 600; font-size: 14px; white-space: nowrap; }
.ossim-tui .tui-mods { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; touch-action: pan-x; scrollbar-width: none; }
.ossim-tui .tui-x { width: 34px; height: 34px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .08); cursor: pointer; }
.ossim-tui .tui-x svg { width: 18px; height: 18px; }
.ossim-tui .tui-sh-body { overflow-y: auto; padding: 0 12px 4px; touch-action: pan-y; overscroll-behavior: contain; min-height: 0; }
.ossim-tui .tui-grp { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.ossim-tui .tui-gn { flex: none; width: 30px; padding-top: 11px; font-size: 11px; color: rgba(255, 255, 255, .5); }
.ossim-tui .tui-keys { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.ossim-tui .tui-key {
  min-width: 46px; height: 40px; padding: 0 10px; border-radius: 9px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .1); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .45);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.ossim-tui .tui-key small { font-size: 9.5px; font-weight: 400; color: rgba(255, 255, 255, .55); margin-top: 1px; }
.ossim-tui .tui-key.mod { height: 32px; min-width: 52px; flex: none; }
.ossim-tui .tui-key.mod.on { background: #2f7cf6; }
.ossim-tui .tui-sh-tip { padding: 2px 14px 10px; font-size: 11px; color: rgba(255, 255, 255, .45); }

/* ---------- 手势说明 ---------- */
.ossim-tui .tui-guide { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(0, 0, 0, .55); opacity: 0; transition: opacity .2s; }
.ossim-tui .tui-guide.show { opacity: 1; }
/* 卡片用网格：标题 / 可滚动列表 / 按钮；视口很矮时按钮挪到标题右边，保证"知道了"始终看得见 */
.ossim-tui .tui-gcard {
  width: min(760px, 100%); max-height: 100%; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "hd" "list" "btn";
  padding: 16px 16px 12px; border-radius: 18px; background: #1d1f23; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.ossim-tui .tui-ghd { grid-area: hd; min-width: 0; margin-bottom: 10px; }
.ossim-tui .tui-gt { font-size: 17px; font-weight: 700; }
.ossim-tui .tui-gs { margin-top: 3px; font-size: 12px; color: rgba(255, 255, 255, .55); }
.ossim-tui .tui-glist {
  grid-area: list; min-height: 0; overflow-y: auto; display: grid; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); gap: 8px; touch-action: pan-y; overscroll-behavior: contain;
}
.ossim-tui .tui-g { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.ossim-tui .tui-g svg { width: 52px; height: 52px; flex: none; }
.ossim-tui .tui-g b { display: block; font-size: 13px; }
.ossim-tui .tui-g span { display: block; margin-top: 2px; font-size: 11.5px; color: rgba(255, 255, 255, .6); }
.ossim-tui .tui-g .f { fill: #fff; stroke: #4ea1ff; stroke-width: 2; }
.ossim-tui .tui-g .f.ghost { opacity: .3; }
.ossim-tui .tui-g .w, .ossim-tui .tui-g .a, .ossim-tui .tui-g .r, .ossim-tui .tui-g .fr { fill: none; stroke: #4ea1ff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ossim-tui .tui-g .fr { stroke: rgba(255, 255, 255, .35); stroke-dasharray: 4 3; }
.ossim-tui .tui-g .r { stroke-dasharray: 70 30; }
.ossim-tui .tui-g text { fill: #4ea1ff; font-size: 13px; font-weight: 700; }
.ossim-tui .tui-g .b { color: #fff; }
.ossim-tui .tui-gbtn { grid-area: btn; justify-self: center; align-self: center; margin-top: 12px; padding: 9px 44px; border-radius: 20px; background: #2f7cf6; font-size: 14px; font-weight: 600; cursor: pointer; }
.ossim-tui .tui-gbtn.down, .ossim-tui .tui-rbtn.down { filter: brightness(1.25); }

@media (max-height: 460px) {
  .ossim-tui .tui-guide { padding: 8px; }
  .ossim-tui .tui-gcard { padding: 10px 12px 8px; border-radius: 14px; }
  .ossim-tui .tui-ghd { margin-bottom: 8px; }
  .ossim-tui .tui-gt { font-size: 15px; }
  .ossim-tui .tui-gs { font-size: 11px; }
  .ossim-tui .tui-glist { gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); }
  .ossim-tui .tui-g { gap: 8px; padding: 5px 7px; border-radius: 10px; }
  .ossim-tui .tui-g svg { width: 36px; height: 36px; }
  .ossim-tui .tui-g b { font-size: 12px; }
  .ossim-tui .tui-g span { font-size: 10.5px; margin-top: 1px; }
  .ossim-tui .tui-gbtn { margin-top: 8px; padding: 7px 36px; font-size: 13px; }
}
/* 很矮（横屏手机里的虚拟机等）：按钮放到标题右边，列表占满剩下的高度 */
@media (max-height: 360px) {
  .ossim-tui .tui-gcard { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "hd btn" "list list"; }
  .ossim-tui .tui-gbtn { margin: 0 0 8px 10px; padding: 6px 22px; }
  .ossim-tui .tui-gs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-height: 240px) {
  .ossim-tui .tui-guide { padding: 4px; }
  .ossim-tui .tui-gs { display: none; }
  .ossim-tui .tui-g svg { width: 28px; height: 28px; }
}
@media (max-width: 420px) {
  .ossim-tui .tui-guide { padding: 8px; }
  .ossim-tui .tui-gcard { padding: 12px 12px 10px; }
  .ossim-tui .tui-g svg { width: 40px; height: 40px; }
}
/* 小画面里的快捷键面板 / 面板 */
@media (max-height: 420px) {
  .ossim-tui .tui-sheet { max-height: 70%; }
  .ossim-tui .tui-sh-hd { padding: 6px 10px 4px; }
  .ossim-tui .tui-key { height: 34px; min-width: 42px; padding: 0 8px; font-size: 12.5px; }
  .ossim-tui .tui-key small { display: none; }
  .ossim-tui .tui-key.mod { height: 30px; }
  .ossim-tui .tui-grp { padding: 3px 0; }
  .ossim-tui .tui-gn { padding-top: 9px; }
  .ossim-tui .tui-sh-tip { display: none; }
  .ossim-tui .tui-it { min-height: 58px; padding: 7px 2px 5px; }
}

/* ---------- "横过来更好用" ---------- */
.ossim-tui .tui-rotate {
  position: fixed; left: 50%; top: 16px; width: min(380px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 14px; background: rgba(28, 30, 34, .95); box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
  opacity: 0; transform: translate(-50%, -16px); transition: opacity .2s, transform .2s;
}
.ossim-tui .tui-rotate.show { opacity: 1; transform: translate(-50%, 0); }
.ossim-tui .tui-rotate svg { width: 38px; height: 38px; flex: none; color: #4ea1ff; }
.ossim-tui .tui-rt { flex: 1; min-width: 0; }
.ossim-tui .tui-rt b { display: block; font-size: 14px; }
.ossim-tui .tui-rt span { display: block; font-size: 11.5px; color: rgba(255, 255, 255, .6); }
.ossim-tui .tui-rbtn { padding: 7px 12px; border-radius: 14px; background: rgba(255, 255, 255, .12); font-size: 12.5px; white-space: nowrap; cursor: pointer; }

/* ---------- 下拉框兜底选择器 ---------- */
.ossim-tui .tui-pick { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .45); }
.ossim-tui .tui-pcard { width: min(360px, 100%); max-height: 80%; display: flex; flex-direction: column; overflow: hidden; border-radius: 14px; background: #fff; color: #111; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); }
.ossim-tui .tui-plist { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.ossim-tui .tui-po { padding: 12px 16px; font-size: 15px; border-bottom: 1px solid #eee; cursor: pointer; }
.ossim-tui .tui-po.on { color: #1a73e8; font-weight: 600; }
.ossim-tui .tui-po.dis { color: #aaa; }
.ossim-tui .tui-po.down { background: #f0f0f0; }

/* ---------- 键盘代理输入框 / 输入法组字预览（直接挂在 body 下） ---------- */
.ossim-tui-proxy {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; resize: none; outline: none;
  opacity: 0; font-size: 16px; color: transparent; background: transparent; caret-color: transparent; pointer-events: none; z-index: -1;
}
.ossim-tui-compose {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 2147483601; padding: 6px 14px; border-radius: 10px;
  background: rgba(28, 30, 34, .94); color: #fff; font: 16px/1.3 system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  pointer-events: none; box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}
