:root {
  color-scheme: dark;

  --bg: #0d0f14;
  --surface: #151820;
  --surface-2: #1b1f29;
  --border: #262b37;
  --border-strong: #343a49;
  --text: #e7e9ee;
  --text-muted: #9ba3b4;
  --text-subtle: #6f7789;

  --accent: #5b8cff;
  --accent-hover: #74a0ff;
  --accent-text: #0b1020;
  --accent-soft: rgba(91, 140, 255, 0.12);

  --beta: #f2b13c;
  --beta-soft: rgba(242, 177, 60, 0.12);

  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.1);
  --success: #3ecf8e;

  --radius: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(91, 140, 255, 0.45);

  font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* ---------- Layout ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  font-size: 1.05rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #fff;
}

.brand-mark img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 48px 16px 32px;
}

.page-center {
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 420px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.card + .card,
.card + .steps {
  margin-top: 16px;
}

.lead {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.footer {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.85rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-block {
  width: 100%;
}

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

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

.btn-secondary {
  background: transparent;
  border-color: var(--beta);
  color: var(--beta);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--beta-soft);
}

.btn-ghost {
  min-height: 36px;
  padding: 6px 12px;
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--text-subtle);
}

.btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-inline {
  display: inline-block;
  vertical-align: -3px;
  margin-right: 8px;
}

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

/* ---------- Download ---------- */

.download-meta {
  margin-top: 10px;
  color: var(--text-subtle);
  font-size: 0.85rem;
  text-align: center;
}

.progress {
  margin-top: 20px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

.progress[data-channel="beta"] .progress-fill {
  background: var(--beta);
}

.progress-bar.is-indeterminate .progress-fill {
  width: 30%;
  animation: indeterminate 1.2s ease-in-out infinite;
}

@keyframes indeterminate {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

.progress-text {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.beta {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.beta summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  width: fit-content;
  padding: 4px 2px;
}

.beta summary::-webkit-details-marker {
  display: none;
}

.beta summary:hover {
  color: var(--text);
}

.chevron {
  width: 16px;
  height: 16px;
  transition: transform 0.15s;
}

.beta[open] .chevron {
  transform: rotate(90deg);
}

.beta-body {
  margin-top: 12px;
}

.beta-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--beta-soft);
  color: var(--beta);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.steps {
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.steps ol {
  margin: 0;
  padding-left: 20px;
}

.steps li + li {
  margin-top: 6px;
}

.steps-title {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---------- Notices ---------- */

.notice {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.notice-error {
  background: var(--danger-soft);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: #ffb3b3;
}

.notice-success {
  color: var(--success);
}

.hint {
  margin-top: 20px;
  color: var(--text-subtle);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Loading (avant vérification de session) ---------- */

.is-checking-session main {
  visibility: hidden;
}

/* ---------- Responsive / motion ---------- */

@media (max-width: 480px) {
  .topbar {
    padding: 12px 16px;
  }

  .page {
    padding-top: 24px;
  }

  .card {
    padding: 24px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.card > .notice:last-child {
  margin: 16px 0 0;
}
