@charset "UTF-8";

/* =========================================================
   Discourse / Linux DO 风格设计系统
   - 变量化明/暗主题
   - 左侧分类侧边栏 + 现代顶栏 + 卡片式话题流
   ========================================================= */

:root {
  --header-h: 56px;
  --sidebar-w: 256px;

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f3;
  --border: #e6e8eb;
  --border-strong: #d6dade;

  --text: #1b1f24;
  --text-muted: #646b73;
  --text-faint: #8b929a;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.10);

  --link: #2563eb;
  --danger: #e5484d;
  --success: #1ca784;

  --nav-bg: rgba(255, 255, 255, 0.82);
  --nav-text: #1b1f24;
  --nav-border: rgba(0, 0, 0, 0.06);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 6px 22px rgba(16, 24, 40, 0.08);
  --shadow-pop: 0 10px 34px rgba(16, 24, 40, 0.14);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0d1014;
  --surface: #16191f;
  --surface-2: #1c2027;
  --surface-3: #232831;
  --border: #2a2f38;
  --border-strong: #353c47;

  --text: #e7eaee;
  --text-muted: #9aa2ac;
  --text-faint: #6b727c;

  --primary: #5b8def;
  --primary-hover: #7aa3f3;
  --primary-soft: rgba(91, 141, 239, 0.16);

  --link: #7aa3f3;
  --danger: #ff6b6f;
  --success: #34d399;

  --nav-bg: rgba(13, 16, 20, 0.86);
  --nav-text: #e7eaee;
  --nav-border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 10px 34px rgba(0, 0, 0, 0.6);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { /* 继承自上面的 dark 块，避免重复 */ }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .2s ease, color .2s ease;
  min-height: 100vh;
}

a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--primary-hover); text-decoration: none; }

#body { width: 100%; }
#body > .container { max-width: 1080px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--nav-border);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  white-space: nowrap;
}
.topbar .brand img { height: 30px; border-radius: 8px; }
.topbar .brand:hover { color: var(--text); }

.topbar .search {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}
.topbar .search input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: .9rem;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.topbar .search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.topbar .search::before {
  content: "\f002";
  font-family: "FontAwesome";
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: .9rem;
}

.topbar .actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar .icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 1.05rem;
  transition: background .15s ease, color .15s ease;
}
.topbar .icon-btn:hover { background: var(--surface-3); color: var(--text); }
.topbar .avatar-btn img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
.topbar .hamburger { display: none; }

/* ---------- 左侧分类侧边栏 ---------- */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 1025;
}
.sidebar.open { transform: translateX(0); box-shadow: var(--shadow-pop); }
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1024;
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

.side-section { margin-bottom: 18px; }
.side-title {
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 10px; margin-bottom: 6px;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .92rem;
  transition: background .12s ease, color .12s ease;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.side-link .fa { width: 18px; text-align: center; }
.side-link .cat-dot { flex: 0 0 auto; }

.side-cat .name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 分类彩色圆点 */
.cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--primary);
  flex: 0 0 auto;
}

@media (min-width: 1200px) {
  .topbar .hamburger { display: none; }
  #body { margin-left: var(--sidebar-w); transition: margin-left .25s ease; }
  .sidebar {
    transform: translateX(0);
    box-shadow: none;
  }
  .sidebar-backdrop { display: none !important; }
}

/* ---------- 内容区 ---------- */
.main { min-width: 0; }

/* 区块标题（最新/热门） */
.feed-tabs {
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 14px;
}
.feed-tabs a {
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-weight: 600; font-size: .9rem;
}
.feed-tabs a:hover { background: var(--surface); color: var(--text); }
.feed-tabs a.active { background: var(--primary); color: #fff; }

/* ---------- 话题列表 ---------- */
.threadlist { margin: 0; }
.card-feed {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.topic {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s ease;
  position: relative;
}
.topic:last-child { border-bottom: 0; }
.topic:hover { background: var(--surface-2); }
.topic.topic-top { background: linear-gradient(0deg, var(--primary-soft), var(--primary-soft)); }
.topic.topic-top:hover { background: var(--primary-soft); }

.topic .avatar-3 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }

.topic-main { flex: 1; min-width: 0; }
.topic-title {
  font-weight: 600;
  font-size: 1.04rem;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topic:hover .topic-title { color: var(--primary); }
.topic-title .badge-pin {
  font-size: .68rem; vertical-align: middle;
  background: var(--danger); color: #fff;
  padding: 1px 6px; border-radius: 5px; margin-right: 6px;
}
.topic-title .badge-lock { color: var(--text-faint); margin-left: 5px; }

.topic-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
  font-size: .8rem;
  color: var(--text-faint);
}
.topic-meta .author { color: var(--text-muted); font-weight: 500; }
.topic-meta .author:hover { color: var(--primary); }
.topic-meta .arrow { color: var(--text-faint); }
.topic-meta .last { color: var(--text-faint); }

/* 分类色标 */
.cat-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .76rem; font-weight: 600;
  color: var(--c, var(--primary));
  background: var(--surface-2);
  background: color-mix(in srgb, var(--c, var(--primary)) 12%, transparent);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  max-width: 160px;
}
.cat-badge .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-badge:hover { filter: brightness(.97); }

