/* === portal.css === */
/* ============================================================
   Member Portal
   ============================================================ */

.portal-shell {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 60% 50% at 15% 0%, rgba(26,115,232,.10), transparent 55%),
    radial-gradient(ellipse 50% 40% at 85% 10%, rgba(16,185,129,.08), transparent 55%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg-light) 28%, var(--bg) 100%);
}

.portal-top-nav {
  position: sticky;
  top: 0;
  z-index: 900;
}

.portal-nav-right {
  gap: 10px;
}

.portal-join-btn {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
}

.portal-secondary-action {
  border-radius: 999px;
}

.portal-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-right: 14px;
  border-radius: 999px;
}

.portal-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15);
}

.avatar-blue { background: linear-gradient(135deg, #1a73e8, #4f9cf9); }
.avatar-green { background: linear-gradient(135deg, #059669, #10b981); }
.avatar-purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.avatar-orange { background: linear-gradient(135deg, #ea580c, #fb923c); }

.portal-notifications {
  position: relative;
}

.portal-notification-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  color: var(--text-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.portal-notification-btn:hover,
.portal-notification-btn[aria-expanded="true"] {
  border-color: rgba(26,115,232,.34);
  color: var(--primary);
  box-shadow: 0 8px 22px rgba(26,115,232,.12);
}

.portal-notification-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 900;
  line-height: 15px;
  text-align: center;
}

.portal-notification-menu {
  display: none;
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(360px, calc(100vw - 28px));
  max-height: 440px;
  overflow: hidden;
  border: 1px solid rgba(224,226,239,.95);
  border-radius: 14px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 22px 60px rgba(12,22,44,.18);
  z-index: 1100;
}

.portal-notification-menu[hidden] {
  display: none !important;
}

.portal-notifications.open .portal-notification-menu {
  display: block;
}

.portal-notifications:not(.open) .portal-notification-menu {
  display: none !important;
}

.portal-notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.notification-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.portal-notification-head strong {
  font-size: 14px;
  color: var(--text-dark);
}

.portal-notification-head button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.notification-close-btn {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border-radius: 999px;
  padding: 5px 8px;
}

.notification-close-btn:hover {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

.portal-notification-list {
  max-height: 374px;
  overflow-y: auto;
  padding: 8px;
}

.portal-notification-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.portal-notification-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.notification-type-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(15,23,42,.06);
  color: #475569;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.portal-notification-item:hover {
  background: #f8fbff;
  border-color: #dbeafe;
}

.portal-notification-item.unread {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.portal-notification-item.notification-type-proposal {
  border-color: rgba(16,185,129,.24);
}

.portal-notification-item.notification-type-proposal.unread {
  background: linear-gradient(180deg, rgba(236,253,245,.96), rgba(240,253,250,.92));
  border-color: rgba(16,185,129,.36);
}

.notification-type-proposal .notification-type-pill {
  background: rgba(16,185,129,.12);
  color: #047857;
}

.notification-type-proposal_review .notification-type-pill {
  background: rgba(26,115,232,.12);
  color: #1557b0;
}

.portal-notification-item strong {
  color: var(--text-dark);
  font-size: 13px;
  line-height: 1.35;
}

.portal-notification-item p {
  margin: 0;
  color: var(--text-med);
  font-size: 12px;
  line-height: 1.45;
}

.portal-notification-meta {
  color: var(--text-light);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.portal-notification-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.notification-type-proposal .portal-notification-action {
  background: #047857;
  box-shadow: 0 8px 18px rgba(4,120,87,.18);
}

.portal-notification-empty {
  padding: 26px 14px;
  color: var(--text-light);
  font-size: 13px;
  text-align: center;
}

.portal-flash {
  max-width: 1120px;
  margin: 18px auto 0;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  font-weight: 600;
}

.portal-flash-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.portal-flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.portal-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 80px;
}

.dashboard-page .portal-hero {
  background: transparent;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-radius: 0;
  padding: 18px 0 6px;
  overflow: visible;
}

.dashboard-page .portal-hero::before {
  display: none;
}

.dashboard-page .portal-panel,
.dashboard-page .hero-score-card,
.dashboard-page .stat-card,
.dashboard-page .track-card,
.dashboard-page .space-card,
.dashboard-page .portal-sidebar-card {
  border-radius: 8px;
  background: var(--portal-surface, rgba(255,255,255,.94));
  border: 1px solid var(--portal-border, rgba(15,23,42,.10));
  box-shadow: var(--portal-shadow-sm, 0 10px 30px rgba(12,22,44,.06));
}

.dashboard-page .portal-hero-panel {
  border-radius: 8px;
}

.dashboard-page .dashboard-section {
  margin-top: 22px;
}

/* Slim secondary-metrics strip — subordinate to hero-score-grid, not another
   full stat-card row, since it only carries the two signals not already
   shown in the hero (cloud files, account role). */
.dashboard-secondary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 4px;
}

.dashboard-secondary-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--portal-surface-muted, rgba(15,17,23,.04));
  border: 1px solid var(--portal-border, rgba(15,23,42,.10));
}

.dashboard-secondary-stat strong {
  font-size: 16px;
  color: var(--text-dark);
}

.dashboard-secondary-stat span {
  font-size: 12px;
  color: var(--text-light);
}

.dashboard-page .track-title-cell {
  flex: 1;
  min-width: 0;
}

.dashboard-page .track-badge {
  border-radius: 8px;
}

.dashboard-page .space-actions {
  margin-top: 8px;
}

.dashboard-page .dashboard-action-list {
  margin-top: 0;
}

.dashboard-page .track-card-empty {
  grid-column: 1 / -1;
}

.dashboard-page .filter-chip:focus-visible,
.dashboard-page .choice-card:focus-visible,
.dashboard-page .btn:focus-visible,
.dashboard-page .btn-outline:focus-visible {
  outline: 3px solid rgba(26,115,232,.24);
  outline-offset: 2px;
}

/* Chrome (background/border/shadow/radius) for these cards is owned by the
   "Portal Professional Polish Layer" further down (single source of truth for
   surface styling) — this rule only keeps the structural layout properties. */
.portal-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, .8fr);
}

.portal-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 55% 60% at 0% 0%, rgba(26,115,232,.12), transparent 60%),
    radial-gradient(ellipse 30% 50% at 100% 20%, rgba(16,185,129,.12), transparent 60%);
}

.portal-hero-content,
.portal-hero-side {
  position: relative;
  z-index: 1;
}

.eyebrow-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(26,115,232,.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.portal-hero h1,
.auth-panel h1,
.page-heading {
  font-size: 46px;
  line-height: 1.06;
  letter-spacing: 0;
  margin-bottom: 12px;
  color: var(--text-dark);
}

.portal-lead,
.auth-panel p,
.page-subtitle {
  color: var(--text-med);
  font-size: 16px;
  line-height: 1.8;
}

.hero-chip-list,
.hero-action-row,
.portal-inline-stats,
.filter-row,
.profile-color-grid,
.space-stack-grid,
.track-grid,
.spaces-grid,
.stats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-chip-list { margin-top: 20px; }

.hero-chip {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(26,115,232,.08);
  border: 1px solid rgba(26,115,232,.12);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.hero-action-row {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.hero-action-row .btn,
.hero-action-row .btn-outline {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 22px;
  font-weight: 700;
}

.hero-score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.hero-score-card {
  padding: 20px 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,250,252,.95));
  border: 1px solid rgba(26,115,232,.14);
  box-shadow: 0 20px 50px rgba(13, 71, 161, .06);
}

.hero-score-card span {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}

.hero-score-card strong {
  display: block;
  font-size: 28px;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.hero-score-card p {
  color: var(--text-med);
  font-size: 13px;
  line-height: 1.6;
}

.portal-inline-stats {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.portal-inline-stat {
  min-width: 120px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(15,17,23,.04);
  border: 1px solid rgba(224,226,239,.9);
}

.portal-inline-stat strong {
  display: block;
  font-size: 24px;
  color: var(--text-dark);
}

.portal-inline-stat span {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
  margin-top: 3px;
}

.portal-hero-side {
  display: grid;
  gap: 14px;
}

.portal-sidebar-card {
  border-radius: 22px;
  padding: 20px;
}

.portal-sidebar-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.portal-sidebar-card p {
  color: var(--text-med);
  font-size: 14px;
  margin-bottom: 12px;
}

.portal-hero-panel {
  position: relative;
  padding: 24px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.75));
  border: 1px solid rgba(26,115,232,.18);
}

.portal-hero-panel-alt {
  background: rgba(255,255,255,.88);
  border-color: rgba(16,185,129,.18);
}

.portal-hero-panel .panel-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(26,115,232,.1);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 16px;
}

.hero-metrics-grid {
  display: grid;
  gap: 10px;
  margin: 16px 0 18px;
}

