:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e3e5ea;
  --text: #1c1f26;
  --muted: #6b7280;
  --blue: #185fa5;
  --blue-bg: #e6f1fb;
  --teal: #0f6e56;
  --teal-bg: #e1f5ee;
  --amber: #854f0b;
  --amber-bg: #faeeda;
  --purple: #534ab7;
  --purple-bg: #eeedfe;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.layout { display: flex; flex-direction: column; height: 100vh; }

.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; }
h1 { font-size: 16px; font-weight: 600; }
.sub { font-size: 12px; color: var(--muted); }
.session-meta { display: flex; gap: 8px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.chip-blue { background: var(--blue-bg); color: var(--blue); border-color: transparent; }

.body { display: flex; flex: 1; overflow: hidden; }
.chat-panel { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; min-width: 0; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 8px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: var(--radius); line-height: 1.6; white-space: pre-wrap; }
.msg.admin { background: var(--panel); border: 1px solid var(--line); align-self: flex-start; border-top-left-radius: 4px; }
.msg.user { background: var(--blue); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.sys { background: var(--amber-bg); color: var(--amber); align-self: center; font-size: 12px; }

.composer { display: flex; gap: 8px; margin-top: 12px; }
.composer input { flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; outline: none; }
.composer input:focus { border-color: var(--blue); }
.composer button { padding: 10px 20px; background: var(--blue); color: #fff; border: none; border-radius: 10px; cursor: pointer; font-size: 14px; }
.composer button:hover { opacity: .9; }
.quick-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.quick { font-size: 12px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--text); }
.quick:hover { border-color: var(--blue); color: var(--blue); }
.upload-btn { margin-top: 8px; font-size: 12px; color: var(--muted); background: none; border: 1px dashed var(--line); border-radius: 10px; padding: 8px; cursor: pointer; width: 100%; }
.upload-btn:hover { color: var(--blue); border-color: var(--blue); }

.side-panel { width: 320px; border-left: 1px solid var(--line); background: var(--panel); padding: 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; width: 0%; background: var(--teal); transition: width .4s; }
.stage-list { list-style: none; }
.stage-list li { font-size: 12px; color: var(--muted); padding: 3px 0; }
.stage-list li.active { color: var(--teal); font-weight: 600; }
.stage-list li.done { color: var(--text); }
.material-list { list-style: none; }
.material-list li { font-size: 12px; padding: 4px 0; color: var(--muted); }
.material-list li.ok { color: var(--teal); }
.material-list li.sk { color: var(--muted); text-decoration: line-through; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; margin-top: 8px; }
.report p { font-size: 12px; }
.report .score { font-size: 28px; font-weight: 700; color: var(--blue); }
.dim-row { display: flex; justify-content: space-between; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { width: 560px; max-width: 92vw; height: 70vh; background: var(--panel); border-radius: 16px; display: flex; flex-direction: column; padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font-size: 15px; }
.close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.play-chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; background: var(--bg); border-radius: 10px; padding: 12px; }

.login-view { flex: 1; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login-brand { margin-bottom: 8px; }
.login-card input { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; outline: none; }
.login-card input:focus { border-color: var(--blue); }
.primary-btn { padding: 12px; background: var(--blue); color: #fff; border: none; border-radius: 10px; font-size: 15px; cursor: pointer; }
.primary-btn:hover { opacity: .9; }
.hidden { display: none !important; }
.chip-logout { cursor: pointer; color: var(--amber); border-color: var(--amber-bg); }
.chip-logout:hover { background: var(--amber-bg); }
.chip-toggle { display: none; cursor: pointer; color: var(--teal); border-color: var(--teal-bg); }
.chip-role { font-weight: 500; }
.chip-admin { background: var(--purple-bg); color: var(--purple); border-color: transparent; }
.chip-guest { background: var(--teal-bg); color: var(--teal); border-color: transparent; }
.chip-log { display: none; cursor: pointer; color: var(--blue); border-color: var(--blue-bg); }
.chip-log:hover { background: var(--blue-bg); }
.divider { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.guest-btn { padding: 10px; background: var(--teal-bg); color: var(--teal); border: 1px solid var(--teal); border-radius: 10px; font-size: 13px; cursor: pointer; }
.guest-btn:hover { background: var(--teal); color: #fff; }
.privacy-note { font-size: 12px; color: var(--amber); line-height: 1.5; background: var(--amber-bg); border-radius: 8px; padding: 8px; }
.log-box { flex: 1; overflow-y: auto; }
.log-box h4 { font-size: 13px; margin: 8px 0 4px; }
.log-box pre { font-size: 12px; white-space: pre-wrap; word-break: break-all; background: var(--bg); border-radius: 8px; padding: 8px; max-height: 30vh; overflow-y: auto; color: var(--text); }
.step-label { font-size: 12px; color: var(--teal); font-weight: 500; margin-left: 6px; }
.stage-list li.active { position: relative; }
.stage-list li.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--teal); border-radius: 2px; }

/* ---------- 移动端响应式 (<=768px) ---------- */
@media (max-width: 768px) {
  .layout { height: 100dvh; }
  .topbar { padding: 10px 12px; }
  .topbar .sub { display: none; }
  .body { flex-direction: column; overflow: auto; }
  .chat-panel { flex: none; height: auto; min-height: 0; padding: 12px; }
  .chat { max-height: 52dvh; min-height: 200px; }
  .msg { max-width: 92%; }
  .side-panel { width: 100%; border-left: none; border-top: 1px solid var(--line); max-height: 40dvh; overflow-y: auto; }
  .side-panel.panel-hidden { display: none; }
  .chip-toggle { display: inline-block; }
  .login-card { width: 88vw; max-width: 340px; }
  .modal-card { width: 96vw; height: 78dvh; }
  .composer input { font-size: 16px; }
  .quick { padding: 8px 12px; }
}
