/* 云智论坛 · 深色主题 */
:root {
  --bg: #0b0e14;
  --bg2: #10141d;
  --panel: #151a25;
  --panel2: #1a2030;
  --border: #242c3e;
  --text: #e7eaf2;
  --muted: #8b93a7;
  --accent: #5b7cfa;
  --accent2: #7c5bfa;
  --up: #ff6b35;
  --down: #5b7cfa;
  --danger: #f0524f;
  --ok: #3fb27f;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; box-sizing: border-box; }
html { overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; outline: none; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
::selection { background: rgba(91,124,250,.35); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: 999px; padding: 7px 16px; font-size: 14px; transition: .15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: #fff; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; border-radius: 999px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 11px; font-style: normal; padding: 0 6px; min-width: 17px;
  height: 17px; display: inline-flex; align-items: center; justify-content: center;
}

/* ============ 布局 ============ */
#app { display: block; min-height: 100vh; }
#rightbar { display: none; }
@media (min-width: 1200px) {
  #app.has-rightbar #rightbar { display: block; padding: 20px 20px 20px 0; position: fixed; top: 0; right: 0; width: 300px; height: 100vh; overflow-y: auto; z-index: 5; background: var(--bg); }
  #app.has-rightbar #main { margin-right: 300px; }
}

/* ============ 侧栏 ============ */
#sidebar {
  position: fixed; top: 0; left: 0; width: 240px; height: 100vh; overflow-y: auto; z-index: 10;
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin;
}
@media (min-width: 901px) {
  #main { width: calc(100vw - 240px); max-width: none; }
}
@media (min-width: 1200px) {
  #app.has-rightbar #main { margin-right: 300px; width: calc(100vw - 240px - 300px); }
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-size: 19px; font-weight: 800; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.logo-wrap img { width: 32px; height: 32px; display: block; }
#btn-new-post { margin: 0 4px 14px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 14.5px;
  border: none; background: none; width: 100%; text-align: left;
}
.side-nav a:hover { background: var(--panel2); text-decoration: none; }
.side-nav a.active { background: var(--panel2); color: var(--accent); font-weight: 600; }
.side-nav a span { flex: 1; }
.side-section { color: var(--muted); font-size: 12px; padding: 14px 10px 6px; letter-spacing: .1em; }
.side-section-row { display: flex; align-items: center; justify-content: space-between; }
#btn-new-cat {
  background: none; border: none; color: var(--accent);
  font-size: 16px; line-height: 1; padding: 0 4px; cursor: pointer;
}
#btn-new-cat:hover { color: #fff; }
.side-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 8px; color: var(--text); }
.user-chip:hover { background: var(--panel2); text-decoration: none; }
.user-chip .u-name { font-weight: 600; font-size: 14px; }
.user-chip .u-sub { font-size: 12px; color: var(--muted); }
.side-actions { display: flex; gap: 6px; padding: 4px 8px 8px; }
.side-actions a { font-size: 13px; color: var(--muted); }
#sb-toggle { display: none; }

.avatar {
  border-radius: 50%; color: #fff; font-weight: 700; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; user-select: none;
}

/* ============ 主区 ============ */
#main { padding: 18px 20px 60px; max-width: 780px; width: 100%; margin: 0 auto; margin-left: 240px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-desc { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.sort-tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.sort-tabs button { border: none; background: none; color: var(--muted); padding: 5px 14px; border-radius: 999px; font-size: 13.5px; }
.sort-tabs button.active { background: var(--panel2); color: var(--text); font-weight: 600; }

