/**
 * 个人中心 /luntan/me
 * 依赖加载顺序：fj-core-tokens.css → home-exact.css → user-hub-exact.css → fj-site-chrome.css → 本文件
 * 复用全站导航/按钮/Hub 标题与面板；此处仅布局、KPI、弹层与侧栏高亮差异。
 */

body.fj-me-page .fj-layout-me {
  padding-top: 0;
  padding-bottom: 0;
  min-height: min(520px, calc(100vh - 180px));
}

/* home-exact 侧栏「发布」用全局 .fj-btn-primary { width:100% }，个人中心主区须恢复行内按钮 */
body.fj-me-page .fj-account-main .fj-btn-primary,
body.fj-me-page .fj-welcome-banner .fj-btn-primary {
  width: auto;
  display: inline-flex;
  margin-bottom: 0;
  text-align: center;
}

body.fj-me-page .fj-account-layout {
  display: grid;
  grid-template-columns: var(--fj-golden-sidebar-width, 220px) minmax(0, 1fr);
  gap: var(--fj-golden-layout-gap, 48px);
  width: 100%;
  margin: 24px auto 64px;
  align-items: start;
  min-height: calc(100vh - 260px);
  min-width: 0;
}

body.fj-me-page .fj-account-sidebar {
  position: sticky;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

body.fj-me-page .fj-sidebar-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--fj-border-subtle);
}

body.fj-me-page .fj-sidebar-avatar.fj-avatar-wrapper {
  width: 48px;
  height: 48px;
  margin: 0;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: none;
}

body.fj-me-page .fj-sidebar-avatar .fj-avatar-overlay {
  font-size: 0.85rem;
}

body.fj-me-page .fj-profile-info {
  min-width: 0;
  flex: 1;
}

body.fj-me-page .fj-profile-name {
  font-weight: 600;
  color: var(--fj-text-primary);
  font-size: 1rem;
  margin-bottom: 4px;
  line-height: 1.25;
  word-break: break-word;
}

body.fj-me-page .fj-account-sidebar .fj-profile-role {
  font-size: 0.75rem;
  font-family: var(--fj-font-tabular), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* 侧栏复用 home .fj-nav-menu，高亮与 Hub 一致（inset 左条） */
body.fj-me-page .fj-account-sidebar .fj-nav-menu {
  gap: 2px;
}

body.fj-me-page .fj-account-sidebar .fj-nav-menu .fj-nav-title {
  margin: 18px 0 8px 0;
  padding-left: 0;
  letter-spacing: 0.05em;
}

body.fj-me-page .fj-account-sidebar .fj-nav-menu > .fj-nav-title:first-child {
  margin-top: 0;
}

body.fj-me-page .fj-account-sidebar .fj-nav-menu .fj-nav-item {
  margin: 2px 0;
}

body.fj-me-page .fj-account-sidebar .fj-nav-menu .fj-nav-item.is-active {
  font-weight: 600;
  background: var(--fj-bg-surface);
  color: var(--fj-text-primary);
  box-shadow: inset 3px 0 0 var(--fj-orange-500);
}

body.fj-me-page .fj-account-sidebar .fj-nav-menu .fj-nav-item.is-active::before {
  content: none;
}

body.fj-me-page .fj-account-sidebar button.fj-nav-item {
  width: 100%;
  text-align: left;
  font: inherit;
}

body.fj-me-page .fj-badge-count {
  background: var(--fj-border-base);
  color: var(--fj-text-primary);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--fj-font-tabular), ui-monospace, monospace;
  flex-shrink: 0;
  margin-left: auto;
}

body.fj-me-page .fj-account-sidebar .fj-nav-danger {
  color: var(--fj-danger);
}

body.fj-me-page .fj-account-sidebar .fj-nav-danger:hover {
  background: var(--fj-danger-bg);
  color: var(--fj-danger);
}

body.fj-me-page .fj-sidebar-foot-link {
  margin-top: 22px;
  font-size: 0.85rem;
  color: var(--fj-text-tertiary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  transition:
    color var(--fj-duration-fast) var(--fj-ease-out),
    background var(--fj-duration-fast) var(--fj-ease-out);
}

body.fj-me-page .fj-sidebar-foot-link:hover {
  color: var(--fj-text-primary);
  background: var(--fj-bg-hover);
}

body.fj-me-page .fj-account-main {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

body.fj-me-page .fj-account-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

body.fj-me-page .fj-account-main .fj-hub-page-head {
  margin-bottom: 0;
}

body.fj-me-page .fj-me-kpi-panel {
  padding: 20px 22px 24px;
}

/* 四张 KPI：固定 2×2，等分宽；窄屏单列 */
body.fj-me-page .fj-me-kpi-panel .fj-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 20px);
  align-items: stretch;
}

body.fj-me-page .fj-me-kpi-panel .fj-metric-grid > .fj-metric-card,
body.fj-me-page .fj-me-kpi-panel .fj-metric-grid > .fj-kpi-card {
  min-width: 0;
}

