/* ============================================================
   个人数学题库 · 样式
   浅色简洁风，响应式布局
   ============================================================ */

:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- 导航栏 ---------- */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar .logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.navbar .logo:hover {
  text-decoration: none;
}

.navbar .nav-links a {
  margin-left: 20px;
  font-size: 14px;
  color: var(--muted);
}

.navbar .nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.nav-links .auth-user {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  margin-left: 14px;
}
#auth-area > a {
  margin-left: 14px;
}

/* ---------- 主体容器 ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 18px;
}

.page-desc {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.filter-bar input[type="search"] {
  flex: 1;
  min-width: 200px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  background: var(--card);
  outline: none;
}

.filter-bar input[type="search"]:focus {
  border-color: var(--accent);
}

.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- 题目卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.problem-card {
  display: block;
  padding: 18px 20px;
  margin-bottom: 14px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

.problem-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}

.problem-card h3 {
  font-size: 17px;
  margin-bottom: 8px;
}

.problem-card .preview {
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.problem-card .meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.diff-easy { background: #ecfdf5; color: var(--success); }
.badge.diff-mid  { background: #fffbeb; color: #b45309; }
.badge.diff-hard { background: #fef2f2; color: var(--danger); }

/* 五级难度（天狗食题） */
.badge.diff-1 { background: #f3f4f6; color: #6b7280; }   /* 难以下咽（最易） */
.badge.diff-2 { background: #ecfdf5; color: #16a34a; }   /* 寡淡（次易） */
.badge.diff-3 { background: #fffbeb; color: #b45309; }   /* 平庸（中间） */
.badge.diff-4 { background: #fff7ed; color: #ea580c; }   /* 美味（次难） */
.badge.diff-5 { background: #fef2f2; color: #dc2626; }   /* 珍馐（最难） */

.meta .date {
  color: var(--muted);
}

/* ---------- 收藏按钮 ---------- */
.fav-btn {
  margin-left: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.fav-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.fav-btn.fav-on {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}
.fav-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* 我的收藏页条目 */
.fav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.fav-item .fav-main {
  flex: 1;
  min-width: 0;
  color: var(--text);
}
.fav-item .fav-main:hover { text-decoration: none; }
.fav-item .fav-main h3 { font-size: 16px; margin-bottom: 6px; }
.fav-item .fav-remove { flex: 0 0 auto; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 0;
  font-size: 15px;
}

/* ---------- 详情页 ---------- */
.back-link {
  font-size: 14px;
  margin-bottom: 16px;
  display: inline-block;
}

.problem-content {
  padding: 26px 28px;
}

.problem-content h1 {
  font-size: 22px;
  margin-bottom: 12px;
}

.problem-content .body {
  font-size: 16px;
}

/* Markdown + LaTeX 渲染区 */
.md-body h1, .md-body h2, .md-body h3 { margin: 18px 0 10px; }
.md-body p { margin: 8px 0; }
.md-body ul, .md-body ol { margin: 8px 0 8px 22px; }
.md-body pre {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 14px;
}
.md-body code {
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}
.md-body pre code { background: none; padding: 0; }
.md-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  color: var(--muted);
  margin: 10px 0;
}
/* KaTeX 公式块居中 */
.md-body .katex-display { margin: 14px 0; }

/* ---------- Markdown 编辑器 ---------- */
.md-editor {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
}
.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px;
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}
.md-toolbar button {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 11px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.md-toolbar button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.md-toolbar button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #c7d2fe;
}
.md-toolbar-spacer { flex: 1; }
.md-toolbar-tip {
  font-size: 12px;
  color: var(--muted);
  align-self: center;
  padding-right: 4px;
}
.md-input {
  display: block;
  flex: 1;
  min-height: 0;
  height: 100%;
  border: none;
  outline: none;
  padding: 12px 14px;
  font-size: 14.5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace;
  resize: none; /* 固定高度，由容器统一控制，保证与预览等高 */
  line-height: 1.7;
  box-sizing: border-box;
  background: var(--card);
  color: var(--text);
}
.md-split {
  display: flex;
  align-items: stretch;
  height: 380px; /* 编辑区统一高度，两侧等高各自滚动 */
}
.md-split .md-input {
  border-right: 1px solid var(--border);
}
.md-preview-wrap {
  flex: 1;
  min-width: 0;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}
/* 渲染框右上角浮动按钮：公式自动换行开关 */
.md-wrap-toggle {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 5;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.md-wrap-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.md-wrap-toggle.on {
  color: var(--accent);
  border-color: #c7d2fe;
  background: var(--accent-soft);
}
/* 渲染块内按钮：悬停/聚焦才显示（避免视觉噪音） */
.md-wrap-holder { position: relative; }
.md-wrap-holder > .md-wrap-toggle {
  opacity: 0;
  transition: opacity 0.15s;
}
.md-wrap-holder:hover > .md-wrap-toggle,
.md-wrap-holder > .md-wrap-toggle:focus-visible {
  opacity: 1;
}
/* 编辑器预览内的按钮常显 */
.md-editor .md-wrap-toggle { opacity: 1; }
.md-preview {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 12px 16px;
  font-size: 15px;
  max-height: none;
  overflow-y: auto;
  background: #fafbfd;
}
.md-preview .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
}
/* 小场景编辑区（答案/回复/私聊输入）用较矮的统一高度 */
#answer-editor .md-split { height: 300px; }
.reply-editor .md-split { height: 240px; }
.chat-input .md-split { height: 220px; }
.chat-input .md-editor { border-radius: 8px; }

/* 视频嵌入（Markdown 渲染） */
.video-embed {
  position: relative;
  padding-top: 56.25%;
  margin: 12px 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- 编辑器全屏 ---------- */
.md-editor-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
}
.md-editor-fullscreen .md-split {
  flex: 1;
  min-height: 0;
}
.md-editor-fullscreen .md-input,
.md-editor-fullscreen .md-preview-wrap {
  max-height: none;
  height: 100%;
  min-height: 0;
}
.md-editor-fullscreen .md-preview {
  max-height: none;
  height: auto;
  flex: 1;
  overflow-y: auto;
}
.md-editor-fullscreen .md-wrap-toggle { top: 10px; right: 14px; }

.answer-box {
  margin: 26px 0 0;
  border-top: 1px dashed var(--border);
  padding-top: 20px;
}

.answer-toggle {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
}

.answer-toggle:hover {
  background: var(--accent);
  color: #fff;
}

.answer-body {
  margin-top: 14px;
  display: none;
}

.answer-body.show { display: block; }

/* ---------- 留言板 ---------- */
.comments-section {
  margin-top: 28px;
  padding: 24px 28px;
}

.comments-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.comment-form-top {
  display: flex;
  gap: 10px;
}

.comment-form-top input {
  flex: 0 0 220px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.comment-form .btn {
  flex: 0 0 auto;
}

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
}

.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.danger {
  background: var(--danger);
}

.comment-item {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.comment-item:last-child { border-bottom: none; }

.comment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 4px;
}

.comment-nick {
  font-weight: 600;
  color: var(--accent);
}

.comment-date {
  color: var(--muted);
  font-size: 12px;
}

.comment-content {
  font-size: 14.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- 楼中楼 ---------- */
.comment-reply {
  border-left: 2px solid var(--border);
  background: #fafbfd;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}
.comment-delta {
  font-size: 14.5px;
  margin: 4px 0;
}
.comment-actions {
  margin-top: 6px;
  display: flex;
  gap: 14px;
}
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { color: var(--accent); }
.comment-more {
  margin: 8px 0 4px;
  font-size: 13px;
}
.reply-box {
  margin-top: 10px;
  padding: 10px;
  background: #fafbfd;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.reply-head {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.reply-head input {
  flex: 1;
  max-width: 220px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.reply-head .btn { padding: 6px 14px; font-size: 13px; }

/* ---------- 管理后台 ---------- */
.admin-login {
  max-width: 380px;
  margin: 60px auto;
  padding: 32px;
}

.admin-login h1 { font-size: 20px; margin-bottom: 18px; text-align: center; }

.admin-login .field { margin-bottom: 14px; }
.admin-login label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.admin-login input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.admin-login .btn { width: 100%; margin-top: 6px; }
.admin-login .msg { font-size: 13px; margin-top: 10px; text-align: center; }
.admin-login .msg.error { color: var(--danger); }
.admin-login .msg.ok { color: var(--success); }

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-list .problem-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: default;
}

.admin-list .problem-card:hover { transform: none; }
.admin-list .info { flex: 1; min-width: 0; }
.admin-list .info h3 { margin-bottom: 4px; font-size: 16px; }
.admin-list .row-actions { display: flex; gap: 8px; }
.row-actions .btn { padding: 5px 12px; font-size: 13px; }

/* 编辑表单 */
.form-card {
  padding: 26px 28px;
  margin-bottom: 20px;
}

.form-card h2 { font-size: 18px; margin-bottom: 16px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input[type="text"],
.field textarea,
.field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 120px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.field-row .field { flex: 1; min-width: 160px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-actions .btn.secondary { margin-left: auto; }

/* 留言管理 */
.comment-item .row-actions { margin-top: 6px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  z-index: 999;
}

.toast.show { opacity: 1; }

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 20px;
}

/* ---------- 响应式（手机适配） ---------- */
@media (max-width: 640px) {
  .container { padding: 18px 14px 40px; }
  .problem-content, .comments-section, .form-card { padding: 18px; }

  /* 导航：允许换行、压缩间距（5 个链接 + 登录区） */
  .navbar-inner {
    flex-wrap: wrap;
    height: auto;
    min-height: 52px;
    padding: 8px 14px;
    row-gap: 2px;
  }
  .navbar .logo { font-size: 16px; }
  .navbar .nav-links a { margin-left: 12px; font-size: 13px; }
  .nav-links .auth-user,
  #auth-area > a { margin-left: 12px; font-size: 13px; }

  /* 详情页徽章行可换行 */
  .problem-content .meta { flex-wrap: wrap; row-gap: 6px; }

  /* 留言表单：昵称全宽、按钮换行 */
  .comment-form-top { flex-wrap: wrap; }
  .comment-form-top input { flex: 1 1 100%; }

  /* 楼中楼缩进减半、内边距收窄 */
  .comment-reply { padding: 6px 10px; }
  .reply-head { flex-wrap: wrap; }
  .reply-head input { flex: 1 1 100%; max-width: none; }

  /* 聊天页：用动态视口高度（防手机键盘挤压），气泡放宽 */
  .chat-box {
    height: calc(100vh - 170px); /* 旧浏览器回退 */
    height: calc(100dvh - 170px);
    min-height: 380px;
  }
  .msg-row { max-width: 88%; }
  .chat-input-row { flex-wrap: wrap; }

  /* 弹窗贴边 */
  .modal { max-width: 100%; }
  .modal-body { padding: 14px 16px; }
  .modal-actions { padding: 12px 16px; }

  /* 公式块可横向滚动，防溢出屏幕 */
  .md-body .katex-display,
  .msg-bubble .katex-display,
  .comment-delta .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 0;
    max-width: 100%;
  }
  .video-embed { width: 100%; }

  /* 管理后台工具栏标题收窄 */
  .admin-toolbar .page-title { font-size: 20px; }
  .admin-toolbar .btn { font-size: 13px; padding: 7px 12px; }

  /* Markdown 编辑器：窄屏堆叠（源码在上、预览在下） */
  .md-split { flex-direction: column; height: auto; }
  .md-split .md-input {
    height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .md-preview-wrap { height: 280px; }
  .md-preview { max-height: none; }
  .md-toolbar-tip { display: none; }
}

@media (max-width: 400px) {
  .navbar .nav-links a { margin-left: 9px; font-size: 12px; }
  .nav-links .auth-user,
  #auth-area > a { margin-left: 9px; font-size: 12px; }
  .navbar .logo { font-size: 15px; }
}

/* ---------- Markdown 渲染内图片 ---------- */
.md-body img {
  max-width: 100%;
  border-radius: 8px;
}
.md-body .katex {
  font-size: 1.05em;
}

/* ---------- KaTeX 核心样式本地兜底 ----------
   即使外部 katex.min.css 加载失败，也保证：
   ① MathML 层隐藏（不出现"公式显示两次"） ② 基本布局正常 */
.katex-display {
  display: block;
  margin: 1em 0;
  text-align: center;
}
.katex-display > .katex {
  display: block;
  text-align: center;
  white-space: nowrap;
}
.katex {
  font: normal 1.21em KaTeX_Main, "Times New Roman", serif;
  line-height: 1.2;
  text-indent: 0;
  text-rendering: auto;
}
.katex-mathml {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
}
.katex .katex-html > .newline {
  display: block;
}
.katex .base {
  position: relative;
  display: inline-block;
  white-space: nowrap;
  width: min-content;
}

/* 对齐块 */
.md-align-left { text-align: left; }
.md-align-center { text-align: center; }
.md-align-right { text-align: right; }
.md-align-justify { text-align: justify; }
/* KaTeX 块级公式默认强制居中，在对齐块内需覆盖 */
.md-align-left .katex-display,
.md-align-left .katex-display > .katex {
  text-align: left;
}
.md-align-right .katex-display,
.md-align-right .katex-display > .katex {
  text-align: right;
}

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; margin: 0; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.latex-preview {
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  min-height: 48px;
  text-align: center;
  overflow-x: auto;
}
#preset-tags .chip {
  display: inline-block;
  margin: 4px 6px 0 0;
}
#preset-tags .chip:hover {
  background: var(--accent-soft);
}

/* ---------- 消息中心 ---------- */
.conv-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  margin-bottom: 12px;
  color: var(--text);
}
.conv-item:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.conv-main {
  flex: 1;
  min-width: 0;
}
.conv-name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.conv-preview {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-time {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}
.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}
.user-row:hover {
  border-color: var(--accent);
}
.user-name {
  font-size: 14px;
}

/* ---------- 聊天页 ---------- */
.chat-box {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 420px;
}
.chat-head {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafbfd;
}
.msg-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 78%;
}
.msg-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}
.msg-bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14.5px;
  word-break: break-word;
}
.msg-row.mine .msg-bubble {
  background: var(--accent);
  color: #fff;
}
.msg-row.mine .msg-bubble a { color: #fff; }
.msg-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.msg-audio audio { max-width: 240px; height: 36px; }
.chat-input {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.chat-input-row .btn { flex: 0 0 auto; }
.rec-btn.recording {
  background: var(--danger);
  animation: recPulse 1s infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* ============================================================
   天狗主题 · 数学星空(光效 + 动效,与 solver 统一)
   ============================================================ */

/* 背景柔光(靛蓝/紫罗兰双色) */
body {
  background:
    radial-gradient(60vmax 60vmax at 88% -8%, rgba(79, 70, 229, 0.14), transparent 60%),
    radial-gradient(55vmax 55vmax at 4% 108%, rgba(139, 92, 246, 0.12), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* 内容层置于粒子背景之上 */
.container { position: relative; z-index: 1; }

/* 导航:磨砂玻璃 + 底部微光 */
.navbar {
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}
.navbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79, 70, 229, 0.45), transparent);
}

/* Logo:渐变流光 */
.navbar .logo {
  background: linear-gradient(90deg, #4f46e5 0%, #8b5cf6 50%, #4f46e5 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: dogLogoFlow 6s linear infinite;
}
@keyframes dogLogoFlow { to { background-position: -200% 0; } }

/* 卡片:悬停微浮 + 光晕 */
.card {
  transition: transform 0.22s ease, box-shadow 0.3s ease, border-color 0.22s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 34px rgba(79, 70, 229, 0.13), 0 2px 6px rgba(0, 0, 0, 0.04);
  border-color: rgba(79, 70, 229, 0.35);
}

/* 主按钮:渐变 + 扫光 */
.btn {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  background-size: 180% 180%;
  transition: background-position 0.45s ease, box-shadow 0.25s ease, transform 0.15s ease, opacity 0.2s;
}
.btn:hover:not(:disabled) {
  background-position: 100% 50%;
  box-shadow: 0 6px 22px rgba(79, 70, 229, 0.38);
  transform: translateY(-1px);
}
.btn { position: relative; overflow: hidden; }
.btn::after {
  content: "";
  position: absolute;
  top: 0; left: -80%;
  width: 45%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
}
.btn:hover:not(:disabled)::after { left: 135%; }

/* 次要按钮保持白底(math-site 用 .btn.secondary) */
.btn.secondary,
.btn.secondary:hover {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  transform: none;
}
.btn.secondary::after { display: none; }

/* 危险按钮保持红色 */
.btn.danger { background: var(--danger); }

/* 筛选搜索框聚焦微光 */
.filter-bar input[type="search"]:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* 输入框聚焦微光 */
input:focus, textarea:focus, select:focus {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* 徽章微光 */
.badge { transition: box-shadow 0.2s; }
.badge:hover { box-shadow: 0 0 12px rgba(79, 70, 229, 0.25); }

/* 移动端降级 */
@media (prefers-reduced-motion: reduce) {
  .btn, .card, .navbar .logo { animation: none !important; transition: none !important; }
}

/* ============================================================
   玻璃质感:卡片/上传区/弹窗半透明,星空粒子透出
   ============================================================ */
.card { background: rgba(255, 255, 255, 0.78); }
.navbar { background: rgba(255, 255, 255, 0.6); }
.modal-box {
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.dropzone { background: rgba(255, 255, 255, 0.7); }

.problem-content { background: rgba(255, 255, 255, 0.8); }

/* ============================================================
   张力强化:方向光带 + 渐变标题 + 三色描边 + 更饱和按钮
   ============================================================ */

/* 背景:斜向光带 + 更浓双色光晕 */
body {
  background:
    linear-gradient(115deg, transparent 40%, rgba(79, 70, 229, 0.10) 40.5%, transparent 41.5%),
    linear-gradient(115deg, transparent 56%, rgba(139, 92, 246, 0.08) 56.5%, transparent 57.5%),
    radial-gradient(70vmax 70vmax at 85% -10%, rgba(79, 70, 229, 0.20), transparent 62%),
    radial-gradient(60vmax 60vmax at 0% 110%, rgba(139, 92, 246, 0.16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

/* 页面大标题:深靛→紫渐变 */
.page-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(120deg, #1e1b4b 0%, #4f46e5 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 导航 active:渐变下划线 */
.nav-links a.active { position: relative; }
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -8px; height: 2.5px;
  background: linear-gradient(90deg, #4f46e5, #8b5cf6);
  border-radius: 2px;
}

/* 卡片悬停:三色渐变描边点亮 */
.card { position: relative; }
.card::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0), rgba(139, 92, 246, 0));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.card:hover::before {
  opacity: 1;
  background: linear-gradient(135deg, #6366f1, #a855f7, #f59e0b);
}

/* 主按钮:更饱和渐变 + 立体光 */
.btn {
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 45%, #a21caf 100%);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), 0 4px 16px rgba(109, 40, 217, 0.25);
}
.btn:hover:not(:disabled) {
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08), 0 8px 28px rgba(109, 40, 217, 0.45);
}

/* 次要按钮回退白底 */
.btn.secondary,
.btn.secondary:hover {
  background: var(--card);
  box-shadow: none;
}

/* ============================================================
   按钮现代化:纯色克制 + 柔和光晕(替代渐变/扫光)
   ============================================================ */
.btn {
  background: #4f46e5;
  background-image: none;
  box-shadow: none;
  border-radius: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.btn::after { display: none !important; } /* 去掉扫光 */
.btn:hover:not(:disabled) {
  background: #4338ca;
  box-shadow: 0 6px 22px rgba(79, 70, 229, 0.32);
  transform: translateY(-1px);
}
.btn:active:not(:disabled) { transform: translateY(0); }
.btn.danger { background: #dc2626; }
.btn.danger:hover:not(:disabled) {
  background: #b91c1c;
  box-shadow: 0 6px 22px rgba(220, 38, 38, 0.3);
}

/* ============================================================
   高级动效:入场 / 进度条 / 涟漪 / 标题模糊入场
   ============================================================ */

/* 滚动入场 */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.55s ease, transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.reveal.in { opacity: 1; transform: none; }
.card.reveal.in:hover,
.dropzone.reveal.in:hover { transform: translateY(-2px); }

/* 顶部滚动进度条 */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0;
  background: linear-gradient(90deg, #4f46e5, #8b5cf6);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.5);
  z-index: 2000;
  pointer-events: none;
}

/* 按钮点击涟漪 */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: scale(0);
  animation: rippleAnim 0.6s ease-out forwards;
  pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(2.8); opacity: 0; } }

/* 页面标题:模糊 → 清晰入场 */
.page-title {
  animation: titleIn 0.7s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(16px); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* ============================================================
   天狗留言板 · 板块切换 / 帖子卡片 / 音频
   ============================================================ */
.board-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.board-tabs .chip {
  padding: 8px 18px;
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.board-tabs .chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.board-tabs .chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 顶层帖子卡片 */
.post-card {
  padding: 14px 20px;
  margin-bottom: 14px;
}
.post-card .comment-head { margin-bottom: 6px; }

/* Markdown 里的音频播放器 */
.audio-embed { margin: 10px 0; }
.audio-embed audio { max-width: 320px; height: 40px; vertical-align: middle; }

/* 编辑器工具栏录音中状态 */
.md-toolbar button.recording {
  background: var(--danger);
  color: #fff;
  animation: recPulse 1s infinite;
}

/* 关注按钮已关注态 */
.follow-btn[data-follow] { color: var(--success); }

/* 游客回复身份标识（非输入框） */
.reply-head .reply-nick-guest {
  color: var(--muted);
  font-size: 13px;
  align-self: center;
}
