/* PaperChef — 学术 × 食品 清新纸感 */

:root {
  --bg: #FAF8F3;
  --bg-soft: #F2EEE3;
  --card: #FFFEFB;
  --border: #E7E0D0;
  --border-strong: #D6CCB6;
  --ink: #2E2B24;
  --ink-soft: #57513F;
  --muted: #8B8474;
  --green: #3E5C40;
  --green-dark: #31492F;
  --green-soft: #E7EDE4;
  --clay: #C96F4A;
  --clay-dark: #A85838;
  --clay-soft: #F7E8DF;
  --red: #A63C2C;
  --red-bg: #FBECE8;
  --red-border: #EBC7BD;
  --warn-ink: #77621D;
  --warn-bg: #FBF3D9;
  --warn-border: #E8D79F;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --shadow: 0 1px 3px rgba(62, 58, 44, 0.06), 0 4px 14px rgba(62, 58, 44, 0.04);
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  background-image: radial-gradient(rgba(62, 92, 64, 0.035) 1px, transparent 1px);
  background-size: 26px 26px;
}

.app { display: flex; min-height: 100vh; }

/* ---------- 侧边导航 ---------- */
.sidebar {
  width: 224px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 16px 20px;
  border-right: 1px solid var(--border);
  background: rgba(250, 248, 243, 0.9);
}

.brand { padding: 0 12px 22px; }

.brand-name {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--green);
}

.brand-name::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--clay);
  vertical-align: 4px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 3px;
  margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink-soft);
  text-align: left;
  padding: 10px 14px;
  border-radius: 9px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--bg-soft); color: var(--green); }

.nav-item.active {
  background: var(--green-soft);
  border-left-color: var(--clay);
  color: var(--green);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 12px 0;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
}

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; padding: 36px 44px 64px; }

.view { display: none; max-width: 880px; }
.view.active { display: block; }

.page-head { margin-bottom: 22px; }

.page-head h2 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 1px;
}

.page-head h2::after {
  content: "";
  display: block;
  width: 38px;
  height: 3px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--clay);
}

.page-desc { margin-top: 10px; font-size: 13.5px; color: var(--muted); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.card h3 {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--green);
  margin-bottom: 12px;
}

/* ---------- 表单 ---------- */
.field-label, .opt label, .opt-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  font-family: var(--sans);
  font-size: 14.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea { resize: vertical; line-height: 1.75; min-height: 120px; }

textarea:focus, input:focus, select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(62, 92, 64, 0.12);
}

input::placeholder, textarea::placeholder { color: #B7AF9E; }

.big-input { font-size: 15.5px; padding: 11px 14px; }

.opts {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-top: 16px;
  align-items: flex-end;
}

.opt { min-width: 140px; }
.opt.grow { flex: 1; min-width: 220px; }

.radio-group { display: flex; gap: 16px; padding: 8px 0 5px; }

.radio {
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.radio input { accent-color: var(--green); width: auto; }

input[type="number"] { width: 110px; }

.actions { margin-top: 18px; display: flex; align-items: center; gap: 12px; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  font-family: var(--sans);
  font-size: 14.5px;
  border-radius: 8px;
  padding: 9px 22px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--green-dark); }

.btn.ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--green);
}
.btn.ghost:hover:not(:disabled) { border-color: var(--green); background: var(--green-soft); }

.btn.small { padding: 4px 13px; font-size: 13px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  margin-right: 8px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 提示条 ---------- */
.error-bar {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-all;
}

.ai-warn {
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-ink);
  font-size: 13.5px;
}

.hint { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }

.muted { color: var(--muted); }
.small-note { font-size: 12.5px; margin-bottom: 10px; }
.meta-line { font-size: 13px; margin: 0 2px 12px; }

/* ---------- 结果区 ---------- */
.result-card { border-top: 3px solid var(--green); }

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}

.result-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
}

.result-text { white-space: pre-wrap; line-height: 1.85; font-size: 15px; }

/* ---------- 文献卡片 ---------- */
.results { display: flex; flex-direction: column; gap: 14px; }

.ref-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.ref-head { display: flex; gap: 10px; align-items: baseline; }

.ref-title {
  flex: 1;
  font-weight: 700;
  font-size: 15.5px;
  line-height: 1.55;
}

.ref-title a { color: var(--ink); text-decoration: none; border-bottom: 1px solid transparent; }
.ref-title a:hover { color: var(--clay-dark); border-bottom-color: var(--clay); }

.badge {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}

.badge-crossref { background: var(--green-soft); color: var(--green); }
.badge-pmc { background: var(--clay-soft); color: var(--clay-dark); }

.ref-meta { margin-top: 6px; font-size: 13px; color: var(--muted); }
.ref-meta .journal { color: var(--ink-soft); }

.abstract {
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

.abstract.open { display: block; -webkit-line-clamp: unset; overflow: visible; }

.abstract-empty { margin-top: 10px; font-size: 13px; color: var(--muted); }

.ref-foot {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ref-doi { font-size: 12px; color: var(--muted); word-break: break-all; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

.table-wrap table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}

.table-wrap th, .table-wrap td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
}

.table-wrap th {
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-weight: 600;
}

.table-wrap tr:nth-child(even) td { background: #FCFBF7; }

td.corr-hl { background: var(--clay-soft) !important; color: var(--clay-dark); font-weight: 700; }
td.corr-diag { color: var(--muted); }

.chart-wrap { position: relative; height: 320px; }

/* ---------- 数据分析 ---------- */
.file-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

#csv-file { display: none; }

.file-label { margin: 0; }

/* ---------- 状态页 ---------- */
.status-list { display: flex; flex-direction: column; gap: 10px; }

.status-row { display: flex; align-items: baseline; gap: 8px; }

.status-row dt {
  width: 88px;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.status-row dd { font-size: 14.5px; }

.status-ok { color: var(--green); font-weight: 700; }
.status-bad { color: var(--red); font-weight: 700; }
.status-tip { font-size: 13px; color: var(--muted); margin-left: 6px; }

.mono { font-family: "SFMono-Regular", Consolas, "Courier New", monospace; font-size: 13.5px; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .app { flex-direction: column; }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: auto;
    flex-direction: column;
    padding: 12px 12px 8px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: rgba(250, 248, 243, 0.97);
  }

  .brand { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 10px; }
  .brand-name { font-size: 19px; }
  .brand-sub { letter-spacing: 2px; }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 2px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    padding: 8px 12px;
    font-size: 14px;
  }

  .nav-item.active { border-bottom-color: var(--clay); background: var(--green-soft); }

  .sidebar-foot { display: none; }

  .main { padding: 20px 16px 48px; }

  .card { padding: 16px; }

  .search-row { flex-wrap: wrap; }
  .search-row input[type="text"] { min-width: 100%; }

  .chart-wrap { height: 260px; }
}

/* ---------- 检索行 ---------- */
.search-row { display: flex; gap: 10px; }
.search-row input[type="text"] { flex: 1; }
.search-row select { width: auto; flex-shrink: 0; }
.search-row .btn { flex-shrink: 0; }
