* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #0a0a0a;
  color: #d4d4d4;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ── Login Screen ─────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #111;
  border: 1px solid #222;
  border-radius: 12px;
  padding: 40px 32px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.login-card .subtitle {
  font-size: 13px;
  color: #666;
  margin-bottom: 28px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 8px;
  color: #d4d4d4;
  font-size: 16px; /* prevents iOS zoom */
  outline: none;
  transition: border-color 0.2s;
}

.login-card input:focus {
  border-color: #d4c36a;
}

.login-card button {
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: #d4c36a;
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-card button:hover {
  opacity: 0.9;
}

.login-card button:active {
  opacity: 0.8;
}

.login-card button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error-msg {
  color: #ff4444;
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* ── Terminal Screen ──────────────────────────────────── */
#terminal-screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
}

#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 12px;
  background: #111;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

#top-bar .status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #39ff14;
  transition: background 0.3s;
}

.status-dot.disconnected {
  background: #ff3914;
}

.status-dot.reconnecting {
  background: #ffaa00;
  animation: pulse 1s ease-in-out infinite;
}

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

#top-bar .actions {
  display: flex;
  gap: 8px;
}

#top-bar button {
  background: none;
  border: 1px solid #333;
  color: #888;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

#top-bar button:hover {
  border-color: #555;
  color: #ccc;
}

#terminal-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── xterm.js overrides ───────────────────────────────── */
.xterm {
  height: 100%;
  padding: 4px;
}

.xterm-viewport {
  overflow-y: auto !important;
}

.xterm-screen {
  height: 100%;
}

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .login-card {
    padding: 32px 24px;
  }

  #terminal-container {
    touch-action: manipulation;
  }
}

/* Prevent iOS overscroll */
body {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ── Keyboard helper (iOS) ────────────────────────────── */
#keyboard-toggle {
  display: none;
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #d4c36a;
  color: #0a0a0a;
  border: none;
  font-size: 20px;
  cursor: pointer;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  touch-action: manipulation;
}

@media (max-width: 768px) {
  #keyboard-toggle {
    display: block;
  }
}
