/* Profile page — 2026-04-21 */

/* P3.0 (2026-05-24): iOS-only hide. Apple Guideline 3.1.1 cấm activation
   unlock features ngoài IAP → ẩn redeem button trên iOS. Pattern same as styles.css. */
html.is-platform-ios [data-ios-hide],
html.is-platform-ios [data-ios-hide="true"] { display: none !important; }

:root {
  --p-bg: #f6f7fb;
  --p-surface: #fff;
  --p-text: #1f2940;
  --p-muted: #5b657c;
  --p-line: #e7eaf2;
  --p-primary: #4f6ef7;
  --p-primary-strong: #3d5ae5;
  --p-success: #10b981;
  --p-danger: #dc2626;
  --p-warning: #d97706;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--p-bg);
  color: var(--p-text);
  /* Sprint A v3 (2026-05-21): Đổi font Nunito → Inter — modern, dễ đọc, brand pro. */
  font-family: 'Inter', 'Nunito', 'Avenir Next', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  letter-spacing: -0.01em;
  line-height: 1.5;
}

html[lang="my"] body {
  font-family: 'Noto Sans Myanmar', 'Inter', 'Nunito', system-ui, sans-serif;
  line-height: 1.7;
  letter-spacing: 0;
}

/* ===== Topbar ===== */
/* 2026-04-24: refactor đồng bộ với module/hoithoai — back arrow plain trắng,
   title UPPERCASE 20/600, layout relative để back absolute căn giữa chiều dọc. */
.profile-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
  background: var(--p-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.profile-back {
  position: absolute;
  left: 14px;
  top: env(safe-area-inset-top, 0px);
  bottom: 0;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
  font-weight: 400;
  transition: opacity 0.15s, transform 0.1s;
}
.profile-back:hover, .profile-back:focus-visible { opacity: 0.8; background: transparent; outline: none; }
.profile-back:active { transform: scale(0.92); }

.profile-title {
  margin: 0;
  padding: 0 64px; /* chừa chỗ cho back (trái) + lang switcher (phải) để title luôn giữa */
  width: 100%;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.1px;
  text-align: center;
  text-transform: uppercase;
  overflow: visible;
  white-space: nowrap;
}

/* ===== Content ===== */
.profile-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.profile-loading {
  text-align: center;
  color: var(--p-muted);
  font-size: 14px;
  margin-top: 40px;
}

/* ===== Cards ===== */
.profile-card {
  background: var(--p-surface);
  border: 1px solid var(--p-line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  margin-bottom: 14px;
}

.profile-card h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--p-primary-strong);
}

.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--p-line);
  font-size: 14.5px;
}
.profile-row:last-child { border-bottom: 0; padding-bottom: 0; }

.profile-row-label {
  color: var(--p-muted);
  flex-shrink: 0;
  font-weight: 600;
}

.profile-row-value {
  text-align: right;
  color: var(--p-text);
  font-weight: 600;
  word-break: break-word;
}

.profile-verify-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--p-success);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

/* ===== Guest ===== */
.profile-guest-hero {
  text-align: center;
  padding: 16px 8px;
}
.profile-guest-icon {
  font-size: 56px;
  margin-bottom: 10px;
  line-height: 1;
}
.profile-guest-hero h2 { margin: 0 0 8px; font-size: 18px; color: var(--p-text); }
.profile-guest-hero p { margin: 0 0 18px; color: var(--p-muted); font-size: 14.5px; }
.profile-guest-note {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--p-muted);
}