.hero-metrics-grid span {
  display: block;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(15,17,23,.04);
  color: var(--text-dark);
  font-weight: 700;
}

.pro-playbook-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 12px;
}

.pro-playbook-list li {
  position: relative;
  padding-left: 24px;
  color: var(--text-med);
  line-height: 1.7;
}

.pro-playbook-list li::before {
  content: '\2714';
  position: absolute;
  left: 0;
  top: 2px;
  color: var(--accent2);
  font-size: 12px;
}

.portal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .8fr);
  gap: 22px;
  margin-top: 22px;
}

.portal-stack {
  display: grid;
  gap: 22px;
}

.portal-panel,
.auth-panel,
.profile-card {
  border-radius: 24px;
  padding: 28px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  font-size: 24px;
}

.panel-header p {
  color: var(--text-med);
  font-size: 14px;
  margin-top: 6px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  border-radius: 20px;
  padding: 20px;
}

.stat-card .label {
  display: block;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}

.stat-card strong {
  font-size: 30px;
  color: var(--text-dark);
  letter-spacing: 0;
}

.stat-card p {
  color: var(--text-med);
  font-size: 13px;
  margin-top: 8px;
}

.filter-row {
  margin-bottom: 16px;
}

.filter-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-light);
  color: var(--text-med);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.track-card {
  border-radius: 22px;
  padding: 20px;
  position: relative;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}

.track-card:hover {
  transform: translateY(-3px);
  border-color: rgba(26,115,232,.25);
  box-shadow: 0 26px 70px rgba(12, 22, 44, .12);
}

.track-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.track-badge {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--track-accent, var(--primary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 12px 24px rgba(0,0,0,.10);
}

.track-card h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.track-meta {
  color: var(--text-light);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.track-card p {
  color: var(--text-med);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 14px;
}

.progress-meter {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  width: var(--track-progress, 0%);
  background: linear-gradient(90deg, var(--primary), #10b981);
}

.track-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.inline-form,
.stack-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-form button,
.stack-form button {
  border-radius: 999px;
}

.spaces-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.space-card {
  border-radius: 22px;
  padding: 20px;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}

.space-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16,185,129,.25);
  box-shadow: 0 22px 50px rgba(12, 22, 44, .08);
}

.space-card h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.space-card p {
  color: var(--text-med);
  font-size: 14px;
  line-height: 1.7;
}

.space-card code {
  display: inline-block;
  margin-top: 10px;
}

.activity-list {
  display: grid;
  gap: 12px;
}

.activity-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg-light);
  border: 1px solid var(--border);
}

.activity-item strong,
.leaderboard-user strong {
  display: block;
  color: var(--text-dark);
  font-size: 14px;
  margin-bottom: 4px;
}

.activity-item span,
.leaderboard-user span {
  color: var(--text-light);
  font-size: 12px;
}

.leaderboard-table {
  display: grid;
  gap: 12px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 140px;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255,255,255,.8);
  border: 1px solid var(--border);
}

.leaderboard-row.is-current {
  border-color: rgba(26,115,232,.35);
  box-shadow: 0 0 0 4px rgba(26,115,232,.10);
}

/* Generic reusable spacing utility (was previously repeated as inline styles per page) */
.section-spacer {
  margin-top: 22px;
}

/* Top-3 treatment: a medal-colored rank badge + left accent, so the leaderboard
   reads as ranked rather than a flat list. */
.leaderboard-row-top1,
.leaderboard-row-top2,
.leaderboard-row-top3 {
  border-left: 3px solid transparent;
}

.leaderboard-row-top1 { border-left-color: #d4a017; }
.leaderboard-row-top2 { border-left-color: #94a3b8; }
.leaderboard-row-top3 { border-left-color: #b3672f; }

.leaderboard-row-top1 .leaderboard-rank {
  background: linear-gradient(135deg, #f5c518, #d4a017);
  box-shadow: 0 10px 24px rgba(212,160,23,.35);
}

.leaderboard-row-top2 .leaderboard-rank {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  box-shadow: 0 10px 24px rgba(100,116,139,.30);
}

.leaderboard-row-top3 .leaderboard-rank {
  background: linear-gradient(135deg, #d99a5b, #b3672f);
  box-shadow: 0 10px 24px rgba(179,103,47,.30);
}

/* Per-row XP bar, scaled relative to the top score — pure CSS, no new data/JS. */
.leaderboard-xp-bar {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: rgba(26,115,232,.10);
  overflow: hidden;
  margin-top: 2px;
}

.leaderboard-xp-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1a73e8, #10b981);
  transition: width .6s cubic-bezier(.22,1,.36,1);
}

[data-theme="dark"] .leaderboard-xp-bar {
  background: rgba(79,156,249,.16);
}

.leaderboard-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
}

.leaderboard-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.leaderboard-score {
  justify-self: end;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-dark);
}

.stack-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(26,115,232,.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  margin-top: 12px;
}

/* ============================================================
   Spaces — Share & Collaborate widget
   (was previously ~40 inline styles, no dark-mode support at all)
   ============================================================ */
.space-collab-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 4px;
  color: var(--text-light);
}

.space-detail-actions {
  margin-top: 8px;
}

.space-editor-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 7px 16px;
}

.space-meta-row {
  margin-top: 12px;
  margin-bottom: 14px;
}

.space-details {
  margin: 10px 0 12px;
}

.space-details-summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-dark);
}

.share-collab-panel {
  margin-top: 10px;
}

.space-collab-desc {
  font-size: 13px;
  color: var(--text-light);
  margin: 0 0 10px;
}

.space-collab-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.collab-perm-select {
  flex: 1;
  min-width: 120px;
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--portal-border, #e2e8f0);
  border-radius: 6px;
  background: var(--portal-surface-solid, #fff);
  color: var(--text-dark);
}

.space-collab-create-btn {
  font-size: 13px;
  padding: 6px 14px;
}

.collab-links-list {
  margin-top: 10px;
}

.collab-members {
  margin-top: 14px;
}

.collab-members-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0 0 6px;
}

.collab-members-list {
  font-size: 13px;
  color: var(--text-light);
}

.space-edit-form {
  margin-top: 10px;
}

.form-actions-flush {
  margin-top: 0;
}

.space-muted-text {
  color: var(--text-light);
}

.collab-empty-text {
  margin: 0;
  font-size: 12px;
}

.collab-link-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.collab-link-input {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--portal-border, #e2e8f0);
  border-radius: 4px;
  background: var(--portal-surface-muted, #f8fafc);
  color: var(--text-dark);
}

.collab-pill {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
}

.collab-pill-edit {
  background: #dcfce7;
  color: #16a34a;
}

.collab-pill-view {
  background: #e0f2fe;
  color: #0369a1;
}

.collab-link-btn {
  font-size: 11px;
  padding: 2px 8px;
}

.collab-member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.collab-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.collab-member-info {
  flex: 1;
  min-width: 0;
}

.collab-member-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.collab-member-meta {
  font-size: 11px;
  color: var(--text-light);
}

[data-theme="dark"] .collab-pill-edit {
  background: rgba(16,185,129,.18);
  color: #6ee7b7;
}

[data-theme="dark"] .collab-pill-view {
  background: rgba(56,189,248,.18);
  color: #7dd3fc;
}

.auth-wrap,
.profile-layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 22px 80px;
}

.auth-layout,
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, .8fr);
  gap: 24px;
}

.auth-panel {
  position: relative;
  overflow: hidden;
}

.auth-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 0% 0%, rgba(26,115,232,.12), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(16,185,129,.10), transparent 35%);
}

.auth-panel > * {
  position: relative;
  z-index: 1;
}

.auth-list {
  list-style: none;
  padding: 0;
  margin: 24px 0 0;
  display: grid;
  gap: 12px;
}

.auth-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: var(--text-med);
}

.auth-list li::before {
  content: '●';
  color: var(--accent2);
  margin-top: 2px;
  font-size: 10px;
}

.form-card {
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(224,226,239,.95);
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 24px 50px rgba(12,22,44,.08);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  color: var(--text-dark);
  border-radius: 16px;
  padding: 13px 15px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(26,115,232,.12);
}

.field small {
  color: var(--text-light);
  font-size: 12px;
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.form-helper {
  color: var(--text-light);
  font-size: 13px;
}

/* ============================================================
   Professional Auth Pages
   ============================================================ */
.auth-page {
  background: radial-gradient(circle at top left, rgba(79,156,249,.12), transparent 24%),
              radial-gradient(circle at bottom right, rgba(16,185,129,.1), transparent 28%),
              linear-gradient(180deg, #081225 0%, #0d1f34 100%);
  min-height: 100vh;
}

.auth-page .auth-wrap-pro {
  max-width: 1180px;
  padding: clamp(32px, 5vw, 58px) 22px 88px;
}

.auth-page .auth-layout-pro {
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr);
  align-items: center;
  gap: 28px;
}

.auth-page .auth-layout-register {
  grid-template-columns: minmax(0, .96fr) minmax(430px, 1fr);
}

.auth-page .auth-panel-pro {
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: 34px;
  border-radius: 18px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(18,33,57,.98) 0%, rgba(24,63,72,.98) 52%, rgba(33,86,67,.98) 100%);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 28px 70px rgba(12,22,44,.20);
}

