/* 周报搭子 · 主题样式（暗色默认 + 亮色，可手动切换/跟随系统） */
:root {
  --bg: #0d1117;
  --bg2: #131a24;
  --card: #161f2c;
  --card2: #1b2635;
  --line: #253248;
  --text: #e6edf3;
  --muted: #8b98ab;
  --accent: #5b8cff;
  --accent2: #3f6ae0;
  --gold: #f5b83d;
  --green: #3fbf7f;
  --danger: #e5604c;
  --topbar-bg: rgba(13, 17, 23, .86);
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

/* 亮色变量：data-theme="light" 手动指定，或系统亮色且用户未强制暗色 */
html[data-theme="light"] {
  --bg: #f5f7fa;
  --bg2: #ffffff;
  --card: #ffffff;
  --card2: #eef2f7;
  --line: #d9e0e8;
  --text: #1c2733;
  --muted: #5f6b7a;
  --accent: #2f6bff;
  --accent2: #1f4fd6;
  --gold: #9c6f14;
  --green: #178a55;
  --danger: #c03d2b;
  --topbar-bg: rgba(255, 255, 255, .88);
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]):not([data-theme="light"]) {
    --bg: #f5f7fa;
    --bg2: #ffffff;
    --card: #ffffff;
    --card2: #eef2f7;
    --line: #d9e0e8;
    --text: #1c2733;
    --muted: #5f6b7a;
    --accent: #2f6bff;
    --accent2: #1f4fd6;
    --gold: #9c6f14;
    --green: #178a55;
    --danger: #c03d2b;
    --topbar-bg: rgba(255, 255, 255, .88);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px; line-height: 1.65;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); background: var(--card2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .9em; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 .5em; }
h2 { font-size: 22px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--topbar-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { color: var(--text); font-size: 17px; display: flex; gap: 8px; align-items: center; }
.brand:hover { text-decoration: none; }
.brand .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 20px; padding: 1px 8px; }
.bar-nav { display: flex; gap: 16px; align-items: center; }
.bar-nav a { color: var(--muted); font-size: 14px; }
.bar-nav a:hover { color: var(--text); }

/* Hero */
.hero { padding: 72px 20px 40px; text-align: center; }
.hero h1 { font-size: clamp(30px, 5vw, 46px); font-weight: 800; letter-spacing: .5px; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .sub { color: var(--muted); font-size: 17px; margin: 14px 0 24px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; margin-bottom: 26px; flex-wrap: wrap; }
.hero-points { list-style: none; margin: 0; padding: 0; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 16px; font-size: 14px; transition: all .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent2); }
.btn.accent { background: rgba(245,184,61,.12); border-color: rgba(245,184,61,.5); color: var(--gold); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 12px 26px; font-size: 16px; }
.btn.xl { padding: 13px 20px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 应用区 */
.app { padding: 30px 20px 10px; }
.app-grid { display: grid; grid-template-columns: 460px 1fr; gap: 18px; align-items: start; }
.app-grid > * { min-width: 0; } /* 防止 pre 长行等 min-content 撑破轨道 */
@media (max-width: 900px) { .app-grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.step-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; }
.step-head h2 { margin: 0; font-size: 17px; }
.step-no { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }

/* 输入面板 */
.repo-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.repo-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.repo-tab { background: var(--card2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 12px; font-size: 13px; }
.repo-tab.active { color: var(--text); border-color: var(--accent); background: rgba(91,140,255,.1); }
.repo-tab .del { margin-left: 7px; color: var(--muted); opacity: .6; }
.repo-tab .del:hover { color: var(--danger); opacity: 1; }
textarea#logInput {
  width: 100%; min-height: 170px; resize: vertical;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
}
textarea#logInput:focus { outline: none; border-color: var(--accent); }
.cmd-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 6px; }
.cmd-chip { font-family: var(--mono); font-size: 12px; color: var(--accent); background: rgba(91,140,255,.08); border: 1px dashed rgba(91,140,255,.5); border-radius: 8px; padding: 4px 10px; }
.cmd-chip:hover { background: rgba(91,140,255,.18); }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0; }
.opt-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); font-size: 14px; }
.opt-row select, .opt-row input[type=date] { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.tpl-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tpl-chip { background: var(--card2); border: 1px solid var(--line); color: var(--muted); border-radius: 20px; padding: 5px 14px; font-size: 13px; }
.tpl-chip.active { color: var(--text); border-color: var(--accent); background: rgba(91,140,255,.12); }
.tpl-chip .lock { font-size: 11px; color: var(--gold); margin-left: 3px; }
.custom-range input { font-size: 13px; }

/* 报告面板 */
.pane-report { min-height: 480px; }
.empty { color: var(--muted); padding: 60px 20px; text-align: center; }
.report-toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.view-tabs { display: flex; gap: 4px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; width: max-content; }
.view-tab { background: transparent; border: 0; color: var(--muted); border-radius: 8px; padding: 5px 14px; font-size: 13px; }
.view-tab.active { background: var(--card2); color: var(--text); }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.report-view {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 22px; max-height: 520px; overflow: auto; font-size: 14.5px;
}
.report-view.source { width: 100%; min-height: 400px; font-family: var(--mono); font-size: 12.5px; color: #cdd9e5; white-space: pre; overflow-x: auto; }
.report-view h1 { font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.report-view h2 { font-size: 16px; margin-top: 1.2em; color: var(--accent); }
.report-view h3 { font-size: 14px; margin-top: 1em; color: var(--muted); }
.report-view ul { margin: 6px 0; padding-left: 20px; }
.report-view li { margin: 3px 0; }
.report-view blockquote { margin: 10px 0 0; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; font-size: 13px; }

/* 统计 */
#statsBox { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 14px; min-width: 0; }
.stat-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 16px; min-width: 90px; text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--accent); }
.stat span { font-size: 12px; color: var(--muted); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 640px) { .charts { grid-template-columns: 1fr; } }
.chart-block { min-width: 0; overflow: hidden; }
.chart-block h4 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; min-width: 0; }
.bar-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-col { width: 100%; max-width: 26px; background: linear-gradient(180deg, var(--accent), var(--accent2)); border-radius: 4px 4px 0 0; min-height: 3px; }
.bar-item .bar-label { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bar-h { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 13px; }
.bar-h .bar-name { width: 70px; color: var(--muted); flex: none; }
.bar-h .bar-track { flex: 1; min-width: 0; background: var(--bg2); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-h .bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #8fb3ff); border-radius: 6px; }
.bar-h .bar-val { width: 30px; text-align: right; color: var(--muted); flex: none; }

/* FAQ / 价格 */
.faq, .pricing { padding: 56px 20px 10px; }
.faq details { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 10px 0 0; }
.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .price-grid { grid-template-columns: 1fr; } }
.price-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; position: relative; display: flex; flex-direction: column; }
.price-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 12px 40px rgba(91,140,255,.15); }
.price-card h3 { font-size: 16px; }
.price-card .p { font-size: 36px; font-weight: 800; }
.price-card .p-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; min-height: 20px; }
.price-card ul { list-style: none; margin: 0 0 18px; padding: 0; flex: 1; }
.price-card li { margin: 7px 0; color: var(--muted); font-size: 14px; }
.ribbon { position: absolute; top: -11px; right: 16px; background: #f5b83d; color: #221; font-size: 12px; font-weight: 700; border-radius: 20px; padding: 2px 12px; }

/* 页脚 */
.foot { border-top: 1px solid var(--line); margin-top: 60px; padding: 26px 0 40px; color: var(--muted); font-size: 13px; }
.foot p { margin: 6px 0; }

/* 弹窗 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: 100%; max-width: 460px; max-height: 86vh; overflow: auto; }
.modal-card.wide { max-width: 640px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3 { margin: 0; }
.modal-head .x { background: none; border: 0; color: var(--muted); font-size: 16px; }
.modal h4 { margin: 18px 0 6px; font-size: 14px; }
.field { display: block; font-size: 13px; color: var(--muted); margin: 10px 0; }
.field input, .field select { display: block; width: 100%; margin-top: 5px; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.lic-row { display: flex; gap: 8px; }
.lic-row input { flex: 1; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 13px; font-family: var(--mono); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.pro-list { list-style: none; padding: 0; color: var(--muted); font-size: 14px; margin: 12px 0 18px; }
.pro-list li { margin: 6px 0; }
textarea.tpl-edit { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12.5px; }

/* Toast */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 20px; font-size: 14px; z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); max-width: 80vw;
}
#toast.err { border-color: var(--danger); }
#toast.ok { border-color: var(--green); }

