:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.btn-primary { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; font-weight: 500; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { background: var(--danger); color: #fff; border: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.sm { padding: 5px 10px; font-size: 12px; }
.full { width: 100%; margin-top: 12px; }

.login-wrap { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 8px 30px rgba(15,23,42,.06); }
.login-card h1 { margin: 0 0 8px; font-size: 20px; }
.login-card .sub { margin: 0 0 18px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.login-card label { display: block; font-size: 13px; margin: 10px 0 4px; font-weight: 500; }
.login-card input { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.err-msg { margin-top: 10px; padding: 8px 10px; background: #fef2f2; color: var(--danger); border-radius: 8px; font-size: 13px; }

.app-shell { display: flex; height: 100%; }
.sidebar { width: 260px; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-head { padding: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.brand { font-weight: 600; font-size: 15px; }
.session-list { flex: 1; overflow-y: auto; padding: 8px; }
.sess-item { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; margin-bottom: 4px; }
.sess-item:hover { background: #f1f5f9; }
.sess-item.active { background: #eff6ff; color: var(--primary); font-weight: 500; }
.sess-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sess-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; }
.sess-del:hover { color: var(--danger); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-badge { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.foot-actions { display: flex; gap: 6px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 54px; background: var(--panel); border-bottom: 1px solid var(--border); padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.top-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-pills { display: flex; gap: 6px; flex-shrink: 0; }
.pill { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--muted); }
.pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.chat-panel { flex: 1; overflow-y: auto; padding: 16px; }
.empty-state { max-width: 680px; margin: 40px auto; text-align: center; }
.empty-state h2 { font-size: 18px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.sample-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.sample-btn { text-align: left; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); cursor: pointer; font-size: 13px; color: var(--text); }
.sample-btn:hover { border-color: var(--primary); background: #f8fafc; }

.task-list { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.task-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.q-box { font-weight: 600; font-size: 14px; margin-bottom: 10px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eff6ff; color: var(--primary); font-weight: 500; flex-shrink: 0; }
.badge.deep { background: #fef3c7; color: #b45309; }
.steps-box { background: #f8fafc; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.step-row { padding: 2px 0; }
.ans-box { font-size: 14px; line-height: 1.65; word-break: break-word; }
.ans-box h1, .ans-box h2, .ans-box h3 { margin: 12px 0 6px; font-size: 15px; }
.ans-box table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.ans-box th, .ans-box td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.ans-box th { background: #f8fafc; }
.ans-box code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.task-foot { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--muted); }

.composer { background: var(--panel); border-top: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit; max-height: 140px; }

.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--panel); width: 100%; max-width: 920px; max-height: 88vh; overflow-y: auto; border-radius: 12px; padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.admin-section { margin-bottom: 18px; }
.admin-section h4 { margin: 0 0 8px; font-size: 14px; }
.section-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.inline-form input { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.disabled-list { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.dis-chip { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 4px 8px; display: flex; align-items: center; gap: 6px; }
.audit-wrap { overflow-x: auto; }
.audit-wrap table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-wrap th, .audit-wrap td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.audit-wrap th { background: #f8fafc; }

.mobile-only { display: none; }
@media (max-width: 768px) {
  .mobile-only { display: inline-block; }
  .sidebar { position: fixed; left: -270px; top: 0; bottom: 0; z-index: 40; transition: left .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.12); }
  .sidebar.open { left: 0; }
}
