/* FaithTutor 演示工作台 —— 暖色、编辑感、信任型视觉
   设计意图：聊天为主角；可信度信号（扎根/安全/成本）就地可见、克制呈现。 */
:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #fbf9f5;
  --ink: #211e1a;
  --muted: #6f675c;
  --faint: #9a9388;
  --line: #e7e1d7;
  --line-strong: #d8d0c2;
  --accent: #2f5d62;        /* 沉静的蓝绿，教育/可信 */
  --accent-soft: #e6efee;
  --ok: #2e7d57;
  --ok-soft: #e7f3ec;
  --warn: #9a6a14;
  --warn-soft: #faf0db;
  --care: #a8456a;          /* 危机用"关怀"色，非报错红 */
  --care-soft: #f7e8ee;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(33, 30, 26, .04), 0 6px 20px rgba(33, 30, 26, .06);
  --font-body: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-head: Georgia, "Songti SC", "Noto Serif SC", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

/* ---- 顶栏 ---- */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); color: #fff; font-weight: 700; letter-spacing: .5px;
  display: grid; place-items: center; font-size: 14px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-family: var(--font-head); font-size: 17px; }
.brand-text em { font-style: normal; font-size: 12px; color: var(--muted); }
.health {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px;
}
.health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.health .dot.on { background: var(--ok); }
.health .dot.off { background: var(--care); }

/* ---- 三栏布局 ---- */
.layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 270px 1fr 348px;
}
.rail, .inspector { background: var(--surface); overflow-y: auto; }
.rail { border-right: 1px solid var(--line); padding: 18px; }
.inspector { border-left: 1px solid var(--line); }

/* ---- 左栏 ---- */
.rail-block { margin-bottom: 22px; }
.rail-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-bottom: 8px; }
.rail-hint { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; }
.presets { display: flex; flex-direction: column; gap: 8px; }
.preset {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 12px; transition: border-color .15s, transform .05s, box-shadow .15s;
}
.preset:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.preset:active { transform: translateY(1px); }
.preset-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.preset-dot.grounded { background: var(--ok); }
.preset-dot.clarify { background: var(--faint); }
.preset-dot.warn { background: var(--warn); }
.preset-dot.care { background: var(--care); }
.preset-label { display: flex; flex-direction: column; font-size: 14px; }
.preset-label small { color: var(--muted); font-size: 11.5px; }

.context summary { cursor: pointer; font-size: 13px; color: var(--ink); padding: 6px 0; }
.context label { display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.context input {
  width: 100%; font: inherit; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink);
}
.legend { display: flex; flex-direction: column; gap: 6px; }

