/* 分析报告查看器 — 移动优先，PC ≥960px 双栏 */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  width: 38px; height: 38px; font-size: 18px; line-height: 1;
  cursor: pointer; color: var(--text); flex: none;
}
.topbar-title {
  flex: 1; font-size: 16px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.link-btn {
  flex: none; font-size: 13px; color: var(--accent); text-decoration: none;
  border: 1px solid var(--accent); padding: 6px 10px; border-radius: 8px;
  background: var(--accent-soft);
}

/* ---------- 布局 ---------- */
.body { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 0; }

.sidebar {
  display: none;
  position: fixed; left: 0; top: 52px; bottom: 0; z-index: 30;
  width: min(88vw, 340px);
  background: var(--card);
  box-shadow: 4px 0 16px rgba(0, 0, 0, .12);
  overflow-y: auto;
  padding: 12px;
}
.sidebar.open { display: block; }
.drawer-mask {
  position: fixed; left: 0; right: 0; top: 52px; bottom: 0;
  background: rgba(15, 23, 42, .4); z-index: 25;
}

.content { padding: 12px; min-width: 0; }

/* ---------- 文件夹选项卡 ---------- */
.folder-tabs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.doc-tabs { margin-top: 4px; }
.section-head {
  font-size: 13px; color: var(--muted);
  margin: 4px 2px 2px;
}
.tab {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 10px 12px; border-radius: 10px; text-align: left;
  font-size: 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.tab-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab .cnt { color: var(--muted); font-size: 12px; flex: none; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab.active .cnt { color: rgba(255, 255, 255, .85); }

/* ---------- 报告列表 ---------- */
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--muted); margin: 4px 2px 8px;
}
.tz-select {
  flex: none; font-size: 12px; padding: 2px 4px;
  border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--text); cursor: pointer;
}
.date-head {
  position: sticky; top: 0; z-index: 1;
  background: var(--card);
  font-size: 13px; font-weight: 600; color: var(--muted);
  padding: 8px 2px 4px; display: flex; justify-content: space-between;
}
.report-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  border: 1px solid transparent; background: transparent;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-size: 14px; color: var(--text);
}
.report-item:hover { background: var(--accent-soft); }
.report-item.active { background: var(--accent-soft); border-color: var(--accent); }
.report-item .time { font-variant-numeric: tabular-nums; }
.toc-item .toc-text { white-space: normal; word-break: break-word; line-height: 1.5; }

