/* Community, post and profile surfaces. Depends on site.css tokens. */
.community-page,
.user-center-page,
.post-page { --community-max: 1180px; }

.community-page > .container,
.user-center-page > .container { display: grid; width: min(calc(100% - 48px), var(--community-max)); max-width: none; margin-inline: auto; padding: 32px 0 92px; gap: 28px; }

/* Community */
.community-page > .container { grid-template-columns: minmax(0, 1fr) 272px; grid-template-areas: "hero hero" "content aside"; }
.community-page .community-hero { grid-area: hero; }
.community-page .main-content { grid-area: content; min-width: 0; }
.community-page .sidebar { grid-area: aside; }
.community-hero {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 18px 2px 30px;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid var(--a-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.community-hero::after { display: none; }
.community-hero-copy,
.community-hero-actions { position: relative; z-index: 1; }
.community-hero h1 { max-width: none; margin: 0; color: var(--a-ink); font-size: clamp(32px, 4vw, 48px); font-weight: 780; letter-spacing: -.05em; line-height: 1.08; }
.community-hero p { max-width: 600px; margin: 10px 0 0; color: var(--a-muted); font-size: 15px; line-height: 1.7; }
.community-hero-actions { display: flex; align-items: center; justify-content: flex-end; }
.community-page .create-post-btn { width: auto; min-width: 142px; min-height: 46px; margin: 0; padding: 0 18px; border-color: var(--a-ink); background: var(--a-ink); color: var(--a-bg); white-space: nowrap; }
.community-page .create-post-btn:hover { border-color: var(--a-accent); background: var(--a-accent); color: var(--a-on-accent); }
.community-page .main-content > .card { overflow: hidden; padding: 0; border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-surface); box-shadow: none; }
.community-page .search-bar { display: flex; gap: 10px; margin: 0; padding: 18px 18px 12px; border: 0; }
.community-page .search-input-wrap { position: relative; min-width: 0; flex: 1; }
.community-page .search-input-wrap > i { position: absolute; top: 50%; left: 14px; z-index: 1; color: var(--a-faint); transform: translateY(-50%); }
.community-page .search-input-wrap input { width: 100%; height: 46px; padding: 0 14px 0 42px; border-color: var(--a-line-strong); background: var(--a-bg); font-size: 16px; }
.community-page .search-btn { min-width: 78px; height: 46px; border: 0; border-radius: var(--a-control-radius); background: var(--a-ink); color: var(--a-bg); }
.community-page .sort-bar { display: flex; gap: 6px; margin: 0; padding: 0 18px 12px; border-bottom: 1px solid var(--a-line); }
.community-page .sort-btn { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--a-muted); }
.community-page .sort-btn.active { background: var(--a-accent-soft); color: var(--a-accent); }
.community-page .category-bar { display: flex; gap: 8px; margin: 0; padding: 14px 18px; overflow-x: auto; border-bottom: 1px solid var(--a-line); scroll-snap-type: x proximity; scrollbar-width: none; }
.community-page .category-bar::-webkit-scrollbar { display: none; }
.community-page .category-btn { min-height: 44px; flex: 0 0 auto; padding: 8px 12px; border: 1px solid var(--a-line); border-radius: 8px; background: var(--a-surface); color: var(--a-muted); scroll-snap-align: start; }
.community-page .category-btn.active { border-color: var(--a-ink); background: var(--a-ink); color: var(--a-bg); }
.community-page #postList { min-height: 0; }
.community-page .post-item { position: relative; margin: 0; padding: 24px 20px; border: 0; border-bottom: 1px solid var(--a-line); border-radius: 0; background: transparent; box-shadow: none; cursor: pointer; }
.community-page .post-item:last-child { border-bottom: 0; }
.community-page .post-item:hover { background: color-mix(in srgb, var(--a-accent) 3%, var(--a-surface)); transform: none; }
.community-page .post-item:active { transform: translateY(1px); }
.community-page .post-item.is-top::before,
.community-page .post-item.is-essence::before { position: absolute; inset: 18px auto 18px 0; width: 3px; border-radius: 0 3px 3px 0; background: var(--a-accent); content: ""; }
.post-item-flags { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.post-flag { color: var(--a-accent); font-size: 12px; font-weight: 730; }
.community-page .post-title { margin: 0; overflow-wrap: anywhere; color: var(--a-ink); font-size: 18px; font-weight: 720; letter-spacing: -.015em; line-height: 1.45; }
.community-page .post-summary { display: -webkit-box; max-width: 72ch; margin: 8px 0 14px; overflow: hidden; color: var(--a-muted); font-size: 14px; line-height: 1.75; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.community-page .post-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--a-muted); font-size: 13px; }
.community-page .post-category { order: -2; background: var(--a-accent-soft); color: var(--a-accent); }
.community-page .post-author { order: -1; color: var(--a-text); }
.community-page .author-avatar { display: inline-grid; width: 28px; height: 28px; flex: 0 0 28px; place-items: center; border: 1px solid var(--a-line); border-radius: 50%; font-size: 11px; font-weight: 750; }
.community-page .sidebar { position: sticky; top: 92px; display: grid; width: auto; height: fit-content; align-content: start; gap: 14px; }
.community-page .sidebar-card { margin: 0; padding: 20px; border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-surface); box-shadow: none; }
.community-page .sidebar-card h3 { margin: 0 0 15px; color: var(--a-ink); font-size: 15px; }
.community-page .stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.community-page .stat-item { padding: 3px 12px; border-right: 1px solid var(--a-line); }
.community-page .stat-item:first-child { padding-left: 0; }
.community-page .stat-item:last-child { border-right: 0; }
.community-page .stat-num { color: var(--a-ink); font-size: 25px; font-variant-numeric: tabular-nums; }
.community-page .stat-label { color: var(--a-muted); font-size: 13px; }
.community-page .sidebar-rules { display: grid; gap: 10px; color: var(--a-muted); font-size: 13px; line-height: 1.65; counter-reset: rule; }
.community-page .sidebar-rules p { position: relative; margin: 0; padding-left: 22px; counter-increment: rule; }
.community-page .sidebar-rules p::before { position: absolute; top: 1px; left: 0; display: grid; width: 16px; height: 20px; place-items: center; color: var(--a-accent); font-size: 12px; font-weight: 750; content: counter(rule); }

