/* =========================================================================
 * style.css —— 论文写作与选刊工作台（浅色主题，纯手写，无第三方 UI 库）
 * ========================================================================= */

:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #fbfcfe;
  --line: #e3e8f0;
  --line-strong: #cfd8e6;
  --text: #1f2937;
  --text-2: #5b667a;
  --muted: #8b95a7;
  --brand: #2563eb;
  --brand-soft: #e8f0ff;
  --ok: #15803d;
  --warn: #b45309;
  --danger: #dc2626;
  --up: #dc2626;   /* 涨/高 → 红（中国习惯） */
  --down: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 18px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

/* ------------------------------ 布局 ------------------------------ */
.shell { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 216px; flex: 0 0 216px;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; overflow: auto; }
.nav-item {
  display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); font-size: 13.5px;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: .85; }
.sidebar-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid var(--line); }
.sidebar-foot p { margin: 2px 0; }

.main { flex: 1 1 auto; min-width: 0; overflow: auto; }
.view { padding: 22px 26px 60px; max-width: 1380px; }

.page { display: flex; flex-direction: column; gap: 16px; }

/* ------------------------------ 通用 ------------------------------ */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.warn-text { color: var(--warn); }
.mt { margin-top: 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Courier New", monospace; }
.hidden { display: none !important; }
.pad { padding: 8px 4px; }
.code { background: #f3f5f9; padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: .2px; }
.page-head p { margin: 0; max-width: 820px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-extra { display: flex; gap: 8px; align-items: center; }
.panel-extra-row { display: flex; gap: 8px; }
.panel-body { padding: 14px; }

.two-col { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.two-col.wide-right { grid-template-columns: 380px 1fr; }
@media (max-width: 1080px) { .two-col, .two-col.wide-right { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } }

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; line-height: 1.4;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4ed8; color: #fff; }
.btn.ghost { background: var(--panel-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: #f3c6c6; background: #fff; }
.btn.danger-ghost:hover { background: #fef2f2; border-color: var(--danger); }
.btn.mini { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.wide { width: 100%; justify-content: center; }

.icon-btn { border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: #f1f4f9; color: var(--danger); }

/* ------------------------------ 表单 ------------------------------ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field-hint { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  padding: 7px 10px; font: inherit; color: var(--text); outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea.input { resize: vertical; }
.title-input { font-size: 15px; font-weight: 600; }
.range { width: 220px; }
.checkbox { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.cb-item { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.mini-select { padding: 3px 6px; font-size: 12px; width: auto; }

/* ------------------------------ 标签 / 芯片 ------------------------------ */
.tag { display: inline-block; background: var(--brand-soft); color: #1e40af; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #f1f5fb; border: 1px solid var(--line); color: var(--text-2); border-radius: 6px; padding: 1px 8px; font-size: 12px; }
.chip.hit { background: #fff1f0; border-color: #fbd5d5; color: #b91c1c; font-weight: 500; }

/* ------------------------------ 表格 ------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.table thead th { background: var(--panel-2); font-weight: 600; color: var(--text-2); position: sticky; top: 0; }
.table.compact th, .table.compact td { padding: 5px 8px; font-size: 12.5px; }
.table tbody tr:hover { background: #f8fafd; }
.table th.num { color: var(--brand); }
.table-scroll { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.cell-corr { text-align: center; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.table.corr td, .table.corr th { text-align: center; }

/* ------------------------------ 写作模块 ------------------------------ */
.draft-list { display: flex; flex-direction: column; gap: 6px; max-height: 620px; overflow: auto; }
.draft-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: #fff; }
.draft-item:hover { border-color: #c7d6f5; }
.draft-item.active { border-color: var(--brand); background: var(--brand-soft); }
.di-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.di-meta { font-size: 12px; color: var(--muted); }

.editor-body { display: flex; flex-direction: column; }
.editor { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 12px; font: inherit; line-height: 1.75; resize: vertical; outline: none; }
.editor:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.sections-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 10px; }
.sections-head h4 { margin: 0; font-size: 13.5px; }
.section-card { border: 1px solid var(--line); border-radius: 9px; padding: 10px; margin-bottom: 12px; background: var(--panel-2); }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sec-name { flex: 1 1 auto; border: 1px dashed var(--line-strong); background: transparent; border-radius: 6px; padding: 4px 8px; font: inherit; font-weight: 600; color: var(--text); }
.sec-name:focus { border-style: solid; border-color: var(--brand); outline: none; }
.sec-actions { display: flex; gap: 4px; }
.word-badge { background: var(--brand-soft); color: #1e40af; border-radius: 999px; padding: 3px 12px; font-size: 12.5px; font-weight: 600; }
.editor-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line); }

/* ------------------------------ 期刊库 ------------------------------ */
.journal-list { display: flex; flex-direction: column; gap: 10px; }
.journal-card { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.journal-card:hover { border-color: #c7d6f5; }
.journal-card.selected { border-color: var(--brand); background: #fbfdff; }
.jc-left { display: flex; align-items: flex-start; padding-top: 3px; }
.jc-main { flex: 1 1 auto; min-width: 0; }
.jc-title { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 14px; }
.jc-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.jc-actions { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }

.preview { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: var(--panel-2); }
.preview-head { display: grid; grid-template-columns: 1fr 220px; gap: 12px; align-items: end; margin: 12px 0 8px; }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mini-stat { flex: 1 1 120px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; }
.ms-val { font-size: 16px; font-weight: 700; color: var(--brand); }
.ms-lab { font-size: 12px; color: var(--muted); }

.sub-title { margin: 14px 0 8px; font-size: 13.5px; }
.weight-list { display: flex; flex-direction: column; gap: 5px; }
.weight-item { display: grid; grid-template-columns: 130px 1fr 150px; gap: 10px; align-items: center; font-size: 12.5px; }
.w-term { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-bar { background: #eef2f8; border-radius: 999px; height: 8px; overflow: hidden; }
.w-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #6366f1); }
.w-val { color: var(--muted); }
.issue-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.issue-card { border: 1px solid var(--line); border-radius: 9px; padding: 10px; background: var(--panel-2); }
.ic-head { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }

/* ------------------------------ 选刊分析 ------------------------------ */
.result-wrap { display: flex; flex-direction: column; gap: 16px; }
.rank-list { display: flex; flex-direction: column; gap: 10px; }
.rank-card { display: flex; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.rank-card.top { border-color: #f0b0ad; box-shadow: 0 0 0 2px rgba(220,38,38,.08); }
.rank-card.dim { opacity: .6; }
.rank-no { font-weight: 700; color: var(--muted); font-size: 13px; width: 30px; padding-top: 4px; }
.rank-score { width: 74px; text-align: center; }
.score-num { font-size: 26px; font-weight: 800; color: var(--up); line-height: 1.1; }
.score-lab { font-size: 11.5px; color: var(--muted); }
.rank-main { flex: 1 1 auto; min-width: 0; }
.rank-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.level { font-size: 11.5px; border-radius: 999px; padding: 1px 9px; font-weight: 600; }
.lv-high { background: #fee2e2; color: #991b1b; }
.lv-mid { background: #ffedd5; color: #9a3412; }
.lv-low { background: #e0f2fe; color: #075985; }
.lv-bad { background: #f1f5f9; color: #64748b; }
.rank-bars { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 2px; }
.hbar { display: grid; grid-template-columns: 92px 1fr 52px; gap: 8px; align-items: center; font-size: 12px; color: var(--text-2); }
.hbar-track { background: #eef2f8; border-radius: 999px; height: 7px; overflow: hidden; }
.hbar-track i { display: block; height: 100%; background: linear-gradient(90deg, #dc2626, #f97316); }
.hbar-val { text-align: right; }

/* ------------------------------ 看板 ------------------------------ */
.progress-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.pp-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.progress-track { height: 10px; background: #eef2f8; border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.progress-track i { display: block; height: 100%; background: linear-gradient(90deg, #16a34a, #4ade80); transition: width .3s; }
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: start; }
@media (max-width: 1100px) { .kanban { grid-template-columns: repeat(2, 1fr); } }
.kanban-col { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 120px; }
.kb-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 8px; border-bottom: 1px dashed var(--line); margin-bottom: 8px; font-size: 13px; }
.kb-head .count { background: #f1f5fb; border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--text-2); }
.task-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; margin-bottom: 8px; background: var(--panel-2); }
.task-title { font-weight: 600; font-size: 13px; }
.task-meta { margin: 4px 0 6px; }
.task-actions { display: flex; gap: 6px; align-items: center; justify-content: space-between; }
.st-doing { border-top: 3px solid #2563eb; }
.st-todo { border-top: 3px solid #94a3b8; }
.st-done { border-top: 3px solid #16a34a; }
.st-block { border-top: 3px solid #dc2626; }

/* ------------------------------ 资料库 ------------------------------ */
.lib-list { display: flex; flex-direction: column; gap: 10px; }
.lib-item { border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; background: #fff; }
.li-head { display: flex; align-items: center; gap: 6px; }
.li-content { font-size: 13px; color: var(--text-2); margin: 6px 0; white-space: pre-wrap; }
.li-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.li-actions { display: flex; gap: 6px; }

/* ------------------------------ Tab / 空态 ------------------------------ */
.tabs { display: flex; flex-direction: column; gap: 12px; }
.tab { border: 1px solid var(--line-strong); background: #fff; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.tabs { flex-direction: row; flex-wrap: wrap; align-items: center; }
.tabs .tab-body { flex: 1 1 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }

.empty { text-align: center; padding: 26px 16px; color: var(--muted); }
.empty-ico { font-size: 30px; color: var(--line-strong); line-height: 1; margin-bottom: 6px; }
.empty p { margin: 0 0 10px; }

.model-out { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.eq-box { background: #f8fafd; border: 1px dashed var(--line-strong); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; overflow-x: auto; }

/* ------------------------------ 弹窗 ------------------------------ */
.modal-overlay { position: fixed; inset: 0; background: rgba(17, 24, 39, .38); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; box-shadow: 0 20px 50px rgba(16,24,40,.22); }
.modal.wide { width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 12px 12px; }
.confirm-msg { margin: 0; }

/* ------------------------------ Toast ------------------------------ */
.toast-box { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #1f2937; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 10px 24px rgba(16,24,40,.2); opacity: .98; transition: .3s; max-width: 380px; }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-ok { background: #15803d; }
.toast-warn { background: #b45309; }
.toast-error { background: #b91c1c; }
