.cms-page { min-height: 100vh; padding-top: 105px; }
.cms-navbar { position: fixed; }
.cms-nav-links { display: flex; gap: 1.5rem; color: var(--text-dim); font-family: 'Orbitron', monospace; font-size: .85rem; }
.cms-nav-links a:hover, .cms-admin-link:hover, .cms-back-link:hover { color: var(--primary); }
.cms-admin-link { color: var(--text-dim); font-family: 'Orbitron', monospace; font-size: .8rem; }
.cms-main { width: min(1050px, calc(100% - 2rem)); margin: 0 auto; padding: 3rem 0 5rem; min-height: 70vh; }
.cms-heading { text-align: center; margin: 1rem 0 2.5rem; }
.cms-heading .section-title { margin: .5rem 0; }
.cms-panel { background: rgba(10, 10, 18, .86); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0, 0, 0, .24); padding: 1.5rem; }
.cms-notice { color: var(--text-dim); text-align: center; min-height: 1.5rem; margin: 1rem 0; }
.cms-error { color: var(--danger); }
.public-posts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 1.25rem; }
.post-card { display: flex; flex-direction: column; align-items: flex-start; gap: .9rem; }
.post-card h2, .public-post h1, .cms-panel h2 { font-family: 'Orbitron', monospace; }
.post-card p { color: var(--text-dim); white-space: pre-wrap; flex: 1; }
.post-date { color: var(--primary); font-size: .9rem; }
.public-post { max-width: 850px; margin: 0 auto; }
.public-post h1 { font-size: clamp(1.7rem, 4vw, 2.8rem); margin: 1.25rem 0 .5rem; }
.post-content { margin-top: 2rem; color: var(--text-dim); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.08rem; line-height: 1.9; }
.cms-back-link { color: var(--primary); }
.cms-button { border: 1px solid var(--primary); border-radius: 6px; padding: .65rem 1rem; color: #05050a; background: var(--primary); font: 600 .85rem 'Orbitron', monospace; cursor: pointer; }
.cms-button:hover { filter: brightness(1.12); }
.cms-button-secondary { background: transparent; color: var(--primary); }
.cms-button-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.cms-button.active { background: var(--primary); color: #05050a; }
.login-panel { max-width: 440px; margin: 0 auto; }
.login-panel h2 { margin-bottom: 1.5rem; }
.cms-form { display: grid; gap: 1rem; }
.cms-form label { display: grid; gap: .4rem; color: var(--text-dim); }
.cms-form input, .cms-form textarea, .cms-form select, .user-row input, .user-row select {
  width: 100%; padding: .7rem .8rem; border: 1px solid var(--border); border-radius: 6px; background: #080811; color: var(--text); font: inherit;
}
.cms-form input:focus, .cms-form textarea:focus, .cms-form select:focus, .user-row input:focus, .user-row select:focus { outline: 1px solid var(--primary); }
.cms-form textarea { resize: vertical; }
.admin-main { max-width: 1280px; }
.admin-toolbar, .panel-heading, .form-actions, .item-actions { display: flex; align-items: center; gap: .75rem; }
.admin-toolbar, .panel-heading { justify-content: space-between; }
.admin-toolbar { margin-bottom: 1rem; }
.admin-tabs { display: flex; gap: .5rem; }
.role-badge, .status-badge { border: 1px solid var(--border); border-radius: 99px; padding: .15rem .6rem; color: var(--primary); font-size: .75rem; }
.admin-columns { display: grid; grid-template-columns: minmax(280px, .9fr) minmax(340px, 1.1fr); align-items: start; gap: 1rem; }
.admin-list-panel, .post-editor { min-width: 0; }
.panel-heading { margin-bottom: 1rem; }
.admin-post-item { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .9rem 0; border-top: 1px solid var(--border-weak); }
.admin-post-item h3 { font-size: 1rem; overflow-wrap: anywhere; }
.item-actions { flex-wrap: wrap; justify-content: flex-end; }
.item-actions .cms-button { padding: .45rem .6rem; font-size: .7rem; }
.status-draft { color: var(--text-dim); }
.status-published { color: var(--accent); }
.cms-help { color: var(--text-dim); margin: .5rem 0 1.5rem; }
.user-create-form { grid-template-columns: repeat(4, minmax(140px, 1fr)); align-items: end; padding: 1rem 0 1.5rem; border-bottom: 1px solid var(--border-weak); }
.user-create-form h3 { grid-column: 1 / -1; }
.user-row { display: grid; grid-template-columns: 1fr 1fr 1fr minmax(150px, 1.4fr) auto; align-items: center; gap: .75rem; padding: 1rem 0; border-bottom: 1px solid var(--border-weak); }
.active-control { display: flex; align-items: center; gap: .4rem; color: var(--text-dim); white-space: nowrap; }
.active-control input { width: auto; }
.footer { margin-top: 2rem; }

@media (max-width: 800px) {
  .admin-columns { grid-template-columns: 1fr; }
  .user-create-form { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .user-row { grid-template-columns: 1fr 1fr; }
  .cms-navbar .nav-container { gap: .75rem; }
}
@media (max-width: 520px) {
  .cms-page { padding-top: 85px; }
  .cms-navbar { padding: .8rem 0; }
  .cms-navbar .logo { font-size: 1rem; }
  .cms-navbar .logo-icon { width: 28px; height: 28px; }
  .cms-nav-links { gap: .75rem; font-size: .7rem; }
  .cms-admin-link { display: none; }
  .admin-toolbar, .panel-heading { align-items: flex-start; flex-direction: column; }
  .admin-post-item { align-items: flex-start; flex-direction: column; }
  .item-actions { justify-content: flex-start; }
  .user-create-form, .user-row { grid-template-columns: 1fr; }
}

/* —— Markdown 正文与预览 —— */
.md-content { white-space: normal; }
.md-content > :first-child { margin-top: 0; }
.md-content h1, .md-content h2, .md-content h3, .md-content h4, .md-content h5, .md-content h6 {
  font-family: 'Orbitron', monospace; color: var(--text); line-height: 1.35; margin: 1.8rem 0 .7rem;
}
.md-content h1 { font-size: 1.7rem; }
.md-content h2 { font-size: 1.4rem; padding-bottom: .4rem; border-bottom: 1px solid var(--border-weak); }
.md-content h3 { font-size: 1.2rem; }
.md-content h4, .md-content h5, .md-content h6 { font-size: 1.05rem; color: var(--primary); }
.md-content p { margin: .9rem 0; }
.md-content ul, .md-content ol { margin: .9rem 0; padding-left: 1.5rem; }
.md-content li { margin: .35rem 0; }
.md-content li > ul, .md-content li > ol { margin: .35rem 0; }
.md-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.md-content strong { color: var(--text); }
.md-content blockquote {
  margin: 1.2rem 0; padding: .6rem 1rem; border-left: 3px solid var(--primary);
  background: rgba(0, 242, 255, .05); border-radius: 0 6px 6px 0; color: var(--text-dim);
}
.md-content blockquote > :first-child { margin-top: 0; }
.md-content blockquote > :last-child { margin-bottom: 0; }
.md-content code {
  font-family: 'JetBrains Mono', Consolas, monospace; font-size: .92em;
  background: rgba(0, 242, 255, .1); border: 1px solid var(--border-weak); border-radius: 4px; padding: .1rem .35rem;
  overflow-wrap: anywhere;
}
.md-content pre.md-code {
  margin: 1.2rem 0; padding: 1rem; overflow-x: auto; border: 1px solid var(--border);
  border-radius: 8px; background: #06060d; line-height: 1.6;
}
.md-content pre.md-code code { background: none; border: 0; padding: 0; font-size: .9rem; white-space: pre; }
.md-content hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--border-weak); }
.md-content img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border-weak); margin: .6rem 0; }
.md-content .md-table-wrap { margin: 1.2rem 0; overflow-x: auto; border: 1px solid var(--border-weak); border-radius: 8px; }
.md-content table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.md-content th, .md-content td { padding: .6rem .8rem; border-bottom: 1px solid var(--border-weak); text-align: left; }
.md-content th { color: var(--primary); background: rgba(0, 242, 255, .06); font-weight: 600; }
.md-content tbody tr:last-child td { border-bottom: 0; }