/* Skeletons */
.community-skeleton { display: grid; }
.community-skeleton-item { padding: 24px 20px; border-bottom: 1px solid var(--a-line); }
.skeleton-line { height: 11px; border-radius: 4px; background: var(--a-surface-2); }
.skeleton-line.title { width: 54%; height: 18px; margin-bottom: 14px; }
.skeleton-line.body { width: 86%; margin-bottom: 10px; }
.skeleton-line.meta { width: 42%; margin-top: 18px; }

/* Profile */
.user-center-page > .container { grid-template-columns: 242px minmax(0, 1fr); grid-template-areas: "profile profile" "menu content"; }
.user-center-page .profile-hero { grid-area: profile; }
.user-center-page .sidebar { grid-area: menu; }
.user-center-page .main-content { grid-area: content; min-width: 0; }
.profile-hero { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 28px; padding: 18px 2px 30px; border: 0; border-bottom: 1px solid var(--a-line); border-radius: 0; background: transparent; box-shadow: none; }
.profile-identity { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: center; gap: 22px; }
.profile-hero .user-avatar-large { width: 88px; height: 88px; margin: 0; border: 1px solid var(--a-line); background: var(--a-surface-2); font-size: 32px; }
.profile-hero .user-avatar-large img,
.user-center-page .header-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-upload-preview { display: grid; width: 72px; height: 72px; flex: 0 0 72px; place-items: center; overflow: hidden; border: 1px solid var(--a-line); border-radius: 50%; background: var(--a-surface-2); font-weight: 750; }
.avatar-upload-preview > img { display: block; width: 100%; height: 100%; max-width: 72px; max-height: 72px; border-radius: inherit; object-fit: cover; }
.profile-copy { min-width: 0; }
.profile-copy h1 { margin: 0; overflow-wrap: anywhere; color: var(--a-ink); font-size: clamp(28px, 3.5vw, 40px); font-weight: 770; letter-spacing: -.035em; line-height: 1.15; }
.profile-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 9px; }
.profile-hero .user-role { margin: 0; }
.profile-hero .join-time { margin: 0; color: var(--a-muted); font-size: 13px; }
.profile-bio { max-width: 600px; margin: 10px 0 0; color: var(--a-muted); font-size: 14px; }
.profile-actions { grid-column: 2; display: flex; gap: 9px; margin-top: -6px; }
.profile-action { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--a-line-strong); border-radius: 8px; background: var(--a-surface); color: var(--a-text); font-size: 13px; font-weight: 660; }
.profile-action.primary { border-color: var(--a-ink); background: var(--a-ink); color: var(--a-bg); }
.profile-stats { display: grid; grid-template-columns: repeat(2, minmax(96px, 1fr)); gap: 0; }
.profile-stats .stat-card { min-width: 106px; padding: 10px 20px; border: 0; border-left: 1px solid var(--a-line); border-radius: 0; background: transparent; box-shadow: none; text-align: left; }
.profile-stats .stat-num { color: var(--a-ink); font-size: 26px; font-variant-numeric: tabular-nums; }
.profile-stats .stat-label { margin-top: 3px; color: var(--a-muted); font-size: 13px; }
.user-center-page .sidebar { position: sticky; top: 92px; width: auto; height: fit-content; }
.user-center-page .side-menu { display: grid; gap: 4px; padding: 8px; overflow: hidden; border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-surface); box-shadow: none; }
.user-center-page .menu-item { display: flex; width: 100%; min-height: 46px; align-items: center; gap: 10px; margin: 0; padding: 10px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--a-muted); text-align: left; white-space: nowrap; }
.user-center-page .menu-item:hover { background: var(--a-surface-2); color: var(--a-ink); }
.user-center-page .menu-item.active { background: var(--a-accent-soft); color: var(--a-accent); }
.user-center-page .menu-item.logout { margin-top: 8px; border-top: 1px solid var(--a-line); border-radius: 0 0 8px 8px; color: var(--a-danger); }
.user-center-page .content-card { min-height: 0; padding: clamp(22px, 4vw, 36px); border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-surface); box-shadow: none; }
.content-heading { margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--a-line); }
.content-heading h2 { margin: 0; color: var(--a-ink); font-size: 24px; font-weight: 740; letter-spacing: -.02em; }
.content-heading p { margin: 6px 0 0; color: var(--a-muted); font-size: 14px; }
.user-center-page .post-item { position: relative; margin: 0; padding: 20px 0; border: 0; border-bottom: 1px solid var(--a-line); border-radius: 0; background: transparent; box-shadow: none; }
.user-center-page .post-item:first-child { padding-top: 0; }
.user-center-page .post-item:last-child { padding-bottom: 0; border-bottom: 0; }
.user-center-page .post-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; color: var(--a-ink); font-size: 16px; font-weight: 700; }
.user-center-page .post-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 9px; color: var(--a-muted); font-size: 13px; }
.request-note { margin: 12px 0 0; padding: 12px 14px; border-left: 3px solid var(--a-accent); background: var(--a-surface-2); color: var(--a-text); font-size: 13px; }
.request-description { margin: 9px 0 0; color: var(--a-muted); font-size: 14px; line-height: 1.7; }
.request-result { display: inline-flex; min-height: 44px; align-items: center; gap: 7px; margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: var(--a-ink); color: var(--a-bg); font-size: 13px; font-weight: 700; }
.empty-state.community-empty { padding: 48px 20px; border: 1px dashed var(--a-line-strong); border-radius: 10px; background: var(--a-bg); }
.empty-state.community-empty i { display: block; margin-bottom: 12px; color: var(--a-accent); font-size: 22px; }
.user-center-page .form-item { margin-bottom: 20px; }
.user-center-page .form-item input,
.user-center-page .form-item textarea { width: 100%; padding: 11px 12px; font-size: 16px; }
.user-center-page .password-field { position: relative; }
.user-center-page .password-field input { padding-right: 56px; }
.user-center-page .password-toggle { position: absolute; top: 50%; right: 2px; display: grid; width: 44px; height: 44px; place-items: center; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--a-muted); transform: translateY(-50%); }
.user-center-page .password-toggle:hover { background: var(--a-surface-2); color: var(--a-ink); }