/* ===== Plan banner ===== */
.profile-plan-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #eef3ff 0%, #e8fff4 100%);
  border-radius: 12px;
  margin-bottom: 12px;
}
.profile-plan-badge {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--p-primary);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.profile-plan-badge.is-free { background: #9ca3af; }
.profile-plan-badge.is-n4 { background: var(--p-primary); }
.profile-plan-badge.is-n3 { background: #8b5cf6; }
.profile-plan-badge.is-n2 { background: linear-gradient(135deg, #f59e0b, #dc2626); }
.profile-plan-badge.is-gift { background: linear-gradient(135deg, #ec4899, #f59e0b); }
.profile-plan-desc {
  margin: 0;
  font-size: 14px;
  color: var(--p-text);
  font-weight: 600;
}

/* ===== Stats grid ===== */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
}
.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: #f9fafb;
  border-radius: 10px;
  border: 1px solid var(--p-line);
}
.profile-stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--p-primary-strong);
  line-height: 1;
}
.profile-stat-label {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--p-muted);
  text-align: center;
  line-height: 1.3;
}

/* ===== Settings ===== */
.profile-setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  font-size: 14.5px;
  font-weight: 600;
}
.profile-select {
  /* Sprint A v5 (2026-05-21): Select rất gọn — anh feedback lang select to quá. */
  padding: 5px 24px 5px 8px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid var(--p-line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  max-width: 150px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'><path fill='%236b7280' d='M0 0l4 5 4-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.profile-select:focus { outline: none; border-color: var(--p-primary); }

.profile-toggle {
  width: 20px;
  height: 20px;
  accent-color: var(--p-primary);
  cursor: pointer;
}

.profile-setting-hint {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--p-muted);
}

/* ===== Buttons ===== */
.profile-btn {
  width: 100%;
  padding: 12px 14px;
  margin-top: 8px;
  font-size: 14.5px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.profile-btn:hover { transform: translateY(-1px); }
.profile-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }

.profile-btn-primary {
  background: var(--p-primary);
  color: #fff;
  border: 0;
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.28);
}
.profile-btn-primary:hover { background: var(--p-primary-strong); }

.profile-btn-secondary {
  background: #fff;
  color: var(--p-text);
  border: 1.5px solid var(--p-line);
}
.profile-btn-secondary:hover { border-color: var(--p-primary); }