.auth-page .auth-panel-pro::before {
  background-image:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: .16;
}

.auth-page .auth-panel-pro .eyebrow-label {
  margin-top: 28px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  color: rgba(255,255,255,.92);
}

.auth-page .auth-panel-pro h1 {
  max-width: 620px;
  color: #fff;
  font-size: 48px;
  line-height: 1.03;
  letter-spacing: 0;
}

.auth-page .auth-panel-pro p {
  max-width: 620px;
  color: rgba(235,246,255,.78);
}

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #102033;
  background: linear-gradient(135deg, #f8fafc, #c7f9e5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 18px 36px rgba(0,0,0,.16);
}

.auth-brand-text {
  display: grid;
  gap: 3px;
}

.auth-brand-text strong {
  color: #fff;
  font-size: 15px;
}

.auth-brand-text small {
  color: rgba(235,246,255,.68);
  font-size: 12px;
}

.auth-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 26px 0 0;
}

.auth-metric {
  min-height: 80px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.08);
}

.auth-metric strong,
.auth-metric span {
  display: block;
}

.auth-metric strong {
  font-size: 20px;
  line-height: 1.1;
  color: #fff;
}

.auth-metric span {
  margin-top: 6px;
  color: rgba(235,246,255,.68);
  font-size: 12px;
  font-weight: 700;
}

.auth-list-pro {
  margin-top: 0;
}

.auth-list li::before {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent2);
  color: transparent;
  margin-top: 8px;
  box-shadow: 0 0 0 4px rgba(16,185,129,.12);
}

.auth-page .auth-panel-pro .auth-list li {
  color: rgba(235,246,255,.76);
}

.auth-page .auth-panel-pro .auth-list li::before {
  background: #55e6a5;
  box-shadow: 0 0 0 4px rgba(85,230,165,.12);
}

.auth-preview-card {
  margin-top: 24px;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.09);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.auth-preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  color: rgba(235,246,255,.70);
  font-size: 13px;
  font-weight: 700;
}

.auth-preview-top strong {
  color: #bbf7d0;
}

.auth-progress-item {
  display: grid;
  gap: 8px;
  color: rgba(235,246,255,.70);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 14px;
}

.auth-progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
}

.auth-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #55e6a5, #79b8ff);
}

.auth-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.auth-preview-grid span {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: rgba(235,246,255,.72);
  font-size: 12px;
  font-weight: 700;
}

.auth-page .auth-form-card {
  width: 100%;
  max-width: 488px;
  justify-self: end;
  padding: 32px;
  border-radius: 18px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 28px 70px rgba(12,22,44,.14);
  border: 1px solid rgba(15,23,42,.08);
  backdrop-filter: blur(20px);
}

.auth-page .auth-layout-register .auth-form-card {
  max-width: 580px;
}

.auth-page .auth-layout-register {
  align-items: start;
}

.auth-form-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(26,115,232,.08);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.auth-form-stepper {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 22px;
}

.auth-form-stepper span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(248,250,252,.85);
  color: var(--text-light);
  font-size: 12px;
  font-weight: 800;
}

.auth-form-stepper span.active {
  background: rgba(26,115,232,.10);
  border-color: rgba(26,115,232,.22);
  color: var(--primary);
}

.auth-page .auth-form-card .panel-header {
  margin-bottom: 24px;
}

.auth-page .auth-form-card .panel-header h2 {
  font-size: 28px;
  letter-spacing: 0;
}

.auth-page .auth-form-card .panel-header p {
  max-width: 420px;
}

.register-form-pro {
  gap: 18px;
}

.auth-form-section {
  display: grid;
  gap: 4px;
  margin-bottom: -4px;
}

.auth-form-section span {
  color: var(--text-dark);
  font-size: 13px;
  font-weight: 900;
}

.auth-form-section small {
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.5;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-head a {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.auth-page .auth-form-card .field input {
  min-height: 50px;
  border-radius: 12px;
  padding: 14px 15px;
}

.auth-page .auth-form-card .field input:hover {
  border-color: rgba(26,115,232,.34);
}

.auth-page .auth-form-card .field input::placeholder {
  color: rgba(105,117,140,.55);
}

.password-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(15,23,42,.08);
}

.password-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #cbd5e1;
  transition: width .22s ease, background-color .22s ease;
}

.password-meter span.is-basic {
  background: #f97316;
}

.password-meter span.is-good {
  background: #0ea5e9;
}

.password-meter span.is-strong {
  background: #10b981;
}

#password-match-text.is-error {
  color: #dc2626;
  font-weight: 700;
}

#password-match-text.is-success {
  color: #059669;
  font-weight: 700;
}

.auth-submit-btn {
  width: 100%;
  min-height: 50px;
  justify-content: center;
  border-radius: 12px;
  font-weight: 900;
}

.auth-terms {
  margin: -4px 0 0;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.auth-switch {
  margin: -2px 0 0;
  color: var(--text-light);
  font-size: 13px;
  text-align: center;
}

.auth-switch a {
  color: var(--primary);
  font-weight: 800;
}

.auth-safe-note {
  margin-top: 22px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(16,185,129,.22);
  background: rgba(16,185,129,.08);
  display: grid;
  gap: 4px;
}

.auth-safe-note strong {
  color: var(--text-dark);
  font-size: 13px;
}

.auth-safe-note span {
  color: var(--text-med);
  font-size: 12px;
  line-height: 1.6;
}

.auth-choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-choice {
  min-height: 72px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  text-align: left;
  border-radius: 12px;
  padding: 13px;
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.auth-choice:hover {
  transform: translateY(-1px);
  border-color: rgba(26,115,232,.34);
}

.auth-choice span {
  color: var(--text-dark);
}

.auth-choice small {
  color: var(--text-light);
  font-size: 11px;
  line-height: 1.3;
}

.auth-choice.active {
  background: rgba(26,115,232,.08);
}

.auth-choice.active span,
.auth-choice.active small {
  color: var(--primary);
}

.profile-layout {
  grid-template-columns: minmax(0, 1fr) minmax(320px, .78fr);
}

.profile-preview {
  display: grid;
  gap: 18px;
}

.profile-hero {
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  font-weight: 900;
}

.profile-avatar-glow {
  box-shadow:
    0 0 0 4px var(--portal-surface-solid, #fff),
    0 0 0 7px rgba(26,115,232,.25),
    0 12px 30px rgba(26,115,232,.20);
}

.profile-name {
  font-size: 22px;
  margin: 0;
  background: linear-gradient(135deg, #1a73e8 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-headline {
  margin: 6px 0 0;
}

.profile-bio {
  margin-top: 16px;
}

.profile-summary-list {
  margin-top: 0;
  list-style: none;
  padding: 0;
}

.profile-completeness {
  margin-top: 18px;
}

.profile-completeness-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(26,115,232,.12);
  overflow: hidden;
  margin-bottom: 6px;
}

.profile-completeness-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1a73e8 0%, #10b981 100%);
  transition: width .6s cubic-bezier(.22,1,.36,1);
}

.profile-completeness-label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
}

[data-theme="dark"] .profile-completeness-bar {
  background: rgba(79,156,249,.18);
}

.profile-color-grid,
.space-stack-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choice-card {
  padding: 12px;
  border-radius: 18px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  text-align: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-med);
}

.choice-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(26,115,232,.12);
  color: var(--primary);
}

.admin-toolbar {
  display: grid;
  grid-template-columns: repeat(5, max-content) minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
}

.admin-tab-btn {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-med);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.admin-tab-btn.active {
  background: linear-gradient(135deg, #1a73e8, #0ea5e9);
  color: #fff;
  border-color: rgba(26,115,232,.5);
  box-shadow: 0 10px 20px rgba(26,115,232,.20);
}

.admin-toolbar-search {
  width: min(100%, 260px);
}

.admin-toolbar-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  background: rgba(255,255,255,.9);
}

.admin-panel {
  display: none;
}

.admin-panel.active {
  display: block;
}

.admin-chart-grid {
  display: grid;
  gap: 14px;
}

.admin-bar-row {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.8);
}

.admin-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  align-items: baseline;
}

.admin-bar-head strong {
  font-size: 14px;
}

.admin-bar-head span {
  font-size: 12px;
  color: var(--text-light);
}

