:root {
  /*
    主题变量（dark）：
    - 所有颜色都通过 CSS 变量集中管理，组件样式尽量只引用变量
    - 切换主题时由 modules/theme.js 切换样式表到 styles.light.css
  */
  --bg: #1e1e1e;
  --panel: #252526;
  --panel2: #1f1f1f;
  --border: #3c3c3c;
  --text: #d4d4d4;
  --muted: #9da0a2;
  --accent: #569cd6;
  --terminalBg: #000000;
  --terminalText: #d4d4d4;
  --terminalGreen: #7cfc98;
}

/* 全局基础：更稳定的盒模型与全高布局 */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  /* 页面基底：背景色/文字色/字体族统一从这里开始 */
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB";
}

/* 主布局：上内容区 + 下终端区 */
.layout {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
}

/* 上半区：内容（左）+ 评论（右） */
.top {
  flex: 3;
  display: flex;
  gap: 12px;
  min-height: 0;
}

/* 面板容器：内容/评论/终端共用的卡片外壳 */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 0;
}

/* 内容面板：标题区 + 内容滚动区 */
.content {
  flex: 4;
  display: flex;
  flex-direction: column;
}

/* 评论面板：标题区 + 列表滚动区 + 输入器 */
.comments {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}

/* 终端面板：黑底等宽字体，强调“终端感” */
.terminal {
  flex: 1;
  background: var(--terminalBg);
  border-color: #0e0e0e;
  display: flex;
  flex-direction: column;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  color: var(--terminalText);
}

/* 内容标题栏：展示当前页面标题与快捷命令入口 */
.contentHeader {
  padding: 18px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0));
}

.contentHeaderRow {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

/* 标题右侧/下方的导航按钮样式（本版本多数被 cmdButton 统一替代） */
.contentHeaderNav {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.contentHeaderNavItem {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(212, 212, 212, 0.92);
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.contentHeaderNavItem:hover {
  border-color: rgba(86, 156, 214, 0.55);
  background: rgba(86, 156, 214, 0.12);
  color: rgba(212, 212, 212, 0.98);
}

.title {
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 700;
  letter-spacing: 0.4px;
}

/* 内容滚动容器（文章阅读区） */
.contentBody {
  padding: 14px 18px;
  flex: 1;
  overflow: auto;
  overscroll-behavior: contain;
  position: relative;
}

.contentBody.contentLoading::after {
  content: "Loading…";
  position: absolute;
  top: 14px;
  left: 18px;
  right: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: none;
}

/* 内容切换过渡：渲染新文章时做淡入淡出/位移动画 */
.contentViewport {
  transition: opacity 180ms ease, transform 180ms ease;
  opacity: 1;
  transform: translateY(0);
}

.contentViewport.switching {
  opacity: 0;
  transform: translateY(6px);
}

/* 内容加载失败/提示文案 */
.contentHint {
  color: var(--muted);
  line-height: 1.65;
  max-width: 76ch;
}

.contentFooter {
  padding: 12px 18px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel2);
}

/* Markdown 文章容器：限制行宽，提升可读性 */
.mdArticle {
  max-width: 76ch;
}

.mdMeta {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.mdDate {
  font-size: 12px;
  color: var(--muted);
}

/* Markdown 正文排版 */
.mdContent {
  line-height: 1.65;
}

.mdContent p.mdIndent {
  text-indent: 2em;
}

.mdContent a {
  color: var(--accent);
}

.mdContent img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  margin: 12px 0;
}

.mdContent table.mdTable {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.mdContent table.mdTable th,
.mdContent table.mdTable td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.mdContent table.mdTable thead th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 700;
}

.mdContent table.mdTable tbody tr:last-child td {
  border-bottom: none;
}

.mdTask {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.mdTask input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* 社交链接：胶囊按钮 + 图标 */
.mdSocialLinks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
}

.mdSocialLink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-decoration: none;
}

.mdSocialLink:hover {
  border-color: rgba(86, 156, 214, 0.55);
  background: rgba(86, 156, 214, 0.12);
  color: var(--text);
}

.mdSocialIcon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex: 0 0 auto;
}

.mdSocialIcon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.mdSocialText {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}

/* 行内 code：用于命令/路径展示 */
.mdContent code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 1px 6px;
}