@media (max-width: 560px) {
  body.fj-me-page .fj-me-kpi-panel .fj-metric-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

body.fj-me-page .fj-metric-card--accent {
  border-color: color-mix(in srgb, var(--fj-orange-500) 35%, var(--fj-border-base));
  background: var(--fj-orange-bg);
}

body.fj-me-page .fj-metric-card--accent .fj-metric-title {
  color: var(--fj-orange-500);
}

body.fj-me-page .fj-text-accent {
  color: var(--fj-orange-500) !important;
}

body.fj-me-page .fj-welcome-banner {
  background: linear-gradient(90deg, var(--fj-orange-bg), var(--fj-bg-surface));
  box-shadow: var(--fj-shadow-card);
}

body.fj-me-page .fj-welcome-banner.show {
  background: linear-gradient(90deg, var(--fj-orange-bg), color-mix(in srgb, var(--fj-bg-surface) 92%, var(--fj-orange-bg)));
}

.mono {
  font-family: var(--fj-font-tabular), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.fj-text-muted {
  color: var(--fj-text-secondary) !important;
}

body.fj-me-page .fj-me-renew-btn {
  flex-shrink: 0;
}

/* 续期：与帖子页线框按钮语义一致（home 未收录） */
.fj-btn-outline {
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  background: transparent;
  color: var(--fj-text-secondary);
  border: 1px solid var(--fj-border-base);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color var(--fj-duration-fast) var(--fj-ease-out),
    color var(--fj-duration-fast) var(--fj-ease-out),
    background var(--fj-duration-fast) var(--fj-ease-out);
}

.fj-btn-outline:hover {
  color: var(--fj-orange-500);
  border-color: var(--fj-orange-500);
  background: var(--fj-orange-bg);
}

@media (max-width: 900px) {
  body.fj-me-page .fj-account-layout {
    grid-template-columns: 1fr;
    gap: 28px;
    margin-top: 16px;
    margin-bottom: 48px;
  }

  body.fj-me-page .fj-account-sidebar {
    position: static;
    top: auto;
  }
}

@media (max-width: 640px) {
  body.fj-me-page .fj-layout-me {
    min-height: 0;
  }

  body.fj-me-page .fj-account-layout {
    gap: 20px;
  }

  body.fj-me-page .fj-me-overview-head {
    flex-direction: column;
    align-items: stretch;
  }
}

.fj-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0;
}

.fj-role-badge.user {
  background: var(--fj-bg-hover);
  color: var(--fj-text-secondary);
  border: 1px solid var(--fj-border-base);
}

.fj-role-badge.author {
  background: var(--fj-orange-bg);
  color: var(--fj-orange-500);
  border: 1px solid color-mix(in srgb, var(--fj-orange-500) 25%, transparent);
}

.fj-role-badge.admin {
  background: var(--fj-danger-bg);
  color: var(--fj-danger);
  border: 1px solid color-mix(in srgb, var(--fj-danger) 28%, transparent);
}

/* 创作者条（与历史 DOM 兼容） */
.fj-welcome-banner {
  display: none;
  width: 100%;
  padding: 12px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-radius: 12px;
  border: 1px solid var(--fj-border-subtle);
  border-left: 3px solid var(--fj-orange-500);
}

.fj-welcome-banner.show {
  display: flex;
}

.fj-welcome-banner-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.fj-welcome-banner-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fj-text-primary);
  margin: 0;
  line-height: 1.35;
}

.fj-welcome-banner-desc {
  font-size: 0.85rem;
  color: var(--fj-text-secondary);
  margin: 0;
  line-height: 1.45;
}

.fj-welcome-banner-cta {
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .fj-welcome-banner.show {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .fj-welcome-banner.show .fj-welcome-banner-text {
    align-items: center;
  }

  .fj-welcome-banner.show .fj-btn {
    width: 100%;
    justify-content: center;
  }
}

/* KPI 栅格与卡片（各页未共用，保留在此） */
.fj-kpi-row,
.fj-kpi-grid,
.fj-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1100px) {
  .fj-kpi-row,
  .fj-kpi-grid,
  .fj-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .fj-kpi-row,
  .fj-kpi-grid,
  .fj-metric-grid {
    grid-template-columns: 1fr;
  }
}

.fj-kpi-card,
.fj-metric-card {
  padding: 18px 20px;
  background: var(--fj-bg-surface);
  border: 1px solid var(--fj-border-base);
  border-radius: 12px;
  box-shadow: var(--fj-shadow-card);
  transition: border-color var(--fj-duration-fast) var(--fj-ease-out);
  min-height: 108px;
  display: flex;
  flex-direction: column;
}

.fj-kpi-card:hover,
.fj-metric-card:hover {
  border-color: var(--fj-border-hover);
}

.fj-kpi-label,
.kpi-label,
.fj-metric-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fj-text-secondary);
  margin-bottom: 10px;
}

.fj-kpi-value-row,
.kpi-value-group,
.fj-metric-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex: 1;
  min-height: 2rem;
}

.fj-kpi-num,
.kpi-value,
.fj-metric-value {
  font-family: var(--fj-font-tabular), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.45rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fj-text-primary);
  line-height: 1.15;
  word-break: break-all;
}