.admin-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #dbe7ff;
}

.admin-bar-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1a73e8, #10b981);
}

.admin-table .leaderboard-row {
  grid-template-columns: 40px 64px minmax(0, 1fr) minmax(190px, auto);
}

.admin-actions-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.admin-danger-btn {
  border-color: #ef4444;
  color: #b91c1c;
}

.admin-danger-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.admin-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.admin-controls-row label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-med);
}

.admin-controls-row select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
}

.admin-pagination {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-med);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.admin-page-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.admin-analytics-grid {
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-analytics-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.86);
}

.admin-analytics-card span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  margin-bottom: 4px;
}

.admin-analytics-card strong {
  font-size: 24px;
  line-height: 1;
}

.admin-mini-visuals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.admin-mini-widget {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.86);
  padding: 10px;
}

.admin-mini-widget h4 {
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--text-med);
}

.admin-mini-chart {
  min-height: 66px;
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.admin-mini-bar {
  flex: 1;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #0ea5e9 0%, #1a73e8 100%);
}

.portal-footer {
  margin-top: 40px;
}

@media (max-width: 1100px) {
  .portal-hero,
  .portal-layout,
  .auth-layout,
  .profile-layout {
    grid-template-columns: 1fr;
  }

  .auth-page .auth-layout-pro,
  .auth-page .auth-layout-register {
    grid-template-columns: 1fr;
  }

  .auth-page .auth-panel-pro {
    min-height: auto;
  }

  .auth-page .auth-form-card {
    max-width: none;
    justify-self: stretch;
  }

  .stats-grid,
  .track-grid,
  .spaces-grid,
  .hero-score-grid,
  .portal-inline-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .portal-main,
  .auth-wrap,
  .profile-layout {
    padding: 22px 16px 64px;
  }

  .auth-page .auth-wrap-pro {
    padding: 24px 16px 64px;
  }

  .portal-nav-right .btn-signin,
  .portal-nav-right .portal-join-btn {
    display: none;
  }

  .portal-hero,
  .portal-panel,
  .auth-panel,
  .form-card,
  .profile-card {
    padding: 22px 18px;
  }

  .auth-page .auth-panel-pro,
  .auth-page .auth-form-card {
    border-radius: 16px;
    padding: 24px 20px;
  }

  .auth-page .auth-panel-pro h1 {
    font-size: 36px;
  }

  .auth-form-stepper {
    grid-template-columns: 1fr;
  }

  .auth-form-stepper span {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .auth-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid,
  .track-grid,
  .spaces-grid,
  .form-row,
  .profile-color-grid,
  .space-stack-grid {
    grid-template-columns: 1fr;
  }

  .auth-page .auth-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Leaderboard — keep rank + user + score on one row, just reduce columns */
  .leaderboard-row {
    grid-template-columns: 56px minmax(0, 1fr) 110px;
    gap: 8px;
  }

  .admin-toolbar {
    grid-template-columns: repeat(3, max-content) 1fr;
    flex-wrap: wrap;
  }

  .admin-toolbar-right {
    grid-column: 1 / -1;
    width: 100%;
  }

  .admin-analytics-grid,
  .admin-mini-visuals {
    grid-template-columns: 1fr;
  }

  .admin-actions-col {
    align-items: flex-start;
  }

  .panel-header,
  .profile-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Stat cards — reduce big number font so it fits in 2-col grid */
  .stat-card strong { font-size: 24px; }

  /* Admin table rows — scroll horizontally if still overflowing */
  .admin-table { overflow-x: auto; display: block; }
}

@media (max-width: 480px) {
  .portal-hero h1,
  .auth-panel h1,
  .page-heading {
    font-size: 28px;
  }

  .auth-page .auth-panel-pro h1 {
    font-size: 30px;
  }

  .auth-brand-row {
    align-items: flex-start;
  }

  .auth-metric-grid,
  .auth-preview-grid,
  .auth-choice-grid {
    grid-template-columns: 1fr;
  }

  .hero-action-row,
  .form-actions,
  .inline-form,
  .stack-form {
    flex-direction: column;
  }

  .hero-score-grid,
  .portal-inline-stats {
    grid-template-columns: 1fr;
  }

  .hero-action-row .btn,
  .hero-action-row .btn-outline,
  .form-actions .btn,
  .form-actions .btn-outline,
  .inline-form button,
  .stack-form button {
    width: 100%;
    justify-content: center;
  }

  /* Keep color swatches and stack options as 2-col on mobile */
  .profile-color-grid,
  .space-stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .auth-page .auth-choice-grid {
    grid-template-columns: 1fr;
  }

  /* Admin toolbar — stack everything on very small screens */
  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  /* Leaderboard — full collapse on truly small screens */
  .leaderboard-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .leaderboard-row > *:last-child { grid-column: 1 / -1; }
}

/* ============================================================
   Admin — Density toggle
   ============================================================ */
.admin-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.admin-toolbar-right .admin-toolbar-search {
  width: min(100%, 260px);
  justify-self: unset;
}

.admin-density-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-med);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.admin-density-btn:hover {
  background: #f1f5ff;
  color: var(--primary);
  border-color: var(--primary);
}

.admin-density-compact .leaderboard-row {
  padding: 8px 14px !important;
  min-height: unset;
}

.admin-density-compact .admin-bar-row {
  padding: 8px 12px;
}

.admin-density-compact .activity-item {
  padding: 8px 12px;
}

/* ============================================================
   Admin — Bulk select
   ============================================================ */
.admin-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #1e40af;
}

.admin-bulk-bar > span {
  flex: 1;
}

.admin-filter-summary {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #dbeafe;
  background: #f8fbff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 700;
}

.admin-empty-state {
  margin-top: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  color: #475569;
  background: #f8fafc;
  font-size: 13px;
}

.admin-bulk-bar button:disabled,
.admin-table button:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.admin-check-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-row-check {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.admin-select-all-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-med);
  cursor: pointer;
  margin-left: auto;
}

.admin-select-all-label input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================================
   Admin — Analytics window selector
   ============================================================ */
.admin-analytics-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.admin-days-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-med);
}

.admin-days-label select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  background: #fff;
}

@media (max-width: 768px) {
  .admin-toolbar-right {
    grid-column: 1 / -1;
    width: 100%;
    justify-self: stretch;
  }

  .admin-toolbar-right .admin-toolbar-search {
    flex: 1;
    width: 100%;
  }

  .admin-table .leaderboard-row {
    grid-template-columns: 1fr;
  }
}

/* ====================================================================
   PRO PORTAL SUITE — Dark Mode + Micro-animations + Visual Polish
   ==================================================================== */

/* ---------- Entry animations for portal cards ---------- */
@keyframes portal-fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.portal-hero,
.portal-panel,
.auth-panel,
.form-card {
  animation: portal-fade-up .5s cubic-bezier(.22,1,.36,1) both;
}

.stats-grid .stat-card:nth-child(1) { animation: portal-fade-up .45s .05s cubic-bezier(.22,1,.36,1) both; }
.stats-grid .stat-card:nth-child(2) { animation: portal-fade-up .45s .10s cubic-bezier(.22,1,.36,1) both; }
.stats-grid .stat-card:nth-child(3) { animation: portal-fade-up .45s .15s cubic-bezier(.22,1,.36,1) both; }
.stats-grid .stat-card:nth-child(4) { animation: portal-fade-up .45s .20s cubic-bezier(.22,1,.36,1) both; }
.stats-grid .stat-card:nth-child(5) { animation: portal-fade-up .45s .25s cubic-bezier(.22,1,.36,1) both; }
.track-grid .track-card:nth-child(1) { animation: portal-fade-up .45s .10s cubic-bezier(.22,1,.36,1) both; }
.track-grid .track-card:nth-child(2) { animation: portal-fade-up .45s .15s cubic-bezier(.22,1,.36,1) both; }
.track-grid .track-card:nth-child(3) { animation: portal-fade-up .45s .20s cubic-bezier(.22,1,.36,1) both; }
.track-grid .track-card:nth-child(4) { animation: portal-fade-up .45s .25s cubic-bezier(.22,1,.36,1) both; }
.spaces-grid .space-card:nth-child(1) { animation: portal-fade-up .45s .08s cubic-bezier(.22,1,.36,1) both; }
.spaces-grid .space-card:nth-child(2) { animation: portal-fade-up .45s .14s cubic-bezier(.22,1,.36,1) both; }
.spaces-grid .space-card:nth-child(3) { animation: portal-fade-up .45s .20s cubic-bezier(.22,1,.36,1) both; }

