/* CoderWar 论坛 - 深色科技风 */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #388bfd;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --radius: 10px;
  --font-sans: 'Noto Sans SC', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .main { transition: none; }
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background: var(--bg) url(/land.png) no-repeat center center fixed;
  background-size: 115%;
  background-position: center;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 0;
  pointer-events: none;
}

body > .app-body {
  position: relative;
  z-index: 1;
}

/* 玻璃拟态：半透明 + 毛玻璃 + 细边框 */
.glass {
  background: rgba(22, 27, 34, 0.65);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}

/* ========== 左侧导航栏：完全贴左、全高、固定不随滚动 ========== */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 220px;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  background: rgba(22, 27, 34, 0.65);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-head {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sidebar-icon {
  color: var(--accent);
  font-size: 0.9rem;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.sidebar-collapse {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.sidebar-collapse:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

body.sidebar-collapsed .app-sidebar {
  width: 64px;
}
body.sidebar-collapsed .sidebar-title,
body.sidebar-collapsed .sidebar-link span:not(.notif-badge),
body.sidebar-collapsed .footer-brand,
body.sidebar-collapsed .footer-privacy {
  display: none;
}
body.sidebar-collapsed .app-body {
  margin-left: 64px;
}
body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px;
}
body.sidebar-collapsed .sidebar-footer {
  padding: 10px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.9;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
  background: rgba(88, 166, 255, 0.35);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-notif {
  position: relative;
}

.sidebar-coins {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-radius: 10px;
  border: 1px solid transparent;
}
.sidebar-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sidebar-footer .footer-brand {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.sidebar-footer .footer-privacy {
  margin: 6px 0 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.9;
}

/* ========== 主区域：居中标题 + 内容 + 右侧固定图标 ========== */
.app-body {
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 主内容区顶部：居中大标题 + 副标题（与参考图一致） */
.page-title-center {
  text-align: center;
  margin-bottom: 32px;
  padding-top: 24px;
}

.page-title-center-h1 {
  margin: 0 0 6px;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.page-title-center-sub {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* 右侧固定竖向图标：固定于视口右侧，不随滚动 */
.right-edge-icons {
  position: fixed;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 90;
  pointer-events: auto;
}

.right-edge-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 27, 34, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  text-decoration: none;
  font-size: 1.1rem;
  cursor: pointer;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: background 0.2s, border-color 0.2s;
  box-sizing: border-box;
}

.right-edge-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
}

.right-edge-icon-ai {
  background: rgba(236, 72, 153, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.right-edge-icon-ai:hover {
  background: rgba(236, 72, 153, 0.55);
  border-color: rgba(255, 255, 255, 0.3);
}

/* 兼容：旧 class 名 */
.logo { font-family: var(--font-mono); font-weight: 600; color: var(--text); text-decoration: none; }
.logo-dot { color: var(--accent); }
.user-wrap { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.header-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-name { font-size: 0.9rem; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav a { color: var(--text-muted); text-decoration: none; }
.nav a:hover { color: var(--accent); }

/* Apple Liquid Glass 按钮 */
.btn-ghost {
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text);
}

.btn-primary {
  display: inline-block;
  padding: 10px 20px;
  background: rgba(88, 166, 255, 0.35);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  background: rgba(88, 166, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Main - 主内容区可滚动，为右侧图标留空 */
.main {
  flex: 1;
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px 48px 24px;
  padding-right: 88px;
  min-width: 0;
  overflow-y: auto;
  transition: opacity 0.15s ease;
}
.main.spa-loading { opacity: 0.6; pointer-events: none; }
.main:focus, .main:focus-visible { outline: none; }

.page-head {
  margin-bottom: 28px;
  position: relative;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
  font-weight: 600;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.btn-new-post {
  position: absolute;
  right: 0;
  top: 0;
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .sep {
  margin: 0 6px;
  opacity: 0.6;
}

/* Forum index - section list（与参考图一致：双列卡片） */
.section-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.section-card {
  background: rgba(22, 27, 34, 0.65);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.section-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.section-link {
  display: block;
  padding: 20px 24px;
  color: inherit;
  text-decoration: none;
}

.section-name {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.section-desc {
  display: block;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.section-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0.9;
}

/* Section page - post list */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: rgba(22, 27, 34, 0.65);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.post-row {
  border-bottom: 1px solid var(--border);
}

.post-row:last-child {
  border-bottom: none;
}

.post-row.pinned {
  background: rgba(88, 166, 255, 0.06);
}

.post-link {
  display: block;
  padding: 14px 20px;
  color: inherit;
  text-decoration: none;
  transition: background 0.1s;
}

.post-link:hover {
  background: var(--bg-hover);
}

.post-title {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
}

.badge.pin {
  font-size: 0.7rem;
  background: var(--orange);
  color: #000;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 8px;
}

.post-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.empty-tip {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px;
  margin: 0;
}

/* Post detail */
.post-article {
  background: rgba(22, 27, 34, 0.65);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
}

.post-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.4;
}

.post-meta-line {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.post-meta-line span + span {
  margin-left: 16px;
}

.post-body {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Replies */
.replies h2 {
  font-size: 1.1rem;
  margin: 0 0 16px;
  color: var(--text-muted);
}

.reply-form {
  margin-bottom: 24px;
}

.reply-form textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

.reply-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

.login-tip {
  margin-bottom: 20px;
  color: var(--text-muted);
}

.login-tip a {
  color: var(--accent);
}

.reply-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reply-item {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  background: rgba(22, 27, 34, 0.6);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
}

.reply-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.reply-body {
  word-break: break-word;
}

.markdown-body { line-height: 1.7; }
.markdown-body pre { background: var(--bg-hover); padding: 12px; border-radius: 8px; overflow-x: auto; }
.markdown-body code { background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.markdown-body pre code { padding: 0; background: none; }
.markdown-body ul, .markdown-body ol { margin: 0.5em 0; padding-left: 1.5em; }
.markdown-body p { margin: 0.5em 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 1em 0 0.5em; font-size: 1.1rem; }

.btn-like, .btn-fav {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.85rem;
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-like:hover, .btn-fav:hover { border-color: var(--accent); color: var(--accent); background: rgba(88, 166, 255, 0.12); }
.btn-like.liked, .btn-fav.favorited { border-color: var(--accent); color: var(--accent); background: rgba(88, 166, 255, 0.2); }
.btn-like-small { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; padding: 0 6px; }
.btn-like-small:hover, .btn-like-small.liked { color: var(--accent); }
.meta-num { margin-left: 8px; color: var(--text-muted); font-size: 0.85rem; }
.btn-report, .btn-report-small { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; padding: 0 6px; }
.btn-report:hover, .btn-report-small:hover { color: var(--red); }

.pagination { display: flex; gap: 8px; margin: 24px 0; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 0.9rem; }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.nav-notif-wrap { position: relative; }
.notif-badge { position: absolute; top: -6px; right: -8px; background: var(--red); color: #fff; font-size: 0.7rem; padding: 1px 5px; border-radius: 10px; min-width: 18px; text-align: center; }
.search-form { display: flex; gap: 10px; margin-bottom: 24px; max-width: 480px; }
.search-form input[type="search"] { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text); }
.search-section { margin-top: 24px; }
.search-user-list, .search-post-list { list-style: none; padding: 0; margin: 0; }
.search-user-list li, .search-post-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.search-avatar { width: 24px; height: 24px; border-radius: 50%; vertical-align: middle; margin-right: 8px; }
.notification-list { list-style: none; padding: 0; margin: 0; }
.notification-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.notif-avatar { width: 36px; height: 36px; border-radius: 50%; }
.notif-time { color: var(--text-muted); font-size: 0.85rem; margin-left: 8px; }
.form-success { color: var(--green); margin-bottom: 12px; }
.public-profile .profile-bio { margin: 12px 0; color: var(--text-muted); }
.recent-posts { margin-top: 32px; }
.recent-posts .post-list { margin-top: 12px; }
.muted { color: var(--text-muted); font-size: 0.9rem; }
body.light { --bg: #f6f8fa; --bg-card: #fff; --bg-hover: #f0f2f5; --border: #d0d7de; --text: #1f2328; --text-muted: #656d76; }
body.light::before { background: transparent; }
body.light .app-sidebar {
  background: rgba(255, 255, 255, 0.72);
  border-right-color: rgba(0, 0, 0, 0.08);
}
body.light .sidebar-head,
body.light .sidebar-footer { border-color: rgba(0, 0, 0, 0.06); }
body.light .sidebar-link:hover { background: rgba(0, 0, 0, 0.06); border-color: rgba(0, 0, 0, 0.08); }
body.light .sidebar-link.active { background: rgba(88, 166, 255, 0.35); color: #fff; border-color: rgba(0, 0, 0, 0.1); }
body.light .right-edge-icon {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.08);
}
body.light .right-edge-icon:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.12);
}
body.light .right-edge-icon-ai {
  background: rgba(236, 72, 153, 0.5);
  border-color: rgba(0, 0, 0, 0.1);
}
body.light .right-edge-icon-ai:hover {
  background: rgba(236, 72, 153, 0.65);
}
body.light .section-card,
body.light .auth-card,
body.light .profile-card { background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(20px) saturate(160%); }
body.light .notif-badge { background: #cf222e; }
.footer-privacy { font-size: 0.8rem; color: var(--text-muted); margin: 8px 0 0; max-width: 480px; }

/* New post form */
.post-form label,
.auth-form label {
  display: block;
  margin-bottom: 16px;
}

.post-form label span,
.auth-form label span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.post-form input[type="text"],
.post-form textarea,
.auth-form input {
  width: 100%;
  max-width: 560px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.post-form textarea {
  max-width: 100%;
  min-height: 200px;
  resize: vertical;
}

.post-form input:focus,
.post-form textarea:focus,
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.post-form .btn-primary,
.auth-form .btn-primary {
  margin-top: 8px;
}

.btn-block {
  width: 100%;
  max-width: 560px;
  text-align: center;
  padding: 12px;
}

.form-error {
  color: var(--red);
  margin: 0 0 12px;
  font-size: 0.9rem;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(22, 27, 34, 0.65);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-users-table th,
.admin-users-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.admin-users-table th {
  font-weight: 600;
  color: var(--text-muted);
}
.admin-users-table tr:last-child td {
  border-bottom: none;
}
.admin-actions form {
  display: inline;
  margin-right: 8px;
}
.admin-actions input[type="text"] {
  width: 100px;
  padding: 4px 8px;
  font-size: 0.85rem;
}
.admin-notify-form label { display: block; margin-bottom: 12px; }
.admin-notify-form select,
.admin-notify-form textarea { max-width: 400px; }

/* Auth pages */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px - 80px);
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.auth-card h1 {
  margin: 0 0 24px;
  font-size: 1.5rem;
  text-align: center;
}

.auth-form input {
  margin-bottom: 0;
}

.auth-form .btn-primary {
  margin-top: 20px;
}

.auth-oauth-row {
  margin: 0 0 16px;
}
.auth-oauth-row .btn-oauth {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s, border-color 0.15s;
}
.auth-oauth-row .btn-oauth:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}
.auth-divider {
  text-align: center;
  margin: 16px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.auth-divider span::before,
.auth-divider span::after {
  content: '';
  display: inline-block;
  width: 60px;
  height: 1px;
  background: var(--border);
  vertical-align: middle;
  margin: 0 10px;
}

.auth-switch {
  text-align: center;
  margin: 20px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(22, 27, 34, 0.72);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  margin-top: auto;
}

.footer-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.site-footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.footer-brand {
  font-size: 0.9rem;
}

.footer-privacy {
  max-width: 520px;
  word-break: normal;
  white-space: normal;
}

/* Error page */
.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-page h1 {
  font-size: 4rem;
  margin: 0 0 8px;
  color: var(--text-muted);
}

.error-page p {
  margin: 0 0 24px;
  color: var(--text-muted);
}

/* AI 助手：右侧固定图标之一，弹层在左侧打开 */
.ai-help-right {
  position: relative;
  display: inline-flex;
}

.ai-help-right .ai-help-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: background 0.2s, border-color 0.2s;
}

.ai-help-panel {
  position: absolute;
  bottom: 0;
  right: 100%;
  margin-right: 12px;
  width: 360px;
  max-width: calc(100vw - 100px);
  height: 420px;
  background: rgba(22, 27, 34, 0.78);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 200;
}
.ai-help-panel[hidden] {
  display: none !important;
}

.ai-help-panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.95rem;
}

.ai-help-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 8px 12px;
  margin: -8px -12px -8px 8px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-help-close:hover {
  color: var(--text);
}

.ai-help-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-help-msg {
  max-width: 90%;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-help-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.ai-help-msg.bot {
  align-self: flex-start;
  background: var(--bg-hover);
  border: 1px solid var(--border);
}

.ai-help-msg.loading {
  align-self: flex-start;
  color: var(--text-muted);
}

.ai-help-input-wrap {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-help-input-wrap textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
}

.ai-help-input-wrap textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.ai-help-send {
  align-self: flex-end;
}

/* 个人资料 */
.profile-card {
  background: rgba(22, 27, 34, 0.7);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
}
.profile-avatar-wrap {
  margin-bottom: 20px;
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}
.profile-dl { margin: 0 0 20px; }
.profile-dl dt { font-size: 0.85rem; color: var(--text-muted); margin-top: 12px; }
.profile-dl dt:first-child { margin-top: 0; }
.profile-dl dd { margin: 4px 0 0; }
.profile-form label { display: block; margin-bottom: 16px; }
.profile-form label span { display: block; margin-bottom: 6px; font-size: 0.9rem; color: var(--text-muted); }
.profile-form input { width: 100%; max-width: 400px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-family: inherit; }
.profile-form input:focus { outline: none; border-color: var(--accent); }
.profile-form input[type="file"] { padding: 6px 0; }
.form-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; display: block; }
.form-hint.small { font-size: 0.8rem; margin-top: 6px; }
.optional-block { margin-top: 12px; }
.profile-avatar-preview { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 8px; }

/* 删帖/删回复 */
.inline-form { display: inline; margin-left: 12px; }
.inline-form button { margin: 0; }
.btn-delete {
  padding: 6px 12px;
  font-size: 0.8rem;
  background: rgba(248, 81, 73, 0.2);
  border: 1px solid rgba(248, 81, 73, 0.5);
  color: var(--red);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
}
.btn-delete:hover { background: rgba(248, 81, 73, 0.35); border-color: var(--red); }
.btn-delete-small {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-muted);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  margin-left: 8px;
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
}
.btn-delete-small:hover { border-color: var(--red); color: var(--red); background: rgba(248, 81, 73, 0.15); }
.reply-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }

.form-success { color: var(--green); margin: 0 0 12px; font-size: 0.9rem; }
.muted { color: var(--text-muted); font-size: 0.9rem; }

/* 好友 / 消息 / 群组 */
.friend-list, .thread-list, .group-list { list-style: none; margin: 0; padding: 0; }
.friend-item, .thread-item, .group-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.friend-item:last-child, .thread-item:last-child, .group-item:last-child { border-bottom: none; }
.friend-avatar img, .friend-avatar-img, .thread-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-hover); display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; color: var(--text-muted); }
.friend-name, .thread-name { font-weight: 500; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.thread-link { display: flex; align-items: center; gap: 12px; flex: 1; text-decoration: none; color: inherit; }
.thread-link:hover { color: var(--accent); }
.thread-info { flex: 1; min-width: 0; }
.thread-preview { font-size: 0.85rem; color: var(--text-muted); display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-list { margin: 20px 0; }
.message-bubble { max-width: 85%; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; }
.message-bubble.mine { margin-left: auto; background: var(--accent); color: #fff; }
.message-bubble.theirs { background: var(--bg-hover); border: 1px solid var(--border); }
.msg-meta { font-size: 0.75rem; opacity: 0.9; }
.msg-content { white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
.message-send-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 16px; }
.message-send-form textarea { flex: 1; min-height: 60px; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-family: inherit; resize: none; }

/* 微信风格聊天 */
:root {
  --wechat-green: #07c160;
  --wechat-bg: #ededed;
  --wechat-bubble-theirs: #fff;
  --wechat-bubble-mine: #95ec69;
}
.chat-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 800px;
  margin: 0 auto;
  background: var(--wechat-bg);
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.chat-back {
  color: var(--wechat-green);
  text-decoration: none;
  font-size: 1rem;
  min-width: 60px;
}
.chat-back:hover { color: var(--accent); }
.chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
}
.chat-title-wrap.column { flex-direction: column; gap: 2px; }
.chat-title-wrap.column .chat-title-desc { font-size: 0.75rem; }
.chat-title-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}
.chat-title-avatar.placeholder {
  background: var(--bg-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.chat-title-name { font-weight: 600; font-size: 1.05rem; }
.chat-title-desc { font-size: 0.8rem; color: var(--text-muted); display: block; }
.chat-header-placeholder { width: 60px; }
.chat-mute-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(200, 60, 60, 0.25);
  border: 1px solid rgba(200, 60, 60, 0.5);
  border-radius: 10px;
  margin: 8px 16px;
  color: #f87171;
  font-size: 0.9rem;
}
body.light .chat-mute-alert {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.4);
  color: #dc2626;
}
.chat-mute-icon { font-size: 1.1rem; }
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 80px;
}
.chat-messages { display: flex; flex-direction: column; gap: 16px; }
.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.chat-row.mine { flex-direction: row-reverse; }
.chat-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-hover);
}
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-avatar .placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.chat-bubble-wrap { max-width: 70%; display: flex; flex-direction: column; align-items: flex-end; }
.chat-row.theirs .chat-bubble-wrap { align-items: flex-start; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 4px;
  position: relative;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bubble.theirs {
  background: var(--wechat-bubble-theirs);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  border-top-left-radius: 2px;
}
.chat-bubble.mine {
  background: var(--wechat-bubble-mine);
  color: #000;
  border-top-right-radius: 2px;
}
.chat-bubble-inner { font-size: 0.95rem; line-height: 1.5; }
.chat-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 4px; }
.chat-bubble-author { font-size: 0.75rem; color: var(--accent); margin-bottom: 2px; }
.chat-footer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  resize: none;
}
.chat-input:focus { outline: none; border-color: var(--wechat-green); }
.chat-send {
  flex-shrink: 0;
  padding: 10px 20px;
  background: var(--wechat-green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}
.chat-send:hover { filter: brightness(1.05); }
.chat-send:disabled, .chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.chat-send:disabled:hover { filter: none; }
.chat-extra-actions { padding: 8px 12px; background: var(--bg-card); border-top: 1px solid var(--border); }
/* 消息列表 - 微信风格 */
.wechat-list .page-title { margin: 0 0 0 16px; padding: 16px 0; font-size: 1.25rem; }
.wechat-thread-list { list-style: none; margin: 0; padding: 0; background: var(--bg-card); }
.wechat-thread-list li { border-bottom: 1px solid var(--border); }
.wechat-thread-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  color: inherit;
}
.wechat-thread-item:hover { background: var(--bg-hover); }
.wechat-thread-avatar {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-hover);
}
.wechat-thread-avatar img { width: 100%; height: 100%; object-fit: cover; }
.wechat-thread-avatar .placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--text-muted); }
.wechat-thread-main { flex: 1; min-width: 0; }
.wechat-thread-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.wechat-thread-name { font-weight: 500; font-size: 1rem; }
.wechat-thread-time { font-size: 0.75rem; color: var(--text-muted); }
.wechat-thread-preview { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-chat { text-align: center; padding: 60px 24px; }
.empty-chat p { color: var(--text-muted); margin-bottom: 20px; }
.group-messages { max-height: 400px; overflow-y: auto; margin: 16px 0; padding: 12px; background: var(--bg-card); border-radius: var(--radius); }
.group-msg { margin-bottom: 12px; }
.group-msg-author { font-weight: 600; font-size: 0.9rem; margin-right: 8px; }
.group-msg-time { font-size: 0.8rem; color: var(--text-muted); }
.group-msg-body { margin-top: 4px; white-space: pre-wrap; }
.group-send-form { display: flex; gap: 8px; align-items: flex-end; }
.group-send-form textarea { flex: 1; min-height: 60px; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-family: inherit; resize: none; }
.leave-form { margin-top: 16px; }
.search-form { display: flex; gap: 8px; margin-bottom: 20px; }
.search-input { flex: 1; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text); font-size: 1rem; }
.group-form label { display: block; margin-bottom: 16px; }
.group-form label span { display: block; margin-bottom: 6px; color: var(--text-muted); }
.group-form input, .group-form textarea { width: 100%; max-width: 400px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text); font-family: inherit; }

/* Responsive - 平板 */
@media (max-width: 768px) {
  .app-sidebar {
    width: 200px;
  }
  .app-body {
    margin-left: 200px;
  }
  .main {
    padding: 20px 16px 32px;
  }
  .page-head h1 {
    font-size: 1.4rem;
  }
  .section-link {
    padding: 16px 20px;
  }
  .post-link {
    padding: 12px 16px;
  }
  .section-list {
    grid-template-columns: 1fr;
  }
  .ai-help-right .ai-help-panel {
    width: 340px;
    height: 380px;
  }
}

/* Responsive - 手机（知乎风格：留白、卡片、大触控） */
@media (max-width: 640px) {
  .main {
    padding: 20px 16px 28px;
  }
  .page-head h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 8px;
  }
  .section-list { gap: 12px; }
  .section-card {
    border-radius: 12px;
    overflow: hidden;
  }
  .section-link {
    padding: 20px 18px;
  }
  .section-name { font-size: 1.05rem; }
  .section-desc { font-size: 0.9rem; margin-top: 4px; }
  .post-list { border-radius: 12px; overflow: hidden; }
  .post-link { padding: 18px; }
  .post-article {
    border-radius: 12px;
    padding: 20px 18px;
  }
  .app-sidebar {
    width: 180px;
  }
  .app-body {
    margin-left: 180px;
  }
  .main {
    padding: 16px 12px 24px;
  }
  .page-head {
    margin-bottom: 20px;
  }
  .page-head h1 {
    font-size: 1.25rem;
  }
  .btn-new-post {
    position: static;
    display: inline-block;
    margin-top: 12px;
    min-height: 44px;
    padding: 10px 18px;
  }
  .section-card .section-link {
    padding: 16px;
  }
  .section-name {
    font-size: 1rem;
  }
  .post-article {
    padding: 16px 12px;
  }
  .post-header h1 {
    font-size: 1.2rem;
  }
  .reply-form textarea {
    min-height: 80px;
  }
  .right-edge-icons {
    right: 12px;
  }
  .right-edge-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  .main {
    padding-right: 24px;
  }
  .ai-help-right .ai-help-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    margin-right: 0;
    right: 0;
    border-radius: 0;
  }
  .ai-help-panel-head {
    padding: 14px 16px;
    min-height: 52px;
  }
  .ai-help-close {
    font-size: 1.8rem;
    margin: -8px -8px -8px 8px;
  }
  .ai-help-messages {
    padding: 16px;
  }
  .ai-help-input-wrap {
    padding: 16px;
  }
  .auth-card {
    margin: 0 12px;
    padding: 24px 20px;
  }
  .profile-card {
    padding: 20px;
  }
  .breadcrumb {
    font-size: 0.8rem;
  }
}

/* 横屏手机 / 小屏优化 */
@media (max-width: 400px) {
  .app-sidebar {
    width: 160px;
  }
  .app-body {
    margin-left: 160px;
  }
  .sidebar-link span:not(.notif-badge) {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
