:root {
  --bg: #0f1216;
  --bg-soft: #171c22;
  --bg-card: #1c222b;
  --border: #2a323d;
  --text: #e6ebf2;
  --text-dim: #9aa6b2;
  --accent: #ff6b8b;
  --accent2: #7c9cff;
  --ok: #4cc38a;
  --warn: #e0a64b;
  --danger: #ef6f6f;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1b2230 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 760px; margin: 0 auto; min-height: 100%; padding: 24px 16px 40px; position: relative; }

.topbar { position: absolute; top: 12px; right: 12px; z-index: 60; }
.topbar .help-link {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent2);
  background: rgba(124, 156, 255, .16);
  border: 1px solid rgba(124, 156, 255, .5);
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.topbar .help-link:hover {
  background: rgba(124, 156, 255, .3);
  color: var(--accent2);
}
.help-ico { font-size: 16px; line-height: 1; }
.help-text { text-decoration: underline; text-underline-offset: 3px; }
.view { animation: fade .25s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 落地页 */
.hero { text-align: center; margin: 16px 0 28px; }
.lock-emoji { font-size: 44px; }
.hero h1 { margin: 8px 0 6px; font-size: 28px; letter-spacing: 1px; }
.subtitle { color: var(--text-dim); margin: 0 auto; max-width: 520px; line-height: 1.6; }
.health-bar { margin-top: 14px; font-size: 13px; }
.health-bar.ok { color: var(--ok); }
.health-bar.warn { color: var(--warn); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.card h2 { margin: 0; font-size: 16px; }
.hint { color: var(--text-dim); font-size: 13px; margin: 0; line-height: 1.6; }
.field-label { font-size: 13px; color: var(--text-dim); margin-bottom: -4px; }
.stage-select {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-size: 14px; outline: none; width: 100%;
}
.stage-select:focus { border-color: var(--accent2); }
input {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-size: 14px; outline: none; width: 100%;
}
input:focus { border-color: var(--accent2); }
button {
  cursor: pointer; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text); border-radius: 10px; padding: 11px 14px; font-size: 14px;
  transition: .15s;
}
button:hover { border-color: var(--accent2); }
button.primary { background: linear-gradient(135deg, var(--accent), #ff8fa3); border: none; color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
button:disabled { opacity: .45; cursor: not-allowed; }
.foot { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 26px; }

/* 使用说明入口 */
.help-link { display: inline-block; color: var(--accent2); border-color: transparent; font-size: 13px; padding: 6px 10px; margin-top: 14px; }
.help-link:hover { color: var(--text); border-color: transparent; }
.help-mini { min-height: 36px; padding: 0 12px; font-size: 13px; color: var(--text-dim); }

/* 使用说明弹窗 */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
.modal-box {
  position: relative; width: 100%; max-width: 660px; max-height: 86vh;
  display: flex; flex-direction: column; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  animation: fade .2s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-x { background: transparent; border: none; color: var(--text-dim); font-size: 22px; line-height: 1; padding: 2px 10px; }
.modal-x:hover { color: var(--text); border: none; }
.modal-body { padding: 18px 22px 24px; overflow-y: auto; }
.help-sec { margin-bottom: 18px; }
.help-sec:last-child { margin-bottom: 0; }
.help-sec h3 { margin: 0 0 8px; font-size: 15px; color: var(--accent); }
.help-sec p { margin: 0 0 8px; font-size: 14px; line-height: 1.75; color: var(--text); }
.help-sec ul { margin: 0; padding-left: 20px; }
.help-sec li { font-size: 14px; line-height: 1.75; color: var(--text); margin-bottom: 6px; }
.help-sec b { color: var(--text); }

.lock-result {
  margin-top: 6px; padding: 14px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(255,107,139,.12), rgba(124,156,255,.12));
  border: 1px solid var(--border); font-size: 14px; line-height: 1.7;
}
.lock-result .code { font-weight: 700; letter-spacing: 2px; color: var(--accent); }
.lock-result .row { display: flex; gap: 8px; margin-top: 10px; }

/* 聊天页 */
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.meta { display: flex; gap: 8px; }
.badge { background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--text-dim); }
.badge b { color: var(--text); }
.role-switch { display: flex; gap: 6px; }
.role { padding: 6px 14px; border-radius: 999px; }
.role.active { background: var(--accent); border: none; color: #fff; font-weight: 600; }

.messages { display: flex; flex-direction: column; gap: 12px; min-height: 320px; max-height: 56vh; overflow-y: auto; padding: 6px 2px; }
.msg { max-width: 82%; padding: 11px 14px; border-radius: 14px; line-height: 1.65; font-size: 14px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent2), #95aaff); color: #0b1020; border-bottom-right-radius: 4px; }
.msg .who { display: block; font-size: 11px; opacity: .7; margin-bottom: 3px; }
.msg-system {
  align-self: center; max-width: 90%; margin: 2px 0; padding: 4px 14px;
  font-size: 12px; color: var(--text-dim); text-align: center;
  border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border);
  line-height: 1.6;
}

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; }

/* 报告页 */
.report-body { display: flex; flex-direction: column; gap: 18px; }
.score-hero {
  text-align: center; padding: 22px; border-radius: 16px;
  background: var(--bg-card); border: 1px solid var(--border);
}
.score-hero .num { font-size: 52px; font-weight: 800; color: var(--accent); }
.score-hero .lab { color: var(--text-dim); font-size: 13px; }
.score-hero .summary { margin-top: 12px; font-size: 15px; line-height: 1.7; }
.score-hero .pair-line { color: var(--text-dim); font-size: 13px; margin-bottom: 6px; }
.chart-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.chart-title { margin: 0 0 12px; font-size: 16px; display: flex; align-items: baseline; gap: 8px; }
.chart-sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }
.chart-canvas { padding: 4px 4px 0; }
.chart-canvas canvas { width: 100%; height: 520px; max-height: 70vh; }
.chart-card.bar .chart-canvas canvas { height: 440px; }
.chart-note { margin: 12px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.6; }
@media (max-width: 640px) {
  .chart-canvas canvas { height: 360px; }
  .chart-card.bar .chart-canvas canvas { height: 400px; }
}
.panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.dim { padding: 12px 0; border-bottom: 1px solid var(--border); }
.dim:last-child { border-bottom: none; }
.dim .top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dim .name { font-weight: 600; }
.dim .ms { color: var(--accent); font-weight: 700; font-size: 18px; }
.dim .ab { color: var(--text-dim); font-size: 12px; }
.dim .analysis { color: var(--text-dim); font-size: 13px; line-height: 1.7; margin-top: 6px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; margin: 4px 6px 0 0; }
.chip.s { background: rgba(76,195,138,.15); color: var(--ok); }
.chip.r-high { background: rgba(239,111,111,.15); color: var(--danger); }
.chip.r-mid { background: rgba(224,166,75,.15); color: var(--warn); }
.chip.r-low { background: rgba(124,156,255,.15); color: var(--accent2); }
.item { padding: 10px 0; border-bottom: 1px solid var(--border); line-height: 1.7; font-size: 14px; }
.item:last-child { border-bottom: none; }
.item .sug { color: var(--text-dim); font-size: 13px; }
.conf { font-size: 12px; color: var(--text-dim); }
.loading { opacity: .6; }

/* 依恋配对 */
.att-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.att-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.att-role { font-size: 12px; color: var(--text-dim); }
.att-type { font-size: 20px; font-weight: 700; margin: 2px 0 4px; color: var(--accent2); }
.att-axis { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.att-note { font-size: 12px; line-height: 1.65; color: var(--text-dim); }
.att-pair { margin-top: 12px; font-size: 14px; font-weight: 600; }
.att-tip { margin-top: 6px; font-size: 12px; color: var(--text-dim); }
@media (max-width: 520px) { .att-grid { grid-template-columns: 1fr; } }

/* 信息不足提示 */
.weak-panel { border-color: var(--warn); }
.weak-panel h3 { color: var(--warn); }

/* 会话找回 */
.resume-card { border-color: var(--accent2); margin-bottom: 16px; }
.resume-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 12px; }
.resume-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.ri-main { min-width: 0; }
.ri-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ri-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 1px; }
.ri-role { font-size: 12px; color: var(--text-dim); }
.ri-flag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(76,195,138,.15); color: var(--ok); }
.ri-flag.dim { background: rgba(124,156,255,.15); color: var(--accent2); }
.ri-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ri-go { flex-shrink: 0; min-height: 44px; padding: 0 18px; }
.danger-text { color: var(--danger); }
.keep-tip { margin-top: 8px; font-size: 12px; color: var(--warn); line-height: 1.6; }

/* 身份选择 */
.who-pick { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.who-label { font-size: 13px; color: var(--text-dim); }
.who {
  min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 14px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim); cursor: pointer;
}
.who.active { border-color: var(--accent); color: var(--text); background: rgba(255,107,139,.12); }
.row.compact { gap: 8px; margin: 0; }
.row.compact button { min-height: 40px; padding: 0 12px; font-size: 13px; }

@media (max-width: 520px) {
  .resume-item { flex-direction: column; align-items: stretch; }
  .ri-go { width: 100%; }
  .chat-header { flex-wrap: wrap; gap: 8px; }
}

/* 打印 / 存 PDF */
@media print {
  body { background: #fff; color: #000; }
  #landing, #chat, .chat-header, .weak-panel, #controls, .composer,
  #helpModal, .help-link, .help-mini { display: none !important; }
  #report { display: block !important; }
  .panel, .chart-card, .score-hero, .att-card {
    background: #fff !important; border-color: #ccc !important; color: #000 !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .dim .analysis, .att-note, .conf, .att-tip, .item .sug { color: #333 !important; }
  .score-hero .num { color: #000 !important; }
}
