* { box-sizing: border-box; }
[hidden] { display: none !important; }
:root { color-scheme: dark; font-family: system-ui, sans-serif; color: #edf0f4; background: #11151c; }
body { margin: 0; }
main { width: min(100%, 960px); margin: auto; padding: 18px 12px max(24px, env(safe-area-inset-bottom)); }
header, .device-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
header { padding: 0 2px 12px; }
h1, h2, p { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; overflow-wrap: anywhere; }
p { color: #bdc9db; padding: 10px 0; }
p:empty { display: none; }
label { display: flex; align-items: center; white-space: nowrap; gap: 5px; }
.devices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 265px), 1fr)); gap: 12px; align-items: start; }
.device { display: grid; gap: 10px; background: #1b222e; border-radius: 12px; padding: 10px; min-width: 0; }
canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 68vh; margin: auto; touch-action: none; border-radius: 4px; }
button, input { font: inherit; }
button { background: #303e54; color: #f1f6ff; border: 0; border-radius: 8px; padding: 8px 9px; min-height: 36px; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #94baff; outline-offset: 2px; }
.toggle { color: #131b29; background: #a5c6ff; }
.keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.keys button { font-size: 12px; }
.pin-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
nav, .device-actions, .script-tools, footer, .row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
nav { margin: 0 0 12px; }
nav > label { margin-left: auto; }
.device-actions { justify-content: flex-end; flex-wrap: nowrap; }
.device-title { min-width: 0; }
.device-label { padding: 3px 0 0; color: #a5c6ff; font-size: .87rem; overflow-wrap: anywhere; }
.panel, .recording { padding: 10px; margin: 0 0 12px; border-radius: 12px; background: #1b222e; }
.recording { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid #f59885; }
.script-row, .steps li { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 0; border-top: 1px solid #303e54; }
.script-row span, .steps li span { min-width: 0; overflow-wrap: anywhere; }
.row-actions { justify-content: flex-end; flex-shrink: 0; }
dialog { max-height: calc(100dvh - 24px); width: min(460px, calc(100% - 24px)); border: 1px solid #53647e; border-radius: 14px; background: #1b222e; padding: 15px; color: inherit; }
dialog::backdrop { background: rgb(10 14 23 / 75%); }
dialog form { display: grid; gap: 10px; }
dialog label { flex-direction: column; align-items: stretch; white-space: normal; }
.device-help { min-width: 0; padding: 9px; border: 1px solid #53647e; border-radius: 8px; }
.device-help summary { color: #a5c6ff; cursor: pointer; }
.device-help p { padding: 8px 0; }
.device-help p:last-child { padding-bottom: 0; }
[data-device-setup], .setup-fields { display: grid; gap: 7px; }
.setup-fields .device-actions { flex-wrap: wrap; justify-content: flex-start; }
#device-discovery p { padding: 6px 0; font-size: .9rem; }
.discovered-device { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid #53647e; padding: 7px 0; }
.discovered-device span { min-width: 0; overflow-wrap: anywhere; }
.discovered-device small { display: block; color: #bdc9db; }
dialog input, select { color: inherit; padding: 7px 8px; border: 1px solid #53647e; background: #141b25; border-radius: 8px; min-width: 0; min-height: 36px; font: inherit; }
dialog input[readonly] { opacity: .68; }
footer { justify-content: flex-end; }
.danger { margin-right: auto; color: #ffd0c8; }
.primary { background: #a5c6ff; color: #131b29; }
.step-editor { display: grid; gap: 8px; padding: 8px; border: 1px solid #53647e; border-radius: 8px; }
.fields { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 6px; }
.step-add { align-items: end; }
.steps { padding: 0; margin: 0; list-style: none; max-height: 165px; overflow: auto; }
.steps:empty { display: none; }
.steps button { min-width: 32px; }
.laptop-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.laptop-card-info { min-width: 0; }
.laptop-card p { padding: 3px 0 0; font-size: .9rem; }
.laptop-card small { display: block; color: #9eacc2; overflow-wrap: anywhere; }
.laptop-card button { flex-shrink: 0; }
.laptop-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
body.laptop-viewer-open { overflow: hidden; }
.laptop-viewer { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #0b1018; color: #edf0f4; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.laptop-viewer-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px; min-height: 48px; background: #1b222e; }
.laptop-viewer-head strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.laptop-viewer-head span { color: #a5c6ff; font-size: .85rem; white-space: nowrap; }
.laptop-viewer-head button { margin-left: auto; }
.laptop-stage { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; background: #10151e; }
.laptop-stage img { display: block; max-width: none; height: auto; margin: auto; touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none; }
.laptop-stage p { text-align: center; padding: 24px; }
.laptop-viewer-controls { background: #1b222e; padding: 6px 8px; display: grid; gap: 6px; }
.laptop-viewer-row { display: flex; gap: 6px; }
.laptop-viewer-row button { min-height: 42px; }
#laptop-zoom-reset { flex: 1; }
#laptop-text-toggle { flex: 1; }
#laptop-text { flex: 1; min-width: 0; border: 1px solid #53647e; border-radius: 8px; padding: 8px; background: #10151e; color: #edf0f4; }
.laptop-key-row button { flex: 1; }
.laptop-key-row button[aria-pressed="true"] { background: #a5c6ff; color: #131b29; }
@media (max-height: 450px) { .laptop-viewer-head { min-height: 38px; } .laptop-viewer-controls { padding: 4px 8px; gap: 4px; } .laptop-viewer-row button { min-height: 34px; } }