.profile-btn-danger {
  background: #fff;
  color: var(--p-danger);
  border: 1.5px solid #fecaca;
}
.profile-btn-danger:hover { background: #fef2f2; border-color: var(--p-danger); }

/* 2026-05-22 (Admin-Entry): button vào dashboard admin — navy professional */
.profile-btn-admin {
  background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #475569 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 4px 14px rgba(30, 41, 59, 0.3);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.profile-btn-admin:hover {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
  box-shadow: 0 8px 20px rgba(30, 41, 59, 0.4);
  transform: translateY(-1px);
}

/* Sprint A.6 (2026-05-21): "Khoe streak" button — gradient nổi bật cho viral CTA */
.profile-btn-share {
  background: linear-gradient(135deg, #4f6ef7 0%, #6f79f6 50%, #8b5cf6 100%);
  color: #fff;
  border: 0;
  box-shadow: 0 6px 18px rgba(79, 110, 247, 0.35);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.profile-btn-share:hover {
  background: linear-gradient(135deg, #4361e0 0%, #6470e8 50%, #7c4cdf 100%);
  box-shadow: 0 10px 24px rgba(79, 110, 247, 0.45);
  transform: translateY(-1px);
}

.profile-action-hint {
  margin: 4px 0 14px;
  font-size: 12.5px;
  color: var(--p-muted);
  text-align: center;
}
.profile-action-hint-danger { color: var(--p-danger); }

.profile-danger-zone h2 { color: var(--p-danger); }

/* ===== Footer ===== */
.legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 20px 16px 24px;
  margin-top: 20px;
  font-size: 12.5px;
  color: #7a849b;
  border-top: 1px solid var(--p-line);
}
.legal-footer a {
  color: var(--p-primary);
  text-decoration: none;
  font-weight: 600;
}
.legal-footer a:hover { text-decoration: underline; }
.legal-footer span { color: #c1c8d5; }

@media (max-width: 480px) {
  .profile-content { padding: 16px 12px calc(40px + env(safe-area-inset-bottom)); }
  .profile-card { padding: 14px 14px 12px; }
  .profile-card h2 { font-size: 15.5px; }
  .profile-row { font-size: 14px; }
  .profile-stat-value { font-size: 20px; }

  /* 2026-05-13 redesign: mobile hero adjustments */
  .profile-hero-card { padding: 14px 14px 16px; }
  .profile-hero-userinfo { padding-top: 14px; padding-bottom: 14px; }
  .profile-hero-icon { width: 48px; height: 48px; font-size: 30px; }
  .profile-hero-name { font-size: 16.5px; }
  .profile-hero-email { font-size: 13.5px; }

  /* Account actions row — giữ 2 cột, button gọn */
  .profile-account-actions { gap: 8px; }
  .profile-account-actions .profile-btn { font-size: 13.5px; padding: 12px 6px; min-height: 48px; }

  /* 2026-05-03: Mobile UX fixes */
  /* Select font 16px chống iOS auto-zoom */
  .profile-select { font-size: 16px; min-height: 44px; padding: 10px 12px; }

  /* Buttons profile — tap target 48px (Apple HIG) */
  .profile-btn { min-height: 48px; padding: 12px 14px; font-size: 14.5px; }
  /* Destructive button (xoá tài khoản) — không stand-alone full-width nữa, kèm trong row */
  .profile-btn-danger { font-weight: 700; }
}

/* ===== Hero card (2026-05-13 redesign) — gộp status + account info + plan ===== */
.profile-hero-card {
  background: linear-gradient(135deg, #ffffff 0%, #f4f7ff 100%);
  border: 1px solid var(--p-line);
  border-left: 4px solid var(--p-primary);
  padding: 18px 20px;
  /* Khi hero-userinfo theo sau, gắn liền sát thành 1 visual block */
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

/* Khi guest (userSections hidden) — hero card đứng độc lập, bo full corner */
.profile-hero-card:has(+ #userSections[hidden]) {
  margin-bottom: 14px;
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;
}

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

.profile-hero-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  line-height: 1;
  background: linear-gradient(135deg, #eef3ff 0%, #e8fff4 100%);
  border-radius: 50%;
  border: 2px solid rgba(79, 110, 247, 0.18);
}

.profile-hero-status {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--p-text);
}

/* Userinfo card (extended hero, design liền mạch — bo trên flat, đứng sát hero card) */
.profile-hero-userinfo {
  margin-top: 0;
  padding-top: 16px;
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-left: 4px solid var(--p-primary);
  background: var(--p-surface);
}

.profile-hero-name {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--p-text);
  word-break: break-word;
}

.profile-hero-email {
  margin: 0 0 4px;
  font-size: 14px;
  color: var(--p-muted);
  word-break: break-all;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-hero-provider {
  margin: 0 0 14px;
  font-size: 12.5px;
  color: var(--p-muted);
}
.profile-hero-provider-value {
  color: var(--p-text);
  font-weight: 700;
}

/* Sprint A v3 (2026-05-21): Profile USER hero redesign — avatar to + name lớn làm title,
   BỎ status row "Đã đăng nhập" + BỎ badge inline (plan info chuyển vào meta row text). */
.profile-user-hero {
  padding: 18px 18px 16px;
}
.profile-user-hero-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 10px;
  position: relative;
}

/* Sprint A v4 (2026-05-21): Icon ⚙️ trigger ở góc trên phải hero card */
.profile-settings-trigger {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  font-family: inherit;
  align-self: flex-start;
}
.profile-settings-trigger:hover {
  background: rgba(79, 110, 247, 0.08);
  border-color: rgba(79, 110, 247, 0.2);
  transform: rotate(45deg);
}
.profile-settings-trigger:focus-visible {
  outline: 2px solid var(--p-primary);
  outline-offset: 2px;
}

/* Settings dialog modal — pattern Facebook/Twitter */
.profile-settings-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: profileSettingsFadeIn 0.18s ease-out;
}
.profile-settings-dialog[hidden] {
  display: none !important;
}
@keyframes profileSettingsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.profile-settings-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.profile-settings-dialog-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  margin: 20px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: profileSettingsSlideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes profileSettingsSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.profile-settings-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--p-line);
}
.profile-settings-dialog-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--p-text);
  letter-spacing: -0.01em;
}
.profile-settings-dialog-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  color: var(--p-muted);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.profile-settings-dialog-close:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--p-text);
}
.profile-settings-dialog-body {
  padding: 16px 18px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile: full-width bottom sheet thay vì modal center */
@media (max-width: 480px) {
  .profile-settings-dialog {
    align-items: flex-end;
  }
  .profile-settings-dialog-panel {
    margin: 0;
    width: 100%;
    max-width: none;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    animation: profileSettingsSlideUpMobile 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes profileSettingsSlideUpMobile {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }
}
.profile-user-hero-avatar {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 1;
  background: linear-gradient(135deg, #eef3ff 0%, #e8fff4 100%);
  border-radius: 50%;
  border: 2px solid rgba(79, 110, 247, 0.18);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: transform 0.15s, border-color 0.15s;
}
.profile-user-hero-avatar:hover {
  transform: scale(1.05);
  border-color: rgba(79, 110, 247, 0.4);
}
.profile-user-hero-avatar:focus-visible {
  outline: 2px solid var(--p-primary);
  outline-offset: 2px;
}
.profile-user-hero-avatar-content {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.profile-user-hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.profile-user-hero-avatar-edit {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--p-primary);
  color: #fff;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(79, 110, 247, 0.3);
  pointer-events: none;
}
.profile-user-hero-headings {
  flex: 1;
  min-width: 0;
}
.profile-user-hero-headings .profile-hero-name {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--p-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-user-hero-headings .profile-hero-email {
  margin: 0;
  font-size: 13px;
  color: var(--p-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  word-break: break-all;
}

/* Sprint A v6 (2026-05-21): Country flag inline cạnh email — bỏ chip background */
.profile-hero-country-flag {
  display: inline-flex;
  align-items: center;
  font-size: 16px;
  line-height: 1;
  cursor: default;
}
/* Plan badge giấu (giữ JS cũ vẫn set textContent nhưng visual ẩn) */
.profile-plan-badge-hidden {
  display: none !important;
}

/* Plan info dạng text trong meta row */
.profile-meta-plan strong {
  color: var(--p-text);
  font-weight: 700;
}

/* Email line: gộp email + verify badge + provider 1 dòng, separator `·` */
.profile-email-sep {
  color: var(--p-muted);
  opacity: 0.5;
  margin: 0 2px;
}

/* Meta row: Tham gia · Gói (country flag chuyển lên cùng dòng email từ Sprint A v6) */
.profile-hero-meta {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--p-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.profile-meta-country {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(79, 110, 247, 0.08);
  border-radius: 10px;
  color: var(--p-text);
  font-weight: 600;
}
.profile-meta-flag {
  font-size: 14px;
  line-height: 1;
}
.profile-meta-sep {
  opacity: 0.5;
}
.profile-meta-join {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Plan desc: chuyển xuống dưới meta, compact, không cần card riêng */
.profile-plan-desc {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--p-muted);
  line-height: 1.5;
}

/* ============== Sprint A (2026-05-21): 3 HERO STAT CARDS ============== */
.profile-hero-stats-card {
  padding: 18px 16px 16px;
}
.profile-hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* ③ 2×2 — thêm card Điểm tích luỹ (was repeat(3)) */
  gap: 10px;
  margin: 6px 0 18px;
}
.profile-hero-stat {
  position: relative;
  padding: 14px 10px 12px;
  border-radius: 14px;
  text-align: center;
  background: linear-gradient(160deg, #f8faff 0%, #f0f4ff 100%);
  border: 1.5px solid rgba(79, 110, 247, 0.12);
  transition: transform 0.15s, box-shadow 0.15s;
}
.profile-hero-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(79, 110, 247, 0.12);
}
.profile-hero-stat-streak {
  background: linear-gradient(160deg, #fff3e6 0%, #ffe4cc 100%);
  border-color: rgba(245, 158, 11, 0.25);
}
.profile-hero-stat-rank {
  background: linear-gradient(160deg, #fef9e6 0%, #fdf2c4 100%);
  border-color: rgba(234, 179, 8, 0.28);
}
.profile-hero-stat-accuracy {
  background: linear-gradient(160deg, #e8fff4 0%, #d1fae5 100%);
  border-color: rgba(16, 185, 129, 0.25);
}
.profile-hero-stat-icon {
  /* Sprint A v3 (2026-05-21): icon to hơn cho hero stat (24 → 36) */
  font-size: 36px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.profile-hero-stat-streak .profile-hero-stat-icon {
  animation: profileFireFlicker 1.8s ease-in-out infinite;
}
@keyframes profileFireFlicker {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08) rotate(-2deg); }
}
.profile-hero-stat-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--p-text);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.02em;
}
.profile-hero-stat-value.is-unranked {
  font-size: 14px;
  font-weight: 700;
  color: var(--p-muted);
}
.profile-hero-stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--p-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 4px 0 2px;
}
.profile-hero-stat-sub {
  font-size: 11.5px;
  color: var(--p-text);
  opacity: 0.75;
  font-weight: 500;
}
.profile-hero-stat-sub > span:nth-child(2) {
  font-weight: 700;
}

/* Activity chart */
.profile-activity-chart-wrap {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--p-line);
}
.profile-activity-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--p-muted);
  font-weight: 600;
}
.profile-activity-chart-sub {
  color: var(--p-text);
  font-weight: 700;
}
.profile-activity-chart {
  position: relative;
  width: 100%;
  height: 60px;
}
.profile-activity-chart svg {
  display: block;
}
.profile-activity-empty {
  margin: 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--p-muted);
  padding: 18px 0;
  font-style: italic;
}

