/* ─────────────────────────────────────────────────────────────
   01. PROFILE MAIN LAYOUT
───────────────────────────────────────────────────────────── */
.profile-main {
  padding: var(--space-8) 0 var(--space-16);
}


/* ─────────────────────────────────────────────────────────────
   02. PROFILE HERO CARD
───────────────────────────────────────────────────────────── */
.profile-hero-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  padding: var(--space-8);
}

/* Gradient background decoration */
.profile-hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(16,185,129,.08) 0%,
    rgba(99,102,241,.06) 50%,
    transparent 100%
  );
  pointer-events: none;
}
.profile-hero-bg::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 280px;
  height: 280px;
  background: radial-gradient(
    circle,
    rgba(16,185,129,.10) 0%,
    transparent 70%
  );
}
.profile-hero-bg::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: 20%;
  width: 200px;
  height: 200px;
  background: radial-gradient(
    circle,
    rgba(99,102,241,.07) 0%,
    transparent 70%
  );
}


/* ─────────────────────────────────────────────────────────────
   03. AVATAR UPLOAD & DISPLAY
───────────────────────────────────────────────────────────── */
.profile-avatar-section {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.profile-avatar-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
/* Drag-over highlight */
.profile-avatar-wrap.drag-over {
  outline: 3px dashed var(--primary);
  outline-offset: 4px;
}

/* The actual avatar image */
.profile-avatar-img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  display: block;
}

/* Initials fallback */
.profile-avatar-initials {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-3xl);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  user-select: none;
}

/* Camera overlay on hover */
.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease);
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.profile-avatar-overlay i { font-size: var(--text-xl); }
.profile-avatar-wrap:hover .profile-avatar-overlay { opacity: 1; }

/* Upload online indicator ring */
.profile-avatar-wrap::after {
  content: '';
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  background: var(--success);
  border: 3px solid var(--surface);
  border-radius: 50%;
}

.profile-avatar-actions{
    display:flex;
    gap:8px;
    justify-content:center;
    margin-top:12px;
    position:relative;
    z-index:2;
}

.profile-avatar-hint {
  font-size: 10px;
  color: var(--text-faint);
  text-align: center;
  max-width: 130px;
  line-height: 1.4;
  margin: 0;
}


/* ─────────────────────────────────────────────────────────────
   04. PROFILE INFO SECTION
───────────────────────────────────────────────────────────── */
.profile-info-section {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.profile-info-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.profile-name {
  font-size: var(--text-3xl);
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.profile-handle {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
}

.profile-info-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Meta row (year, college, country, joined) */
.profile-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
}

.profile-meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}
.profile-meta-item i {
  color: var(--text-faint);
  font-size: 0.9em;
  flex-shrink: 0;
}

.profile-bio {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 560px;
  margin: 0;
}


/* ─────────────────────────────────────────────────────────────
   05. RANK BADGE
───────────────────────────────────────────────────────────── */
.profile-rank-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  background: linear-gradient(135deg, var(--primary-pale), #eff6ff);
  border: 1.5px solid rgba(16,185,129,.25);
  border-radius: var(--radius-xl);
  padding: var(--space-3) var(--space-5);
  width: fit-content;
}

.profile-rank-num {
  font-size: var(--text-2xl);
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.profile-rank-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-rank-pct {
  color: var(--primary);
  font-weight: 700;
}


/* ─────────────────────────────────────────────────────────────
   06. QUICK STATS GRID
───────────────────────────────────────────────────────────── */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.profile-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease);
}
.profile-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Stat icon variants */
.profile-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-spring);
}
.profile-stat-card:hover .profile-stat-icon {
  transform: scale(1.15) rotate(-5deg);
}

.psi-green  { background: var(--primary-pale);  color: var(--primary);   }
.psi-blue   { background: #dbeafe; color: #2563eb; }
.psi-orange { background: var(--accent-pale);   color: var(--accent-dark); }
.psi-purple { background: var(--secondary-pale);color: var(--secondary);  }
.psi-teal   { background: #ccfbf1; color: #0d9488; }
.psi-rose   { background: #ffe4e6; color: #f43f5e; }

.profile-stat-body {
  flex: 1;
  min-width: 0;
}

.profile-stat-val {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-stat-lbl {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}


/* ─────────────────────────────────────────────────────────────
   07. PROFILE TABS BAR
───────────────────────────────────────────────────────────── */
.profile-tabs-bar {
  display: flex;
  gap: var(--space-1);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-1);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.profile-tabs-bar::-webkit-scrollbar { display: none; }

.profile-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-lg);
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease);
}
.profile-tab i { font-size: 0.9em; }
.profile-tab:hover {
  color: var(--text);
  background: var(--surface);
}
.profile-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}


