:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: rgba(24, 27, 36, 0.92);
  --surface-solid: #181b24;
  --border: rgba(255, 255, 255, 0.1);
  --text: #eef0f5;
  --muted: #9aa1b2;
  --accent: #4f8cff;
  --accent-text: #ffffff;
  --ok: #34c77b;
  --warn: #f0a33a;
  --bad: #ef5b5b;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button, select, input { font: inherit; color: inherit; }

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* Holding a control must not select its label or pop up the iOS copy menu. */
button, .bar, .keys, .panel, .overlay {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- login ---------- */

.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
}

.logo { align-self: center; border-radius: 14px; margin-bottom: 10px; }
.card h1 { margin: 0; text-align: center; font-size: 24px; }
.sub { margin: 4px 0 20px; text-align: center; color: var(--muted); }
.card label { font-size: 14px; color: var(--muted); margin: 10px 0 6px; }

.card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f1219;
  font-size: 17px;
}
.card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.card button[type=submit] {
  margin-top: 22px;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  font-size: 17px;
}
.card button:disabled { opacity: 0.6; }

.msg { min-height: 1.4em; margin: 14px 0 0; text-align: center; color: var(--bad); font-size: 15px; }

/* ---------- viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

#screen {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.bar {
  position: absolute;
  top: calc(8px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  max-width: calc(100% - 16px - var(--safe-left) - var(--safe-right));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10;
}

.bar button, .bar select {
  height: 34px;
  min-width: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 15px;
  white-space: nowrap;
}
.bar select { -webkit-appearance: none; appearance: none; padding-right: 12px; max-width: 130px; }
.bar button.on { background: var(--accent); color: var(--accent-text); }

.dot {
  width: 12px;
  height: 12px;
  margin: 0 4px 0 6px;
  flex: none;
  border-radius: 50%;
  background: var(--warn);
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.show-bar {
  position: absolute;
  top: calc(6px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  width: 36px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  z-index: 10;
}

.panel {
  position: absolute;
  top: calc(58px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100% - 16px));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 11;
}

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0; }
.row.buttons { margin-top: 12px; }
.row.buttons button { flex: 1; }
.label { color: var(--muted); font-size: 14px; }
.hint { margin: 2px 0 8px; color: var(--muted); font-size: 13px; }

.panel button {
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.09);
  font-size: 14px;
}
.panel button.danger { color: var(--bad); }

.seg { display: flex; background: rgba(255, 255, 255, 0.06); border-radius: 9px; padding: 2px; }
.seg button { background: transparent; padding: 7px 10px; }
.seg button.on { background: var(--accent); color: var(--accent-text); }

.help h2 { margin: 0 0 8px; font-size: 17px; }
.help ul { margin: 0 0 12px; padding-left: 18px; font-size: 15px; }
.help li { margin: 5px 0; }
.help button { width: 100%; }

.keys {
  position: absolute;
  left: 50%;
  bottom: calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100% - 16px));
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.keyrow { display: flex; gap: 5px; }
.keyrow + .keyrow { margin-top: 5px; }
.keyrow button {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 2px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 14px;
}
.keyrow button { touch-action: none; }
.keyrow button.on { background: var(--accent); color: var(--accent-text); }
.keyrow button.down { background: rgba(255, 255, 255, 0.3); }

.overlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 32px);
  padding: 16px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  z-index: 5;
}
.overlay p { margin: 0; }
.overlay button {
  margin-top: 12px;
  padding: 9px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* Stays focusable for the iOS keyboard while invisible. */
.kb {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  font-size: 16px;
  border: 0;
  padding: 0;
  caret-color: transparent;
}
