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

:root {
  --bg:            #060e0a;
  --surface:       #0c1a12;
  --surface-2:     #122010;
  --border:        rgba(52, 211, 153, 0.12);
  --border-bright: rgba(52, 211, 153, 0.28);
  --accent:        #047857;
  --accent-mid:    #059669;
  --accent-bright: #34d399;
  --text:          #ddeee5;
  --muted:         #6a9a7a;
  --glow:          rgba(4, 120, 87, 0.18);
  --glow-bright:   rgba(52, 211, 153, 0.12);
  --toggle-bg:     #0c1a12;
}

html.light {
  --bg:            #f0f5f2;
  --surface:       #ffffff;
  --surface-2:     #e8f2ec;
  --border:        rgba(4, 120, 87, 0.15);
  --border-bright: rgba(4, 120, 87, 0.35);
  --accent:        #047857;
  --accent-mid:    #059669;
  --accent-bright: #065f46;
  --text:          #0d2b1e;
  --muted:         #4a7a5a;
  --glow:          rgba(4, 120, 87, 0.1);
  --glow-bright:   rgba(4, 120, 87, 0.08);
  --toggle-bg:     #e8f2ec;
}

html {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

body {
  min-height: 100vh;
  position: relative;
  padding: 2rem;
}

/* ---- Starfield ---- */
#starfield {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.star {
  position: absolute;
  pointer-events: none;
  transform-origin: center;
  opacity: 0;
  will-change: opacity, transform;
}

/* Dot stars */
.star.dot {
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: white;
}

html.light .star.dot { background: #2d6a4f; }

/* Sparkle stars — 4-pointed via two crossed bars */
.star.sparkle::before,
.star.sparkle::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 50%;
}

html.light .star.sparkle::before,
html.light .star.sparkle::after { background: #2d6a4f; }

.star.sparkle::before {
  width: var(--size);
  height: calc(var(--size) * 0.18);
}

.star.sparkle::after {
  width: calc(var(--size) * 0.18);
  height: var(--size);
}

/* ---- Ambient glow ---- */
.glow-orb {
  position: fixed;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  transition: background 0.3s;
}

/* ---- Theme toggle ---- */
.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-bright);
  background: var(--toggle-bg);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
}

.theme-toggle:hover {
  box-shadow: 0 0 12px var(--glow-bright);
  border-color: var(--accent-bright);
}

/* ---- Main content ---- */
main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  width: 100%;
  max-width: 480px;
  min-height: calc(100vh - 4rem); /* 4rem = body's 2rem padding top + bottom */
  margin: 0 auto;
  animation: fadeUp 0.5s ease both;
}

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

/* ---- Header ---- */
.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.app-icon {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  filter: drop-shadow(0 0 18px rgba(52, 211, 153, 0.35));
}

.app-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-title span { color: var(--accent-bright); }

html.light .app-title span { color: var(--accent); }

.app-tagline {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 340px;
}

/* ---- Divider ---- */
.rune-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.rune-divider::before,
.rune-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-bright), transparent);
}