/* ---- 状态 chip ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid transparent; width: fit-content; }
.chip .cdot { width: 7px; height: 7px; border-radius: 50%; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.ok .cdot { background: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); } .chip.warn .cdot { background: var(--warn); }
.chip.care { background: var(--care-soft); color: var(--care); } .chip.care .cdot { background: var(--care); }
.chip.neutral { background: var(--surface-2); color: var(--muted); border-color: var(--line); } .chip.neutral .cdot { background: var(--faint); }

/* ---- 中栏：聊天 ---- */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.chat-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); }
.chat-head h1 { font-family: var(--font-head); font-size: 20px; margin-top: 2px; }
.session { display: flex; align-items: center; gap: 18px; margin: 0; }
.session > div { display: flex; flex-direction: column; }
.session dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.session dd { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
#conversationPill { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.messages { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.empty { margin: auto; max-width: 380px; text-align: center; color: var(--muted); }
.empty h2 { font-family: var(--font-head); color: var(--ink); font-size: 18px; margin-bottom: 6px; }

.msg { max-width: 760px; width: fit-content; }
.msg.user { align-self: flex-end; }
.msg-role { font-size: 11px; color: var(--faint); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg.user .msg-role { justify-content: flex-end; }
.bubble {
  border-radius: var(--radius); padding: 13px 16px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); line-height: 1.62;
  white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble { background: var(--accent); color: #fff; border-color: transparent; }
.msg.care .bubble { background: var(--care-soft); border-color: #eccdd8; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

/* 引用来源卡片 */
.cites { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cite {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  background: var(--surface-2); border-radius: 8px; padding: 9px 11px;
}
.cite-src { font-size: 12px; font-weight: 600; color: var(--accent); display: flex; justify-content: space-between; gap: 8px; }
.cite-src code { font-weight: 400; color: var(--faint); font-size: 10.5px; font-family: ui-monospace, Menlo, monospace; }
.cite-quote { font-size: 13px; color: var(--muted); margin-top: 4px; }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite both; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* 输入区 */
.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 10px;
  padding: 16px 24px 22px; background: var(--surface); border-top: 1px solid var(--line);
}
.composer textarea {
  resize: none; font: inherit; padding: 12px 14px; border: 1px solid var(--line-strong);
  border-radius: 12px; background: var(--surface-2); color: var(--ink); max-height: 180px; line-height: 1.5;
}
.composer textarea:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
#sendButton {
  align-self: end; background: var(--accent); color: #fff; border: none; border-radius: 12px;
  padding: 0 22px; height: 46px; font-size: 15px; font-weight: 600; transition: filter .15s;
}
#sendButton:hover { filter: brightness(1.06); }
#sendButton:disabled { opacity: .55; cursor: progress; }
.composer-hint { grid-column: 1 / 2; margin: 0; font-size: 11.5px; color: var(--faint); }

/* ---- 右栏检视台 ---- */
.tabs { display: flex; gap: 4px; padding: 12px 14px 0; border-bottom: 1px solid var(--line); }
.tab {
  background: none; border: none; padding: 9px 12px; font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; padding: 16px 14px; }
.tab-panel.active { display: block; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h3 { font-size: 14px; }
.summary { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }

.cards { display: flex; flex-direction: column; gap: 9px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.card-title { font-size: 13px; font-weight: 600; }
.card dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 12px; }
.card dt { color: var(--faint); } .card dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; word-break: break-word; }
.card.empty-card { color: var(--muted); text-align: center; background: none; border-style: dashed; }

/* ---- 通用按钮 ---- */
.ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.ghost:hover { color: var(--ink); border-color: var(--line-strong); }
.ghost.sm { padding: 4px 10px; font-size: 12px; }
.solid { background: var(--accent); color: #fff; border: none; border-radius: 9px; padding: 9px 14px; font-size: 13.5px; font-weight: 600; }
.solid:hover { filter: brightness(1.06); }
.wide { width: 100%; margin-bottom: 12px; }
.muted { color: var(--muted); } .tiny { font-size: 11px; } .faint { color: var(--faint); }

/* ---- 响应式：窄屏堆叠 ---- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; }
  .rail { border-right: none; border-bottom: 1px solid var(--line); }
  .rail .legend { display: none; }
  .presets { flex-direction: row; flex-wrap: wrap; }
  .preset { flex: 1 1 160px; }
  .inspector { border-left: none; border-top: 1px solid var(--line); max-height: 42vh; }
  .msg { max-width: 100%; }
}

/* ---- 角色外框 ---- */
.roleswitch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.roleswitch .role { border: none; background: none; padding: 6px 16px; border-radius: 999px; font-size: 13.5px; color: var(--muted); }
.roleswitch .role:hover { color: var(--ink); }
.roleswitch .role.active { background: var(--accent); color: #fff; font-weight: 600; }

.stage { flex: 1; min-height: 0; }
.view { height: 100%; display: none; }
.view.active { display: grid; }
.learner-grid { grid-template-columns: 250px 1fr 250px; }
.learner-aside { border-left: 1px solid var(--line); border-right: none; }
body.learner-only .roleswitch { display: none; }
body.learner-only .learner-aside { display: none; }
body.learner-only .learner-grid { grid-template-columns: 250px 1fr; }

.prog { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.prog .bar { height: 7px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; margin-top: 4px; overflow: hidden; }
.prog .bar i { display: block; height: 100%; background: var(--accent); }
.ph { font-size: 10px; color: var(--warn); background: var(--warn-soft); border-radius: 999px; padding: 1px 7px; font-weight: 600; vertical-align: middle; }

/* 仪表盘视图（教师/运营） */
.view.dash { display: none; grid-template-rows: auto 1fr; overflow-y: auto; background: var(--bg); }
.view.dash.active { display: grid; }
.dash-head { padding: 20px 28px 6px; }
.dash-head h1 { font-family: var(--font-head); font-size: 22px; }
.dash-grid { padding: 16px 28px 28px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-content: start; }
.card-block { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card-block.span2 { grid-column: span 2; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 6px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); }
.table td { padding: 7px 6px; border-bottom: 1px solid var(--line); color: var(--ink); }
.table tr:last-child td { border-bottom: none; }
.fld { display: block; margin-bottom: 10px; }
.fld span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.fld textarea { width: 100%; font: inherit; font-size: 13px; line-height: 1.5; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); color: var(--ink); resize: vertical; }
.fld textarea:focus { background: var(--surface); border-color: var(--accent); outline: none; }
.solid.sm { padding: 6px 12px; font-size: 12.5px; }
.access-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(33, 30, 26, .46);
  backdrop-filter: blur(8px);
}
.access-gate.hidden { display: none; }
.access-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(33, 30, 26, .18);
}
.access-card h1 {
  margin-top: 4px;
  font-family: var(--font-head);
  font-size: 25px;
}
.access-card p {
  color: var(--muted);
  margin: 10px 0 16px;
}
.access-card label {
  display: block;
  margin-bottom: 14px;
}
.access-card label span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.access-card input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 11px 12px;
  font: inherit;
  background: var(--surface-2);
}
.access-error {
  min-height: 18px;
  color: var(--care) !important;
  font-size: 12px;
}
.convo-card p {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.convo-meta {
  color: var(--faint);
  font-size: 11px;
}
.mini-cites {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.mini-cites span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--accent);
  background: var(--surface);
  font-size: 11px;
}
@media (max-width: 1080px) {
  .learner-grid { grid-template-columns: 1fr; }
  body.learner-only .learner-grid { grid-template-columns: 1fr; }
  .learner-aside { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .card-block.span2 { grid-column: span 1; }
}

/* 同意勾选（B-清单 #2） */
.consent-check { display: flex; gap: 10px; align-items: flex-start; text-align: left; font-size: 14px; line-height: 1.5; margin: 4px 0 12px; cursor: pointer; }
.consent-check input { margin-top: 3px; flex: 0 0 auto; width: 16px; height: 16px; }
