:root { --safe-t: env(safe-area-inset-top); --safe-b: env(safe-area-inset-bottom); --safe-l: env(safe-area-inset-left); --safe-r: env(safe-area-inset-right); --acc: #0a84ff; --kb: 0px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: #f5f5f7; font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#app { position: absolute; inset: 0; }
.hidden { display: none !important; }
.screen { position: absolute; inset: 0; }
.muted { color: #8e8e93; } .small { font-size: 13px; } .err { color: #ff453a; min-height: 1.2em; font-size: 14px; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
input { font: inherit; font-size: 17px; }
.primary { background: var(--acc); color: #fff; border-radius: 12px; padding: 14px; width: 100%; font-weight: 600; }
.primary:active { opacity: .8; }

/* login */
#login { display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(120% 80% at 50% 0%, #16233b 0%, #000 60%); }
.card { width: 100%; max-width: 360px; text-align: center; }
.logo img { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 10px 40px rgba(10,132,255,.35); }
h1 { font-size: 28px; margin: 14px 0 4px; letter-spacing: -.02em; }
#loginForm { margin-top: 26px; display: grid; gap: 12px; }
#loginForm input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid #2c2c2e; background: #1c1c1e; color: #fff; outline: none; -webkit-user-select: text; user-select: text; }
#loginForm input:focus { border-color: var(--acc); }

/* picker */
#picker { overflow-y: auto; padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 18px); background: radial-gradient(120% 60% at 50% 0%, #121c2e 0%, #000 55%); }
.pickhead { display: flex; align-items: center; justify-content: space-between; }
.pickhead h1 { font-size: 34px; margin: 6px 0 14px; }
.iconbtn { font-size: 22px; width: 44px; height: 44px; border-radius: 22px; background: #1c1c1e; }
#machines { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.mcard { background: linear-gradient(180deg, #1c1c1e, #151517); border: 1px solid #2c2c2e; border-radius: 20px; padding: 18px; display: grid; gap: 12px; transition: transform .12s; }
.mcard:active { transform: scale(.985); }
.mtop { display: flex; align-items: center; gap: 14px; }
.micon { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg,#2a3a5a,#0f1726); display: grid; place-items: center; font-size: 26px; }
.mname { font-size: 19px; font-weight: 600; }
.mstat { font-size: 14px; color: #8e8e93; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: #636366; display: inline-block; flex: none; }
.dot.green { background: #30d158; box-shadow: 0 0 8px #30d158; } .dot.yellow { background: #ffd60a; } .dot.red { background: #ff453a; }
.mbtns { display: flex; gap: 10px; }
.mbtns button { flex: 1; padding: 12px; border-radius: 12px; background: #2c2c2e; font-weight: 600; font-size: 15px; }
.mbtns button.go { background: var(--acc); }
.mbtns button:disabled { opacity: .4; }
.mnote { font-size: 13px; color: #ffd60a; }

/* session */
#session { background: #000; }
#stage { position: absolute; left: 0; top: 0; width: 100%; height: var(--vvh, 100%); overflow: hidden; touch-action: none; }
#surface { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#surface canvas { display: block; width: 100% !important; height: 100% !important; image-rendering: auto; margin: 0 !important; }
#overlay { position: absolute; inset: 0; touch-action: none; }
#ring { position: absolute; left: 0; top: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%; border: 2px solid rgba(255,255,255,.85); background: rgba(10,132,255,.25); pointer-events: none; opacity: 0; transition: opacity .15s, background .1s, width .1s, height .1s; will-change: transform; }
#ring.on { opacity: 1; } #ring.down { background: rgba(10,132,255,.7); }
#stats { position: absolute; left: calc(var(--safe-l) + 8px); top: calc(var(--safe-t) + 8px); font: 600 11px/1.3 ui-monospace, Menlo, monospace; background: rgba(0,0,0,.55); padding: 4px 7px; border-radius: 6px; pointer-events: none; color: #9cff9c; white-space: pre; }
#pill { position: absolute; top: calc(var(--safe-t) + 6px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 12px; border-radius: 20px; background: rgba(30,30,32,.62); -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6); font-size: 13px; font-weight: 600; opacity: .55; transition: opacity .2s; }
#pill:active, #pill:hover { opacity: 1; }
.pillbtn { width: 30px; height: 30px; border-radius: 15px; background: rgba(255,255,255,.12); font-size: 13px; }
#toast { position: absolute; top: calc(var(--safe-t) + 50px); left: 50%; transform: translateX(-50%); background: rgba(30,30,32,.85); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); padding: 10px 16px; border-radius: 14px; font-size: 14px; max-width: 86vw; text-align: center; pointer-events: none; }
#bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px calc(var(--safe-r) + 6px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 6px); background: rgba(22,22,24,.72); -webkit-backdrop-filter: blur(24px) saturate(1.8); backdrop-filter: blur(24px) saturate(1.8); border-top: .5px solid rgba(255,255,255,.08); transform: translateY(calc(-1 * var(--kb))); will-change: transform; }
#session.kbopen #bar { padding-bottom: 6px; }
#bar.hidden-bar { display: none; }
.row { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; touch-action: pan-x; }
.row::-webkit-scrollbar { display: none; }
.k { flex: none; min-width: 44px; height: 42px; padding: 0 11px; border-radius: 10px; background: rgba(255,255,255,.1); font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; transition: background .08s, transform .08s; }
.k:active, .k.pressed { background: rgba(255,255,255,.28); transform: scale(.94); }
.k.on { background: var(--acc); } .k.lock { background: #ff9f0a; color: #000; }
.k.wide { padding: 0 14px; } .k.acc { background: rgba(10,132,255,.35); }
.sep { flex: none; width: 1px; background: rgba(255,255,255,.12); margin: 6px 2px; }
#kbd { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; font-size: 16px; border: 0; padding: 0; resize: none; caret-color: transparent; color: transparent; background: transparent; pointer-events: none; }

/* sheet */
#sheetBack { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
#sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 21; background: #1c1c1e; border-radius: 22px 22px 0 0; padding: 18px 18px calc(var(--safe-b) + 18px); max-height: 88%; overflow-y: auto; }
#sheet h2 { margin: 2px 0 12px; font-size: 20px; }
#sheet label { display: block; font-size: 13px; color: #8e8e93; margin: 12px 0 6px; }
#sheet input[type=text], #sheet input[type=password] { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid #2c2c2e; background: #000; color: #fff; outline: none; -webkit-user-select: text; user-select: text; }
.seg { display: flex; background: #2c2c2e; border-radius: 10px; padding: 2px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.seg button.on { background: #636366; }
.trow { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: .5px solid #2c2c2e; }
.switch { width: 51px; height: 31px; border-radius: 16px; background: #39393d; position: relative; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch.on { background: #30d158; } .switch.on::after { transform: translateX(20px); }
.sbtns { display: grid; gap: 10px; margin-top: 16px; }
.sbtns button { padding: 13px; border-radius: 12px; background: #2c2c2e; font-weight: 600; }
.sbtns button.primary { background: var(--acc); }
.sbtns button.danger { color: #ff453a; }