/* Mobile: stack 3 cards xuống 1 column hoặc giữ grid nhỏ */
@media (max-width: 480px) {
  .profile-hero-stats-grid { gap: 6px; }
  .profile-hero-stat { padding: 12px 6px 10px; }
  .profile-hero-stat-icon { font-size: 28px; }
  .profile-hero-stat-value { font-size: 22px; }
  .profile-hero-stat-label { font-size: 10.5px; }
  .profile-hero-stat-sub { font-size: 10.5px; }
}

/* ============== Sprint A.3 (2026-05-21): 4 mini saved chip ============== */
.profile-saved-card {
  padding: 16px 16px 14px;
}
.profile-saved-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.profile-saved-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px 8px;
  background: var(--p-surface);
  border: 1.5px solid var(--p-line);
  border-radius: 12px;
  transition: border-color 0.15s, transform 0.15s;
  text-align: center;
}
.profile-saved-chip:hover {
  border-color: rgba(79, 110, 247, 0.3);
  transform: translateY(-1px);
}
.profile-saved-chip-icon {
  font-size: 20px;
  line-height: 1;
  margin-bottom: 2px;
}
.profile-saved-chip-value {
  font-size: 17px;
  font-weight: 800;
  color: var(--p-primary);
  line-height: 1.1;
}
.profile-saved-chip-label {
  font-size: 11px;
  color: var(--p-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
@media (max-width: 480px) {
  .profile-saved-chips { gap: 6px; }
  .profile-saved-chip { padding: 8px 4px 6px; }
  .profile-saved-chip-icon { font-size: 18px; }
  .profile-saved-chip-value { font-size: 15px; }
  .profile-saved-chip-label { font-size: 10px; }
}

/* ============== Sprint A.1.5 (2026-05-21): COLLAPSIBLE ACCORDION ============== */
.profile-collapsible {
  padding: 0;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.profile-collapsible[data-collapsed="false"] {
  box-shadow: 0 4px 14px rgba(79, 110, 247, 0.1);
}
.profile-collapsible-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.profile-collapsible-header:hover {
  background: rgba(79, 110, 247, 0.04);
}
.profile-collapsible-header:focus-visible {
  outline: 2px solid var(--p-primary);
  outline-offset: -2px;
}
.profile-collapsible-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.profile-collapsible-title {
  flex: 1;
  font-size: 16px;
  font-weight: 800;
  color: var(--p-text);
  margin: 0;
}
.profile-collapsible-chevron {
  flex-shrink: 0;
  font-size: 14px;
  color: var(--p-muted);
  transition: transform 0.25s ease;
}
.profile-collapsible[data-collapsed="true"] .profile-collapsible-chevron {
  transform: rotate(-90deg);
}
.profile-collapsible-body {
  padding: 0 18px 16px;
  border-top: 1px solid var(--p-line);
  margin-top: 0;
  animation: profileCollapsibleSlide 0.22s ease-out;
}
.profile-collapsible[data-collapsed="true"] .profile-collapsible-body {
  display: none;
}
@keyframes profileCollapsibleSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Padding-top reset cho body khi mở (vì border-top thay cho margin) */
.profile-collapsible-body > :first-child {
  margin-top: 14px;
}
.profile-collapsible-body .profile-setting-row:first-child {
  margin-top: 14px;
}

/* Account-specific tinting (đỏ nhẹ cho delete area) */
.profile-collapsible-account .profile-collapsible-icon {
  filter: hue-rotate(-20deg);
}

/* Group divider trong 1 collapsible chung (Sprint A.1.5 v2 — anh chốt gộp 1 nút) */
.profile-settings-group {
  padding-top: 4px;
}
.profile-settings-group-title {
  margin: 6px 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--p-muted);
}
.profile-settings-divider {
  margin: 20px 0 8px;
  border: 0;
  border-top: 1px dashed var(--p-line);
}

/* ===== Sprint A v3 (2026-05-21): Account section compact ===== */
/* Subscription + Export buttons: nhỏ hơn, ít margin, layout đơn giản */
.profile-settings-group #btnManageSubscription,
.profile-settings-group #btnExport {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--p-surface);
  border: 1px solid var(--p-line);
  color: var(--p-text);
  text-align: left;
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.profile-settings-group #btnManageSubscription:hover,
.profile-settings-group #btnExport:hover {
  background: rgba(79, 110, 247, 0.04);
  border-color: rgba(79, 110, 247, 0.3);
}
.profile-settings-group .profile-action-hint {
  margin: 4px 0 4px 4px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--p-muted);
}

