/* codes论坛 - Material Design 风格 + 响应式 + 暗色模式 */
:root {
  --primary: #7c5cff;
  --primary-dark: #6a4de6;
  --primary-light: #a595ff;
  --bg: #f5f5fa;
  --surface: #ffffff;
  --surface-2: #fafaff;
  --text: #1f1f2e;
  --text-2: #6b6b80;
  --border: #e8e8f0;
  --shadow: 0 2px 12px rgba(40, 30, 90, .08);
  --shadow-lg: 0 8px 32px rgba(40, 30, 90, .16);
  --radius: 14px;
  --up: #e53935;      /* 中国习惯：赞/涨=红 */
  --down: #43a047;
  --danger: #e53935;
  --appbar-h: 60px;
}
[data-theme="dark"] {
  --bg: #121217;
  --surface: #1e1e26;
  --surface-2: #25252f;
  --text: #ececf2;
  --text-2: #a0a0b3;
  --border: #32323e;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  padding-top: var(--appbar-h); min-height: 100vh;
  line-height: 1.6; transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

/* 顶栏 */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--appbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--primary); color: #fff; box-shadow: var(--shadow); z-index: 100;
}
.icon-btn {
  background: none; border: none; color: inherit; font-size: 22px;
  cursor: pointer; padding: 6px; border-radius: 8px; line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,.15); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand-mark {
  background: rgba(255,255,255,.2); border-radius: 8px; padding: 2px 8px;
  font-family: monospace; font-size: 15px;
}
.search-box { flex: 1; max-width: 480px; margin: 0 auto; }
.search-box input {
  width: 100%; padding: 9px 16px; border: none; border-radius: 24px;
  background: rgba(255,255,255,.2); color: #fff; font-size: 14px; outline: none;
}
.search-box input::placeholder { color: rgba(255,255,255,.8); }
.search-box input:focus { background: rgba(255,255,255,.3); }
.appbar-actions { display: flex; align-items: center; gap: 8px; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--primary-light); }

/* 抽屉 */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 260px; background: var(--surface);
  transform: translateX(-100%); transition: transform .25s ease; z-index: 200;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 20px; background: var(--primary); color: #fff; font-weight: 700; font-size: 18px; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 150; }
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
#drawerNav { padding: 12px; overflow-y: auto; }
.nav-item {
  display: block; padding: 12px 16px; border-radius: 10px; color: var(--text);
  margin-bottom: 4px; font-size: 15px; transition: background .15s;
}
.nav-item:hover, .nav-item.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.nav-divider { height: 1px; background: var(--border); margin: 12px 8px; }

/* 主内容 */
.main { max-width: 960px; margin: 0 auto; padding: 20px 16px 80px; }
.loading { text-align: center; padding: 80px 20px; color: var(--text-2); }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border: 4px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 卡片 */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 14px; transition: transform .15s, box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-title { font-size: 17px; font-weight: 600; margin: 0 0 8px; line-height: 1.4; }
.card-title a:hover { color: var(--primary); }
.card-meta { font-size: 12px; color: var(--text-2); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.card-excerpt { color: var(--text-2); font-size: 14px; margin: 10px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* 标签 chip */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px;
  background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary);
  border-radius: 16px; font-size: 12px; margin: 2px 4px 2px 0;
}
.chip:hover { background: color-mix(in srgb, var(--primary) 22%, transparent); }

/* 统计条 */
.stat-row { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--text-2); }
.stat { display: inline-flex; align-items: center; gap: 4px; }
.stat.up.active { color: var(--up); }
.stat.down.active { color: var(--down); }

/* 分页 */
.pagination { display: flex; justify-content: center; gap: 8px; margin: 24px 0; flex-wrap: wrap; }
.page-btn {
  min-width: 38px; height: 38px; padding: 0 12px; border: none; border-radius: 10px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: pointer;
}
.page-btn.active { background: var(--primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: 10px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* FAB */
.fab {
  position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px;
  border: none; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 30px; cursor: pointer; box-shadow: var(--shadow-lg); z-index: 90;
  transition: transform .15s;
}
.fab:hover { transform: scale(1.08) rotate(90deg); }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.form-control {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 14px; outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
textarea.form-control { min-height: 140px; resize: vertical; line-height: 1.6; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 4px; }

/* 对话框 */
.modal-root:empty { display: none; }
.modal-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-head { padding: 20px 22px 0; display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-2); cursor: pointer; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 0 22px 22px; display: flex; gap: 10px; justify-content: flex-end; }

/* Toast */
.toast-root { position: fixed; top: 76px; right: 16px; z-index: 400; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #32323e; color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: 14px; animation: slideIn .2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--down); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

/* 内容正文渲染 */
.content-body { line-height: 1.8; font-size: 15px; word-wrap: break-word; }
.content-body h1,.content-body h2,.content-body h3 { line-height: 1.3; margin: 20px 0 10px; }
.content-body pre { background: var(--surface-2); padding: 14px; border-radius: 10px; overflow-x: auto; }
.content-body code { background: color-mix(in srgb, var(--primary) 10%, transparent); padding: 2px 6px; border-radius: 5px; font-family: monospace; }
.content-body pre code { background: none; padding: 0; }
.content-body blockquote { border-left: 3px solid var(--primary); margin: 12px 0; padding: 4px 16px; color: var(--text-2); background: var(--surface-2); }
.content-body img { max-width: 100%; border-radius: 8px; }
.content-body a { color: var(--primary); text-decoration: underline; }

/* 详情页 */
.detail-title { font-size: 24px; font-weight: 700; margin: 0 0 14px; line-height: 1.35; }
.author-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.author-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-light); object-fit: cover; }
.author-name { font-weight: 600; }
.section-title { font-size: 16px; font-weight: 600; margin: 24px 0 12px; padding-left: 10px; border-left: 3px solid var(--primary); }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* 开关行 */
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }

/* 响应式 */
@media (max-width: 720px) {
  .brand-name { display: none; }
  .search-box { max-width: none; }
  .main { padding: 12px 10px 80px; }
  .card { padding: 14px; }
  .detail-title { font-size: 20px; }
  .toast-root { left: 16px; right: 16px; }
}