/* Post detail */
.post-page > .container { width: min(calc(100% - 48px), 900px); max-width: 900px; padding: 32px 0 92px; }
.post-page .back-btn { display: inline-flex; min-height: 44px; align-items: center; gap: 8px; margin: 0 0 16px; padding: 8px 11px; border: 1px solid var(--a-line); border-radius: 8px; background: var(--a-surface); color: var(--a-muted); }
.post-page .post-card,
.post-page .comment-section { padding: clamp(26px, 5vw, 52px); border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-surface); box-shadow: none; }
.post-page .post-card { margin-bottom: 20px; }
.post-page .post-header { margin-bottom: 30px; padding-bottom: 24px; border-bottom: 1px solid var(--a-line); }
.post-page .post-title { max-width: 22ch; margin: 0 0 22px; overflow-wrap: anywhere; color: var(--a-ink); font-size: clamp(30px, 5vw, 46px); font-weight: 770; letter-spacing: -.04em; line-height: 1.16; }
.post-page .post-meta { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; color: var(--a-muted); font-size: 13px; }
.post-page .post-author { display: flex; align-items: center; gap: 10px; }
.post-page .author-avatar { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--a-line); border-radius: 50%; }
.post-page .comment-avatar { display: grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 750; }
.post-page .reply-avatar { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; border-radius: 50%; font-size: 11px; font-weight: 750; }
.post-page .author-name { color: var(--a-ink); }
.post-page .post-time { color: var(--a-muted); font-size: 13px; }
.post-page .post-stats { color: var(--a-muted); }
.post-page .post-content { max-width: 72ch; overflow-wrap: anywhere; color: var(--a-text); font-size: 16px; line-height: 1.95; }
.post-page .post-review-status { border-color: color-mix(in srgb, var(--a-accent) 28%, var(--a-line)); background: var(--a-accent-soft); color: var(--a-accent); }
.post-page .section-title { margin: 0 0 22px; color: var(--a-ink); font-size: 22px; }
.post-page .comment-input-box { padding: 16px; border: 1px solid var(--a-line); border-radius: 10px; background: var(--a-bg); }
.post-page .comment-input-box textarea { width: 100%; min-height: 112px; padding: 0; border: 0; background: transparent; color: var(--a-text); box-shadow: none; font-size: 16px; }
.post-page .comment-submit-row { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--a-line); }
.post-page .btn-submit { min-height: 44px; padding: 8px 14px; }
.post-page .comment-list { gap: 0; }
.post-page .comment-item { padding: 22px 0; border-bottom: 1px solid var(--a-line); }
.post-page .comment-item:last-child { border-bottom: 0; }
.post-page .comment-username,
.post-page .reply-username { color: var(--a-ink); }
.post-page .comment-content,
.post-page .reply-content { overflow-wrap: anywhere; color: var(--a-text); }
.post-page .comment-time,
.post-page .reply-time { color: var(--a-muted); font-size: 12px; }
.post-page .reply-action,
.post-page .view-more-replies { min-height: 44px; padding: 8px; border: 0; background: transparent; color: var(--a-accent); font-size: 13px; }
.post-page .reply-list { margin-top: 14px; padding: 4px 16px; border-left: 2px solid var(--a-line); background: transparent; }