/* ---------- Stat card — hover + gradient number ---------- */
.stat-card {
  transition: transform .25s ease, box-shadow .25s ease;
  will-change: transform;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #1a73e8, #10b981);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease;
}
.stat-card:hover::after { transform: scaleX(1); }
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 48px rgba(26,115,232,.14);
}
.stat-card strong {
  background: linear-gradient(135deg, #1a73e8 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
}

/* ---------- Track card hover ---------- */
.track-card {
  transition: transform .25s ease, box-shadow .25s ease, border-color .2s ease;
}
.track-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(26,115,232,.12);
  border-color: rgba(26,115,232,.3);
}

/* ---------- Animated progress meter fill ---------- */
.progress-meter span {
  transition: width .9s cubic-bezier(.22,1,.36,1);
}

/* ---------- Space card hover ---------- */
.space-card {
  transition: transform .25s ease, box-shadow .25s ease, border-color .2s ease;
}
.space-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(26,115,232,.12);
  border-color: rgba(26,115,232,.3);
}

/* ---------- Portal panel top accent on hover ---------- */
.portal-panel {
  position: relative;
  overflow: hidden;
}
.portal-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #1a73e8, #8b5cf6, #10b981);
  opacity: 0;
  transition: opacity .3s ease;
  z-index: 1;
}
.portal-panel:hover::before { opacity: 1; }