.post-card {
  display: flex; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
  transition: border-color .15s;
}
.post-card:hover { border-color: #34405c; }
.vote-col { display: flex; flex-direction: column; align-items: center; background: var(--bg2); padding: 10px 8px; min-width: 46px; gap: 2px; }
.vote-btn { background: none; border: none; color: var(--muted); font-size: 15px; padding: 2px 6px; border-radius: 6px; line-height: 1; }
.vote-btn:hover { background: var(--panel2); color: var(--text); }
.vote-btn.up.active { color: var(--up); }
.vote-btn.down.active { color: var(--down); }
.score { font-weight: 700; font-size: 13px; }
.post-body { padding: 10px 14px; flex: 1; min-width: 0; }
.post-meta { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cat-tag {
  background: var(--panel2); color: var(--accent); font-size: 12px; font-weight: 600;
  border-radius: 4px; padding: 1px 7px;
}
.cat-tag:hover { text-decoration: none; filter: brightness(1.2); }
.post-title { display: block; color: var(--text); font-size: 17px; font-weight: 600; margin: 3px 0 2px; }
.post-title:hover { color: var(--accent); text-decoration: none; }
.post-snippet { color: var(--muted); font-size: 13.5px; margin: 2px 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-foot { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); align-items: center; }
.post-foot a { color: var(--muted); }
/* 卡片媒体：左图右文；视频优先于图片，可直接播放 */
.card-media { margin-top: 10px; }
.card-media img { width: auto; max-width: 320px; max-height: 220px; object-fit: cover; border-radius: 10px; display: inline-block; border: 1px solid var(--border); cursor: zoom-in; }
.card-media video { width: auto; max-width: 320px; max-height: 220px; border-radius: 10px; display: inline-block; background: #000; }
.card-media iframe { width: 320px; height: 220px; border: 0; border-radius: 10px; display: inline-block; background: #000; }
/* 评论卡内的 markdown 图片 */
.cf-media { display: block; margin: 6px 0 2px; }
.cf-media img { max-width: 200px; max-height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
/* 标签 */
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.tag-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12.5px; background: var(--border); color: var(--muted); text-decoration: none; cursor: pointer; }
.tag-chip:hover { background: var(--accent); color: #fff; text-decoration: none; }
.tag-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.btn-dismiss { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; opacity: 0.45; padding: 2px 6px; border-radius: 6px; }
.post-card:hover .btn-dismiss { opacity: 1; }
.btn-dismiss:hover { background: var(--border); color: var(--text); }
.load-more { display: block; margin: 14px auto; }
.empty { text-align: center; color: var(--muted); padding: 70px 20px; }
.empty .big { font-size: 42px; margin-bottom: 8px; }

/* ============ 帖子详情 ============ */
.post-detail { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.post-detail h1 { font-size: 23px; margin: 4px 0 10px; line-height: 1.35; }
.post-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.md-body { font-size: 15px; overflow-wrap: break-word; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 { margin: 16px 0 8px; line-height: 1.4; }
.md-body h1 { font-size: 21px; } .md-body h2 { font-size: 19px; } .md-body h3 { font-size: 17px; }
.md-body p { margin: 8px 0; }
.md-body code { background: var(--bg2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 13px; font-family: Consolas, Monaco, monospace; }
.md-body pre { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.md-body pre code { background: none; border: none; padding: 0; }
.md-body blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 4px 14px; color: var(--muted); background: rgba(91,124,250,.06); border-radius: 0 8px 8px 0; }
.md-body img { max-width: 100%; border-radius: 8px; }
.md-body ul, .md-body ol { padding-left: 24px; margin: 8px 0; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* ============ 富文本正文 ============ */
.rich-body { font-size: 15px; overflow-wrap: break-word; }
.rich-body img { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.rich-body iframe { width: 100%; max-width: 720px; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; display: block; margin: 8px 0; }
.rich-body video { max-width: 100%; border-radius: 8px; margin: 6px 0; }
.rich-body audio { width: 100%; margin: 6px 0; }
.rich-body blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 4px 14px; color: var(--muted); background: rgba(91,124,250,.06); border-radius: 0 8px 8px 0; }
.rich-body hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.rich-body pre { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.rich-body code { background: var(--bg2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 13px; font-family: Consolas, Monaco, monospace; }
.rich-body pre code { background: none; border: none; }
.rich-body a { word-break: break-all; }
.rich-body ul, .rich-body ol { padding-left: 24px; margin: 8px 0; }
.rich-body table { max-width: 100%; margin: 10px 0; }
.rich-body td, .rich-body th { word-break: break-word; }
.rt-area table { max-width: 100%; margin: 6px 0; }
.rt-area td, .rt-area th { word-break: break-word; min-width: 40px; }
.rich-body h1, .rich-body h2, .rich-body h3, .rich-body h4 { margin: 16px 0 8px; line-height: 1.4; }
.rich-body h1 { font-size: 21px; } .rich-body h2 { font-size: 19px; } .rich-body h3 { font-size: 17px; }

/* ============ 富文本编辑器 ============ */
.rt-editor { border: 1px solid var(--border); border-radius: 10px; background: var(--bg2); overflow: hidden; }
.rt-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px; border-bottom: 1px solid var(--border); background: var(--panel);
  transition: opacity .15s;
}
.rt-bar.rt-uploading { opacity: .55; pointer-events: none; }
.rt-btn {
  min-width: 30px; height: 28px; border: none; background: none; color: var(--muted);
  border-radius: 6px; cursor: pointer; font-size: 13px; padding: 0 6px;
  font-family: Georgia, serif;
}
.rt-btn:hover { background: var(--panel2); color: var(--text); }
.rt-btn.on { background: rgba(91,124,250,.22); color: var(--accent); }
.rt-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 5px; }
.rt-ai-menu {
  position: absolute; z-index: 130; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 6px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5); min-width: 210px;
}
.rt-ai-item { padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--text); }
.rt-ai-item:hover { background: var(--panel2); }
.rt-color-menu {
  position: absolute; z-index: 130; background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5); min-width: 240px;
}
.rt-color-title { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.rt-color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.rt-color-swatch { width: 100%; aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; padding: 0; }
.rt-color-swatch:hover { outline: 2px solid var(--accent); }
.rt-color-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.rt-color-row input[type=color] { width: 36px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; }
.rt-color-clear { font-size: 12.5px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.rt-bar.rt-uploading::after {
  content: '🤖 云小智生成中…'; position: absolute; right: 10px; top: 7px;
  font-size: 12px; color: var(--accent);
}
.rt-area {
  min-height: 200px; padding: 12px 14px; outline: none;
  font-size: 15px; line-height: 1.7; overflow-wrap: break-word;
}
.rt-compact .rt-area { min-height: 90px; font-size: 14px; }
.rt-area.rt-empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rt-area img { max-width: 100%; border-radius: 8px; }
.rt-area iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; }
.rt-area blockquote { border-left: 3px solid var(--accent); margin: 8px 0; padding: 2px 12px; color: var(--muted); }
.rt-area.audio, .rt-area video { max-width: 100%; }

.comment-editor { margin: 14px 0 18px; }
.comment-editor textarea { min-height: 90px; }
.comment-editor .row { display: flex; justify-content: space-between; margin-top: 8px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; }

.comment-item { display: flex; gap: 10px; padding: 8px 0 8px 2px; }
.comment-children { margin: 4px 0 4px 30px; border-left: 2px solid rgba(0,255,156,.25); padding-left: 12px; }
.comment-children.flat { margin: 4px 0; border-left: none; padding-left: 0; }
.reply-to-tag { color: var(--muted); font-size: 12px; margin-left: 2px; }
.comment-item > a { flex-shrink: 0; }
.reply-toggle { background: none; border: none; color: var(--accent); font-size: 12.5px; cursor: pointer; padding: 4px 0 4px 2px; }
.reply-toggle:hover { text-decoration: underline; }
.comment-main { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.comment-head .author { color: var(--text); font-weight: 600; }
.comment-body { font-size: 14px; }
.comment-foot { display: flex; gap: 10px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.comment-foot button { background: none; border: none; color: var(--muted); font-size: 12.5px; padding: 0; }
.comment-foot button:hover { color: var(--accent); }
.comment-deleted { color: var(--muted); font-style: italic; }
.collapsed-note { color: var(--muted); font-size: 12.5px; cursor: pointer; }

/* ============ 右栏 ============ */
.side-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.side-card h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.stat-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; }
.stat-row b { font-size: 14px; }
.hot-item { display: block; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text); }
.hot-item:last-child { border: none; }
.hot-item small { color: var(--muted); display: block; }

/* ============ 右侧悬浮工具组（垂直居中） ============ */
#fab-group {
  position: fixed; right: 20px; top: 50%; transform: translateY(-50%);
  z-index: 65; display: flex; flex-direction: column; gap: 64px; /* 隔开一个图标的距离，防误触 */
}
#search-fab, #ai-fab {
  width: 54px; height: 54px; border-radius: 50%;
  border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
#post-fab {
  position: fixed; right: 80px; bottom: 80px;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #00ff9c, #00b864);
  box-shadow: 0 8px 26px rgba(0, 255, 156, .55);
  border: none; cursor: grab; padding: 0;
  display: flex !important; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
  z-index: 9999 !important; touch-action: none; user-select: none; opacity: 1;
  transform: none;
}
#post-fab:active { cursor: grabbing; }
#post-fab svg { width: 28px; height: 28px; pointer-events: none; }
#post-fab:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(0, 255, 156, .6); }
#post-fab.dragging { transition: none; transform: scale(1.12); }
#search-fab {
  background: linear-gradient(135deg, #00b3d6, #5b7cfa);
  box-shadow: 0 8px 26px rgba(0, 179, 214, .4);
}
#search-fab svg { width: 26px; height: 26px; }
#search-fab:hover { transform: scale(1.08); box-shadow: 0 12px 30px rgba(0, 179, 214, .55); }
#ai-fab {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 26px rgba(91, 124, 250, .45);
}
#ai-fab:hover { transform: scale(1.08); box-shadow: 0 12px 34px rgba(91, 124, 250, .6); }
#ai-fab img { width: 36px; height: 36px; border-radius: 50%; pointer-events: none; }
#ai-fab.open { transform: rotate(90deg); }
#ai-fab::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(91, 124, 250, .5);
  animation: fabPulse 2.4s ease-out infinite;
}
@keyframes fabPulse {
  0% { transform: scale(.9); opacity: .9; }
  70%, 100% { transform: scale(1.35); opacity: 0; }
}

/* ============ 搜索弹窗 ============ */
.search-modal { width: 620px; max-width: 100%; }
.search-input-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-results { max-height: 55vh; overflow-y: auto; }
.search-section h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.search-hit { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.search-hit:hover { background: var(--panel2); }
.search-hit .s-title { font-weight: 600; font-size: 14px; color: var(--text); }
.search-hit .s-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tag-chips.compact { gap: 6px; }
.tag-chips.compact .tag-chip { font-size: 11px; padding: 2px 8px; }
.tag-chips.compact .tag-chip small { margin-left: 2px; font-size: 10px; }
.tag-chip {
  background: var(--panel2); border: 1px solid var(--border); color: var(--accent);
  border-radius: 999px; padding: 5px 14px; font-size: 13px; cursor: pointer;
}
.tag-chip:hover { border-color: var(--accent); }
.tag-chip small { color: var(--muted); margin-left: 4px; }

/* 评论信息流卡片 */
.comment-card .cf-content { display: block; margin: 4px 0 6px; color: var(--text); }
.comment-card .cf-content .rich-body, .comment-card .cf-content .md-body {
  font-size: 14px;
}
.comment-card .cf-content .rich-body > p:first-child,
.comment-card .cf-content .md-body > p:first-child { margin: 0; }
.comment-card .cf-content:hover .cf-text { text-decoration: none; }
/* 信息流里的评论图片：缩略图，点击放大 */
.post-card img:not(.avatar-img):not(.emoji) { max-height: 220px !important; max-width: 320px !important; width: auto !important; height: auto !important; object-fit: cover !important; border-radius: 6px; cursor: zoom-in; margin: 4px 4px 0 0; display: inline-block !important; }
.post-card video:not([data-no-thumb]) { max-height: 220px !important; max-width: 320px !important; display: inline-block !important; }
.post-card iframe { max-height: 220px !important; max-width: 320px !important; display: inline-block !important; }
/* 帖子详情页评论区：图片略缩 */
.comment-body img { max-width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; cursor: zoom-in; }
.comment-body video, .comment-body iframe { max-width: 100%; max-height: 320px; display: block; margin: 6px 0; }
/* 图片灯箱 */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 9999; display: none; align-items: center; justify-content: center; cursor: zoom-out; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* 评论定位高亮 */
.comment-flash { animation: commentFlash 2.4s ease; border-radius: 8px; }
@keyframes commentFlash {
  0%, 55% { background: rgba(91, 124, 250, .22); }
  100% { background: transparent; }
}

/* ============ AI 弹窗 ============ */
#ai-panel {
  position: fixed; right: 88px; top: 50%; z-index: 60;
  transform: translateY(-50%);
  width: 430px; height: min(660px, calc(100vh - 60px));
  max-width: calc(100vw - 24px);
  background: var(--bg2); border: 1px solid var(--border); border-radius: 18px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  transform-origin: right center;
  animation: popUp .2s ease;
}
@keyframes popUp {
  from { transform: translateY(-50%) scale(.95); opacity: 0; }
  to { transform: translateY(-50%) scale(1); opacity: 1; }
}
#ai-panel.hidden { display: none; }
.ai-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--panel); }
.ai-header img { width: 32px; height: 32px; }
.ai-title { flex: 1; line-height: 1.25; }
.ai-title b { font-size: 15px; }
.ai-title small { display: block; color: var(--muted); font-size: 11.5px; }
.ai-icon-btn { background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 30px; height: 30px; font-size: 14px; }
.ai-icon-btn:hover { border-color: var(--accent); }
.ai-messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.ai-msg { display: flex; gap: 9px; max-width: 100%; }
.ai-msg .avatar { margin-top: 2px; }
.ai-bubble { min-width: 0; overflow-wrap: break-word; font-size: 14px; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg.user .ai-bubble { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-radius: 14px 4px 14px 14px; padding: 9px 13px; white-space: pre-wrap; }
.ai-msg.assistant .ai-bubble { background: var(--panel); border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; padding: 10px 13px; width: 100%; }
.ai-msg.assistant .ai-bubble .md-body { font-size: 13.5px; }
.ai-bubble p { margin: 6px 0; }
.ai-bubble pre { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; font-size: 12.5px; }
.ai-bubble code { font-family: Consolas, Monaco, monospace; font-size: 12.5px; background: var(--bg2); border-radius: 4px; padding: 1px 5px; }
.ai-bubble pre code { background: none; padding: 0; }
.ai-bubble a { word-break: break-all; }
.ai-tool-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; margin: 2px 4px 2px 0;
}
.ai-tool-chip.done { color: var(--ok); border-color: rgba(63,178,127,.4); }
.ai-tool-chip.fail { color: var(--danger); border-color: rgba(240,82,79,.4); }
.ai-cursor::after { content: '▍'; animation: blink 1s infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.ai-suggest { display: flex; gap: 7px; flex-wrap: wrap; padding: 8px 14px 4px; }
.ai-suggest button {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  font-size: 12px; border-radius: 999px; padding: 5px 12px;
}
.ai-suggest button:hover { color: var(--accent); border-color: var(--accent); }
#ai-form { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--panel); align-items: flex-end; }
#ai-input { min-height: 44px; max-height: 140px; }
#ai-send { padding: 10px 18px; }
.ai-chats { border-bottom: 1px solid var(--border); background: var(--panel); max-height: 220px; overflow-y: auto; padding: 6px; }
.ai-chats.hidden { display: none; }
.ai-chat-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; color: var(--text); cursor: pointer; }
.ai-chat-item:hover { background: var(--panel2); }
.ai-chat-item.active { background: var(--panel2); color: var(--accent); }
.ai-chat-item .del { margin-left: auto; background: none; border: none; color: var(--muted); visibility: hidden; }
.ai-chat-item:hover .del { visibility: visible; }
.ai-chat-item .del:hover { color: var(--danger); }
.ai-cta { text-align: center; padding: 12px; }
.ai-config-tip { background: var(--panel); border: 1px dashed var(--accent); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin: 4px 0; }

/* ============ 弹窗 / Toast ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4,6,12,.7); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  width: 460px; max-width: 100%; max-height: 88vh; overflow-y: auto; padding: 22px 24px;
  animation: pop .18s ease;
}
.modal.wide { width: 640px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 16px; font-size: 19px; }
.modal .field { margin-bottom: 13px; }
.modal .field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.tab-row { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-row button { background: none; border: none; color: var(--muted); padding: 9px 14px; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab-row button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-row .tab-expand {
  color: var(--accent); font-weight: 800; font-size: 16px; padding: 6px 10px;
  border-bottom: 2px solid transparent; cursor: pointer;
  text-shadow: 0 0 6px var(--accent), 0 0 12px var(--accent);
}
.tab-row .tab-expand:hover { opacity: 0.8; }
@media (max-width: 720px) {
  .tab-row { flex-wrap: nowrap; overflow: hidden; gap: 2px; margin-bottom: 12px; }
  .tab-row button { padding: 8px 9px; font-size: 13px; }
  /* 默认只显示前 4 个 tab，其余隐藏，点箭头展开 */
  .tab-row > button:not(.tab-expand):nth-child(n+5) { display: none; }
  .tab-row.expanded { flex-wrap: wrap; overflow: visible; }
  .tab-row.expanded > button:not(.tab-expand) { display: inline-block; }
  .sort-tabs { gap: 2px; padding: 2px; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sort-tabs button { padding: 4px 9px; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; }

  /* 移动端：私信/通知/个人主页 防溢出 */
  #main { padding: 10px 8px 60px; width: 100%; max-width: 100%; margin-left: 0; }
  .two-col { gap: 0; }
  #conv-list, #conv-view { width: 100%; min-width: 0; }
  .chat-box { width: 100%; min-width: 0; }
  .chat-msgs { padding: 10px; }
  .chat-msg { max-width: 92%; font-size: 13.5px; word-break: break-word; }
  .notif-item { width: 100%; max-width: 100%; min-width: 0; flex-wrap: wrap; gap: 6px; padding: 8px 10px; margin: 0 0 6px 0; font-size: 13px; box-sizing: border-box; }
  .notif-item > span:first-child { font-size: 16px; flex-shrink: 0; }
  .notif-item > div:nth-child(2) { min-width: 0; flex: 1 1 0; overflow: hidden; word-break: break-word; }
  .notif-item .n-text { font-size: 12px; display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .notif-item .hint { font-size: 11px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .notif-del { flex-shrink: 0; }
  .profile-head { width: 100%; flex-wrap: wrap; padding: 14px; gap: 10px; }
  .profile-head > div:last-child { width: 100%; flex-wrap: wrap; }
  .profile-stats { flex-wrap: wrap; gap: 6px 10px; font-size: 12.5px; }
  .chat-input-row { flex-wrap: wrap; gap: 6px; }
  .chat-input-row textarea { min-width: 0; flex: 1 1 140px; width: 100%; }
  .conv-item { padding: 10px; gap: 8px; width: 100%; min-width: 0; }
  .conv-item .c-info { min-width: 0; }
  .conv-menu { min-width: 108px; max-width: 60vw; }
  .page-head { flex-wrap: wrap; gap: 8px; }
  .soc-bind-row { flex-wrap: wrap; gap: 6px; }
  .ai-header { flex-wrap: wrap; gap: 6px; padding: 8px; }
  .post-card { max-width: 100%; }
  input, textarea, select, button { max-width: 100%; }
}

#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 18px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4);
  animation: pop .18s ease; max-width: 90vw;
}
.toast.err { border-color: var(--danger); }
.toast.ok { border-color: var(--ok); }

/* 回到顶部 */
#back-top {
  position: fixed; right: 24px; bottom: 80px; z-index: 55;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border);
  color: var(--accent); font-size: 20px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .2s, transform .2s, box-shadow .2s;
}
#back-top.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#back-top:hover { box-shadow: 0 6px 24px rgba(0,0,0,.4), 0 0 12px rgba(91,124,250,.35); }

