
:root {
  color-scheme: dark;
  --bg: #0c0d10;
  --surface: #15171c;
  --surface-hover: #1e2129;
  --line: rgba(236, 239, 244, 0.14);
  --reticle: rgba(236, 239, 244, 0.22);
  --ink: #eceff4;
  --muted: #8b92a2;
  --signal: #38d9a9;
  --warn: #f0b429;
  --danger: #ef6461;
  --font-sans: "Inter", "SF Pro Display", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

button, input {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible, input:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

/* Studio monitor hairline corner reticle */
.reticle {
  position: fixed;
  inset: 14px;
  pointer-events: none;
  z-index: 1;
}

.corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--reticle);
  border-style: solid;
  border-width: 0;
}

.corner.tl { top: 0; left: 0; border-top-width: 1.5px; border-left-width: 1.5px; }
.corner.tr { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 1.5px; border-left-width: 1.5px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }

/* Login view */
.login-view {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  z-index: 2;
}

.login-view[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.85rem;
  color: var(--muted);
}

.field input,
.name-form input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 1rem;
  min-height: 44px;
  user-select: text;
}

/* Standby slate */
.standby {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  z-index: 2;
}

.standby[hidden] { display: none; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tally {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.dot[data-state="ready"] {
  background: var(--signal);
  box-shadow: 0 0 10px rgba(56, 217, 169, 0.45);
}

.dot[data-state="connecting"] {
  background: var(--warn);
  animation: pulse 1.6s ease-in-out infinite;
}

.dot[data-state="offline"] {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.slate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding-bottom: 24px;
}

.name-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.name-row[hidden] { display: none; }

.device-name {
  margin: 0;
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
  text-wrap: balance;
}

.name-form {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.name-form[hidden] { display: none; }

.name-form input {
  min-width: 210px;
}

.resolution {
  margin: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--muted);
}

.actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.pill-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}

.pill-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: rgba(236, 239, 244, 0.28);
}

.pill-btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.pill-btn.primary:hover:not(:disabled) {
  background: #ffffff;
}

.pill-btn.full {
  width: 100%;
  margin-top: 4px;
}

.pill-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(21, 23, 28, 0.78);
  color: var(--ink);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.icon-btn:hover {
  background: var(--surface-hover);
}

.icon-btn.subtle {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.icon-btn.subtle:hover {
  color: var(--ink);
  background: var(--surface);
}

.icon-btn[aria-pressed="true"] {
  color: var(--muted);
  border-color: var(--warn);
}

.icon-btn.danger:hover {
  color: var(--danger);
  border-color: rgba(239, 100, 97, 0.5);
}

.error-msg {
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 0.875rem;
  max-width: 40ch;
}

/* Live VNC stage */
.stage {
  position: fixed;
  inset: 0;
  background: #000;
  touch-action: none;
  z-index: 10;
}

.stage[hidden] { display: none; }

.vnc-screen {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.kbd-proxy {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.hud {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 14px;
  background: rgba(12, 13, 16, 0.76);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 20;
  transition: opacity 220ms ease, transform 220ms ease;
}

.hud[data-visible="false"] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}

.hud-wake {
  position: fixed;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: transparent;
  border: 0;
  z-index: 15;
  cursor: pointer;
}

/* Pull-a-window dialog */
.picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.picker-backdrop[hidden] { display: none; }

@media (min-width: 640px) {
  .picker-backdrop {
    align-items: center;
  }
}

.picker-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 78vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px 18px;
  border-bottom: 1px solid var(--line);
}

.picker-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.picker-head-actions {
  display: flex;
  gap: 4px;
}

.picker-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.win-row {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  min-height: 48px;
  transition: background 120ms ease, border-color 120ms ease;
}

.win-row:hover {
  background: var(--surface-hover);
  border-color: var(--line);
}

.win-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.win-title {
  font-size: 0.94rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-sub {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-ws {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(236, 239, 244, 0.06);
}

.win-ws.here {
  color: var(--signal);
  background: rgba(56, 217, 169, 0.12);
}

.picker-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  .dot[data-state="connecting"] { animation: none; }
  .pill-btn, .icon-btn, .hud, .win-row { transition: none; }
}
