:root {
  color-scheme: light;
  --shell: #eeefeb;
  --ink: #222823;
  --muted: #626b63;
  --line: #c6cbc3;
  --accent: #267353;
  font: 15px -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--shell); color: var(--ink);
}
header, main, aside { width: min(100%, 1080px); margin-inline: auto; }
header { display: flex; align-items: center; gap: 9px; padding: 3px 10px 3px 16px; }
.brand { display: flex; align-items: center; gap: 7px; margin-right: auto; font-size: 17px; font-weight: 670; letter-spacing: -.055em; }
svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.brand svg { width: 26px; height: 26px; }
#state { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
#state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #8a918a; }
#state.online::before { background: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon { display: grid; place-items: center; width: 44px; height: 44px; background: transparent; border: none; border-radius: 50%; }
.icon:active { background: #dde1db; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 clamp(6px, 2vw, 18px) 6px; gap: 6px; }
#monitor { position: relative; min-height: 0; flex: 1; display: grid; place-items: center; background: #141816; border-radius: 12px; overflow: hidden; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#screen:not([src]), [hidden], body.padonly #monitor, body.padonly #keys { display: none !important; }
#hint { color: #aab2aa; display: grid; justify-items: center; gap: 10px; font-size: 12px; }
#hint svg { width: 32px; height: 32px; }
#surface { flex: 1.12; min-height: 0; display: flex; flex-direction: column; container-type: size; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#keys { display: grid; gap: 3px; padding: 4px 0; }
#keys div { display: flex; gap: clamp(2px, .7vw, 5px); }
#keys button { flex: 1; min-width: 0; height: clamp(16px, 7.7cqh, 42px); padding: 0; border: 0; border-radius: 4px; background: #303630; color: #fafbf8; box-shadow: inset 0 -1px #1e231e; font-size: clamp(9px, 2.6vw, 15px); font-weight: 500; }
#keys div:first-child button { height: clamp(15px, 6.3cqh, 32px); background: #444b44; font-size: clamp(9px, 2.2vw, 12px); }
#keys button[data-code="49"] { flex: 4; }
#keys button.active, #keys button:active { background: var(--accent); }
#pad { position: relative; flex: 1; min-height: 0; display: grid; place-items: end center; margin-top: 4px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #e5e8e2; }
#pad small { margin-bottom: 9px; color: #677166; font-size: 9px; font-weight: 600; letter-spacing: .2em; }
aside:not(:empty), #panel-error:not(:empty) { padding: 8px 12px; font-size: 13px; color: #823f2c; }
dialog { width: min(340px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; color: var(--ink); border: 1px solid #d5d9d2; border-radius: 18px; background: #fafbf8; box-shadow: 0 12px 55px #10171126; }
dialog::backdrop { background: #17201855; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
h1 { margin: 0; font-size: 23px; font-weight: 640; letter-spacing: -.045em; }
#close { margin: -8px -8px -8px 0; color: var(--muted); font-size: 25px; }
label { display: block; margin-bottom: 7px; font-size: 12px; color: var(--muted); }
input, select { width: 100%; height: 44px; padding-inline: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; }
#connect, #disconnect { width: 100%; min-height: 44px; margin-top: 14px; border: 0; border-radius: 8px; }
#connect { display: flex; justify-content: space-between; align-items: center; padding-inline: 14px; background: var(--ink); color: white; font-weight: 600; }
#disconnect { background: #e8ebe5; }
output { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-height: 480px) {
  header { padding-block: 0; }
  main { gap: 3px; }
  #surface { flex: 1.55; }
  #keys { gap: 1px; padding-block: 2px; }
  #pad small { margin-bottom: 4px; }
}

/* The glass over the image is also the relative trackpad. The header stays reachable. */
.immersive main { position: relative; width: 100%; max-width: none; padding: 0; }
.immersive #monitor { border-radius: 0; }
.immersive #surface { position: absolute; inset: 0; }
.immersive #keys, .immersive #pad { display: none; }