/* ---------- Form card animated top gradient border ---------- */
.form-card {
  position: relative;
  overflow: hidden;
}
.form-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #1a73e8, #8b5cf6, #10b981, #1a73e8);
  background-size: 300% 100%;
  animation: gradient-slide-border 4s linear infinite;
  z-index: 1;
}
@keyframes gradient-slide-border {
  0%   { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

/* ---------- Flash message slide-in animation ---------- */
.portal-flash {
  animation: flash-slide-in .35s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes flash-slide-in {
  from { opacity: 0; transform: translateY(-12px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.portal-flash.flash-dismissing {
  animation: flash-slide-out .3s ease forwards;
}
@keyframes flash-slide-out {
  from { opacity: 1; transform: translateY(0); max-height: 80px; margin-bottom: 14px; }
  to   { opacity: 0; transform: translateY(-10px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}

/* ---------- Button micro-interactions ---------- */
.btn-primary:hover {
  box-shadow: 0 12px 30px rgba(26,115,232,.30);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(1px); }

/* ---------- Leaderboard row hover ---------- */
.leaderboard-table .leaderboard-row {
  transition: background .2s ease, transform .2s ease;
  border-radius: 14px;
}
.leaderboard-table .leaderboard-row:hover {
  background: rgba(26,115,232,.06);
  transform: scale(1.005);
}

/* ---------- Portal inline stats ---------- */
.portal-inline-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.portal-inline-stat { text-align: center; }
.portal-inline-stat strong {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.1;
  display: block;
  background: linear-gradient(135deg, #1a73e8, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.portal-inline-stat span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  display: block;
  margin-top: 2px;
}

/* ---------- Hero chip list ---------- */
.hero-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.hero-chip {
  display: inline-flex; align-items: center; padding: 5px 12px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(26,115,232,.1); color: var(--primary);
  border: 1px solid rgba(26,115,232,.2);
  transition: background .2s, box-shadow .2s;
}
.hero-chip:hover {
  background: rgba(26,115,232,.18);
  box-shadow: 0 0 0 3px rgba(26,115,232,.15);
}

/* ---------- Portal sidebar card hover ---------- */
.portal-sidebar-card {
  transition: transform .25s ease, box-shadow .25s ease;
}
.portal-sidebar-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 40px rgba(26,115,232,.12);
}

/* ---------- Admin mini bars enhanced ---------- */
.admin-mini-bar {
  cursor: pointer;
  transition: filter .15s ease, transform .15s ease;
}
.admin-mini-bar:hover {
  filter: brightness(1.3);
  transform: scaleY(1.05);
  transform-origin: bottom;
}

/* ---------- Skeleton shimmer (loading states) ---------- */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, rgba(200,210,230,.3) 25%, rgba(200,210,230,.6) 50%, rgba(200,210,230,.3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  color: transparent !important;
  pointer-events: none;
}

/* ====================================================================
   DARK MODE — PORTAL OVERRIDES
   ==================================================================== */

[data-theme="dark"] .portal-shell {
  background:
    radial-gradient(ellipse 60% 40% at 20% 30%, rgba(26,115,232,.18), transparent),
    radial-gradient(ellipse 50% 35% at 80% 70%, rgba(16,185,129,.14), transparent),
    #0d0e1a;
}

[data-theme="dark"] .portal-hero,
[data-theme="dark"] .portal-panel,
[data-theme="dark"] .auth-panel,
[data-theme="dark"] .form-card,
[data-theme="dark"] .profile-card,
[data-theme="dark"] .portal-sidebar-card {
  background: rgba(25,26,46,.92);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border-color: rgba(37,39,66,.95);
  box-shadow: 0 8px 32px rgba(0,0,0,.40);
}

[data-theme="dark"] .stat-card {
  background: rgba(25,26,46,.90);
  border-color: rgba(37,39,66,.95);
}

[data-theme="dark"] .track-card,
[data-theme="dark"] .space-card {
  background: rgba(25,26,46,.88);
  border-color: rgba(37,39,66,.9);
}

[data-theme="dark"] .track-card:hover,
[data-theme="dark"] .space-card:hover {
  border-color: rgba(26,115,232,.45);
  box-shadow: 0 20px 40px rgba(0,0,0,.30);
}

[data-theme="dark"] .stat-card:hover {
  box-shadow: 0 24px 48px rgba(0,0,0,.35);
}

[data-theme="dark"] .leaderboard-row {
  background: rgba(25,26,46,.80);
  border-color: rgba(37,39,66,.85);
}

[data-theme="dark"] .leaderboard-table .leaderboard-row:hover {
  background: rgba(26,115,232,.12);
}

[data-theme="dark"] .leaderboard-row.is-current {
  background: rgba(26,115,232,.18);
  border-color: rgba(26,115,232,.40);
}

[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea {
  background: rgba(13,14,26,.85);
  border-color: rgba(37,39,66,.95);
  color: #dde3f5;
}

[data-theme="dark"] .field input:focus,
[data-theme="dark"] .field select:focus,
[data-theme="dark"] .field textarea:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 4px rgba(26,115,232,.22);
  background: rgba(10,11,22,.92);
}

[data-theme="dark"] .field label { color: rgba(200,214,240,.85); }
[data-theme="dark"] .field small,
[data-theme="dark"] .form-helper { color: rgba(160,180,220,.65); }
[data-theme="dark"] .field small a,
[data-theme="dark"] .form-helper a { color: #7fb3ff; }

[data-theme="dark"] .filter-chip {
  background: rgba(25,26,46,.8);
  border-color: rgba(37,39,66,.9);
  color: rgba(200,214,240,.7);
}

[data-theme="dark"] .filter-chip.active {
  background: rgba(26,115,232,.25);
  border-color: rgba(26,115,232,.55);
  color: #93c5fd;
}

[data-theme="dark"] .admin-tab-btn {
  background: rgba(25,26,46,.85);
  border-color: rgba(37,39,66,.9);
  color: rgba(200,214,240,.75);
}

[data-theme="dark"] .admin-tab-btn.active {
  background: linear-gradient(135deg, #1a73e8, #0ea5e9);
  color: #fff;
  border-color: transparent;
}

[data-theme="dark"] .admin-bar-row,
[data-theme="dark"] .admin-analytics-card,
[data-theme="dark"] .admin-mini-widget {
  background: rgba(25,26,46,.85);
  border-color: rgba(37,39,66,.9);
  color: rgba(220,230,255,.8);
}

[data-theme="dark"] .admin-bar-track { background: rgba(26,115,232,.18); }

[data-theme="dark"] .admin-page-link {
  background: rgba(25,26,46,.85);
  border-color: rgba(37,39,66,.9);
  color: rgba(200,214,240,.75);
}

[data-theme="dark"] .admin-page-link.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

[data-theme="dark"] .admin-toolbar-search input,
[data-theme="dark"] .admin-controls-row select {
  background: rgba(13,14,26,.85);
  border-color: rgba(37,39,66,.9);
  color: #dde3f5;
}

[data-theme="dark"] .portal-flash-error {
  background: rgba(239,68,68,.18);
  color: #fca5a5;
  border-color: rgba(239,68,68,.35);
}

[data-theme="dark"] .portal-flash-success {
  background: rgba(16,185,129,.18);
  color: #6ee7b7;
  border-color: rgba(16,185,129,.35);
}

[data-theme="dark"] .choice-card {
  background: rgba(25,26,46,.8);
  border-color: rgba(37,39,66,.9);
  color: rgba(200,214,240,.7);
}

[data-theme="dark"] .choice-card.active {
  background: rgba(26,115,232,.22);
  border-color: rgba(26,115,232,.5);
  color: #93c5fd;
}

[data-theme="dark"] .auth-page .auth-panel-pro {
  background:
    linear-gradient(135deg, rgba(13,24,42,.98) 0%, rgba(18,50,61,.98) 52%, rgba(20,72,55,.98) 100%);
  border-color: rgba(122,162,210,.20);
}

[data-theme="dark"] .auth-page .auth-form-card {
  background: rgba(18,20,35,.96);
  border-color: rgba(64,76,112,.72);
}

[data-theme="dark"] .auth-form-kicker {
  background: rgba(26,115,232,.18);
  color: #93c5fd;
}

[data-theme="dark"] .auth-brand-mark {
  color: #0d1424;
}

[data-theme="dark"] .auth-safe-note {
  background: rgba(16,185,129,.12);
  border-color: rgba(16,185,129,.28);
}

[data-theme="dark"] .auth-safe-note strong,
[data-theme="dark"] .auth-choice span {
  color: rgba(235,246,255,.88);
}

[data-theme="dark"] .auth-safe-note span,
[data-theme="dark"] .auth-choice small,
[data-theme="dark"] .auth-switch {
  color: rgba(200,214,240,.66);
}

[data-theme="dark"] .auth-choice.active span,
[data-theme="dark"] .auth-choice.active small {
  color: #93c5fd;
}

[data-theme="dark"] .auth-form-stepper span {
  background: rgba(25,26,46,.78);
  border-color: rgba(64,76,112,.72);
  color: rgba(200,214,240,.66);
}

[data-theme="dark"] .auth-form-stepper span.active {
  background: rgba(26,115,232,.20);
  border-color: rgba(26,115,232,.40);
  color: #93c5fd;
}

[data-theme="dark"] .auth-form-section span {
  color: rgba(235,246,255,.88);
}

[data-theme="dark"] .auth-form-section small,
[data-theme="dark"] .auth-terms {
  color: rgba(200,214,240,.62);
}

[data-theme="dark"] .password-meter {
  background: rgba(255,255,255,.10);
}

[data-theme="dark"] .hero-chip {
  background: rgba(26,115,232,.18);
  color: #7fb3ff;
  border-color: rgba(26,115,232,.35);
}

[data-theme="dark"] .stack-tag {
  background: rgba(26,115,232,.16);
  color: #7fb3ff;
}

[data-theme="dark"] .portal-top-nav {
  background: rgba(13,14,26,.95);
  border-color: rgba(37,39,66,.95);
}

[data-theme="dark"] .portal-user-pill {
  background: rgba(25,26,46,.92);
  border-color: rgba(37,39,66,.9);
  color: rgba(220,230,255,.9);
}

[data-theme="dark"] .auth-list li {
  color: rgba(200,214,240,.7);
}

[data-theme="dark"] .auth-list li::before { color: #10b981; }

[data-theme="dark"] .portal-inline-stats {
  border-color: rgba(37,39,66,.9);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, rgba(37,39,66,.6) 25%, rgba(55,60,100,.8) 50%, rgba(37,39,66,.6) 75%);
  background-size: 200% 100%;
}

[data-theme="dark"] .admin-filter-summary,
[data-theme="dark"] .admin-empty-state {
  color: rgba(200,214,240,.6);
}

[data-theme="dark"] .panel-header p,
[data-theme="dark"] .portal-lead {
  color: rgba(200,214,240,.7);
}

@media (prefers-reduced-motion: reduce) {
  .portal-hero,
  .portal-panel,
  .form-card,
  .stat-card,
  .track-card,
  .space-card,
  .portal-sidebar-card,
  .portal-flash,
  .progress-meter span {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================
   Portal Professional Polish Layer
   ============================================================ */
.portal-shell {
  --portal-surface: rgba(255,255,255,.94);
  --portal-surface-solid: #ffffff;
  --portal-surface-muted: #f7f9fc;
  --portal-border: rgba(15,23,42,.10);
  --portal-border-strong: rgba(15,23,42,.16);
  --portal-shadow-sm: 0 8px 24px rgba(12,22,44,.07);
  --portal-shadow-md: 0 18px 44px rgba(12,22,44,.10);
  --portal-shadow-lg: 0 28px 70px rgba(12,22,44,.14);
  --portal-focus: 0 0 0 4px rgba(26,115,232,.18);
  background:
    linear-gradient(180deg, #f7faff 0%, #f4f7fb 42%, #ffffff 100%);
}

.dashboard-page.portal-shell {
  background:
    linear-gradient(180deg, #f7faff 0%, #f4f7fb 48%, #ffffff 100%);
}

.portal-main {
  max-width: 1200px;
  padding-bottom: 72px;
}

.portal-top-nav {
  border-bottom: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 10px 30px rgba(2,6,23,.22);
}

.portal-join-btn,
.portal-secondary-action,
.portal-user-pill,
.portal-flash,
.hero-chip,
.stack-tag,
.track-badge,
.filter-chip,
.choice-card,
.auth-choice,
.auth-form-stepper span,
.admin-tab-btn,
.admin-page-link,
.admin-controls-row select,
.admin-toolbar-search input {
  border-radius: 8px;
  letter-spacing: 0;
}

.portal-hero {
  border-radius: 8px;
  padding: 30px;
  gap: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.98), rgba(248,251,255,.96));
  border: 1px solid var(--portal-border);
  box-shadow: var(--portal-shadow-md);
}

.portal-hero::before {
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #1a73e8 0%, #0f9f6e 70%, #d97706 100%);
  opacity: .95;
}

.dashboard-page .portal-hero {
  background: transparent;
  border: 0;
  box-shadow: none;
}

:is(.portal-panel, .auth-panel, .auth-page .auth-panel-pro, .auth-page .auth-form-card, .form-card, .profile-card, .stat-card, .track-card, .space-card, .portal-sidebar-card, .hero-score-card, .admin-analytics-card, .admin-mini-widget, .admin-bar-row, .auth-preview-card, .auth-safe-note) {
  border-radius: 8px;
  border: 1px solid var(--portal-border);
  background: var(--portal-surface);
  box-shadow: var(--portal-shadow-sm);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

:is(.track-card, .space-card, .stat-card, .portal-sidebar-card, .admin-analytics-card, .admin-mini-widget, .auth-choice, .choice-card):hover {
  border-color: var(--portal-border-strong);
  box-shadow: var(--portal-shadow-md);
  transform: translateY(-2px);
}

.portal-panel::before,
.form-card::before {
  border-radius: 8px 8px 0 0;
}

.panel-header {
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--portal-border);
}

.panel-header h2,
.portal-hero h1,
.auth-panel h1,
.auth-page .auth-panel-pro h1,
.auth-page .auth-form-card .panel-header h2,
.page-heading,
.stat-card strong,
.auth-metric strong,
.admin-analytics-card strong {
  letter-spacing: 0;
}

.portal-lead,
.panel-header p,
.page-subtitle {
  max-width: 72ch;
}

.hero-chip,
.stack-tag,
.track-badge {
  border: 1px solid rgba(26,115,232,.14);
  background: rgba(26,115,232,.08);
}

.portal-inline-stats {
  border-radius: 8px;
  border: 1px solid var(--portal-border);
  background: rgba(255,255,255,.70);
}

.stat-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
}

.track-card,
.space-card {
  min-height: 100%;
}

.progress-meter,
.auth-progress-bar,
.admin-bar-track {
  border-radius: 999px;
  background: rgba(26,115,232,.12);
}

.progress-meter span,
.auth-progress-bar span,
.admin-bar-track span {
  background: linear-gradient(90deg, #1a73e8 0%, #0f9f6e 100%);
}

.field input,
.field select,
.field textarea,
.admin-toolbar-search input,
.admin-controls-row select {
  border: 1px solid var(--portal-border);
  background: rgba(255,255,255,.94);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.72);
  transition:
    border-color .18s ease,
    box-shadow .18s ease,
    background-color .18s ease;
}

.field input,
.field select,
.admin-toolbar-search input,
.admin-controls-row select {
  min-height: 42px;
}

.field textarea {
  min-height: 118px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.admin-toolbar-search input:focus,
.admin-controls-row select:focus {
  outline: none;
  border-color: rgba(26,115,232,.56);
  box-shadow: var(--portal-focus);
}

.auth-page .auth-form-card .field input {
  border-radius: 8px;
}

.auth-submit-btn,
.btn-primary {
  border-radius: 8px;
  background: linear-gradient(135deg, #1a73e8 0%, #0f9f6e 118%);
  box-shadow: 0 12px 26px rgba(26,115,232,.22);
}

.auth-submit-btn:hover,
.btn-primary:hover {
  box-shadow: 0 16px 32px rgba(26,115,232,.26);
  transform: translateY(-1px);
}

.btn-outline,
.admin-danger-btn,
.admin-page-link,
.filter-chip,
.choice-card,
.auth-choice {
  transition:
    border-color .18s ease,
    background-color .18s ease,
    color .18s ease,
    box-shadow .18s ease,
    transform .18s ease;
}

.leaderboard-table,
.admin-table {
  display: grid;
  gap: 8px;
}

.leaderboard-table .leaderboard-row,
.admin-table .leaderboard-row {
  border-radius: 8px;
  border: 1px solid var(--portal-border);
  background: var(--portal-surface);
  box-shadow: 0 1px 2px rgba(12,22,44,.04);
}

.leaderboard-table .leaderboard-row:hover,
.admin-table .leaderboard-row:hover {
  border-color: var(--portal-border-strong);
  box-shadow: var(--portal-shadow-sm);
}

.leaderboard-row.is-current {
  border-color: rgba(26,115,232,.42);
  box-shadow: 0 0 0 4px rgba(26,115,232,.10), var(--portal-shadow-sm);
}

.admin-toolbar {
  align-items: stretch;
}

.admin-toolbar-search {
  width: 100%;
}

.admin-tab-btn {
  min-height: 40px;
}

.admin-tab-btn.active {
  background: linear-gradient(135deg, #1a73e8 0%, #0f9f6e 118%);
  box-shadow: 0 10px 22px rgba(26,115,232,.20);
}

.admin-controls-row label {
  letter-spacing: 0;
}

.admin-page-link:hover {
  border-color: rgba(26,115,232,.36);
  box-shadow: var(--portal-shadow-sm);
  text-decoration: none;
}

.portal-flash {
  box-shadow: var(--portal-shadow-sm);
}

.portal-flash-success {
  background: #ecfdf5;
  border-color: rgba(16,185,129,.28);
  color: #065f46;
}

.portal-flash-error {
  background: #fff1f2;
  border-color: rgba(244,63,94,.30);
  color: #9f1239;
}

[data-theme="dark"] .portal-shell {
  --portal-surface: rgba(22,24,42,.92);
  --portal-surface-solid: #151827;
  --portal-surface-muted: #101321;
  --portal-border: rgba(148,163,184,.18);
  --portal-border-strong: rgba(148,163,184,.30);
  --portal-shadow-sm: 0 8px 24px rgba(0,0,0,.34);
  --portal-shadow-md: 0 18px 44px rgba(0,0,0,.44);
  --portal-shadow-lg: 0 28px 70px rgba(0,0,0,.56);
  --portal-focus: 0 0 0 4px rgba(79,156,249,.22);
  background:
    linear-gradient(180deg, #0d101e 0%, #101321 48%, #090b14 100%);
}

[data-theme="dark"] .dashboard-page.portal-shell {
  background:
    linear-gradient(180deg, #0d101e 0%, #101321 48%, #090b14 100%);
}

[data-theme="dark"] .portal-hero {
  background:
    linear-gradient(180deg, rgba(22,24,42,.96), rgba(16,19,33,.96));
  border-color: var(--portal-border);
}

[data-theme="dark"] :is(.portal-panel, .auth-panel, .auth-page .auth-panel-pro, .auth-page .auth-form-card, .form-card, .profile-card, .stat-card, .track-card, .space-card, .portal-sidebar-card, .hero-score-card, .admin-analytics-card, .admin-mini-widget, .admin-bar-row, .auth-preview-card, .auth-safe-note, .leaderboard-table .leaderboard-row, .admin-table .leaderboard-row) {
  background: var(--portal-surface);
  border-color: var(--portal-border);
}

[data-theme="dark"] .portal-inline-stats,
[data-theme="dark"] .field input,
[data-theme="dark"] .field select,
[data-theme="dark"] .field textarea,
[data-theme="dark"] .admin-toolbar-search input,
[data-theme="dark"] .admin-controls-row select {
  background: rgba(16,19,33,.92);
  border-color: var(--portal-border);
}

[data-theme="dark"] .hero-chip,
[data-theme="dark"] .stack-tag,
[data-theme="dark"] .track-badge {
  background: rgba(79,156,249,.12);
  border-color: rgba(79,156,249,.24);
}

[data-theme="dark"] .portal-flash-success {
  background: rgba(6,95,70,.22);
  border-color: rgba(16,185,129,.34);
  color: #86efac;
}

[data-theme="dark"] .portal-flash-error {
  background: rgba(127,29,29,.24);
  border-color: rgba(248,113,113,.34);
  color: #fecaca;
}

@media (max-width: 1100px) {
  .portal-hero {
    padding: 26px;
  }

  .admin-analytics-grid,
  .admin-mini-visuals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .portal-main {
    padding-inline: 16px;
  }

  .portal-hero {
    padding: 22px;
  }

  .portal-hero h1,
  .auth-panel h1,
  .page-heading {
    font-size: clamp(30px, 9vw, 42px);
  }

  .admin-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-toolbar-search {
    grid-column: 1 / -1;
  }

  .leaderboard-table .leaderboard-row,
  .admin-table .leaderboard-row {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .admin-actions-col {
    align-items: stretch;
  }
}

@media (max-width: 520px) {
  .portal-main {
    padding-inline: 14px;
  }

  .portal-hero,
  :is(.portal-panel, .auth-panel, .auth-page .auth-panel-pro, .auth-page .auth-form-card, .form-card, .profile-card, .stat-card, .track-card, .space-card, .portal-sidebar-card) {
    padding-inline: 18px;
  }

  .admin-analytics-grid,
  .admin-mini-visuals {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* track-card/space-card/stat-card/portal-sidebar-card are already covered above */
  :is(.admin-analytics-card, .admin-mini-widget, .auth-choice, .choice-card, .auth-submit-btn, .btn-primary) {
    transition: none !important;
  }
}

/* ── Explore page ─────────────────────────────────────────────────────── */
.explore-search-form {
  margin-bottom: 24px;
}

.explore-owner {
  font-size: 13px;
  color: var(--text-med);
  margin: 8px 0;
}

.explore-owner a {
  font-weight: 600;
}

.explore-pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.explore-pagination a {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text-med);
  font-size: 14px;
  font-weight: 600;
}

.explore-pagination a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.space-tags {
  font-size: 12px;
  color: var(--text-med);
  margin: 4px 0 10px;
}

/* ── Guided developer curriculum ─────────────────────────────────────── */
.learning-hero { align-items: stretch; }
.learning-principles { max-width: 390px; }
.learning-principles ol { margin: 18px 0 0; padding-left: 22px; display: grid; gap: 14px; color: var(--text-med); }
.learning-section-head { margin: 12px 0 22px; }
.learning-phase-list { display: grid; gap: 18px; margin-bottom: 28px; }
.learning-phase-card { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 24px; padding: 28px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-sm); }
.learning-phase-marker { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), #0ea5e9); color: #fff; font-size: 22px; font-weight: 900; }
.learning-phase-meta { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 8px; }
.learning-phase-meta span { padding: 5px 10px; border-radius: 999px; background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 800; }
.learning-phase-body h3 { margin: 0 0 8px; font-size: clamp(22px, 3vw, 30px); }
.learning-phase-body > p { max-width: 820px; color: var(--text-med); }
.learning-skill-links { display: flex; flex-wrap: wrap; gap: 9px; margin: 18px 0; }
.learning-skill-links a { padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; font-weight: 750; background: var(--surface-raised); }
.learning-practice-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(210px, 1fr); gap: 14px; }
.learning-practice-grid > div { padding: 16px; border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--border); }
.learning-practice-grid p { margin: 7px 0 0; color: var(--text-med); }
.learning-workflow { margin-bottom: 34px; }
.learning-workflow-grid { list-style: none; margin: 0; padding: 0; counter-reset: workflow; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.learning-workflow-grid li { counter-increment: workflow; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); display: grid; gap: 7px; }
.learning-workflow-grid li::before { content: counter(workflow, decimal-leading-zero); color: var(--primary); font-size: 12px; font-weight: 900; }
.learning-workflow-grid span { color: var(--text-med); font-size: 14px; }
@media (max-width: 760px) {
  .learning-phase-card { grid-template-columns: 1fr; padding: 20px; }
  .learning-practice-grid, .learning-workflow-grid { grid-template-columns: 1fr; }
  .learning-principles { max-width: none; }
}
.clipboard-fallback {
  position: fixed;
  opacity: 0;
  pointer-events: none;
}

.collab-avatar-1 { background: #2563eb; }
.collab-avatar-2 { background: #7c3aed; }
.collab-avatar-3 { background: #0891b2; }
.collab-avatar-4 { background: #059669; }
.collab-avatar-5 { background: #d97706; }
.collab-avatar-6 { background: #dc2626; }
.reset-link-row { margin-top: 8px; }
.is-hidden, .admin-filter-hidden { display: none !important; }
.portal-flash-dismissible { display: flex; align-items: center; gap: 8px; }
.flash-close-button { background: none; border: 0; cursor: pointer; margin-left: auto; font-size: 18px; line-height: 1; opacity: .6; padding: 0 0 0 12px; color: inherit; flex-shrink: 0; }
.track-title-cell { flex: 1; min-width: 0; }
.track-accent-1 { --track-accent: #2563eb; }
.track-accent-2 { --track-accent: #7c3aed; }
.track-accent-3 { --track-accent: #0891b2; }
.track-accent-4 { --track-accent: #059669; }
.track-accent-5 { --track-accent: #d97706; }
.track-accent-6 { --track-accent: #dc2626; }
span.progress-width-0 { width: 0%; }
span.progress-width-1 { width: 1%; }
span.progress-width-2 { width: 2%; }
span.progress-width-3 { width: 3%; }
span.progress-width-4 { width: 4%; }
span.progress-width-5 { width: 5%; }
span.progress-width-6 { width: 6%; }
span.progress-width-7 { width: 7%; }
span.progress-width-8 { width: 8%; }
span.progress-width-9 { width: 9%; }
span.progress-width-10 { width: 10%; }
span.progress-width-11 { width: 11%; }
span.progress-width-12 { width: 12%; }
span.progress-width-13 { width: 13%; }
span.progress-width-14 { width: 14%; }
span.progress-width-15 { width: 15%; }
span.progress-width-16 { width: 16%; }
span.progress-width-17 { width: 17%; }
span.progress-width-18 { width: 18%; }
span.progress-width-19 { width: 19%; }
span.progress-width-20 { width: 20%; }
span.progress-width-21 { width: 21%; }
span.progress-width-22 { width: 22%; }
span.progress-width-23 { width: 23%; }
span.progress-width-24 { width: 24%; }
span.progress-width-25 { width: 25%; }
span.progress-width-26 { width: 26%; }
span.progress-width-27 { width: 27%; }
span.progress-width-28 { width: 28%; }
span.progress-width-29 { width: 29%; }
span.progress-width-30 { width: 30%; }
span.progress-width-31 { width: 31%; }
span.progress-width-32 { width: 32%; }
span.progress-width-33 { width: 33%; }
span.progress-width-34 { width: 34%; }
span.progress-width-35 { width: 35%; }
span.progress-width-36 { width: 36%; }
span.progress-width-37 { width: 37%; }
span.progress-width-38 { width: 38%; }
span.progress-width-39 { width: 39%; }
span.progress-width-40 { width: 40%; }
span.progress-width-41 { width: 41%; }
span.progress-width-42 { width: 42%; }
span.progress-width-43 { width: 43%; }
span.progress-width-44 { width: 44%; }
span.progress-width-45 { width: 45%; }
span.progress-width-46 { width: 46%; }
span.progress-width-47 { width: 47%; }
span.progress-width-48 { width: 48%; }
span.progress-width-49 { width: 49%; }
span.progress-width-50 { width: 50%; }
span.progress-width-51 { width: 51%; }
span.progress-width-52 { width: 52%; }
span.progress-width-53 { width: 53%; }
span.progress-width-54 { width: 54%; }
span.progress-width-55 { width: 55%; }
span.progress-width-56 { width: 56%; }
span.progress-width-57 { width: 57%; }
span.progress-width-58 { width: 58%; }
span.progress-width-59 { width: 59%; }
span.progress-width-60 { width: 60%; }
span.progress-width-61 { width: 61%; }
span.progress-width-62 { width: 62%; }
span.progress-width-63 { width: 63%; }
span.progress-width-64 { width: 64%; }
span.progress-width-65 { width: 65%; }
span.progress-width-66 { width: 66%; }
span.progress-width-67 { width: 67%; }
span.progress-width-68 { width: 68%; }
span.progress-width-69 { width: 69%; }
span.progress-width-70 { width: 70%; }
span.progress-width-71 { width: 71%; }
span.progress-width-72 { width: 72%; }
span.progress-width-73 { width: 73%; }
span.progress-width-74 { width: 74%; }
span.progress-width-75 { width: 75%; }
span.progress-width-76 { width: 76%; }
span.progress-width-77 { width: 77%; }
span.progress-width-78 { width: 78%; }
span.progress-width-79 { width: 79%; }
span.progress-width-80 { width: 80%; }
span.progress-width-81 { width: 81%; }
span.progress-width-82 { width: 82%; }
span.progress-width-83 { width: 83%; }
span.progress-width-84 { width: 84%; }
span.progress-width-85 { width: 85%; }
span.progress-width-86 { width: 86%; }
span.progress-width-87 { width: 87%; }
span.progress-width-88 { width: 88%; }
span.progress-width-89 { width: 89%; }
span.progress-width-90 { width: 90%; }
span.progress-width-91 { width: 91%; }
span.progress-width-92 { width: 92%; }
span.progress-width-93 { width: 93%; }
span.progress-width-94 { width: 94%; }
span.progress-width-95 { width: 95%; }
span.progress-width-96 { width: 96%; }
span.progress-width-97 { width: 97%; }
span.progress-width-98 { width: 98%; }
span.progress-width-99 { width: 99%; }
span.progress-width-100 { width: 100%; }

/* Hands-on challenge workbench */
.learning-challenge-links { display: flex; flex-wrap: wrap; gap: .65rem; margin-top: 1rem; }
.challenge-page { padding-top: 2rem; }
.challenge-breadcrumb { display: flex; align-items: center; gap: .55rem; margin-bottom: 1.5rem; color: var(--muted, #64748b); font-size: .9rem; }
.challenge-breadcrumb a { color: var(--primary, #2563eb); font-weight: 700; }
.challenge-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; align-items: end; margin-bottom: 1.5rem; }
.challenge-hero h1 { margin: .45rem 0 .65rem; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.05; }
.challenge-limits { display: grid; grid-template-columns: repeat(3, minmax(7rem, 1fr)); gap: .65rem; margin: 0; }
.challenge-limits div { padding: .85rem 1rem; border: 1px solid var(--border, #dbe3ef); border-radius: .8rem; background: var(--surface, #fff); }
.challenge-limits dt { color: var(--muted, #64748b); font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.challenge-limits dd { margin: .3rem 0 0; font-weight: 800; }
.challenge-workbench { display: grid; grid-template-columns: minmax(16rem, .7fr) minmax(0, 1.6fr); gap: 1rem; align-items: stretch; }
.challenge-requirements ol { display: grid; gap: .65rem; padding-left: 1.35rem; }
.challenge-requirements li { padding-left: .25rem; }
.challenge-hint-text { min-height: 2.6rem; color: var(--muted, #64748b); }
.challenge-auth-note { margin-top: 1.25rem; padding: 1rem; border-radius: .75rem; background: rgba(37, 99, 235, .08); }
.challenge-auth-note p { margin: .35rem 0 0; }
.challenge-editor-panel { min-width: 0; }
.challenge-editor-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .65rem; font-weight: 800; }
.challenge-editor-head span { color: var(--muted, #64748b); font-size: .85rem; }
.challenge-source { box-sizing: border-box; display: block; width: 100%; min-height: 30rem; resize: vertical; padding: 1rem; border: 1px solid #2d3b52; border-radius: .8rem; background: #0d1524; color: #e5edf8; font: 500 .9rem/1.65 "Fira Code", Consolas, monospace; tab-size: 2; }
.challenge-source:focus { outline: 3px solid rgba(59, 130, 246, .35); border-color: #60a5fa; }
.challenge-editor-help { color: var(--muted, #64748b); font-size: .82rem; }
.challenge-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.challenge-results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.challenge-result-list, .challenge-history-list { display: grid; gap: .55rem; padding: 0; list-style: none; }
.challenge-result-list li, .challenge-history-list li { display: flex; gap: .7rem; align-items: center; padding: .7rem .8rem; border: 1px solid var(--border, #dbe3ef); border-radius: .65rem; }
.challenge-test-pass, .challenge-history-list .is-passed { color: #087443; background: rgba(16, 185, 129, .07); }
.challenge-test-fail, .challenge-history-list .is-failed { color: #b42318; background: rgba(239, 68, 68, .06); }
.challenge-history-list li { justify-content: space-between; align-items: flex-start; color: inherit; }
.challenge-history-list span { color: var(--muted, #64748b); font-size: .82rem; text-align: right; }
.challenge-empty { max-width: 42rem; margin: 4rem auto; text-align: center; }
@media (max-width: 900px) {
  .challenge-hero, .challenge-workbench, .challenge-results-grid { grid-template-columns: 1fr; }
  .challenge-limits { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .challenge-limits { grid-template-columns: 1fr; }
  .challenge-source { min-height: 24rem; font-size: .82rem; }
  .challenge-history-list li { flex-direction: column; }
  .challenge-history-list span { text-align: left; }
}

