:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --text: #f2f3f5;
  --muted: #9aa0ab;
  --accent: #4f8cff;
  --danger: #ff5c5c;
  --bar: rgba(20, 22, 28, 0.92);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
}
[hidden] { display: none !important; }

.panel {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.card { width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 56px; margin-bottom: 8px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; }

input, button { font: inherit; }
input[type=password] {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid #2c313b;
  background: var(--card); color: var(--text); margin-bottom: 12px; -webkit-user-select: text; user-select: text;
}
button { border: 0; border-radius: 12px; padding: 14px 16px; width: 100%; margin-top: 8px; cursor: pointer; }
.primary { background: var(--accent); color: #fff; font-weight: 600; }
.secondary { background: #2a2f3a; color: var(--text); }
.danger { background: var(--danger); color: #fff; font-weight: 600; }
.link { background: none; color: var(--muted); }
button:disabled { opacity: 0.5; }

#remote { position: fixed; inset: 0; display: flex; flex-direction: column; background: #000; }
#screen { flex: 1; min-height: 0; position: relative; overflow: hidden; }
#toolbar {
  display: flex; gap: 4px; padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  background: var(--bar); overflow-x: auto;
}
#toolbar button {
  width: auto; flex: 1 1 0; margin: 0; padding: 10px 2px; min-width: 38px; white-space: nowrap;
  background: #262a33; color: var(--text); font-size: 14px; border-radius: 10px;
}
#toolbar button.on { background: var(--accent); }
#kbd { position: absolute; left: -1000px; top: 0; width: 10px; height: 10px; opacity: 0; font-size: 16px; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: flex-end; z-index: 10; }
.sheet-body {
  width: 100%; background: var(--card); border-radius: 18px 18px 0 0;
  padding: 18px 16px max(16px, env(safe-area-inset-bottom)); max-height: 80%; overflow-y: auto;
}
#sheet-items button { background: #262a33; color: var(--text); text-align: left; }
#sheet-items button.danger { background: var(--danger); color: #fff; }

#toast {
  position: fixed; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translateX(-50%);
  background: #2a2f3a; color: var(--text); padding: 10px 16px; border-radius: 12px; z-index: 20;
  max-width: 90%; box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
#toast.error { background: var(--danger); color: #fff; }
