/* ===========================================================
   OSSim 内核样式：全局重置 / 屏幕容器 / 启动管理器 / 关机屏 / 手机外框 / 窗口管理器基础行为
   各系统自己的样式必须全部写在 .os-<id> 之下，不要改这里的全局规则
   =========================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background: #000; color: #fff;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { user-select: none; -webkit-user-select: none; }
/* 注意：touch-action 会与祖先取交集，所以不能放在 body 上，只放在拖拽把手上 */
.wm-win [data-wm-drag], .wm-rs, [data-touch-none] { touch-action: none; }
input, textarea, [contenteditable="true"] { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; }
img, svg { -webkit-user-drag: none; }

/* ---------- 屏幕：逻辑分辨率 + 缩放 ---------- */
#ossim { position: fixed; inset: 0; overflow: hidden; background: #000; }
.ossim-screen {
  position: absolute; left: 0; top: 0; overflow: hidden;
  transform-origin: 0 0;
  contain: layout paint;
}
.ossim-shell-root { position: absolute; inset: 0; overflow: hidden; }

/* ---------- 加载提示 ---------- */
.ossim-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 13px/1.4 ui-monospace, Consolas, 'OSSim Mono', monospace; color: #8a8a8a; background: #000;
}
.ossim-error {
  position: absolute; inset: 0; padding: 32px; background: #000080; color: #fff;
  font: 14px/1.6 Consolas, 'OSSim Mono', monospace; white-space: pre-wrap; overflow: auto; user-select: text;
}

