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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #e3f0ff 0%, #f0f4ff 50%, #e8ecf4 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a2e;
  -webkit-font-smoothing: antialiased;
}

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

.card {
  background: #fff;
  border-radius: 20px;
  padding: 48px 36px;
  box-shadow:
    0 4px 24px rgba(42, 171, 238, 0.08),
    0 1px 4px rgba(0, 0, 0, 0.04);
  text-align: center;
  transition: transform 0.2s ease;
}

.logo {
  margin-bottom: 28px;
}

.logo svg {
  filter: drop-shadow(0 2px 8px rgba(42, 171, 238, 0.3));
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #1a1a2e;
}

.subtitle {
  font-size: 0.95rem;
  color: #6b7280;
  margin-bottom: 24px;
  line-height: 1.5;
}

.state {
  animation: fadeIn 0.3s ease;
}

.hidden {
  display: none !important;
}

/* Spinner */
.spinner {
  width: 36px;
  height: 36px;
  margin: 8px auto 0;
  border: 3px solid #e5e7eb;
  border-top-color: #2AABEE;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  background: linear-gradient(135deg, #2AABEE, #229ED9);
  color: #fff;
  box-shadow: 0 2px 12px rgba(42, 171, 238, 0.35);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(42, 171, 238, 0.45);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #f3f4f6;
  color: #4b5563;
  box-shadow: none;
}

.btn-secondary:hover {
  background: #e5e7eb;
  box-shadow: none;
}

.hint {
  font-size: 0.82rem;
  color: #9ca3af;
  margin-top: 16px;
}

/* Avatar */
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #2AABEE, #229ED9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  background: #ecfdf5;
  color: #059669;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.error-text {
  color: #dc2626;
}

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

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

/* Dashboard */
.dashboard-container {
  max-width: 500px;
}

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

.badge-success {
  background: #ecfdf5;
  color: #059669;
  font-size: 0.95rem;
  padding: 8px 20px;
}

.profile-section {
  margin-bottom: 28px;
}

.avatar-lg {
  width: 88px;
  height: 88px;
  font-size: 2.2rem;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: #f3f4f6;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 24px;
}

.info-item {
  background: #fff;
  padding: 14px 16px;
  text-align: left;
}

.info-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 4px;
}

.info-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: #1a1a2e;
  word-break: break-all;
}

.session-active {
  color: #059669;
}

.session-expired {
  color: #dc2626;
}

.token-section {
  margin-bottom: 24px;
  text-align: left;
}

.token-box {
  margin-top: 6px;
  padding: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.72rem;
  color: #6b7280;
  word-break: break-all;
  line-height: 1.5;
  max-height: 80px;
  overflow-y: auto;
}

.dashboard-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  box-shadow: none;
}

.btn-danger:hover {
  background: #fecaca;
  box-shadow: none;
}

/* Callback page */
.callback-container {
  max-width: 600px;
}

.inline-code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.85em;
  color: #6366f1;
}

.cb-section {
  margin-top: 28px;
  margin-bottom: 24px;
  text-align: left;
}

.cb-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #1a1a2e;
}

.cb-description {
  font-size: 0.88rem;
  color: #6b7280;
  line-height: 1.6;
  margin-bottom: 16px;
}

.cb-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0;
}

.cb-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #9ca3af;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s ease;
}

.cb-tab:hover {
  color: #4b5563;
}

.cb-tab.active {
  color: #2AABEE;
  border-bottom-color: #2AABEE;
}

.cb-panel {
  margin-top: 0;
}

.code-block {
  background: #1a1a2e;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 0 0 10px 10px;
  overflow-x: auto;
  font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.7;
  margin: 0;
  text-align: left;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

.code-block code {
  color: inherit;
  font: inherit;
}

.cb-tip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 24px;
  text-align: left;
  font-size: 0.85rem;
  color: #1e40af;
  line-height: 1.6;
}

.cb-tip ol {
  margin: 8px 0 0 18px;
  padding: 0;
}

.cb-tip li {
  margin-bottom: 4px;
}

.cb-tip code {
  background: #dbeafe;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.82em;
}

/* Redirect progress bar */
.redirect-progress {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}

.redirect-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2AABEE, #229ED9);
  border-radius: 3px;
  animation: redirectProgress 3s linear forwards;
}

@keyframes redirectProgress {
  0% { width: 0; }
  100% { width: 100%; }
}

.redirect-fallback-reveal {
  animation: fadeIn 0.3s ease;
}

/* Debug panel */
.debug-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  font-family: 'SF Mono', SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.75rem;
}

.debug-toggle {
  display: inline-block;
  padding: 6px 14px;
  margin: 0 0 0 12px;
  background: #1a1a2e;
  color: #a3e635;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.debug-toggle:hover {
  background: #2d2d4a;
}

.debug-body {
  background: #1a1a2e;
  color: #e2e8f0;
  padding: 16px;
  max-height: 50vh;
  overflow-y: auto;
  border-top: 2px solid #a3e635;
}

.debug-title {
  font-weight: 700;
  color: #a3e635;
  margin-bottom: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  color: #cbd5e1;
}

@media (max-width: 480px) {
  .card {
    padding: 36px 24px;
    border-radius: 16px;
  }

  h1 {
    font-size: 1.3rem;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-actions {
    flex-direction: column;
  }
}