/* Logout: button vừa phải. Delete: dạng text-link đỏ nhỏ ở dưới (không button to). */
.profile-settings-group .profile-account-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--p-line);
}
.profile-settings-group .profile-account-actions #btnLogout {
  width: 100%;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--p-surface);
  border: 1px solid var(--p-line);
  color: var(--p-text);
  border-radius: 8px;
}
.profile-settings-group .profile-account-actions #btnDelete {
  width: auto;
  align-self: center;
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  background: transparent;
  border: 0;
  color: var(--p-danger, #dc2626);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s;
}
.profile-settings-group .profile-account-actions #btnDelete:hover {
  color: #991b1b;
  text-decoration-style: solid;
}
.profile-settings-group .profile-action-hint-danger {
  font-size: 11px;
  text-align: center;
  color: var(--p-muted);
  margin: 4px 0 0;
}

/* Codes row inside hero */
.profile-codes-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--p-line);
  border-bottom: 0;
}

/* Standalone button (ngoài card, đứng riêng giữa các card) */
.profile-btn-standalone {
  margin-top: 0;
  margin-bottom: 14px;
}

/* Account actions row: Logout + Delete cùng 1 hàng */
.profile-account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.profile-account-actions .profile-btn {
  margin-top: 0;
  padding: 12px 8px;
  font-size: 14px;
}

