:root {
  --accent:    272 85% 65%;
  --accent-hi: 278 100% 76%;
  --accent-lo: 265 65% 48%;

  --bg-0: #08060f;
  --bg-1: #0f0c1a;
  --bg-2: #151122;
  --bg-3: #1c172c;
  --line: #2b2440;
  --line-soft: #1f1a30;

  --ink-1: #f0eef8;
  --ink-2: #bdb8d4;
  --ink-3: #7a6f9a;
  --ink-4: #4a4168;

  --font-ui: "Space Grotesk", -apple-system, system-ui, sans-serif;
  --radius: 10px;
}

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

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

body {
  background: var(--bg-0);
  color: var(--ink-2);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle star field */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 25%, hsl(var(--accent-hi) / 0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 42% 10%, hsl(var(--accent-hi) / 0.25) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 70% 18%, hsl(var(--accent-hi) / 0.35) 0%, transparent 100%),
    radial-gradient(1px 1px at 88% 35%, hsl(var(--accent-hi) / 0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 25% 55%, hsl(var(--accent-hi) / 0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 70%, hsl(var(--accent-hi) / 0.2) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 5% 80%, hsl(var(--accent-hi) / 0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 85%, hsl(var(--accent-hi) / 0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 35% 90%, hsl(var(--accent-hi) / 0.15) 0%, transparent 100%),
    radial-gradient(120% 60% at 100% 0%, hsl(var(--accent) / 0.06) 0%, transparent 60%),
    radial-gradient(80% 60% at 0% 100%, hsl(var(--accent) / 0.04) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

#root { position: relative; z-index: 1; height: 100%; }

a { color: hsl(var(--accent-hi)); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Centered layout ───────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-1);
}

.accent { color: hsl(var(--accent-hi)); }

/* ── Card ───────────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 36px 32px;
}

.auth-card-narrow {
  max-width: 360px;
}

.auth-card-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.auth-card-sub {
  font-size: 14px;
  color: var(--ink-3);
  margin: 0 0 28px;
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: hsl(var(--accent) / 0.8);
  font-weight: 600;
  margin-bottom: 10px;
}

/* ── Fields ─────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field label {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}

.field-link { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.field-link:hover { color: hsl(var(--accent-hi)); text-decoration: none; }

.field input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 13px;
  color: var(--ink-1);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}

.field input::placeholder { color: var(--ink-4); }

.field input:focus {
  border-color: hsl(var(--accent) / 0.7);
  box-shadow: 0 0 0 3px hsl(var(--accent) / 0.1);
}

.field-error {
  font-size: 12px;
  color: #e06c6c;
  margin-top: 2px;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 11px 20px;
  background: hsl(var(--accent));
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 120ms ease, transform 80ms ease;
  margin-top: 8px;
  letter-spacing: -0.01em;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:active { transform: scale(0.99); }

.btn-ghost {
  padding: 11px 20px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 120ms ease;
  text-decoration: none;
  display: inline-block;
}

.btn-ghost:hover {
  border-color: hsl(var(--accent) / 0.5);
  color: var(--ink-1);
  text-decoration: none;
}

/* ── Social buttons ─────────────────────────────────────────────── */
.social-buttons { display: flex; flex-direction: column; gap: 8px; }

.btn-social {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-1);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.btn-social:hover {
  background: var(--bg-3);
  border-color: var(--ink-4);
}

/* ── Divider ────────────────────────────────────────────────────── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--ink-4);
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid;
  line-height: 1.4;
}

.alert-error { background: rgba(220,80,80,0.08); border-color: rgba(220,80,80,0.25); color: #e88080; }
.alert-info  { background: hsl(var(--accent)/0.07); border-color: hsl(var(--accent)/0.25); color: hsl(var(--accent-hi)); }

/* ── Footer ─────────────────────────────────────────────────────── */
.auth-switch {
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
  margin-top: 22px;
}
.auth-switch a { color: hsl(var(--accent-hi)); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: 13px;
  margin-bottom: 24px;
}
.back-link:hover { color: var(--ink-1); text-decoration: none; }

/* ── Account panel ──────────────────────────────────────────────── */
.account-layout {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.account-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-1);
}

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

.account-topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  color: var(--ink-3);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: hsl(var(--accent) / 0.2);
  border: 1px solid hsl(var(--accent) / 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: hsl(var(--accent-hi));
}

.account-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  padding: 40px 32px;
  gap: 40px;
}

@media (max-width: 700px) {
  .account-body { grid-template-columns: 1fr; padding: 24px 16px; }
  .account-nav { display: flex; flex-direction: row; gap: 4px; overflow-x: auto; }
}

.account-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}

.account-nav-item:hover { background: var(--bg-2); color: var(--ink-1); text-decoration: none; }
.account-nav-item.active { background: hsl(var(--accent) / 0.1); color: hsl(var(--accent-hi)); }
.account-nav-item svg { flex-shrink: 0; opacity: 0.7; }
.account-nav-item.active svg { opacity: 1; }

.account-content { min-width: 0; }

.account-section { display: none; }
.account-section.active { display: block; }

.account-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.account-section-sub {
  font-size: 13.5px;
  color: var(--ink-3);
  margin: 0 0 28px;
}

.account-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.account-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.account-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-1);
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.badge-success { background: rgba(74,210,149,0.12); color: #4ad295; border: 1px solid rgba(74,210,149,0.2); }
.badge-warning { background: rgba(250,180,80,0.12); color: #fab450; border: 1px solid rgba(250,180,80,0.2); }
.badge-neutral { background: var(--bg-2); color: var(--ink-3); border: 1px solid var(--line); }

.btn-sm {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  border-radius: 7px;
  cursor: pointer;
  transition: all 120ms;
}

.btn-sm-primary {
  background: hsl(var(--accent));
  border: none;
  color: #fff;
}
.btn-sm-primary:hover { opacity: 0.85; }

.btn-sm-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.btn-sm-ghost:hover { border-color: hsl(var(--accent)/0.5); color: var(--ink-1); }

.btn-sm-danger {
  background: transparent;
  border: 1px solid rgba(220,80,80,0.3);
  color: #e06c6c;
}
.btn-sm-danger:hover { background: rgba(220,80,80,0.08); }

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.session-item:last-child { border-bottom: none; padding-bottom: 0; }

.session-meta { font-size: 13px; color: var(--ink-3); margin-top: 3px; }

.totp-qr {
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  display: inline-block;
  margin: 16px 0;
}

.totp-secret {
  font-family: monospace;
  font-size: 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--ink-2);
  word-break: break-all;
  margin-bottom: 16px;
}

.alert-success { background: rgba(74,210,149,0.08); border-color: rgba(74,210,149,0.25); color: #4ad295; }

/* ── Password strength ──────────────────────────────────────────── */
.pw-strength {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.pw-strength-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  transition: background 200ms ease;
}

.pw-strength-label {
  font-size: 11.5px;
  margin-top: 5px;
  font-weight: 500;
  min-height: 16px;
  transition: color 200ms;
}

.pw-reqs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pw-req {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-4);
  transition: color 150ms;
}

.pw-req::before {
  content: "○";
  font-size: 10px;
  flex-shrink: 0;
  transition: all 150ms;
}

.pw-req.met { color: #4ad295; }
.pw-req.met::before { content: "✓"; }

.pw-match-msg {
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}

/* ── Consent scopes ─────────────────────────────────────────────── */
.scope-list { margin: 20px 0; display: flex; flex-direction: column; gap: 8px; }
.scope-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-4); margin-bottom: 4px; }
.scope-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 8px; font-size: 13.5px; color: var(--ink-2);
}
.scope-item svg { color: hsl(var(--accent-hi)); flex-shrink: 0; }