.md-hint { margin: -.4rem 0 0; color: var(--text-dim); font-size: .78rem; line-height: 2; }
.md-hint code { font-family: 'JetBrains Mono', Consolas, monospace; background: rgba(0, 242, 255, .08); border: 1px solid var(--border-weak); border-radius: 4px; padding: .05rem .3rem; }
.md-preview-panel { border: 1px solid var(--border-weak); border-radius: 8px; background: rgba(5, 5, 10, .5); padding: .8rem 1rem; }
.md-preview-head { display: flex; align-items: center; justify-content: space-between; color: var(--text-dim); font-family: 'Orbitron', monospace; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.md-preview-head .cms-button { padding: .3rem .6rem; font-size: .68rem; }
.md-preview-panel .md-content { margin-top: .6rem; font-size: 1rem; line-height: 1.8; }
.md-preview-panel.collapsed #contentPreview { display: none; }

/* —— 文章列表表格 —— */
.admin-columns { grid-template-columns: minmax(360px, 1.25fr) minmax(330px, 1fr); }
.admin-posts-table-wrap { overflow-x: auto; border: 1px solid var(--border-weak); border-radius: 8px; }
.admin-posts-table { width: 100%; border-collapse: collapse; font-size: .82rem; table-layout: fixed; }
.admin-posts-table thead th {
  text-align: left; padding: .55rem .65rem; white-space: nowrap;
  color: var(--text-dim); font-family: 'Orbitron', monospace; font-size: .66rem;
  letter-spacing: .06em; text-transform: uppercase;
  background: rgba(0, 242, 255, .05); border-bottom: 1px solid var(--border-weak);
}
.admin-posts-table tbody td { padding: .55rem .65rem; border-bottom: 1px solid var(--border-weak); vertical-align: middle; }
.admin-posts-table tbody tr:last-child td { border-bottom: 0; }
.admin-posts-table tbody tr:hover { background: rgba(0, 242, 255, .035); }
.admin-posts-table th:nth-child(1) { width: 34%; }
.admin-posts-table th:nth-child(2) { width: 20%; }
.admin-posts-table th:nth-child(3) { width: 12%; }
.admin-posts-table th:nth-child(4) { width: 13%; }
.admin-posts-table th:nth-child(5) { width: 21%; }
.cell-title .title-text {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-weight: 600; cursor: default;
}
.cell-slug code {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: 'JetBrains Mono', Consolas, monospace; font-size: .74rem; color: var(--text-dim);
  background: none; border: 0; padding: 0;
}
.cell-date { color: var(--text-dim); white-space: nowrap; font-size: .76rem; }
.cell-actions { text-align: right; }
.cell-actions .item-actions { flex-wrap: nowrap; justify-content: flex-end; gap: .3rem; }
.cell-actions .cms-button { padding: .32rem .5rem; font-size: .64rem; white-space: nowrap; text-decoration: none; }
.status-badge { display: inline-block; font-size: .68rem; white-space: nowrap; }

@media (max-width: 1100px) {
  .admin-posts-table th:nth-child(2), .admin-posts-table td.cell-slug { display: none; }
}

/* —— 文章表格：加宽布局（覆盖先前的窄版设定） —— */
.admin-main { max-width: 1560px; }
.admin-columns { grid-template-columns: minmax(600px, 1.6fr) minmax(340px, 1fr); gap: 1.25rem; }
.admin-posts-table { table-layout: fixed; }
.admin-posts-table th:nth-child(1) { width: 46%; }
.admin-posts-table th:nth-child(2) { width: 15%; }
.admin-posts-table th:nth-child(3) { width: 14%; }
.admin-posts-table th:nth-child(4) { width: 25%; }
.admin-posts-table td.cell-slug { display: table-cell; }
.admin-posts-table th:nth-child(2) { display: table-cell; }
.cell-title { min-width: 0; }
.cell-title .title-slug {
  display: block; margin-top: .18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: 'JetBrains Mono', Consolas, monospace; font-size: .7rem; color: var(--text-dim); opacity: .8;
}
.status-badge { font-size: .64rem; padding: .1rem .45rem; }
.cell-actions .item-actions { gap: .35rem; flex-wrap: nowrap; }
.cell-actions .cms-button { padding: .32rem .55rem; font-size: .62rem; }

@media (max-width: 900px) {
  .admin-columns { grid-template-columns: 1fr; }
}

/* —— 全站后台真正放开宽度（覆盖 .cms-main 的 1050px 限制） —— */
.cms-main.admin-main {
  width: min(1760px, calc(100% - 2.5rem));
  max-width: none;
}
.admin-columns { grid-template-columns: minmax(680px, 1.7fr) minmax(360px, 1fr); gap: 1.5rem; }
.admin-posts-table th:nth-child(1) { width: 48%; }
.admin-posts-table th:nth-child(2) { width: 14%; }
.admin-posts-table th:nth-child(3) { width: 15%; }
.admin-posts-table th:nth-child(4) { width: 23%; }
.cell-date { font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-actions .item-actions { gap: .35rem; }
.cell-actions .cms-button { padding: .34rem .6rem; font-size: .63rem; }

/* —— 列宽最终微调：保证操作列三个按钮不挤压 —— */
.admin-posts-table th:nth-child(1) { width: 49%; }
.admin-posts-table th:nth-child(2) { width: 13%; }
.admin-posts-table th:nth-child(3) { width: 14%; }
.admin-posts-table th:nth-child(4) { width: 24%; }
.cell-actions { white-space: nowrap; }
.cell-actions .item-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: .3rem; }
.cell-actions .cms-button { padding: .3rem .52rem; font-size: .6rem; letter-spacing: 0; }