/* ---------- 关机后的黑屏 ---------- */
.ossim-off {
  position: absolute; inset: 0; background: #000; display: flex; align-items: center; justify-content: center;
  color: #444; font: 13px/1.6 'OSSim Inter', system-ui, sans-serif; cursor: pointer; text-align: center;
}
.ossim-off .pw {
  width: 54px; height: 54px; border-radius: 50%; border: 2px solid #333; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center; transition: border-color .2s, color .2s;
}
.ossim-off:hover .pw { border-color: #666; color: #888; }

/* ---------- 手机外框（桌面浏览器里显示手机系统时） ---------- */
.ossim-stage {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 10%, #2b2f36 0%, #15171b 55%, #0b0c0e 100%);
}
.ossim-device {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  border-radius: var(--dev-radius, 68px);
  background: linear-gradient(145deg, #3a3d42, #1c1d20 40%, #2a2c30);
  box-shadow: 0 0 0 2px #0d0d0f, 0 0 0 3px #4a4d52, 0 30px 80px rgba(0,0,0,.65), inset 0 0 0 2px rgba(255,255,255,.06);
  padding: var(--dev-bezel, 14px);
}
.ossim-device .dev-screen {
  position: relative; width: 100%; height: 100%; overflow: hidden; background: #000;
  border-radius: calc(var(--dev-radius, 68px) - var(--dev-bezel, 14px));
  isolation: isolate;
}
.ossim-device .dev-btn {
  position: absolute; width: 5px; background: linear-gradient(90deg, #2b2d31, #4b4e54); border-radius: 3px; cursor: pointer;
}
.ossim-device .dev-btn:active { filter: brightness(1.4); }
.ossim-device .dev-btn.power { right: -5px; }
.ossim-device .dev-btn.vol-up, .ossim-device .dev-btn.vol-down, .ossim-device .dev-btn.action { left: -5px; }
.ossim-device.iphone .dev-btn.action { top: 17%; height: 4%; }
.ossim-device.iphone .dev-btn.vol-up { top: 24%; height: 7.5%; }
.ossim-device.iphone .dev-btn.vol-down { top: 33%; height: 7.5%; }
.ossim-device.iphone .dev-btn.power { top: 26%; height: 11%; }
.ossim-device.pixel { --dev-radius: 52px; --dev-bezel: 12px; background: linear-gradient(145deg, #2c2e33, #151619 45%, #26282c); }
.ossim-device.pixel .dev-btn { right: -5px; left: auto; }
.ossim-device.pixel .dev-btn.power { top: 20%; height: 7%; }
/* Pixel 的音量摇杆：视觉上是一根长键，分上下两段各自触发 */
.ossim-device.pixel .dev-btn.vol-up { top: 30%; height: 6.5%; border-radius: 3px 3px 0 0; }
.ossim-device.pixel .dev-btn.vol-down { top: 36.5%; height: 6.5%; border-radius: 0 0 3px 3px; }
.ossim-device.pixel .dev-btn.action { display: none; }
/* iPad（横屏）：顶部按钮在上边缘，音量键在右边缘 */
.ossim-device.ipad { --dev-radius: 42px; --dev-bezel: 22px; background: linear-gradient(145deg, #3b3e44, #1f2023 45%, #2d2f33); }
.ossim-device.ipad .dev-btn.action { display: none; }
.ossim-device.ipad .dev-btn.power { top: -5px; right: auto; left: 8%; width: 6%; height: 5px; background: linear-gradient(180deg, #4b4e54, #2b2d31); }
.ossim-device.ipad .dev-btn.vol-up { left: auto; right: -5px; top: 9%; height: 6%; }
.ossim-device.ipad .dev-btn.vol-down { left: auto; right: -5px; top: 16%; height: 6%; }
.ossim-stage .stage-exit {
  position: absolute; left: 16px; top: 14px; z-index: 5;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: #bbb;
  font: 12px/1 'OSSim Inter', system-ui, sans-serif; padding: 8px 12px; border-radius: 8px; cursor: pointer;
}
.ossim-stage .stage-exit:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ---------- 窗口管理器：只放行为相关的最少样式，外观由各系统决定 ---------- */
.wm-layer { position: absolute; inset: 0; pointer-events: none; }
.wm-layer > * { pointer-events: auto; }
.wm-win { position: absolute; display: flex; flex-direction: column; --wm-dur: .2s; }
.wm-win [data-wm-body] { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; overflow: hidden; }
.wm-win.wm-min { visibility: hidden; pointer-events: none; }
.wm-win.wm-anim { transition: transform var(--wm-dur) ease-in, opacity var(--wm-dur) ease-in; }
.wm-win.wm-anim-rect { transition: left .18s ease-out, top .18s ease-out, width .18s ease-out, height .18s ease-out; }
.wm-win.wm-opening { opacity: 0; transform: scale(.97); }
.wm-win { transition: opacity .16s ease-out, transform .16s ease-out; }
.wm-win.wm-moving, .wm-win.wm-resizing { transition: none; }
.wm-win.wm-closing { opacity: 0; transform: scale(.97); pointer-events: none; }
.wm-rs { position: absolute; z-index: 5; }
.wm-rs-n, .wm-rs-s { left: 6px; right: 6px; height: 6px; cursor: ns-resize; }
.wm-rs-n { top: -3px; } .wm-rs-s { bottom: -3px; }
.wm-rs-e, .wm-rs-w { top: 6px; bottom: 6px; width: 6px; cursor: ew-resize; }
.wm-rs-e { right: -3px; } .wm-rs-w { left: -3px; }
.wm-rs-ne, .wm-rs-nw, .wm-rs-se, .wm-rs-sw { width: 12px; height: 12px; }
.wm-rs-ne { top: -3px; right: -3px; cursor: nesw-resize; } .wm-rs-sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
.wm-rs-nw { top: -3px; left: -3px; cursor: nwse-resize; } .wm-rs-se { bottom: -3px; right: -3px; cursor: nwse-resize; }
.wm-win.wm-max .wm-rs { display: none; }
@media (pointer: coarse) {
  .wm-rs-n, .wm-rs-s { height: 14px; } .wm-rs-n { top: -7px; } .wm-rs-s { bottom: -7px; }
  .wm-rs-e, .wm-rs-w { width: 14px; } .wm-rs-e { right: -7px; } .wm-rs-w { left: -7px; }
  .wm-rs-ne, .wm-rs-nw, .wm-rs-se, .wm-rs-sw { width: 22px; height: 22px; }
}
.wm-layer.wm-dragging iframe, .wm-win:not(.wm-active) iframe { pointer-events: none; }
.wm-layer.wm-dragging { cursor: default; }
.wm-snap-preview { position: absolute; pointer-events: none; opacity: 0; transition: opacity .15s, left .15s, top .15s, width .15s, height .15s; }
.wm-snap-preview.show { opacity: 1; }

/* ---------- 终端（OSSim.Term）基础骨架；颜色/字体由系统覆盖 ---------- */
.ossim-term {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 6px;
  font-family: 'OSSim Mono', Consolas, monospace; font-size: 13px; line-height: 1.35;
  white-space: pre-wrap; word-break: break-all; cursor: text; user-select: text; -webkit-user-select: text;
  outline: none;
}
.ossim-term .t-line { min-height: 1.35em; }
.ossim-term .t-input-line { display: flex; flex-wrap: wrap; }
.ossim-term .t-input { position: relative; flex: 1 1 auto; min-width: 2ch; outline: none; white-space: pre-wrap; caret-color: transparent; }
.ossim-term .t-caret { display: inline-block; width: .6em; height: 1.15em; vertical-align: text-bottom; background: currentColor; animation: ossim-blink 1.06s steps(1) infinite; }
.ossim-term.t-unfocused .t-caret { animation: none; background: transparent; outline: 1px solid currentColor; outline-offset: -1px; }
.ossim-term.t-cursor-bar .t-caret { width: 2px; }
.ossim-term.t-cursor-under .t-caret { height: 2px; vertical-align: baseline; }
.ossim-term .t-hidden-input { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }
@keyframes ossim-blink { 50% { opacity: 0; } }
.ossim-term .c-black { color: var(--t-black, #000); } .ossim-term .c-red { color: var(--t-red, #c50f1f); }
.ossim-term .c-green { color: var(--t-green, #13a10e); } .ossim-term .c-yellow { color: var(--t-yellow, #c19c00); }
.ossim-term .c-blue { color: var(--t-blue, #0037da); } .ossim-term .c-magenta { color: var(--t-magenta, #881798); }
.ossim-term .c-cyan { color: var(--t-cyan, #3a96dd); } .ossim-term .c-white { color: var(--t-white, #ccc); }
.ossim-term .c-bright-black { color: var(--t-bblack, #767676); } .ossim-term .c-bright-red { color: var(--t-bred, #e74856); }
.ossim-term .c-bright-green { color: var(--t-bgreen, #16c60c); } .ossim-term .c-bright-yellow { color: var(--t-byellow, #f9f1a5); }
.ossim-term .c-bright-blue { color: var(--t-bblue, #3b78ff); } .ossim-term .c-bright-magenta { color: var(--t-bmagenta, #b4009e); }
.ossim-term .c-bright-cyan { color: var(--t-bcyan, #61d6d6); } .ossim-term .c-bright-white { color: var(--t-bwhite, #f2f2f2); }
.ossim-term .c-bold { font-weight: 700; }
.ossim-term .c-dim { opacity: .7; }
.ossim-term .c-underline { text-decoration: underline; }
.ossim-term .c-inverse { background: currentColor; }
.ossim-term .c-inverse > span { filter: invert(1); }