/* ===== Status card legacy (giữ cho backward compat — không dùng nữa, có thể xoá sau) ===== */
.profile-status-card {
  border-left: 4px solid var(--p-primary);
}
.profile-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 600;
  padding: 4px 0;
}
.profile-status-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(156, 163, 175, 0.18);
  transition: background 0.2s, box-shadow 0.2s;
}
.profile-status-label {
  flex: 1;
  word-break: break-word;
}

/* Guest block trong status card */
.profile-guest-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--p-line);
  text-align: center;
}
.profile-guest-block[hidden] { display: none; }
.profile-guest-sub {
  margin: 0 0 12px;
  color: var(--p-muted);
  font-size: 14px;
}
.profile-guest-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--p-muted);
  font-style: italic;
}

/* ============================================================
   Language switcher (2026-04-22) — mounted by ui/lang-switcher.js
   Styles copy từ styles.css / module.css, điều chỉnh cho topbar nền tím.
   ============================================================ */
.lang-switcher-slot {
  position: absolute;
  right: 6px;
  top: calc(env(safe-area-inset-top, 0px) + 2px);
  display: flex;
  align-items: center;
}

.lang-wrap { position: relative; }
.lang-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lang-btn:active { transform: scale(0.96); }
.lang-btn .lang-flag { font-size: 16px; line-height: 1; }
.lang-btn .lang-code { font-size: 10px; }
.lang-btn .lang-caret { font-size: 9px; opacity: 0.7; }
.lang-btn[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: max-content;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(47,55,82,0.18);
  padding: 3px;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.lang-menu[hidden] { display: none; }

.lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #2d3a5b;
  font-size: 13px;
  text-align: left;
  width: 100%;
  white-space: nowrap;
}
.lang-option:hover { background: #fef2ec; }
.lang-option.is-active { background: #ffe8da; color: #d95a2a; font-weight: 700; }
.lang-option-label { flex: 1; }