/* ─────────────────────────────────────────────────────────────
   08. PANEL: STATS
───────────────────────────────────────────────────────────── */
.profile-panels-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

/* Generic profile card */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.profile-card-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.profile-card-title i { color: var(--primary); }

.profile-card-sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-5);
}

/* ── Accuracy Ring ── */
.profile-accuracy-ring-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  margin-top: var(--space-4);
}

.profile-accuracy-ring {
  position: relative;
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}

.profile-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.profile-ring-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 10;
}

.profile-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4,0,0.2,1),
              stroke 0.4s var(--ease);
}

.profile-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.profile-ring-pct {
  font-size: var(--text-2xl);
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.profile-ring-lbl {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Legend */
.profile-accuracy-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.profile-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.profile-legend-item strong { color: var(--text); }

.profile-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Activity Chart ── */
.profile-activity-chart-wrap {
  margin-top: var(--space-4);
  width: 100%;
  height: 130px;
  position: relative;
}
.profile-activity-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}


/* ─────────────────────────────────────────────────────────────
   09. PANEL: SUBJECT MASTERY BARS
───────────────────────────────────────────────────────────── */
.profile-subject-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.profile-subject-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.profile-subject-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.profile-subject-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}

.profile-subject-level {
  font-size: var(--text-xs);
  font-weight: 600;
}

.profile-subject-bar-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.profile-subject-bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.profile-subject-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  width: 0%;
  /* Width animated by JS */
}

.profile-subject-pct {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  min-width: 34px;
  text-align: right;
}


/* ─────────────────────────────────────────────────────────────
   10. PANEL: BADGES GRID
───────────────────────────────────────────────────────────── */
.profile-badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.profile-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  border-radius: var(--radius-xl);
  text-align: center;
  cursor: default;
  position: relative;
  transition: transform var(--duration-fast) var(--ease-spring);
  border: 1.5px solid var(--border);
}

/* Unlocked */
.profile-badge.badge-unlocked {
  background: linear-gradient(135deg, var(--primary-pale), #eff6ff);
  border-color: rgba(16,185,129,.25);
}
.profile-badge.badge-unlocked:hover {
  transform: scale(1.06);
}

/* Locked */
.profile-badge.badge-locked {
  background: var(--bg-secondary);
  border-color: var(--border);
  opacity: 0.6;
}

.profile-badge-icon {
  font-size: 2rem;
  line-height: 1;
}

.profile-badge-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.3;
}
.profile-badge.badge-unlocked .profile-badge-label {
  color: var(--text);
}

/* Checkmark on unlocked */
.profile-badge-check {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 18px;
  height: 18px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}


/* ─────────────────────────────────────────────────────────────
   11. PANEL: SETTINGS – TOGGLES & SELECTS
───────────────────────────────────────────────────────────── */
.profile-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

.profile-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}
.profile-setting-row:last-of-type { border-bottom: none; }

.profile-setting-select-row {
  align-items: center;
  flex-wrap: wrap;
}

.profile-setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-setting-info strong {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}
.profile-setting-info span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Toggle switch */
.profile-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.profile-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.profile-toggle-track {
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--duration-base) var(--ease);
}
.profile-toggle input:checked ~ .profile-toggle-track {
  background: var(--primary);
}
.profile-toggle input:focus-visible ~ .profile-toggle-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.profile-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform var(--duration-base) var(--ease-spring);
}
.profile-toggle input:checked ~ .profile-toggle-track .profile-toggle-thumb {
  transform: translateX(20px);
}

/* Time input */
.profile-time-input {
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  outline: none;
  transition: border-color var(--duration-fast) var(--ease);
}
.profile-time-input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

.profile-setting-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-4);
  margin-top: var(--space-2);
  border-top: 1px solid var(--border);
}


/* ─────────────────────────────────────────────────────────────
   12. SETTINGS – ACCOUNT & DANGER ZONE
───────────────────────────────────────────────────────────── */
.profile-account-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.profile-account-btn {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  text-align: left;
  width: 100%;
  border-radius: var(--radius-lg);
  transition: all var(--duration-fast) var(--ease);
}
.profile-account-btn > i {
  font-size: var(--text-xl);
  color: var(--primary);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.profile-account-btn div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.profile-account-btn strong {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
}
.profile-account-btn span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.profile-account-btn:hover {
  border-color: var(--primary);
  background: var(--primary-pale);
}

/* Danger zone */
.profile-danger-zone {
  border: 1.5px solid rgba(239,68,68,.25);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: rgba(239,68,68,.03);
}

.profile-danger-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--danger);
  margin: 0 0 var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.profile-danger-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.profile-danger-btn {
  justify-content: flex-start;
  color: var(--text-muted);
  border-color: var(--border);
  font-size: var(--text-sm);
}
.profile-danger-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-pale);
}