/* 移动端适配 */
@media (max-width: 640px) {
  .bar-nav a { display: none; } /* 顶栏只留设置按钮，防溢出换行 */
  .hero { padding: 44px 20px 30px; }
  .hero h1 { font-size: 30px; }
  .card { padding: 16px; }
  .report-view { padding: 14px 16px; }
  .opt-row { align-items: flex-start; flex-direction: column; }
  .custom-range { display: flex; gap: 6px; align-items: center; }
  .custom-range[hidden] { display: none; }
  .custom-range input { width: auto; max-width: 40vw; }
  .charts { grid-template-columns: 1fr; }
  .stat { flex: 1; }
}

/* 解析实时提示 */
.parse-hint { color: var(--green); font-size: 12.5px; margin: 6px 0 0; }

/* 拖拽导入高亮 */
textarea#logInput.drop-hint { border-color: var(--accent); border-style: dashed; background: rgba(91,140,255,.06); }

/* 报告内联 Pro 提示条 */
.pro-inline {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(245,184,61,.07); border: 1px solid rgba(245,184,61,.35);
  border-radius: 10px; padding: 10px 14px; margin-top: 12px;
  color: var(--muted); font-size: 13px;
}
.pro-inline[hidden] { display: none; }

/* Markdown 视图可编辑 */
textarea.report-view.source { resize: vertical; cursor: text; color: var(--text); }

/* .btn 的 display:inline-flex 会覆盖 UA 的 [hidden]，需显式关闭 */
#undoAiBtn[hidden] { display: none; }

/* 打印：只保留报告本体（周报打印/存 PDF 场景） */
@media print {
  body { background: #fff; color: #111; }
  .topbar, .hero, .pane-input, .faq, .pricing, .foot, .report-toolbar, #statsBox,
  .pro-inline, .hint, .app-grid .pane-report .step-head, #updateBar, #toast, .modal { display: none !important; }
  .app { padding: 0; }
  .app-grid { grid-template-columns: 1fr; }
  .card { border: 0; background: #fff; padding: 0; }
  .report-view { border: 0; background: #fff; max-height: none; overflow: visible; color: #111; padding: 0; }
  .report-view h1, .report-view h2 { color: #111; }
  textarea.report-view.source { display: none; }
}

/* SW 新版本提示条 */
#updateBar {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--card2); color: var(--text); border: 1px solid var(--accent);
  border-radius: 12px; padding: 10px 16px; font-size: 14px; z-index: 210;
  display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.25);
  max-width: 80vw;
}
#updateBar[hidden] { display: none; }
