:root {
  color-scheme: light dark;
  --bg: #f1f5f9;
  --bg-glow: #dbe7fb;
  --surface: #ffffff;
  --border: #d5dde8;
  --text: #0f172a;
  --muted: #566378;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 12px 32px rgb(15 23 42 / 10%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --bg-glow: #15233f;
    --surface: #131c2e;
    --border: #2a3750;
    --text: #e8edf5;
    --muted: #9aa8bd;
    --accent: #6b9bff;
    --accent-hover: #8ab0ff;
    --on-accent: #0b1220;
    --danger: #fda29b;
    --danger-bg: #3a1a18;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 16px 40px rgb(0 0 0 / 35%);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.in-desk { background: #202124; overflow: hidden; overscroll-behavior: none; }

button { font: inherit; cursor: pointer; }
.primary, .secondary {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 10px;
  font-weight: 600;
  transition: background-color .15s ease;
}
.primary { background: var(--accent); color: var(--on-accent); border: 1px solid transparent; }
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .65; cursor: progress; }
.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
:is(button, input):focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* Sign-in */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(90rem 40rem at 50% -10%, var(--bg-glow), transparent 70%), var(--bg);
}
.card {
  width: min(100%, 420px);
  padding: clamp(24px, 6vw, 40px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
h1 { margin: 0 0 4px; font-size: clamp(24px, 5vw, 28px); line-height: 1.2; letter-spacing: -.02em; }
.lead { margin: 0 0 24px; color: var(--muted); }
.field { margin-bottom: 16px; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
input[type=text], input[type=password] {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  /* 16px stops iOS zooming into the field */
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.password { position: relative; }
.password input { padding-right: 72px; }
#toggle-password {
  position: absolute;
  inset: 4px 4px 4px auto;
  width: 60px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.error { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }
form .primary { width: 100%; margin-top: 8px; }

/* Remote screen */
.desk, .screen { position: fixed; inset: 0; width: 100%; height: 100%; background: #202124; }
.screen { height: 100dvh; }

.status {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-radius: 10px;
  background: rgb(32 33 36 / 92%);
  color: #fff;
  font-size: 15px;
  white-space: nowrap;
}
.spinner { width: 18px; height: 18px; border: 2px solid rgb(255 255 255 / 30%); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

.sheet {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(calc(100% - 32px), 420px);
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.sheet h2 { margin: 0 0 4px; font-size: 18px; }
.sheet p { margin: 0 0 16px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions button { flex: 1; }
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgb(32 33 36 / 95%);
  color: #fff;
  font-size: 14px;
  z-index: 11;
}
.drop {
  position: fixed; inset: 12px;
  display: grid; place-items: center;
  border: 2px dashed #fff;
  border-radius: 14px;
  background: rgb(15 23 42 / 70%);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  pointer-events: none;
  z-index: 12;
}

.keyboard-toggle {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgb(32 33 36 / 55%);
  color: #fff;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}
.keyboard-input {
  position: fixed; left: 0; bottom: 0;
  width: 1px; height: 1px;
  opacity: 0;
  border: 0; padding: 0;
  font-size: 16px;
  resize: none;
}