.profile-delete-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-pale);
}


/* ─────────────────────────────────────────────────────────────
   13. EDIT PROFILE MODAL
───────────────────────────────────────────────────────────── */
.profile-edit-modal {
  max-width: 600px;
  max-height: 90dvh;
  overflow-y: auto;
}

.profile-edit-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.profile-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.profile-form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.profile-form-full {
  grid-column: span 2;
}

.profile-form-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.profile-form-input {
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-sm);
  outline: none;
  transition:
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}
.profile-form-input::placeholder { color: var(--text-faint); }
.profile-form-input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus);
}

select.profile-form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.profile-form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.profile-form-hint {
  font-size: 10px;
  color: var(--text-faint);
}

.profile-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}


/* ─────────────────────────────────────────────────────────────
   14. CROP MODAL
───────────────────────────────────────────────────────────── */
.crop-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  min-height: 200px;
  border: 1px solid var(--border);
}


/* ─────────────────────────────────────────────────────────────
   15. ANIMATIONS
───────────────────────────────────────────────────────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1);    }
}

.profile-hero-card{
    display:grid;
    grid-template-columns:220px 1fr;
    gap:40px;
    align-items:center;
}

.profile-badge.badge-unlocked {
  animation: fadeSlideUp 300ms var(--ease) both;
}
.profile-badges-grid .profile-badge:nth-child(1) { animation-delay: 0ms;   }
.profile-badges-grid .profile-badge:nth-child(2) { animation-delay: 50ms;  }
.profile-badges-grid .profile-badge:nth-child(3) { animation-delay: 100ms; }
.profile-badges-grid .profile-badge:nth-child(4) { animation-delay: 150ms; }
.profile-badges-grid .profile-badge:nth-child(5) { animation-delay: 200ms; }
.profile-badges-grid .profile-badge:nth-child(6) { animation-delay: 250ms; }


/* ─────────────────────────────────────────────────────────────
   16. DARK MODE
───────────────────────────────────────────────────────────── */
[data-theme="dark"] .profile-hero-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .profile-hero-bg {
  background: linear-gradient(
    135deg,
    rgba(16,185,129,.05) 0%,
    rgba(99,102,241,.04) 50%,
    transparent 100%
  );
}

[data-theme="dark"] .profile-avatar-initials {
  border-color: var(--surface-2);
}
[data-theme="dark"] .profile-avatar-img {
  border-color: var(--surface-2);
}
[data-theme="dark"] .profile-avatar-wrap::after {
  border-color: var(--surface);
}

[data-theme="dark"] .profile-rank-badge {
  background: linear-gradient(135deg, var(--primary-pale), rgba(99,102,241,.08));
  border-color: rgba(16,185,129,.2);
}

[data-theme="dark"] .profile-stat-card {
  background: var(--surface);
  border-color: var(--border);
}
[data-theme="dark"] .psi-green  { background: rgba(16,185,129,.12); }
[data-theme="dark"] .psi-blue   { background: rgba(59,130,246,.12); }
[data-theme="dark"] .psi-orange { background: rgba(245,158,11,.12); }
[data-theme="dark"] .psi-purple { background: rgba(99,102,241,.12); }
[data-theme="dark"] .psi-teal   { background: rgba(20,184,166,.12); }
[data-theme="dark"] .psi-rose   { background: rgba(244,63,94,.12);  }

