:root {
  color-scheme: light;
  --bg: #EEF1F5;
  --surface: #FFFFFF;
  --ink: #18202D;
  --muted: #5B6676;
  --line: #D5DBE4;
  --accent: #2B55E0;
  --accent-ink: #FFFFFF;
  --live: #D98E04;
  --ok: #17905F;
  --bad: #C23A26;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121821;
    --surface: #1A2230;
    --ink: #E4E9F0;
    --muted: #98A3B3;
    --line: #2A3445;
    --accent: #7393FF;
    --accent-ink: #0D1320;
    --live: #F0B03A;
    --ok: #39C38B;
    --bad: #F2705C;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body { overscroll-behavior: none; }

.view { display: none; min-height: 100%; }
.view.on { display: flex; }
.view:not(.session) {
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.panel { width: min(100%, 380px); margin: auto; padding: 32px 24px; }
.panel.wide { width: min(100%, 540px); }

h1 { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.01em; margin: 0; line-height: 1.2; }
.sub { color: var(--muted); margin: 6px 0 8px; }

label { display: block; font-size: 0.875rem; color: var(--muted); margin-top: 16px; }
input {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
}
button {
  font: inherit; cursor: pointer; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
button:disabled { opacity: 0.6; cursor: default; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; width: 100%; margin-top: 24px; padding: 13px; font-weight: 600; }
.ghost { background: transparent; }
.err { color: var(--bad); min-height: 1.4em; font-size: 0.875rem; margin: 12px 0 0; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }

/* Computer list: each row is a small monitor with a status lamp */
.hosts { list-style: none; padding: 0; margin: 0 0 16px; border-top: 1px solid var(--line); }
.hosts li { display: flex; align-items: center; gap: 16px; padding: 16px 2px; border-bottom: 1px solid var(--line); }
.glyph { position: relative; flex: none; width: 42px; height: 30px; border: 2px solid var(--ink); border-radius: 4px; margin-bottom: 6px; }
.glyph::after { content: ""; position: absolute; left: 50%; bottom: -8px; width: 16px; height: 3px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); }
.glyph i { position: absolute; right: 4px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.glyph.busy i { background: var(--live); }
.grow { flex: 1; min-width: 0; }
.hosts .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hosts .meta { display: block; font-size: 0.85rem; color: var(--muted); }
.hosts button { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.empty { color: var(--muted); margin: 0 0 16px; }

/* Session: always dark, the remote screen is the content */
.session { position: fixed; inset: 0; flex-direction: column; background: #000; }
#stage { position: relative; flex: 1; overflow: hidden; touch-action: none; background: #000; user-select: none; -webkit-user-select: none; }
#screen { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#video { display: block; width: 100%; height: 100%; background: #000; pointer-events: none; }
#overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px; text-align: center; color: #E4E9F0; background: rgba(8, 11, 16, 0.72);
}
#overlay.hide { display: none; }
#overlay p { margin: 0; max-width: 34ch; }
.light { color: #E4E9F0; border-color: #3A465A; }

#toolbar {
  display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none;
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  background: #151B26; border-top: 1px solid #263042;
}
#toolbar::-webkit-scrollbar { display: none; }
#toolbar button {
  flex: none; min-width: 44px; min-height: 40px; padding: 8px 12px; font-size: 0.9rem;
  background: #1F2735; color: #E4E9F0; border-color: #2E384B;
}
#toolbar button[aria-pressed="true"] { background: #F0B03A; color: #151B26; border-color: #F0B03A; }
#toolbar .end { margin-left: auto; background: #3B2020; border-color: #5C2B2B; }
#stats { flex: none; padding: 0 8px; font-size: 0.8rem; color: #98A3B3; white-space: nowrap; font-variant-numeric: tabular-nums; }

#kbd { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; resize: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