.rune-divider span {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ---- Action cards ---- */
.actions {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.18s;
}

.action-card:hover {
  background: var(--surface-2);
  border-color: var(--border-bright);
  box-shadow: 0 0 28px var(--glow-bright);
  transform: translateY(-2px);
}

.action-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.action-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.action-title {
  font-size: 1rem;
  font-weight: 700;
}

.action-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

.action-arrow {
  margin-left: auto;
  color: var(--accent-bright);
  font-size: 1.1rem;
  opacity: 0.7;
  transition: opacity 0.18s, transform 0.18s;
}

html.light .action-arrow { color: var(--accent); }

.action-card:hover .action-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* ---- Sign in link ---- */
.signin-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.signin-link a {
  color: var(--accent-bright);
  text-decoration: none;
  font-weight: 600;
}

html.light .signin-link a { color: var(--accent); }

.signin-link a:hover { text-decoration: underline; }

/* ---- Back link ---- */
.back-link {
  position: fixed;
  top: 1.25rem;
  left: 1.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
  z-index: 10;
}

.back-link:hover { color: var(--text); }

/* ---- Auth card ---- */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ---- Tabs ---- */
.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.auth-tab {
  flex: 1;
  padding: 0.45rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.auth-tab:not(.active):hover { color: var(--text); }

/* ---- Form ---- */
.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.875rem;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input::placeholder { color: var(--muted); opacity: 0.55; }

.form-input:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px var(--glow);
}

.form-hint {
  font-size: 0.71rem;
  color: var(--muted);
  opacity: 0.7;
}

/* ---- Buttons ---- */
.btn-primary {
  padding: 0.68rem 1.25rem;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  width: 100%;
  margin-top: 0.25rem;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-primary:hover {
  background: var(--accent-mid);
  box-shadow: 0 0 20px var(--glow);
}

.btn-primary:active { transform: scale(0.98); }

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

.btn-ghost {
  padding: 0.6rem 1.25rem;
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent-mid);
}

/* ---- Error message ---- */
.form-error {
  font-size: 0.82rem;
  color: #f87171;
  padding: 0.6rem 0.875rem;
  background: rgba(248, 113, 113, 0.07);
  border: 1px solid rgba(248, 113, 113, 0.18);
  border-radius: 6px;
  display: none;
}

.form-error.visible { display: block; }

/* ---- Avatar ---- */
.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 28px var(--glow);
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
}

/* ---- Profile card ---- */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 700;
  margin-top: 0.75rem;
}

.profile-username {
  font-size: 0.85rem;
  color: var(--accent-bright);
  font-weight: 600;
}

html.light .profile-username { color: var(--accent); }

.profile-since {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.7;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
}

/* ---- Intent banner ---- */
.intent-banner {
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  width: 100%;
  line-height: 1.5;
}

.intent-banner strong { color: var(--accent-bright); }
html.light .intent-banner strong { color: var(--accent); }

/* ---- Avatar image ---- */
img.avatar {
  object-fit: cover;
  background: var(--surface-2);
}

/* ---- Avatar picker (settings) ---- */
.avatar-picker {
  position: relative;
  width: 96px;
  height: 96px;
  cursor: pointer;
  align-self: center;
  flex-shrink: 0;
}

.avatar-picker .avatar,
.avatar-picker img.avatar {
  width: 96px;
  height: 96px;
  font-size: 2.5rem;
}

.avatar-picker-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 1.25rem;
  pointer-events: none;
}

.avatar-picker:hover .avatar-picker-overlay { opacity: 1; }

/* ---- Card section separator ---- */
.card-sep {
  height: 1px;
  background: var(--border);
  margin: 0.5rem 0;
}

/* ---- Link button ---- */
.btn-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}

.btn-link:hover { color: var(--text); }
.btn-link.danger:hover { color: #f87171; }

/* ---- Success message ---- */
.form-success {
  font-size: 0.82rem;
  color: var(--accent-bright);
  padding: 0.6rem 0.875rem;
  background: rgba(52, 211, 153, 0.07);
  border: 1px solid rgba(52, 211, 153, 0.18);
  border-radius: 6px;
  display: none;
}

html.light .form-success { color: var(--accent); }
.form-success.visible { display: block; }

/* ---- Password strength meter ---- */
.strength-meter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.strength-bar {
  display: flex;
  flex: 1;
  gap: 3px;
}

.strength-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.2s;
}

.strength-label {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 44px;
  text-align: right;
  color: var(--muted);
  transition: color 0.2s;
}

/* ---- Password rules checklist ---- */
.pw-rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0;
}

.pw-rules li::before {
  content: '✗  ';
  opacity: 0.45;
}

.pw-rules li.met {
  color: var(--accent-bright);
}

.pw-rules li.met::before {
  content: '✓  ';
  opacity: 1;
}

html.light .pw-rules li.met { color: var(--accent); }