[data-theme="dark"] .profile-tabs-bar {
  background: var(--surface-2);
  border-color: var(--border);
}
[data-theme="dark"] .profile-tab:hover { background: var(--surface-3); }
[data-theme="dark"] .profile-tab.active {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .profile-card {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .profile-ring-bg {
  stroke: var(--surface-2);
}

[data-theme="dark"] .profile-subject-bar-track {
  background: var(--surface-2);
}

[data-theme="dark"] .profile-badge.badge-unlocked {
  background: linear-gradient(135deg, var(--primary-pale), rgba(99,102,241,.08));
  border-color: rgba(16,185,129,.2);
}
[data-theme="dark"] .profile-badge.badge-locked {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .profile-toggle-track {
  background: var(--border-strong);
}

[data-theme="dark"] .profile-time-input {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .profile-form-input {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] select.profile-form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] .profile-account-btn:hover {
  background: var(--primary-pale);
}

[data-theme="dark"] .profile-danger-zone {
  background: rgba(239,68,68,.04);
  border-color: rgba(239,68,68,.2);
}

[data-theme="dark"] .profile-modal-footer {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .crop-preview-wrap {
  background: var(--surface-2);
  border-color: var(--border);
}


/* ─────────────────────────────────────────────────────────────
   17. RESPONSIVE – TABLET (≤ 1024px)
───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .profile-stats-grid    { grid-template-columns: repeat(3, 1fr); }
  .profile-panels-grid   { grid-template-columns: 1fr; }
  .profile-settings-grid { grid-template-columns: 1fr; }
  .profile-badges-grid   { grid-template-columns: repeat(4, 1fr); }
  .profile-hero-card     { gap: var(--space-6); }
}


/* ─────────────────────────────────────────────────────────────
   18. RESPONSIVE – MOBILE (≤ 768px)
───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .profile-main { padding: var(--space-5) 0 var(--space-12); }

  /* Hero stacks vertically */
  .profile-hero-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-6) var(--space-5);
    gap: var(--space-5);
  }

  .profile-avatar-wrap{
    display:flex;
    align-items:center;
    justify-content:center;
}

.profile-avatar-img[hidden]{
    display:none !important;
}

.profile-avatar-initials[hidden]{
    display:none !important;
}

  .profile-avatar-section { width: 100%; }

  .profile-avatar-wrap,
  .profile-avatar-img,
  .profile-avatar-initials { width: 100px; height: 100px; }
  .profile-avatar-initials  { font-size: var(--text-2xl); }

  .profile-info-top { flex-direction: column; align-items: center; }
  .profile-info-actions { justify-content: center; }

  .profile-meta-row { justify-content: center; }

  .profile-rank-badge { margin: 0 auto; }

  /* Stats: 2 cols */
  .profile-stats-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
  .profile-stat-val   { font-size: var(--text-lg); }

  /* Tabs scroll */
  .profile-tabs-bar { padding: 4px; }
  .profile-tab      { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }

  /* Accuracy ring smaller */
  .profile-accuracy-ring-wrap { flex-direction: column; align-items: center; text-align: center; }
  .profile-accuracy-ring      { width: 120px; height: 120px; }
  .profile-accuracy-legend    { align-items: center; flex-direction: row; flex-wrap: wrap; justify-content: center; }

  /* Badges: 3-col */
  .profile-badges-grid { grid-template-columns: repeat(3, 1fr); }

  /* Settings single column */
  .profile-settings-grid { grid-template-columns: 1fr; }

  /* Form row single col */
  .profile-form-row   { grid-template-columns: 1fr; }
  .profile-form-full  { grid-column: span 1; }

  /* Edit modal full-screen on mobile */
  .modal-overlay:has(.profile-edit-modal) {
    align-items: flex-end;
    padding: 0;
  }
  .profile-edit-modal {
    max-width: 100%;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    max-height: 90dvh;
  }

  .profile-modal-footer { padding: var(--space-4); }

  .profile-name    { font-size: var(--text-2xl); }
  .profile-card    { padding: var(--space-4); }
}


/* ─────────────────────────────────────────────────────────────
   19. RESPONSIVE – SMALL (≤ 480px)
───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .profile-stats-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .profile-stat-card  { padding: var(--space-3); }
  .profile-stat-icon  { width: 34px; height: 34px; font-size: var(--text-base); }
  .profile-stat-val   { font-size: var(--text-base); }
  .profile-stat-lbl   { font-size: 9px; }

  .profile-badges-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-badge       { padding: var(--space-3) var(--space-2); }
  .profile-badge-icon  { font-size: 1.5rem; }
  .profile-badge-label { font-size: 10px; }

  .profile-name    { font-size: var(--text-xl); }
  .profile-handle  { font-size: var(--text-xs); }
  .profile-bio     { font-size: var(--text-xs); }

  .profile-tabs-bar  { gap: 2px; }
  .profile-tab       { padding: var(--space-2) var(--space-2); gap: var(--space-1); }
  .profile-tab span  { display: none; } /* icon only on tiny screens */

  .profile-accuracy-ring { width: 100px; height: 100px; }
  .profile-ring-pct      { font-size: var(--text-xl); }

  .profile-account-btn   { padding: var(--space-3) var(--space-4); }

  .profile-avatar-wrap,
  .profile-avatar-img,
  .profile-avatar-initials { width: 88px; height: 88px; }
}
img[hidden],
.profile-avatar-img[hidden],
.profile-avatar-initials[hidden] {
  display: none !important;
}

.profile-avatar-wrap {
  position: relative;
  overflow: hidden;
}