:root {
  color-scheme: dark;
  background: #0e1116;
  color: #f1f4fb;
  font: 16px/1.5 Inter, system-ui, sans-serif;
  --muted: #a9b5c7;
  --line: #343e50;
  --surface: #171d27;
  --accent: #b1ccff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button, input {
  min-height: 44px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  background: var(--surface);
}
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.6; cursor: wait; }
button:hover:enabled { border-color: var(--accent); }
button[aria-pressed="true"], .primary { color: #10244b; background: var(--accent); font-weight: 650; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
p { margin: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.65rem; font-size: 1.1rem; font-weight: 750; }
.mark { width: 13px; height: 13px; border-radius: 4px; background: var(--accent); }
main { max-width: 1600px; margin: auto; padding: 1rem; }
.pair-panel {
  width: min(100%, 420px);
  margin: clamp(1.5rem, 12vh, 7rem) auto 0;
  padding: clamp(1.25rem, 5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}
.screen-mark { width: 34px; height: 23px; border: 2px solid var(--accent); border-radius: 4px; position: relative; }
.screen-mark::after { content: ''; position: absolute; width: 16px; height: 2px; left: 7px; bottom: -7px; background: var(--accent); }
h1 { margin: 1.5rem 0 0.5rem; line-height: 1.2; letter-spacing: -0.035em; }
.pair-panel p { color: var(--muted); }
.pair-panel form { display: grid; gap: 0.65rem; margin-top: 1.5rem; }
.pair-panel input { background: #0e1116; min-width: 0; }
#pair-error, #login-error, #input-error, #windows-error { color: #ffbcba; }
#login-error { margin-top: 0.7rem; }

body:has(.session:not([hidden])) .topbar { display: none; }
main:has(.session:not([hidden])) { padding: 0.5rem; }
.session { display: grid; gap: 0.4rem; }
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.35rem; }
.session-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.25rem; }
.session-actions button { min-height: 36px; padding: 0.25rem 0.5rem; font-size: 0.875rem; }
#status { color: var(--accent); }
.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  min-width: 0;
  min-height: min(24vh, 12rem);
  overflow: clip;
  background: #07090d;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}
#screen, #windows-screen { display: block; max-width: 100%; max-height: 65vh; touch-action: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
#windows-pointer { position: absolute; width: 12px; height: 17px; pointer-events: none; background: white; filter: drop-shadow(1px 1px 1px black); clip-path: polygon(0 0, 0 90%, 32% 62%, 53% 100%, 72% 90%, 53% 55%, 100% 55%); }
#windows-form { display: grid; gap: 0.65rem; align-self: start; width: min(100%, 360px); padding: 1.25rem; text-align: left; }
#windows-form h2 { margin: 0 0 0.35rem; font-size: 1.25rem; }
#windows-form input { min-width: 0; }
.windows-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.session:fullscreen {
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0.4rem;
  padding-bottom: calc(0.4rem + var(--keyboard-inset, 0px));
  background: #0e1116;
}
.session:fullscreen .stage { border: 0; border-radius: 0; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.session:fullscreen :is(#screen, #windows-screen) { max-height: 100%; }
#screen-message { color: var(--muted); padding: 1rem; }
#typing { position: absolute; inset: auto auto 0 0; width: 1px; height: 1px; opacity: 0; padding: 0; border: 0; font-size: 16px; pointer-events: none; }
.session-actions .keyboard-button { width: 36px; padding: 0; font-size: 1.125rem; }
@media (max-width: 440px) {
  .session-actions button:not(.keyboard-button) { padding-inline: 0.4rem; font-size: 0.8rem; }
  #status { font-size: 0.75rem; }
}