/* ============ 设置页 ============ */
.settings-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px; }
.settings-card h3 { margin: 0 0 6px; font-size: 16px; }
.settings-card .desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.key-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; flex-wrap: wrap; }
.key-item:last-child { border: none; }
.key-item .k-name { font-weight: 600; }
.perm-tag { font-size: 11px; border-radius: 4px; padding: 1px 6px; font-weight: 600; }
.perm-read { background: rgba(91,124,250,.15); color: var(--accent); }
.perm-write { background: rgba(63,178,127,.15); color: var(--ok); }
.perm-banned { background: rgba(240,82,79,.15); color: var(--danger); }
.fb-open { background: rgba(255,178,53,.15); color: #e6a23c; }

/* ============ 广告卡片 ============ */
.ad-card {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); margin: 10px 0 10px 42px; overflow: hidden;
  transition: border-color .15s;
}
.ad-card:hover { border-color: var(--accent); }
.ad-tag {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  font-size: 11px; color: #ffd479; background: rgba(0,0,0,.55);
  border-radius: 4px; padding: 1px 7px; pointer-events: none;
}
.ad-card > a { display: flex; align-items: stretch; gap: 12px; color: var(--text); }
.ad-card > a:hover { text-decoration: none; }
.ad-card img { width: 200px; height: 120px; object-fit: cover; flex-shrink: 0; }
.ad-body { padding: 12px 14px 12px 0; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.ad-body b { font-size: 16px; }
.ad-body p { color: var(--muted); font-size: 13px; margin: 4px 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ad-link-hint { color: var(--accent); font-size: 12.5px; }

/* ============ 管理后台 ============ */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.stat-card b { font-size: 24px; display: block; line-height: 1.3; }
.stat-card span { color: var(--muted); font-size: 12.5px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; background: var(--bg2); white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-toolbar input { flex: 1; min-width: 140px; width: auto; }
.k-meta { color: var(--muted); font-size: 12px; width: 100%; }
.radio-row { display: flex; gap: 18px; margin: 6px 0 2px; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); cursor: pointer; }
.radio-row input { width: auto; }
.new-key-box { background: var(--bg2); border: 1px dashed var(--ok); border-radius: 10px; padding: 12px 14px; margin-top: 10px; word-break: break-all; font-family: Consolas, monospace; font-size: 13px; }
.doc-block { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-family: Consolas, Monaco, monospace; font-size: 12.5px; white-space: pre; margin: 10px 0; }
.doc-table { width: 100%; font-size: 13px; border-collapse: collapse; }
.doc-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.doc-table code { color: var(--accent); }
.test-result { margin-top: 10px; font-size: 13.5px; }
.test-result.ok { color: var(--ok); }
.test-result.err { color: var(--danger); }

/* ============ 私信 / 通知 ============ */
.two-col { display: grid; grid-template-columns: 280px 1fr; gap: 12px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.conv-item { display: flex; gap: 10px; padding: 11px 12px; border-radius: 10px; cursor: pointer; align-items: center; }
.conv-item:hover, .conv-item.active { background: var(--panel2); }
.conv-item .c-info { flex: 1; min-width: 0; }
.conv-item .c-name { font-weight: 600; font-size: 14px; }
.conv-item .c-last { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.pinned { background: var(--panel2); }
.conv-item.has-unread { background: rgba(0,255,156,.08); }
.conv-item.has-unread .c-name { color: var(--accent); }
.conv-item .badge { margin-left: 6px; }
.conv-actions { display: flex; gap: 2px; opacity: .7; transition: opacity .15s; flex-shrink: 0; position: relative; }
.conv-item:hover .conv-actions { opacity: 1; }
.conv-act { background: transparent; border: none; cursor: pointer; font-size: 18px; font-weight: 700; padding: 4px 8px; border-radius: 6px; line-height: 1; color: var(--accent); }
.conv-act:hover { background: var(--bg2); color: var(--accent); }
.conv-menu { position: absolute; right: 0; top: 28px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.35); z-index: 50; min-width: 120px; overflow: hidden; }
.conv-menu button { display: block; width: 100%; padding: 8px 14px; background: transparent; border: none; cursor: pointer; text-align: left; font-size: 13px; color: var(--text); }
.conv-menu button:hover { background: var(--bg2); color: var(--accent); }
.dm-attach { margin-top: 6px; }
.dm-attach img, .dm-attach audio { display: block; }
.chat-box { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 420px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 75%; padding: 8px 13px; border-radius: 14px; font-size: 14px; white-space: pre-wrap; overflow-wrap: break-word; }
.chat-msg.mine { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-radius: 14px 4px 14px 14px; }
.chat-msg.theirs { align-self: flex-start; background: var(--panel2); border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.notif-item { display: flex; gap: 12px; padding: 13px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.notif-item:hover { border-color: var(--accent); }
.notif-item.unread { border-left: 3px solid var(--accent); }
.notif-item .n-text { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-del { opacity: 0; transition: opacity .15s; align-self: center; color: var(--muted); }
.notif-item:hover .notif-del { opacity: 1; }
.notif-del:hover { color: #d33; background: var(--bg2); }

/* ============ 用户主页 ============ */
.profile-head { display: flex; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }
.profile-head .p-info h2 { margin: 0; font-size: 20px; }
.profile-head .p-info .bio { color: var(--muted); font-size: 13.5px; margin: 4px 0; }
.profile-stats { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }

/* ============ 社交图标 ============ */
.soc-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.soc-link { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; overflow: hidden; transition: transform .15s; }
.soc-link:hover { transform: translateY(-2px) scale(1.08); }
.soc-link svg { width: 100%; height: 100%; }
.soc-bind-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.soc-bind-row .soc-link { flex-shrink: 0; }
.avatar-img { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-block; }

/* ============ 设置表单网格 ============ */
.form-grid { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; align-items: center; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.avatar-preview { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }

/* ============ 可搜索版块选择器 ============ */
.cat-combo { position: relative; }
.cat-drop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  max-height: 240px; overflow-y: auto; display: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .45);
}
.cat-drop.open { display: block; }
.cat-opt { padding: 8px 12px; cursor: pointer; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.cat-opt:hover, .cat-opt.hl { background: var(--panel2); }
.cat-opt small { color: var(--muted); margin-left: auto; font-size: 12px; }
.cat-opt.empty-opt { color: var(--muted); cursor: default; }

/* ============ 关注推荐（右栏） ============ */
.follow-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.follow-row:last-of-type { border-bottom: none; }
.follow-row .f-info { flex: 1; min-width: 0; }
.follow-row .f-name { font-weight: 600; font-size: 14px; color: var(--text); }

/* ============ 返回栏 / 面包屑 ============ */
.back-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.btn-back { padding: 5px 14px; font-size: 13.5px; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; }
.crumb a { color: var(--accent); flex-shrink: 0; }
.crumb-sep { color: var(--muted); }
.crumb-cur { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============ 主题切换 ============ */
html[data-theme='hacker'] {
  --bg: #0a0e12;
  --bg2: #0f1419;
  --panel: #0d1218;
  --panel2: #131a22;
  --border: #1a3a2a;
  --text: #c8d6e5;
  --muted: #5a7a6a;
  --accent: #00ff9c;
  --accent2: #00d4ff;
  --up: #39ff14;
  --down: #00d4ff;
  --danger: #ff3366;
  --ok: #00ff9c;
  --warn: #ffb000;
}

/* ==== 黑客风主题：终端质感 + 辉光 + 网格 ==== */
html[data-theme='hacker'] body {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Courier New', monospace;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(0,255,156,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,255,156,.04) 1px, transparent 1px),
    radial-gradient(ellipse at top, #0f1a14 0%, #0a0e12 60%);
  background-size: 32px 32px, 32px 32px, 100% 100%;
  color: var(--text);
}
html[data-theme='hacker'] body::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 9998;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(255,255,255,.015) 2px,
    rgba(255,255,255,.015) 3px
  );
  mix-blend-mode: overlay;
}
html[data-theme='hacker'] a { color: var(--accent); text-shadow: 0 0 6px rgba(0,255,156,.35); }
html[data-theme='hacker'] a:hover { text-shadow: 0 0 10px rgba(0,255,156,.7); }

html[data-theme='hacker'] .post-card,
html[data-theme='hacker'] .settings-card,
html[data-theme='hacker'] .notif-item,
html[data-theme='hacker'] .conv-item,
html[data-theme='hacker'] .chat-box,
html[data-theme='hacker'] .ai-chat-window,
html[data-theme='hacker'] .ad-card,
html[data-theme='hacker'] .admin-table,
html[data-theme='hacker'] .modal {
  background: var(--panel);
  border: 1px solid rgba(0,255,156,.22);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0,255,156,.06), 0 0 14px rgba(0,255,156,.06);
}
html[data-theme='hacker'] .post-card:hover {
  border-color: rgba(0,255,156,.55);
  box-shadow: 0 0 0 1px rgba(0,255,156,.15), 0 0 18px rgba(0,255,156,.18);
}

html[data-theme='hacker'] .btn {
  background: transparent;
  border: 1px solid rgba(0,255,156,.45);
  color: var(--accent);
  border-radius: 3px;
  font-family: inherit;
  text-shadow: none;
}
html[data-theme='hacker'] .btn:hover {
  background: rgba(0,255,156,.12);
  box-shadow: 0 0 12px rgba(0,255,156,.35);
}
html[data-theme='hacker'] .btn-primary {
  background: var(--accent);
  color: #001a08;
  border-color: var(--accent);
  font-weight: 700;
}
html[data-theme='hacker'] .btn-primary:hover {
  background: #33ffb3;
  box-shadow: 0 0 18px rgba(0,255,156,.6);
}

html[data-theme='hacker'] input,
html[data-theme='hacker'] textarea,
html[data-theme='hacker'] select {
  background: #0a1016;
  border: 1px solid rgba(0,255,156,.3);
  color: var(--text);
  border-radius: 3px;
  font-family: inherit;
}
html[data-theme='hacker'] input:focus,
html[data-theme='hacker'] textarea:focus,
html[data-theme='hacker'] select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0,255,156,.18);
  outline: none;
}

html[data-theme='hacker'] .post-title { color: #e8fff3; font-weight: 700; }
html[data-theme='hacker'] .post-title:hover { color: var(--accent); text-shadow: 0 0 10px rgba(0,255,156,.6); }
html[data-theme='hacker'] .post-snippet { color: var(--muted); }

html[data-theme='hacker'] .cat-tag,
html[data-theme='hacker'] .tag-chip {
  background: rgba(0,255,156,.08);
  border: 1px solid rgba(0,255,156,.35);
  color: var(--accent);
  border-radius: 2px;
  font-family: inherit;
}
html[data-theme='hacker'] .cat-tag::before { content: '['; color: var(--muted); }
html[data-theme='hacker'] .cat-tag::after { content: ']'; color: var(--muted); }

html[data-theme='hacker'] .side-nav a { color: var(--muted); font-family: inherit; }
html[data-theme='hacker'] .side-nav a.active {
  color: var(--accent);
  background: rgba(0,255,156,.08);
  border-left: 2px solid var(--accent);
  text-shadow: 0 0 8px rgba(0,255,156,.5);
}
html[data-theme='hacker'] .side-nav a.active::before { content: '> '; color: var(--accent); }

html[data-theme='hacker'] .vote-col {
  background: rgba(0,255,156,.04);
  border-right: 1px solid rgba(0,255,156,.2);
}
html[data-theme='hacker'] .vote-btn { color: var(--muted); }
html[data-theme='hacker'] .vote-btn.up.active { color: var(--up); text-shadow: 0 0 8px rgba(57,255,20,.7); }
html[data-theme='hacker'] .vote-btn.down.active { color: var(--down); text-shadow: 0 0 8px rgba(0,212,255,.7); }
html[data-theme='hacker'] [data-score] { color: var(--accent); font-weight: 700; }

html[data-theme='hacker'] h1, html[data-theme='hacker'] h2, html[data-theme='hacker'] h3 {
  font-family: inherit;
  color: #e8fff3;
  text-shadow: 0 0 12px rgba(0,255,156,.25);
}
html[data-theme='hacker'] .brand, html[data-theme='hacker'] .logo {
  text-shadow: 0 0 8px var(--accent), 0 0 18px rgba(0,255,156,.4);
}
html[data-theme='hacker'] .logo-wrap {
  background: #0a0e12;
  border-color: rgba(0,255,156,.45);
  box-shadow: 0 0 10px rgba(0,255,156,.25);
}
html[data-theme='ink'] .logo-wrap {
  background: #ffffff;
  border-color: #d8cfb8;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
html[data-theme='hacker'] .brand::after, html[data-theme='hacker'] .logo::after {
  content: '▋';
  margin-left: 4px;
  color: var(--accent);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

html[data-theme='hacker'] code, html[data-theme='hacker'] pre, html[data-theme='hacker'] .doc-block, html[data-theme='hacker'] .new-key-box {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  background: #0a1016;
  border: 1px solid rgba(0,255,156,.25);
  border-radius: 3px;
}
html[data-theme='hacker'] .md-body pre, html[data-theme='hacker'] .rich-body pre, html[data-theme='hacker'] .ai-bubble pre {
  position: relative;
  padding-top: 28px;
}
html[data-theme='hacker'] .md-body pre::before,
html[data-theme='hacker'] .rich-body pre::before,
html[data-theme='hacker'] .ai-bubble pre::before {
  content: '● ● ●  terminal';
  position: absolute; top: 8px; left: 12px;
  color: var(--muted); font-size: 11px; letter-spacing: 2px;
}

html[data-theme='hacker'] .tab-row button { color: var(--muted); border-bottom: 2px solid transparent; }
html[data-theme='hacker'] .tab-row button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-shadow: 0 0 8px rgba(0,255,156,.6);
}

html[data-theme='hacker'] .chat-msg.mine {
  background: rgba(0,255,156,.15);
  color: var(--accent);
  border: 1px solid rgba(0,255,156,.4);
  border-radius: 3px 12px 12px 12px;
}
html[data-theme='hacker'] .chat-msg.theirs {
  background: var(--panel2);
  border: 1px solid var(--border);
}

html[data-theme='hacker'] .notif-item.unread { border-left: 3px solid var(--accent); }
html[data-theme='hacker'] .conv-item.pinned { background: rgba(0,255,156,.06); }

html[data-theme='hacker'] .modal { background: var(--panel); }
html[data-theme='hacker'] .modal-actions .btn-primary { background: var(--accent); color: #001a08; }

/* 滚动条 */
html[data-theme='hacker'] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme='hacker'] ::-webkit-scrollbar-track { background: #0a1016; }
html[data-theme='hacker'] ::-webkit-scrollbar-thumb {
  background: rgba(0,255,156,.35);
  border-radius: 4px;
  border: 2px solid #0a1016;
}
html[data-theme='hacker'] ::-webkit-scrollbar-thumb:hover { background: rgba(0,255,156,.6); }

/* 卡片入场：打字机式淡入 */
@keyframes hacker-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
html[data-theme='hacker'] .post-card { animation: hacker-in .25s ease-out; }

html[data-theme='hacker'] .perm-tag { border-radius: 2px; font-family: inherit; }
html[data-theme='hacker'] .perm-write { background: rgba(0,255,156,.15); color: var(--accent); border: 1px solid rgba(0,255,156,.4); }

html[data-theme='hacker'] .ai-header, html[data-theme='hacker'] .ai-title {
  font-family: inherit;
}
html[data-theme='hacker'] .ai-bubble.user .ai-bubble,
html[data-theme='hacker'] .ai-msg.user .ai-bubble {
  background: rgba(0,255,156,.15);
  color: var(--accent);
  border: 1px solid rgba(0,255,156,.4);
  background-image: none;
}

html[data-theme='ink'] {
  --bg: #f4f1e8;
  --bg2: #ede8db;
  --panel: #faf7ef;
  --panel2: #e9e3d3;
  --border: #d9d0ba;
  --text: #2c2a24;
  --muted: #7d7666;
  --accent: #7a5c34;
  --accent2: #5f4a2e;
  --up: #b3541e;
  --down: #46688a;
  --danger: #a03030;
  --ok: #4a7a52;
}
html[data-theme='ink'] .btn-primary { background: linear-gradient(135deg, #7a5c34, #5f4a2e); }

/* ============ 版块搜索 / 折叠 ============ */
.cat-search-wrap { padding: 0 6px 6px; }
#cat-search { font-size: 12.5px; padding: 5px 10px; border-radius: 8px; }
.cat-more-btn { margin: 2px 6px 0; padding: 5px 12px; font-size: 12.5px; color: var(--muted); border: 1px dashed var(--border); background: none; width: calc(100% - 12px); }
.cat-more-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ============ 右栏设置卡片 ============ */
.pref-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.pref-btn { border: 1px solid var(--border); background: var(--bg2); color: var(--text); border-radius: 8px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.pref-btn:hover { border-color: var(--accent); }
.pref-btn.active { border-color: var(--accent); color: var(--accent); font-weight: 600; background: rgba(91,124,250,.08); }

/* 右栏紧凑设置卡片（下拉选择） */
.pref-card { display: flex; flex-direction: column; gap: 10px; }
.pref-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pref-label { font-size: 13px; color: var(--muted); font-weight: 600; flex: 0 0 auto; }
.pref-select {
  flex: 1 1 auto; min-width: 0;
  border: 1px solid var(--border); background: var(--bg2); color: var(--text);
  border-radius: 8px; padding: 5px 8px; font-size: 13px; cursor: pointer;
  outline: none;
}
.pref-select:hover, .pref-select:focus { border-color: var(--accent); }
.pref-select option { background: var(--bg2); color: var(--text); }
.footer-copy { text-align: center; color: var(--muted); font-size: 12px; padding: 14px 8px 4px; }
.footer-copy a { color: var(--text); font-weight: 700; }
.footer-copy a:hover { color: var(--accent); text-decoration: none; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }

  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 80;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  #sidebar.open { transform: none; }
  #sb-toggle {
    display: block; position: fixed; top: 12px; right: 12px; z-index: 90;
    background: var(--panel2); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; width: 38px; height: 38px; font-size: 17px;
  }
  #sb-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; }
  #main { padding-top: 64px; }
  #ai-panel {
    right: 16px; left: 16px; width: auto; top: 50%;
    height: min(480px, calc(100vh - 160px));
    border-radius: 12px;
  }
  #ai-panel .ai-header { padding: 6px 10px; }
  #ai-panel .ai-header img { width: 24px; height: 24px; }
  #ai-panel .ai-title { font-size: 12.5px; }
  #ai-panel .ai-title small { font-size: 10.5px; }
  #ai-panel .ai-msg { gap: 5px; font-size: 12px; margin: 4px 0; }
  #ai-panel .ai-msg .avatar { width: 22px !important; height: 22px !important; font-size: 11px !important; }
  #ai-panel .ai-bubble { padding: 6px 9px !important; font-size: 12px !important; border-radius: 10px !important; }
  #ai-panel .ai-bubble .md-body { font-size: 12px; line-height: 1.45; }
  #ai-panel .ai-bubble .md-body p { margin: 4px 0; }
  #ai-panel .ai-bubble .md-body pre { padding: 6px 8px; font-size: 11px; }
  #ai-panel .ai-chats { max-height: 110px; padding: 4px; }
  #ai-panel .ai-chat-item { padding: 5px 7px; font-size: 12px; gap: 6px; }
  #ai-panel .ai-suggest { padding: 5px 8px; gap: 5px; }
  #ai-panel .ai-suggest button { padding: 3px 7px; font-size: 11px; }
  #ai-panel .ai-input-row { padding: 6px 8px; gap: 5px; }
  #ai-panel textarea, #ai-panel input { font-size: 12px; padding: 5px 8px; min-height: 32px; }
  #ai-panel .btn { padding: 5px 10px; font-size: 12px; }
  #fab-group { right: 12px; gap: 52px; }
  #search-fab, #ai-fab { width: 44px; height: 44px; }
  #ai-fab img { width: 32px; height: 32px; }
  #post-fab { width: 48px; height: 48px; right: 50px; bottom: 50px; z-index: 9999 !important; }
  #post-fab svg { width: 22px; height: 22px; }

  /* 私信聊天窗改为居中弹窗样式 */
  .chat-box {
    min-height: 0;
    max-height: calc(100vh - 140px);
    border-radius: 12px;
  }
  .chat-msgs { min-height: 200px; max-height: calc(100vh - 260px); }
  .chat-msg { font-size: 12.5px; padding: 7px 10px; }
  .chat-input-row { padding: 8px; }
  .chat-input-row textarea { font-size: 12.5px; }

  /* 帖子详情页：内容防溢出 */
  .md-body, .rich-body { max-width: 100%; font-size: 14px; word-break: break-word; overflow-wrap: anywhere; }
  .md-body img, .rich-body img { max-width: 100%; height: auto; }
  .md-body pre, .rich-body pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .md-body iframe, .rich-body iframe { max-width: 100%; width: 100% !important; }
  .md-body video, .rich-body video { max-width: 100%; height: auto; }
  .md-body table, .rich-body table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .md-body .post-body, .rich-body .post-body { padding: 10px 12px; }
  .post-body { padding: 10px 12px; }

  /* 弹窗精致化 */
  .modal { width: calc(100vw - 24px) !important; padding: 14px !important; border-radius: 12px; }
  .modal.wide { width: calc(100vw - 24px) !important; }
  .modal h2 { font-size: 15px; margin: 0 0 10px; }
  .modal .field { margin-bottom: 9px; }
  .modal .field label { font-size: 12px; margin-bottom: 3px; }
  .modal .field input, .modal .field textarea, .modal .field select { font-size: 13px; padding: 6px 9px; }
  .modal-actions { gap: 6px; margin-top: 12px; }
  .modal-actions .btn { padding: 6px 12px; font-size: 12.5px; }
  .search-modal { width: calc(100vw - 24px) !important; }
  .search-modal input { font-size: 13px; padding: 7px 10px; }
  .search-section h4 { font-size: 12.5px; margin: 10px 0 6px; }
  .search-section .post-card, .search-section .comment-card { padding: 8px 10px; font-size: 12.5px; }
  .tag-chips button { font-size: 11.5px; padding: 3px 9px; }
  .load-more { display: block; width: calc(100% - 20px); margin: 14px auto; padding: 10px; font-size: 13px; }
}
