:root {
  --bg: #faf9f5;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --border: #e5e2dc;
  --accent: #1f2328;
  --red: #b42318;
  --red-bg: #fef3f2;
  --yellow: #b54708;
  --yellow-bg: #fffaeb;
  --green: #067647;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 96px; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--card);
}
.brand { font-weight: 700; font-size: 17px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.quota-badge { font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.quota-badge.exhausted { color: var(--red); border-color: var(--red); }
.privacy-notice { margin-top: 24px; font-size: 12px; padding: 8px 12px; border-top: 1px solid var(--border); }
.privacy-notice summary { cursor: pointer; }

.container { max-width: 880px; margin: 20px auto; padding: 0 16px 48px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 20px; margin-bottom: 14px;
}
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 14px 0 8px; }

textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit; resize: vertical;
}
.input-collapsed { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.input-footer { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip {
  background: #f3f1ec; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.chip:hover { background: #e8e5de; }

.btn-primary {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 14px; cursor: pointer;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.link-btn { background: none; border: none; color: #0969da; cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }

.muted { color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }

.skeleton { margin-top: 12px; }
.skel-line {
  height: 14px; background: linear-gradient(90deg, #eee 25%, #f6f6f6 50%, #eee 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; margin-bottom: 8px;
}
.skel-line.short { width: 60%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.error-box {
  margin-top: 10px; padding: 10px 12px; background: var(--red-bg);
  color: var(--red); border: 1px solid #fecdca; border-radius: 8px; font-size: 13px;
}

/* 仪表盘 */
.dashboard-card {
  position: sticky; top: 0; z-index: 50;
  background: var(--card);
  transition: box-shadow 0.2s ease;
}
#result-section { overflow-anchor: none; }
.dashboard-card.stuck { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); }
.dashboard-card.compact { padding: 8px 14px; }
.dashboard-card.compact .headline,
.dashboard-card.compact .gauge-zones,
.dashboard-card.compact .conf-note,
.dashboard-card.compact .marker-hint,
.dashboard-card.compact #score-range,
.dashboard-card.compact .synthesis-line,
.dashboard-card.compact #excluded-line { display: none; }
.dashboard-card.compact .score-label { font-size: 18px; }
.dashboard-card.compact .score-action { margin-top: 0; font-size: 13px; }
.dashboard-card.compact .dash-top { align-items: center; flex-wrap: nowrap; }
.dashboard-card.compact .gauge-wrap { margin: 8px 0 0; }
.dashboard-card.compact .gauge-track { height: 10px; }
.dashboard-card.compact .gauge-marker { height: 16px; top: -3px; }

.dash-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.score-label { font-size: 26px; font-weight: 700; line-height: 1.2; }
.score-action { font-size: 14px; font-weight: 600; margin-top: 4px; }
.dash-right { min-width: 220px; }
.conf-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.conf-track { flex: 1; height: 8px; background: #eee; border-radius: 999px; overflow: hidden; }
.conf-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s ease; }
.conf-note { font-size: 11px; color: var(--muted); margin-top: 4px; }

.gauge-wrap { margin: 18px 0 12px; }
.gauge-track {
  position: relative; width: 100%; height: 14px;
  background: #efede8; border-radius: 999px; overflow: visible;
}
.gauge-interval {
  position: absolute; top: 0; height: 100%;
  background: rgba(31, 35, 40, 0.22); border-radius: 999px;
  transition: left 0.4s ease, width 0.4s ease;
}
.gauge-marker {
  position: absolute; top: -3px; width: 6px; height: 20px;
  background: var(--accent); border-radius: 3px; transform: translateX(-50%);
  transition: left 0.4s ease;
}
.marker-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.gauge-zones {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-top: 6px;
}
.headline { white-space: pre-line; margin: 8px 0 0; font-size: 14px; }

/* 风险条 */
.risk-card summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.flags-list { list-style: none; padding: 0; margin: 10px 0 0; }
.flags-list li { padding: 7px 10px; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.flag-red { background: var(--red-bg); color: var(--red); }
.flag-yellow { background: var(--yellow-bg); color: var(--yellow); }

/* 清单 */
.checklist-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.group-block { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.group-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.group-name { font-weight: 600; font-size: 14px; }
.group-gain { font-size: 12px; color: var(--green); }

.field-row {
  display: grid; grid-template-columns: 1.2fr 1.2fr auto; align-items: center;
  gap: 10px; padding: 7px 0; border-bottom: 1px dashed #f0eee9;
}
.field-row.skipped { opacity: 0.5; }
.field-label { font-size: 13px; }
.field-control { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.field-control input[type="text"], .field-control input[type="number"] {
  width: 130px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.chip-opt {
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  padding: 3px 9px; font-size: 12px; cursor: pointer;
}
.chip-opt.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.field-actions { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; }
.save-tick { color: var(--green); font-size: 12px; display: inline-block; width: 14px; text-align: center; }
.save-tick.hidden { display: inline-block !important; visibility: hidden; }
.clarify-banner { grid-column: 1 / -1; background: var(--yellow-bg); color: var(--yellow); padding: 4px 8px; border-radius: 6px; font-size: 12px; }

.append-box { display: flex; gap: 8px; margin-top: 14px; }
.append-box input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* 详细分析 */
.analysis-header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stale-banner { font-size: 12px; color: var(--yellow); background: var(--yellow-bg); padding: 3px 8px; border-radius: 6px; }
.factors-table { display: grid; gap: 6px; }
.factor-row { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.advisor-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; font-size: 13px; }
.simple-list { padding-left: 18px; margin: 0 0 10px; font-size: 13px; }
.vd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; font-size: 13px; }
.vd-col { border: 1px solid var(--border); border-radius: 8px; padding: 10px; }

.disclaimer { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; }

.drawer {
  position: fixed; top: 0; right: 0; width: 320px; height: 100%;
  background: var(--card); border-left: 1px solid var(--border);
  padding: 16px; overflow-y: auto; z-index: 100;
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; }
.history-title { font-weight: 600; font-size: 14px; cursor: pointer; }
.history-meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-top: 4px; }

.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-content { width: 420px; max-width: 92vw; }
.modal-content label { display: block; font-size: 13px; margin-bottom: 10px; }
.modal-content input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.row-error { grid-column: 1 / -1; color: var(--red); font-size: 12px; }
.synthesis-line { margin: 6px 0 0; font-size: 13px; font-weight: 600; cursor: pointer; }
.group-block.highlight { background: #fffaeb; transition: background 0.3s; }
.group-excluded { color: var(--muted); font-size: 13px; padding: 6px 0; }

@media (max-width: 640px) {
  .dash-right { min-width: 0; flex: 1; }
  .field-row { grid-template-columns: 1fr; }
  .vd-grid { grid-template-columns: 1fr; }
}
