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

:root {
  --bg: #0d0d0d;
  --card-bg: #1a1a24;
  --card-border: rgba(255, 255, 255, 0.08);
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --text: #f0f0f0;
  --text-muted: #888;
  --input-bg: #111119;
  --input-border: rgba(255, 255, 255, 0.12);
  --input-focus: #6c63ff;
  --error: #ff5c5c;
  --success: #4caf7d;
  --radius: 16px;
  --radius-btn: 100px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.container {
  width: 100%;
  max-width: 420px;
}

/* ── Screens ── */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

.screen.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 40px 32px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Logo ── */
.logo-area {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.logo {
  height: 72px;
  max-width: 100%;
  object-fit: contain;
  filter: invert(1);
}

/* ── Typography ── */
h1 {
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  text-align: center;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ── Form ── */
form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  width: 100%;
}

input[type="text"],
input[type="tel"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="tel"]:focus {
  border-color: var(--input-focus);
}

input::placeholder {
  color: var(--text-muted);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 14px 28px;
  transition: background 0.2s, opacity 0.2s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 8px 16px;
  margin-top: -8px;
}

.btn-ghost:hover {
  color: var(--text);
}

/* ── Method selector ── */
.method-selector {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.method-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-method {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  border-radius: 14px;
  padding: 16px 12px;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.btn-method:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Instance badge ── */
.instance-name-badge {
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: var(--radius-btn);
  padding: 6px 16px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
}

/* ── Connect content ── */
.connect-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.connect-content.hidden {
  display: none;
}

/* ── Loader ── */
.loader-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loader-area.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(108, 99, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Loader inline em botões */
.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.btn-loader.hidden { display: none; }

/* ── QR Code ── */
.qr-wrapper {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-image {
  width: 220px;
  height: 220px;
  display: block;
}

.status-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.timer-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.7;
  text-align: center;
}

/* ── Pair code ── */
.paircode-display {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 20px 32px;
  text-align: center;
}

#paircode-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2em;
}

/* ── Success ── */
#content-success {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 8px 0;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: rgba(76, 175, 125, 0.15);
  border: 2px solid var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--success);
}

/* ── Error ── */
.error-msg {
  font-size: 0.85rem;
  color: var(--error);
  text-align: center;
  padding: 0 4px;
}

.error-msg.hidden { display: none; }

.error-icon {
  width: 52px;
  height: 52px;
  background: rgba(255, 92, 92, 0.12);
  border: 2px solid var(--error);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--error);
}

.error-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Hidden utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 400px) {
  .card {
    padding: 32px 20px 24px;
  }

  #paircode-value {
    font-size: 1.75rem;
  }

  #qr-image {
    width: 190px;
    height: 190px;
  }
}