/* Community dialog must keep fields and actions reachable above the soft keyboard. */
.community-page .modal-overlay { padding: 16px; }
.community-page .modal-box { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: hidden; }
.community-page .modal-body { display: grid; gap: 18px; overflow-y: auto; padding: 20px; }
.community-page .modal-body .form-item { margin: 0; }
.community-page .modal-body textarea { min-height: 140px; font-size: 16px; }
.community-page .modal-footer { flex: 0 0 auto; }

@media (max-width: 820px) {
  .community-page > .container,
  .user-center-page > .container { width: min(calc(100% - 28px), var(--community-max)); grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 20px 0 92px; }
  .community-page > .container { grid-template-areas: "hero" "content" "aside"; }
  .user-center-page > .container { grid-template-areas: "profile" "menu" "content"; }
  .community-hero,
  .profile-hero { grid-template-columns: 1fr; gap: 18px; padding: 12px 0 24px; }
  .community-hero-actions { justify-content: flex-start; }
  .community-page .sidebar { position: static; grid-template-columns: 1fr 1fr; top: auto; }
  .user-center-page .sidebar { position: sticky; top: 62px; z-index: 50; width: calc(100% + 28px); margin-left: -14px; background: var(--a-bg); }
  .user-center-page .side-menu { display: flex; gap: 6px; padding: 8px 14px; overflow-x: auto; border-right: 0; border-left: 0; border-radius: 0; scroll-snap-type: x proximity; scrollbar-width: none; }
  .user-center-page .side-menu::-webkit-scrollbar { display: none; }
  .user-center-page .menu-item { width: auto; min-width: max-content; flex: 0 0 auto; padding-inline: 13px; scroll-snap-align: start; }
  .user-center-page .menu-item.logout { margin-top: 0; border-top: 0; border-left: 1px solid var(--a-line); border-radius: 8px; }
  .profile-stats { width: 100%; }
  .profile-stats .stat-card:first-child { padding-left: 0; border-left: 0; }
  .post-page .post-meta { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 560px) {
  .community-page > .container,
  .user-center-page > .container,
  .post-page > .container { width: min(calc(100% - 24px), var(--community-max)); }
  .community-hero h1 { font-size: 32px; }
  .community-hero p { font-size: 14px; }
  .community-page .community-hero-actions,
  .community-page .create-post-btn { width: 100%; }
  .community-page .search-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding-inline: 14px; }
  .community-page .sort-bar,
  .community-page .category-bar { padding-inline: 14px; }
  .community-page .post-item { padding: 20px 16px; }
  .community-page .post-summary { -webkit-line-clamp: 3; }
  .community-page .sidebar { grid-template-columns: 1fr; }
  .profile-identity { grid-template-columns: 68px minmax(0, 1fr); gap: 14px; }
  .profile-hero .user-avatar-large { width: 68px; height: 68px; font-size: 25px; }
  .profile-copy h1 { font-size: 28px; }
  .profile-actions { display: grid; grid-template-columns: 1fr 1fr; grid-column: 1 / -1; margin-top: 2px; }
  .profile-stats { grid-column: 1 / -1; }
  .user-center-page .content-card { padding: 21px 18px; }
  .content-heading h2 { font-size: 22px; }
  .post-page > .container { padding-top: 20px; }
  .post-page .post-card { padding: 28px 20px; }
  .post-page .comment-section { padding: 24px 18px; }
  .post-page .post-title { max-width: none; font-size: 29px; }
  .post-page .post-stats { flex-wrap: wrap; }
  .community-page .modal-overlay { align-items: flex-end; padding: 12px; }
  .community-page .modal-box { max-height: calc(100dvh - 24px - env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: no-preference) {
  .community-page .post-item { transition: background-color .18s ease; }
}

/* Personal centre: tabs must stay reachable without horizontal page overflow. */
@media (max-width: 820px) {
  .user-center-page .sidebar { position: static; width: 100%; margin: 0; background: transparent; }
  .user-center-page .side-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 0; overflow: visible; border: 0; background: transparent; }
  .user-center-page .menu-item { min-width: 0; min-height: 46px; justify-content: center; padding: 8px 7px; border: 1px solid var(--a-line); border-radius: 9px; background: var(--a-surface); font-size: 13px; text-align: center; white-space: normal; }
  .user-center-page .menu-item i { flex: 0 0 auto; }
  .user-center-page .menu-item.logout { margin: 0; border: 1px solid color-mix(in srgb, var(--a-danger) 24%, var(--a-line)); border-radius: 9px; }
}
@media (max-width: 430px) {
  .user-center-page .side-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .user-center-page .menu-item { justify-content: flex-start; padding-inline: 12px; }
  .profile-actions { grid-template-columns: 1fr; }
}

.artdi-public .avatar-image { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.community-load-error { padding: 40px; color: var(--a-danger); text-align: center; }
.community-response-dump { max-height: 300px; margin-top: 10px; padding: 15px; overflow: auto; border-radius: 8px; background: var(--a-surface-2); color: var(--a-muted); font-size: 12px; text-align: left; }
.avatar-edit-row { display: flex; align-items: center; gap: 20px; }
.avatar-input { display: none; }
.avatar-edit-btn { padding: 8px 20px; font-size: 13px; }
.avatar-edit-help { margin: 8px 0 0; color: var(--a-muted); font-size: 12px; }
.request-history-item { cursor: default; }