/* 可点击命令按钮：统一 data-cmd 的视觉入口（内容区/标题栏/评论区按钮复用） */
.cmdButton {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 1px 6px;
  cursor: pointer;
  user-select: none;
}
.cmdButton:hover {
  border-color: rgba(86, 156, 214, 0.45);
  background: rgba(86, 156, 214, 0.08);
}

/* 代码块：用于文章中的多行代码示例 */
.mdContent pre {
  overflow: auto;
  background: #1b1b1c;
  border: 1px solid #2d2d2d;
  border-radius: 10px;
  padding: 12px;
}

.mdContent pre code {
  background: transparent;
  border: none;
  padding: 0;
}

/* 文章列表（Latest / All Posts） */
.mdPostList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mdPostItem {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border: 1px solid #2d2d2d;
  background: #1b1b1c;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  user-select: none;
}

.mdPostItem:hover {
  border-color: rgba(86, 156, 214, 0.45);
  background: rgba(86, 156, 214, 0.08);
}

.mdPostDate {
  width: 92px;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.mdPostTitle {
  flex: 1 1 auto;
  font-weight: 600;
}

.mdPostCmd {
  flex: 0 0 auto;
}

/* 小节标题（Comments、Command Cheat Sheet 等） */
.sectionTitle {
  font-size: 12px;
  letter-spacing: 0.2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* 表格容器：用于命令速查表，允许横向滚动 */
.tableWrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #1b1b1c;
}

.cheatSheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.cheatSheet th,
.cheatSheet td {
  padding: 10px 12px;
  border-bottom: 1px solid #2d2d2d;
  vertical-align: top;
}

.cheatSheet th {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.cheatSheet tr:last-child td {
  border-bottom: none;
}

.cheatSheet td:nth-child(1) {
  width: 88px;
  color: var(--accent);
  font-weight: 600;
}

.cheatSheet td:nth-child(2) {
  width: 160px;
  color: #c586c0;
}

/* 评论区：列表 + 空状态 + 输入器 */
.commentsHeader {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.commentsList {
  padding: 10px 10px 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  opacity: 1;
  transform: translateY(0);
}

.commentsList.switching {
  opacity: 0;
  transform: translateY(6px);
}

.commentsEmpty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  padding: 18px 12px;
}

.commentsComposer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

.commentsInput {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}

.commentsInput:focus {
  border-color: rgba(86, 156, 214, 0.55);
}

.commentItem {
  border: 1px solid #2d2d2d;
  background: #1b1b1c;
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}

.commentMeta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid #2d2d2d;
}

.commentName {
  font-weight: 600;
  color: rgba(212, 212, 212, 0.72);
  max-width: 64%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commentDate {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.commentText {
  margin: 0;
  color: var(--text);
  line-height: 1.5;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 10px;
}

/* 终端输出区：滚动、换行规则与高亮色 */
.terminalOutput {
  flex: 1;
  overflow: auto;
  padding-right: 6px;
  font-size: 14px;
  line-height: 1.55;
}

.terminalLine {
  white-space: pre-wrap;
  word-break: break-word;
}

.terminalLine.dim {
  color: rgba(212, 212, 212, 0.78);
}

.terminalLine.green {
  color: var(--terminalGreen);
}

.terminalJump {
  text-decoration: underline;
  cursor: pointer;
  text-underline-offset: 3px;
}

.terminalJump:hover {
  color: var(--accent);
}

/* 终端输入行：prompt + 光标 + 输入框 */
.terminalInputRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.terminalInputRow:not(:focus-within) .cursor {
  opacity: 0;
  animation: none;
}

.prompt {
  color: var(--terminalGreen);
  white-space: nowrap;
}

.terminalInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--terminalText);
  font: inherit;
  caret-color: transparent;
  padding: 2px 0;
}

/* 光标：模拟终端闪烁光标（输入框本身隐藏 caret） */
.cursor {
  width: 10px;
  height: 18px;
  background: rgba(212, 212, 212, 0.85);
  border-radius: 2px;
  animation: blink 1.05s step-end infinite;
}

@keyframes blink {
  0%,
  55% {
    opacity: 1;
  }
  56%,
  100% {
    opacity: 0;
  }
}

/* 响应式：窄屏时将上半区改为上下堆叠 */
@media (max-width: 980px) {
  .top {
    flex-direction: column;
  }

  .content,
  .comments {
    flex: 1;
  }
}
