
:root{
  --bg: #f5f6f7;
  --card: #ffffff;
  --text: #111827;
  --text-weak: #333333;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --border: #e5e7eb;
  --border-weak: #f3f4f6;
  --primary: #3b82f6;
  --primary-2: #1d4ed8;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --shadow: 0 8px 18px rgba(17,24,39,.06);
  --radius: 8px;
  --radius-sm: 6px;
  --font: "Microsoft YaHei","Segoe UI",system-ui,-apple-system,Roboto,"Helvetica Neue",Arial,"Noto Sans","Apple Color Emoji","Segoe UI Emoji";
}

html[data-theme="dark"]{
  --bg: #0b1220;
  --card: #111827;
  --text: #e5e7eb;
  --text-weak: #e5e7eb;
  --muted: #9ca3af;
  --muted2: #6b7280;
  --border: #1f2937;
  --border-weak: rgba(255,255,255,.06);
  --primary: #60a5fa;
  --primary-2: #93c5fd;
  --primary-hover: #3b82f6;
  --shadow: 0 14px 30px rgba(0,0,0,.35);
}

*{ margin:0; padding:0; box-sizing:border-box; }
html,body{ height:100%; }
body{
  background: var(--bg);
  color: var(--text-weak);
  line-height: 1.5;
  font-size: 14px;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a{ color: inherit; text-decoration: none; }
a:hover{ color: var(--primary); }
img{ max-width:100%; height:auto; }

.container{
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 10px 84px; /* 预留底部导航高度 */
}

/* 顶部导航（前台 + 后台复用） */
.top-bar, .topbar{
  background-color: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-nav, .topbar-inner{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* Logo */
.logo, .brand{
  display: flex;
  align-items: center;
  color: var(--primary-2);
  font-weight: 800;
  font-size: 18px;
  text-decoration: none;
  gap: 8px;
  white-space: nowrap;
}
.logo-badge, .brand-mark{
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59,130,246,.10);
  border: 1px solid var(--border);
  color: var(--primary-2);
}
.brand-text{ font-size: 18px; }

/* 搜索框 */
.search-box{
  flex: 1;
  max-width: 520px;
  margin: 0 12px;
  position: relative;
}
.search-box input,
.search-input{
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid rgba(209,213,219,.95);
  border-radius: 20px;
  background-color: rgba(249,250,251,.9);
  color: var(--text);
  font-size: 14px;
  transition: all .2s;
  outline: none;
}
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] .search-input{
  border-color: rgba(255,255,255,.12);
  background-color: rgba(255,255,255,.04);
}
.search-box input:focus,
.search-input:focus{
  border-color: var(--primary);
  background-color: var(--card);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.search-box .search-ico{
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted2);
}
.search{ margin:0; }

/* 右侧动作 */
.user-actions, .topbar-actions{
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.user-action-item{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  position: relative;
}
.user-action-item i{ font-size: 16px; }
.user-action-item:hover{ color: var(--primary); }

.login-btn{
  background-color: var(--primary);
  color: white !important;
  padding: 6px 16px;
  border-radius: 16px;
  font-weight: 600;
  transition: background-color .2s;
}
.login-btn:hover{ background-color: var(--primary-hover); }

.iconbtn{
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 16px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(17,24,39,.04);
}
.iconbtn:hover{ color: var(--primary); }
.iconbtn:active{ transform: translateY(1px); }

/* 兼容旧版按钮 */
.pill{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 1px 0 rgba(17,24,39,.04);
}
.pill.primary{
  background: var(--primary);
  border-color: transparent;
  color: white;
}
.pill.ghost{ background: transparent; }
.pill:active{ transform: translateY(1px); }

/* 标签导航 */
.tab-nav{
  background-color: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
}
.tab-nav::-webkit-scrollbar{ height: 3px; }
.tab-nav::-webkit-scrollbar-thumb{ background-color: rgba(209,213,219,.8); }
.tabs{
  display: inline-flex;
  min-width: 100%;
}
.tab{
  padding: 12px 16px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: all .2s;
}
.tab:hover{ color: var(--primary); }
.tab.active{
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* 主内容布局 */
.main-content{
  display: flex;
  margin-top: 10px;
  gap: 15px;
  min-height: calc(100vh - 150px);
}
.left-content{ flex: 1; min-width: 0; }
.right-content{ width: 300px; flex-shrink: 0; }

@media (max-width: 980px){
  .main-content{ flex-direction: column; }
  .right-content{ width: auto; }
  .search-box{ max-width: 100%; margin: 0 8px; }
}

@media (max-width: 640px){
  .search-box{ display:none; }
  .brand-text{ font-size: 16px; }
  .user-action-item .text{ display:none; }
  .container{ padding-bottom: 96px; }
}

/* 通用模块/卡片 */
.module, .card{
  background-color: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 15px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card.pad{ padding: 0; } /* 改为由 module-body 控制 */
.module-header, .card-header{
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.module-title, .card-title{
  font-weight: 700;
  color: var(--text);
  font-size: 15px;
  margin: 0;
}
.more-link{
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
.more-link:hover{ color: var(--primary); }
.module-body{ padding: 0; }
.section-title{
  padding: 12px 16px 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

/* 顶部提示 */
.notice{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  margin: 12px 0;
}
.notice.danger{
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.06);
}

/* 列表（仿示例 post-item） */
.post-list{ padding: 0; }
.post-item{
  display: block;
  padding: 16px;
  border-bottom: 1px solid var(--border-weak);
  cursor: pointer;
  transition: background-color .2s;
  color: inherit;
}
.post-item:hover{ background-color: rgba(249,250,251,.85); }
html[data-theme="dark"] .post-item:hover{ background-color: rgba(255,255,255,.03); }
.post-item:last-child{ border-bottom: none; }

.post-item.sticky{ background-color: rgba(254,247,205,.85); }
html[data-theme="dark"] .post-item.sticky{ background-color: rgba(245,158,11,.10); }
.post-item.sticky:hover{ background-color: rgba(254,243,199,.95); }
html[data-theme="dark"] .post-item.sticky:hover{ background-color: rgba(245,158,11,.14); }

.post-item-inner{
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.post-thumb{
  width: 112px;
  height: 74px;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(243,244,246,.9);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
html[data-theme="dark"] .post-thumb{ background: rgba(255,255,255,.04); }
.post-thumb img{ width:100%; height:100%; object-fit: cover; display:block; }
@media (max-width: 640px){
  .post-thumb{ width: 96px; height: 64px; }
}

.post-main{ min-width:0; flex:1; }
.post-badges{ display:flex; gap:6px; margin-bottom: 8px; flex-wrap: wrap; }
.post-badge{
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.post-badge.sticky{ background-color: var(--warning); color: white; }
.post-badge.essence{ background-color: var(--success); color: white; }
.post-badge.draft{ background-color: rgba(107,114,128,.18); color: var(--muted); }

.post-title{
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}
.post-content{
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-footer{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.post-tags{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.post-tag, .badge{
  background-color: var(--border-weak);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}
.badge.primary{
  background-color: rgba(59,130,246,.12);
  color: var(--primary);
  border: 1px solid rgba(59,130,246,.18);
}

.post-stats{
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted2);
  font-size: 13px;
}
.post-stat{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 兼容旧版 post-card（用于搜索/标签页旧输出） */
.post-card{
  display:flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-weak);
}
.post-card:hover{ background-color: rgba(249,250,251,.85); }
html[data-theme="dark"] .post-card:hover{ background-color: rgba(255,255,255,.03); }
.post-card:last-child{ border-bottom: none; }
.post-cover{
  width: 112px;
  height: 74px;
  border-radius: var(--radius);
  overflow:hidden;
  background: rgba(243,244,246,.9);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.post-cover img{ width:100%; height:100%; object-fit:cover; display:block; }
.post-main h3{ margin:0; font-size:16px; font-weight:700; line-height:1.25; }
.post-main p{ margin:6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow:hidden; }
.meta{ margin-top: 10px; color: var(--muted2); font-size: 13px; display:flex; gap: 12px; flex-wrap: wrap; }

/* 右侧热榜（仿示例 trending） */
.trending-list{ padding: 0 16px 16px; }
.trending-item{
  display:block;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-weak);
}
.trending-item:hover{ background-color: rgba(249,250,251,.75); }
html[data-theme="dark"] .trending-item:hover{ background-color: rgba(255,255,255,.03); }
.trending-item:last-child{ border-bottom: none; }
.trending-rank{
  display:inline-block;
  width: 18px;
  height: 18px;
  text-align:center;
  line-height:18px;
  background-color: var(--border-weak);
  border-radius: 4px;
  margin-right: 8px;
  font-size: 12px;
  color: var(--muted);
}
.trending-rank.top{
  background-color: rgba(254,226,226,.9);
  color: #dc2626;
}
html[data-theme="dark"] .trending-rank.top{
  background-color: rgba(239,68,68,.16);
  color: #f87171;
}
.trending-text{ color: var(--text); font-size: 14px; }
.trending-meta{ color: var(--muted2); font-size: 12px; margin-top: 4px; }

/* 文章详情 */
.post-body{ padding: 16px; }
.post-body h1{ margin: 0 0 10px; font-size: 20px; color: var(--text); }
.post-meta{
  display:flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}
.content{
  line-height: 1.75;
  font-size: 15px;
  word-break: break-word;
  color: var(--text-weak);
}
.content a{ color: var(--primary); text-decoration: underline; }
.content img{
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.content pre{
  overflow:auto;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(243,244,246,.75);
}
html[data-theme="dark"] .content pre{ background: rgba(255,255,255,.04); }
.content code{
  font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size: .95em;
}
.content blockquote{
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  background: rgba(59,130,246,.08);
  border-radius: var(--radius);
}

/* 附件 */
.attachments{
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.attachments ul{
  list-style: none;
  margin-top: 10px;
  display: grid;
  gap: 10px;
}
.file{
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(243,244,246,.75);
}
html[data-theme="dark"] .file{ background: rgba(255,255,255,.04); }
.file-left{ display:flex; align-items:center; gap: 10px; min-width:0; }
.file-icon{
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--card);
  border: 1px solid var(--border);
}
.file-name{
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 52vw;
}
.file-meta{ color: var(--muted2); font-size: 12px; margin-top: 3px; }
.file-right{ flex: 0 0 auto; }

/* 页脚 */
.footer{
  border-top: 1px solid var(--border);
  padding: 18px 0;
  margin-top: 20px;
  background: transparent;
}
.footer-inner{
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 10px;
  display:flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.small{ font-size: 12px; }
.muted{ color: var(--muted); }

/* 底部导航（移动端） */
.bottom-nav{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--card);
  border-top: 1px solid var(--border);
  display: none;
  justify-content: space-around;
  padding: 10px 0;
  z-index: 100;
}
.bottom-nav-item{
  display:flex;
  flex-direction: column;
  align-items: center;
  color: var(--muted2);
  text-decoration: none;
  font-size: 11px;
  gap: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
}
.bottom-nav-item i{ font-size: 18px; }
.bottom-nav-item.active{ color: var(--primary); }
@media (max-width: 640px){
  .bottom-nav{ display:flex; }
}

/* 表单 */
.field{ margin: 10px 0; }
.label{ font-weight: 800; font-size: 13px; margin-bottom: 6px; display:block; color: var(--text); }
.input, .textarea, .select{
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(209,213,219,.95);
  background: rgba(249,250,251,.9);
  color: var(--text);
  outline: none;
  transition: all .2s;
}
html[data-theme="dark"] .input,
html[data-theme="dark"] .textarea,
html[data-theme="dark"] .select{
  border-color: rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
}
.textarea{ min-height: 120px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus{
  border-color: var(--primary);
  background-color: var(--card);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.help{ margin-top: 6px; color: var(--muted); font-size: 12px; }

/* 按钮 */
.btnrow{ display:flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 800;
  cursor:pointer;
  transition: background-color .2s, border-color .2s;
}
.btn:hover{ border-color: rgba(59,130,246,.35); }
.btn.primary{
  background: var(--primary);
  color: white;
  border-color: transparent;
}
.btn.primary:hover{ background: var(--primary-hover); }
.btn.danger{
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.25);
  color: var(--danger);
}
.btn:active{ transform: translateY(1px); }

/* 表格 */
.table{
  width: 100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
}
.table th, .table td{
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}
.table th{
  font-size: 12px;
  color: var(--muted);
  font-weight: 900;
  letter-spacing: .3px;
}
.table tr:last-child td{ border-bottom: none; }
.table a{ color: var(--primary); }

/* 简易编辑器 */
.editor-toolbar{
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  background: rgba(243,244,246,.75);
}
html[data-theme="dark"] .editor-toolbar{ background: rgba(255,255,255,.04); }
.toolbtn{
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
}
.toolbtn:hover{ border-color: rgba(59,130,246,.35); }
.toolbtn:active{ transform: translateY(1px); }
.editor-area{
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px;
  min-height: 260px;
  background: var(--card);
  color: var(--text);
  outline: none;
}
.editor-area img{
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.emoji-panel{
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px;
  background: rgba(249,250,251,.9);
  display: none;
}
html[data-theme="dark"] .emoji-panel{ background: rgba(255,255,255,.04); }
.emoji-panel button{
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 6px;
  border-radius: 8px;
}
.emoji-panel button:hover{
  background: rgba(59,130,246,.12);
}

/* 小工具 */
.kbd{
  font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 6px;
  background: var(--card);
  color: var(--muted);
}
.link{ color: var(--primary); }
.link:hover{ text-decoration: underline; }


/* ===== 兼容旧模板（后台/安装页） ===== */
.pad{ padding: 16px; }
.card.pad{ padding: 16px; }
.card.pad .card-header{
  margin: -16px -16px 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.card-sub{
  margin-top: 6px;
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.grid{
  display: grid;
  gap: 12px;
}
.grid.two{
  grid-template-columns: 1fr 360px;
  align-items: start;
}
@media (max-width: 980px){
  .grid.two{ grid-template-columns: 1fr; }
}

/* emoji 面板补齐 */
.emoji-panel.open{ display:block; }
.emoji-head{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.emoji-grid{
  display:grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
}
@media (max-width: 640px){
  .emoji-grid{ grid-template-columns: repeat(8, 1fr); }
}

/* footer 子区域 */
.footer-left, .footer-right{ display:flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.footer-left{ align-items: flex-start; flex-direction: column; gap: 6px; }

/* 安装页小宽度容器 */
.narrow{ max-width: 760px; margin: 0 auto; }


/* Admin UI Enhancements */
.admin-page-head{margin-bottom:12px}
.admin-actions-nav .user-action-item.is-active{background:var(--card); border:1px solid var(--border); box-shadow:0 6px 18px rgba(0,0,0,.08)}
.admin-plugin-list{display:grid; gap:12px}
.admin-plugin-item{display:flex; gap:12px; align-items:flex-start; justify-content:space-between; border:1px solid var(--border); border-radius:16px; padding:14px; background:var(--card)}
.admin-plugin-title{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.admin-plugin-desc{margin-top:8px; color:var(--text); opacity:.92; line-height:1.55}
.admin-plugin-actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap}
.admin-plugin-main{min-width:0; flex:1}
.admin-plugin-main code{padding:2px 6px; border-radius:8px; background:rgba(127,127,127,.12)}

.admin-bottom-nav{
  position:fixed;
  left:0; right:0; bottom:0;
  display:none;
  gap:0;
  padding:10px 12px calc(10px + env(safe-area-inset-bottom));
  background:color-mix(in srgb, var(--bg) 92%, transparent);
  border-top:1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index:999;
}
.admin-bottom-item{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  text-decoration:none;
  color:var(--text);
  padding:10px 8px;
  border-radius:14px;
}
.admin-bottom-item i{font-size:18px}
.admin-bottom-item span{font-size:12px; opacity:.9}
.admin-bottom-item.is-active{background:var(--card); border:1px solid var(--border)}
@media (max-width: 820px){
  .admin .admin-bottom-nav{display:flex}
  .admin{padding-bottom:86px}
  .admin .admin-actions-nav{display:none}
}