.fj-kpi-num--sm {
  font-size: 1.1rem;
}

.kpi-value.kpi-value--muted {
  color: var(--fj-text-secondary);
}

.kpi-value.kpi-value--accent {
  color: var(--fj-orange-500);
}

.kpi-value.kpi-value--quota {
  color: var(--fj-success);
}

[data-theme="light"] .kpi-value.kpi-value--quota {
  color: color-mix(in srgb, var(--fj-success) 85%, #14532d);
}

.fj-kpi-progress {
  width: 100%;
  height: 3px;
  background: var(--fj-border-base);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.fj-kpi-progress-fill {
  height: 100%;
  background: var(--fj-orange-500);
  border-radius: 2px;
  transition: width 0.5s ease-out;
}

.fj-kpi-progress-fill.success {
  background: var(--fj-success);
}

.fj-form-group {
  margin-bottom: 24px;
}

.fj-form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--fj-text-secondary);
  margin-bottom: 8px;
}

.fj-input {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--fj-bg-hover);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--fj-text-primary);
  font-size: 0.95rem;
  transition: all var(--fj-duration-normal) var(--fj-ease-out);
}

.fj-input:focus {
  border-color: var(--fj-orange-500);
  background-color: var(--fj-bg-surface);
  box-shadow: 0 0 0 2px var(--fj-orange-glow);
}

.fj-form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--fj-border-subtle);
}

.fj-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.48);
  z-index: 1500;
  padding: 16px;
}

.fj-modal.show {
  display: flex;
}

.fj-modal-card {
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  padding: 18px;
  background: var(--fj-bg-surface);
  border: 1px solid var(--fj-border-base);
  box-shadow: var(--fj-shadow-modal);
}

.fj-modal-desc {
  color: var(--fj-text-secondary);
  font-size: 13px;
  margin-top: 6px;
}

.fj-modal-hint {
  margin-top: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--fj-text-secondary);
}

.fj-modal-hint.error {
  color: var(--fj-danger);
}

.fj-modal-hint.success {
  color: var(--fj-success);
}

.fj-avatar-wrapper {
  position: relative;
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 1px solid var(--fj-border-base);
  background: var(--fj-bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

.fj-avatar-face {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.fj-avatar-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--fj-duration-fast);
  color: #fff;
  font-size: 1.5rem;
}

.fj-avatar-wrapper:hover .fj-avatar-overlay {
  opacity: 1;
}

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

.fj-avatar-option {
  border: 1px solid var(--fj-border-base);
  border-radius: 10px;
  background: var(--fj-bg-hover);
  padding: 8px;
}

.fj-avatar-option span {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  display: block;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.fj-upload-row {
  margin-bottom: 12px;
}

.fj-upload-row .fj-btn {
  width: 100%;
}

.fj-crop-area {
  border: 1px solid var(--fj-border-base);
  border-radius: 10px;
  padding: 12px;
  background: var(--fj-bg-hover);
  margin-bottom: 12px;
}

.fj-crop-canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

#avatarCropCanvas {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: var(--fj-bg-base);
  border: 1px solid var(--fj-border-subtle);
}

.fj-zoom-range {
  width: 100%;
  margin-bottom: 8px;
}

.toast-host {
  position: fixed;
  top: 84px;
  right: 20px;
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  min-width: 220px;
  max-width: 360px;
  border-radius: 10px;
  border: 1px solid var(--fj-border-base);
  background: var(--fj-bg-surface);
  box-shadow: var(--fj-shadow-card);
  transform: translateY(-4px);
  opacity: 0;
  animation: fj-toast-in 180ms var(--fj-ease-out) forwards;
}

.toast-item-inner {
  padding: 10px 12px;
  color: var(--fj-text-primary);
  font-size: 13px;
  border-left: 2px solid var(--fj-border-hover);
}

.toast-item--success .toast-item-inner {
  border-left-color: color-mix(in srgb, var(--fj-success) 70%, transparent);
}

.toast-item--error .toast-item-inner {
  border-left-color: var(--fj-orange-500);
}

.toast-item--info .toast-item-inner {
  border-left-color: var(--fj-border-hover);
}

.toast-item.leaving {
  animation: fj-toast-out 180ms var(--fj-ease-out) forwards;
}

@keyframes fj-toast-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fj-toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.fj-me-security-form {
  max-width: 480px;
  width: 100%;
}

.fj-me-security-form + .fj-me-security-form {
  margin-top: 16px;
}

.fj-form-hint {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--fj-text-tertiary);
}

.fj-me-security-form .fj-form-group:last-of-type {
  margin-bottom: 0;
}

.fj-me-security-actions {
  justify-content: flex-start;
  padding-top: 16px;
  margin-top: 8px;
  border-top: 1px solid var(--fj-border-subtle);
}

#avatarPickerModal .fj-avatar-option-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-image: var(--fj-me-avatar-opt-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* 概览顶栏：标题区 + 主按钮 */
body.fj-me-page .fj-me-overview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--fj-border-subtle);
}