.badge {
  margin-left: auto; flex: none;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.badge.md { background: #dcfce7; color: #166534; }
.badge.json, .badge.text { background: #e0e7ff; color: #3730a3; }

.placeholder {
  margin: 40px auto; text-align: center; color: var(--muted); font-size: 14px;
}
.error-bar {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 8px 12px; border-radius: 8px; font-size: 13px; margin: 10px 12px 0;
}

/* ---------- 报告内容 ---------- */
.report-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; min-height: 60vh;
}
.report-meta { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.report-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.report-sub {
  font-size: 12px; color: var(--muted);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.report-body { margin-top: 14px; }
.raw-pre {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  background: #0f172a; color: #e2e8f0;
  padding: 14px; border-radius: 8px; font-size: 13px;
}

/* ---------- Markdown ---------- */
.md-body { font-size: 14.5px; line-height: 1.75; }
.md-body h1 { font-size: 22px; border-bottom: 2px solid var(--line); padding-bottom: 8px; }
.md-body h2 {
  font-size: 18px; margin: 26px 0 10px;
  padding-left: 10px; border-left: 4px solid var(--accent);
}
.md-body h2 { scroll-margin-top: 60px; }   /* 顶栏 sticky 52px，目录跳转时避免标题被遮挡 */
.md-body h3 { font-size: 16px; margin: 18px 0 8px; }
.md-body h4 { font-size: 15px; margin: 14px 0 6px; }
.md-body p { margin: 8px 0; }
.md-body ul, .md-body ol { padding-left: 22px; margin: 8px 0; }
.md-body li { margin: 4px 0; }
.md-body blockquote {
  margin: 10px 0; padding: 8px 14px;
  background: #fffbeb; border-left: 4px solid #f59e0b;
  color: #78350f; border-radius: 0 8px 8px 0;
}
.md-body code {
  background: #f3f4f6; padding: 1px 6px; border-radius: 5px;
  font-family: Consolas, "Courier New", monospace; font-size: 13px;
}
.md-body pre {
  background: #0f172a; color: #e2e8f0;
  padding: 12px; border-radius: 8px; overflow-x: auto;
}
.md-body pre code { background: transparent; padding: 0; color: inherit; }
.md-body table {
  border-collapse: collapse; width: 100%; margin: 12px 0;
  font-size: 13.5px; display: block; overflow-x: auto;
}
.md-body th, .md-body td {
  border: 1px solid var(--line); padding: 8px 10px;
  text-align: left; vertical-align: top;
}
.md-body th { background: #f3f4f6; white-space: nowrap; }
.md-body img { max-width: 100%; height: auto; }   /* 图片超宽时等比缩放至内容区宽度 */
.md-body hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------- JSON 视图 ---------- */
.json-root { font-size: 14px; }
.j-row {
  display: grid; grid-template-columns: minmax(90px, 200px) 1fr;
  gap: 10px; padding: 7px 0;
  border-bottom: 1px dashed #eef0f3;
}
.j-key { color: #92400e; font-weight: 600; word-break: break-all; }
.j-val { line-height: 1.65; word-break: break-word; white-space: pre-wrap; }
.j-val.num { color: #0f766e; font-weight: 600; }
.j-val.bool { color: #7c3aed; font-weight: 600; }
.j-val.null { color: #ef4444; font-style: italic; }
.j-val-wrap { min-width: 0; }
.j-bar {
  height: 6px; max-width: 240px;
  background: #eef2ff; border-radius: 3px; overflow: hidden; margin-top: 5px;
}
.j-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
}

.j-section { border: 1px solid var(--line); border-radius: 10px; margin: 9px 0; overflow: hidden; }
.j-sec-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: #f9fafb; cursor: pointer; user-select: none;
}
.j-sec-head:hover { background: #f3f4f6; }
.arrow { color: var(--muted); font-size: 12px; width: 14px; flex: none; }
.j-sec-head .j-key { font-size: 14.5px; }
.j-hint { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }
.j-sec-body { padding: 6px 12px 10px; background: #fff; }

.j-item { margin: 8px 0; padding-left: 10px; border-left: 3px solid #c7d2fe; }
.j-item .j-sec-head { background: #f5f3ff; }
.j-item-title { font-weight: 700; color: #4338ca; word-break: break-word; }

.j-li { padding: 7px 2px; border-bottom: 1px dashed #eef0f3; line-height: 1.7; }
.j-li:last-child { border-bottom: none; }
.j-empty { color: var(--muted); font-size: 13px; padding: 6px 0; }

/* ---------- 首页（素描画 + 悬浮按钮） ---------- */
.content.home { padding: 0; }
.home-section {
  position: relative; width: 100%; height: calc(100vh - 52px); overflow: hidden;
  background: #f2efe9;
}
.home-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.home-pc { display: none; }
.home-buttons {
  position: absolute;
  display: flex; flex-direction: column; align-items: flex-end;  /* 手机端：靠右纵向排列 */
  gap: 10px;
  right: 18px; top: 10%;
}
.home-btn {
  border: 1px solid rgba(0, 0, 0, .16);
  background: rgba(255, 255, 255, .78);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  border-radius: 999px;
  padding: 9px 20px;
  font-size: 14px; color: #1f2937;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .10);
  transition: background .15s, box-shadow .15s, transform .1s;
}
.home-btn:hover {
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.home-btn:active { transform: translateY(1px); }
/* 介绍文字：手机端占左侧（右侧留给按钮），深灰 + 白描边阴影保证纸纹上清晰 */
.home-intro {
  position: absolute;
  left: 18px; right: 150px; top: 10%;
  font-size: 13px; line-height: 1.9;
  color: #4b5563;
  text-shadow: 0 1px 2px rgba(255, 255, 255, .65);
}

/* ---------- PC 双栏 ---------- */
@media (min-width: 960px) {
  .icon-btn { display: none; }
  .body { grid-template-columns: 330px minmax(0, 1fr); }
  .body.home-layout { grid-template-columns: 1fr; }   /* 首页收起侧栏时画占满整屏 */
  .sidebar.collapsed { display: none; }
  .home-pc { display: block; }
  .home-m { display: none; }
  .home-buttons {
    flex-direction: row; align-items: center;
    right: auto; left: 28%; top: 50%; transform: translate(-50%, -50%);
    gap: 14px;
  }
  .home-btn { padding: 12px 30px; font-size: 16px; }
  .home-intro { left: 2%; right: auto; top: 12%; width: min(360px, 26vw); font-size: 15px; }
  .sidebar {
    display: block; position: sticky; top: 52px;
    height: calc(100vh - 52px); width: auto; max-width: none;
    box-shadow: none; border-right: 1px solid var(--line);
  }
  .drawer-mask { display: none; }
  .content { padding: 20px 24px; }
  .report-card { padding: 22px 28px; }
}