/* 右侧统计 */
.topic-stats {
  display: flex; align-items: center; gap: 16px;
  flex: 0 0 auto;
  color: var(--text-faint);
  font-size: .8rem;
}
.topic-stats .stat { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.topic-stats .stat b { color: var(--text-muted); font-size: .92rem; font-weight: 700; }
.topic-stats .stat.replies b { color: var(--primary); }

@media (max-width: 768px) {
  .topic-stats .views { display: none; }
  .topic { padding: 13px 14px; gap: 10px; }
  .topic-title { font-size: .98rem; }
  .cat-badge { max-width: 110px; }
  .topic-meta .last { display: none; }
}

/* mod 勾选框 */
.topic input[type="checkbox"] { margin-top: 4px; }

/* ---------- 通用卡片 / 按钮 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.card-header {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-footer { background: var(--surface-2); border-top: 1px solid var(--border); }
.card-title { font-weight: 600; color: var(--text); }

.btn { border-radius: var(--radius-sm); font-weight: 600; transition: all .15s ease; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { border-radius: var(--radius-sm); }

.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }
.text-grey, .text-gray { color: var(--text-muted) !important; }

/* 头像尺寸 */
.avatar-1, .avatar-2, .avatar-3, .avatar-4, .avatar-5 { object-fit: cover; border-radius: 50%; }

/* ---------- 帖子 ---------- */
.message { line-height: 1.8; color: var(--text); font-size: .98rem; }
.message p { margin: .5rem 0; }
.message img {
  max-width: 100%; height: auto !important;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: .5rem;
}
.message a { color: var(--link); }
.message pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto;
}
.blockquote {
  font-size: .88rem;
  background: var(--surface-2);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: .6rem 1rem !important;
  color: var(--text-muted);
}
li.quote { background: var(--surface-2); border-left: 3px solid var(--primary); }

/* ---------- 面包屑 / 分页 ---------- */
.breadcrumb {
  background: transparent; border: none; border-radius: 0;
  padding: 0 0 12px; color: var(--text-muted); font-size: .85rem;
}
.breadcrumb-item a { color: var(--link); }
.breadcrumb-item.active { color: var(--text-muted); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-faint); }

.pagination { flex-wrap: wrap; }
.page-item { margin: 0 .15rem; }
.page-link {
  color: var(--primary); background: var(--surface);
  border-color: var(--border); border-radius: var(--radius-sm);
  transition: all .15s ease;
}
.page-link:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-item.disabled .page-link { color: var(--text-faint); background: var(--surface); border-color: var(--border); }

/* ---------- 表单 ---------- */
.form-control {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem var(--primary-soft);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-faint); }
textarea#message { border-radius: var(--radius-sm); }

/* ---------- 杂项 ---------- */
.alert { border-radius: var(--radius-sm); }
.dropdown-menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); }
.dropdown-item { color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--primary); }
.table { color: var(--text); }
.table td, .table th { border-color: var(--border); }
hr { border-top: 1px solid var(--border); }
.nav_tag_list td a { color: var(--link); }
.nav_tag_list .active { font-weight: 700; color: var(--primary); }

/* 右侧信息卡 */
.aside .card { position: sticky; top: calc(var(--header-h) + 16px); }
.aside .card-site-info h5, .aside .card-user-info h5 { font-weight: 700; }
.aside .card-footer table td { padding: 4px 2px; font-size: .82rem; }
.aside .card-footer b { color: var(--text); }

/* 发帖浮动按钮（移动端） */
.fab-new {
  position: fixed; right: 18px; bottom: 22px;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 1.4rem; box-shadow: var(--shadow-pop); z-index: 1031;
}
.fab-new:hover { background: var(--primary-hover); color: #fff; }

@media (max-width: 1199px) {
  .topbar .hamburger { display: inline-flex; }
  .fab-new { display: inline-flex; }
  .aside { display: none !important; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ---------- 发帖编辑器工具条 ---------- */
.editor-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.editor-toolbar .etb {
  min-width: 34px; height: 32px; padding: 0 9px;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--text-muted);
  font-size: .85rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, color .12s ease;
}
.editor-toolbar .etb:hover { background: var(--surface); color: var(--text); }
.editor-toolbar .etb:active { background: var(--primary-soft); color: var(--primary); }
.editor-toolbar .etb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
#message {
  border-top-left-radius: 0; border-top-right-radius: 0;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9rem; line-height: 1.7;
}

/* ---------- 帖子内容（富文本） ---------- */
.message h1, .message h2, .message h3, .message h4, .message h5, .message h6 {
  line-height: 1.3; margin: 1rem 0 .6rem; font-weight: 700; color: var(--text);
}
.message h1 { font-size: 1.6rem; }
.message h2 { font-size: 1.4rem; }
.message h3 { font-size: 1.2rem; }
.message h4 { font-size: 1.05rem; }
.message blockquote {
  background: var(--surface-2); border-left: 3px solid var(--primary);
  padding: .6rem 1rem; color: var(--text-muted); border-radius: var(--radius-sm);
}
.message code {
  background: var(--surface-2); padding: .15em .4em; border-radius: 6px;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88em; color: var(--text);
}
.message pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; overflow: auto;
}
.message pre code { background: transparent; padding: 0; }
.message ul, .message ol { padding-left: 1.4rem; margin: .5rem 0; }
.message li { margin: .2rem 0; }
.message a { color: var(--link); }
