:root {
  --bg-primary: #0a0a0a;
  --bg-card: #121212;
  --bg-card-subtle: #18181b;
  --border-subtle: #27272a;
  --border-strong: #3f3f46;
  
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  --accent-white: #ffffff;
  --accent-black: #000000;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Subtle background noise texture */
.noise-overlay {
  position: fixed;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
}

.page-container {
  width: 100%;
  max-width: 460px;
  padding: 24px 20px;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  background: var(--accent-white);
  color: var(--accent-black);
  padding: 3px 7px;
  border-radius: 4px;
}

.brand-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

/* Status Pill */
.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}

.connection-pill.online .status-dot {
  background: var(--accent-white);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.connection-pill.waiting .status-dot {
  background: #a1a1aa;
  animation: pulse 1.8s infinite ease-in-out;
}

.connection-pill.error .status-dot {
  background: #ef4444;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  transition: var(--transition);
}

.section-view {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.section-view.active {
  display: flex;
}

.card-header {
  margin-bottom: 24px;
}

.card-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 320px;
  margin: 0 auto;
}

/* QR Code Box */
.qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.qr-box {
  width: 260px;
  height: 260px;
  background: var(--accent-white);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 4px;
  transition: opacity 0.3s ease;
}

.qr-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--accent-black);
  font-size: 12px;
  font-weight: 500;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--accent-black);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.qr-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
}

.overlay-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Progress bar */
.countdown-bar-container {
  width: 260px;
  height: 3px;
  background: var(--bg-card-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.countdown-bar {
  width: 100%;
  height: 100%;
  background: var(--accent-white);
  transition: width 1s linear;
}

/* Pairing code */
.pairing-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.pairing-label {
  font-size: 12px;
  color: var(--text-muted);
}

.pairing-code {
  font-size: 14px;
  font-family: monospace;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent-white);
}

/* Buttons */
.actions-row {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-white);
  color: var(--accent-black);
}

.btn-primary:hover {
  background: #e4e4e7;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
  background: #202023;
}

.btn-outline-danger {
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

/* Steps Instructions */
.instructions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 22px;
  text-align: left;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-secondary);
}

.step-num {
  font-size: 11px;
  font-weight: 700;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--bg-card-subtle);
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

/* Connected View */
.connected-icon-wrapper {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--accent-white);
}

.connected-details {
  width: 100%;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 22px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.detail-label {
  color: var(--text-muted);
}

.detail-value {
  font-family: monospace;
  color: var(--text-primary);
  font-weight: 500;
}

.detail-value.status-online {
  color: var(--accent-white);
  font-weight: 600;
}

/* Footer */
.footer {
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.instance-id {
  font-family: monospace;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px 8px;
  border-radius: 5px;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.copy-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-subtle);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  background: var(--accent-white);
  color: var(--accent-black);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  z-index: 100;
  transition: var(--transition);
}

.hidden {
  display: none !important;
}
