:root{--primary:#0b3868;--accent:#b89076;--text:#172b43;--text2:#64758a;--border:#e2e8ef;--bg:#f5f7fa;--focus:0 0 0 3px #0b386826}
body{font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB",sans-serif}
button,input,select,textarea{font:inherit}button,a,input,select,textarea{touch-action:manipulation}
button:focus-visible,a:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--accent);outline-offset:4px}
button:disabled{cursor:wait}[hidden]{display:none!important}
.menu-toggle,.drawer-close,.mobile-admin-head{display:none}
.drawer-backdrop{display:none;border:0;position:fixed;inset:0;background:#10243b66;z-index:79}
#login{background:#edf2f7!important;background-image:none!important}
.login-card{border:1px solid #dbe3ec;box-shadow:0 18px 64px #15375812!important;border-radius:18px!important;width:420px!important;padding:38px!important;max-width:calc(100vw - 32px)!important}
.login-card::before{height:4px}.login-card h2{font-size:23px;letter-spacing:-.4px;margin-bottom:10px}.login-card>p{font-size:13px;line-height:1.8;color:var(--text2)}
.brand{margin-bottom:28px!important}.brand .name{font-size:21px;font-weight:600;letter-spacing:.4px}.brand .name em{font-size:12px!important;margin-top:3px}
.login-card input{min-width:0}.login-card .foot,.login-card .tip{color:var(--text2);line-height:1.8;margin-top:18px}.login-card .btn{min-height:46px;letter-spacing:1px!important}
body[data-surface="student"] .app{height:100dvh}
body[data-surface="student"] .side{width:264px}
.side-head{padding:26px 20px!important}.side-head span{letter-spacing:1px}.side-head b{font-weight:600}
.side .new-chat{min-height:42px;display:flex;align-items:center;justify-content:center;border-radius:9px}
.side-tools{padding-bottom:8px}.side-foot{padding-bottom:18px!important;line-height:1.9!important}
.chat-head{height:76px!important;padding:0 36px!important}.chat-title{min-width:0;gap:10px}.chat-title #bar-name{font-size:16px;font-weight:600}.chat-title .phone{font-size:12px}
.chat-wrap{background:#fcfdff}.msgs{padding:38px max(28px,calc((100% - 850px)/2))!important}
.msg{margin-bottom:26px}.bubble{font-size:15px;line-height:1.9;max-width:82%;overflow-wrap:anywhere}
.msg.bot .bubble{border-color:#e4eaf1;background:#fff}.welcome-card{padding:30px!important;width:min(650px,100%);max-width:100%!important;border-radius:16px!important}
.welcome-card h3{font-size:23px!important;line-height:1.5;letter-spacing:-.4px;margin-bottom:12px!important}.welcome-card p{color:var(--text2);line-height:1.9;font-size:14px}
.chips{margin-top:24px!important;display:flex;flex-direction:column;align-items:flex-start;gap:9px!important}.chip{white-space:normal;text-align:left;border-radius:9px!important;padding:11px 14px!important;font-size:13px!important;line-height:1.6;background:#f8fafc!important;color:var(--primary)!important}
.input-bar{padding:18px max(28px,calc((100% - 850px)/2)) calc(14px + env(safe-area-inset-bottom))!important;background:#fcfdff!important}
.input-row{gap:10px!important;align-items:flex-end}.input-row textarea{min-width:0!important;min-height:52px!important;font-size:15px!important;border-radius:12px!important;padding:14px!important;background:#fff;line-height:1.5}
.input-row .send{width:52px;height:52px;flex:0 0 52px;border-radius:12px}.input-hint{font-size:11px;color:#7b8899;margin-top:11px!important}
.stop-btn,.retry-btn{border:1px solid var(--border);background:#fff;color:var(--primary);border-radius:9px;padding:10px 13px;white-space:nowrap;cursor:pointer}.stop-btn{height:52px}.retry-btn{display:block;margin-top:10px;font-size:12px}.response-error{color:#b74239;font-size:13px}
.hw-panel{width:min(760px,92vw)!important;max-height:90dvh!important;padding:26px!important;border-radius:16px!important}.hw-card{border-radius:12px!important}
body[data-surface="teacher"]{background:#f5f7fa}
.sidebar{width:240px!important}.sidebar .logo{padding:27px 22px;gap:12px}.logo b{font-size:17px}.sidebar .nav{padding:22px 12px}.nav-item{min-height:44px;margin-bottom:6px!important;padding:11px 14px!important;font-size:13px}
.nav-item.active{box-shadow:inset 3px 0 var(--accent);background:#ffffff16!important}
.main{margin-left:240px!important;padding:34px 36px!important}.page-head{margin-bottom:26px!important;gap:15px}.page-head h2{font-size:24px!important;letter-spacing:-.5px}.page-head p{line-height:1.8!important;margin-top:6px!important}
.card,.agent-card{border-color:#e1e7ee!important;box-shadow:0 2px 6px #15375803;border-radius:14px!important;padding:24px}
.card-title{font-size:16px!important}.card-desc{line-height:1.8!important}.btn{min-height:37px;border-radius:8px;font-size:13px}.btn-primary{box-shadow:0 2px 5px #0b386810}.btn-sm{min-height:34px}
.agent-grid{grid-template-columns:repeat(auto-fill,minmax(290px,1fr))!important;gap:20px!important}.agent-name{font-size:16px!important}.agent-meta{line-height:1.8}
.user-bar{flex-wrap:wrap!important;gap:10px!important;padding:18px!important}.user-bar .name{flex:1;min-width:130px;line-height:1.7;overflow-wrap:anywhere}.user-bar button{flex:1;min-height:32px}
.modal{border-radius:16px!important;padding:28px!important;max-height:90dvh!important}.modal h3{font-size:19px}.form-grid{gap:18px!important}.input,.select,.textarea{min-height:40px;border-radius:8px}
.usage-breakdown{display:flex;gap:12px;flex-wrap:wrap;margin:0 0 24px}.usage-breakdown span{background:#fff;border:1px solid var(--border);padding:9px 13px;border-radius:8px;color:var(--text2);font-size:12px}.usage-breakdown b{margin-left:12px;color:var(--primary)}
.md .math-block{display:block;max-width:100%;overflow-x:auto;overflow-y:hidden;padding:4px 0;overscroll-behavior-x:contain}
.md .math-block .katex-display{margin:.45em 0}
.md .math-block .katex-display>.katex{display:inline-block;min-width:100%;white-space:nowrap}
.md .math-inline{display:inline-block;max-width:100%;overflow-x:auto;overflow-y:hidden;vertical-align:middle;padding:2px 0}
.md .katex{font-size:1.05em;white-space:nowrap;overflow-wrap:normal;word-break:normal}
.md .math-source{white-space:pre-wrap;overflow-wrap:anywhere}
@media(max-width:767px){
  body{width:100%;overflow-x:hidden}.menu-toggle{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;min-width:40px;border:1px solid var(--border);border-radius:9px;background:#fff;color:var(--primary);cursor:pointer}
  .drawer-close{display:flex;position:absolute;right:10px;top:12px;border:0;background:#ffffff16;color:#fff;width:32px;height:32px;align-items:center;justify-content:center;font-size:24px;border-radius:8px}
  .drawer-backdrop:not([hidden]){display:block}.drawer-open .side,.drawer-open .sidebar{transform:translateX(0)!important;visibility:visible!important}.drawer-open{overflow:hidden!important}
  body[data-surface="student"] .side,.sidebar{position:fixed!important;inset:0 auto 0 0;width:284px!important;height:100dvh;transform:translateX(-102%);visibility:hidden;z-index:80;transition:transform .18s ease;overflow-y:auto}
  .side-head{padding:24px 44px 20px 18px!important}.side .history{min-height:40px}.chat-head{height:66px!important;padding:0 14px!important;gap:11px}.chat-title{flex:1;display:flex;flex-direction:column;align-items:flex-start!important;gap:2px!important;line-height:1.4}.chat-title #bar-name{font-size:14px;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.chat-title .phone{display:none}.chat-title .status{font-size:10px}.head-ops{gap:8px!important}.head-ops>div{display:none}.lang-sel{max-width:76px;font-size:11px}
  .msgs{padding:22px 16px!important}.msg{gap:8px;margin-bottom:20px}.msg .av{width:30px!important;height:30px!important;min-width:30px;border-radius:9px!important;font-size:16px!important}.bubble{max-width:calc(100% - 38px)!important;font-size:14px;padding:12px 14px;line-height:1.85}
  .msg.bot .bubble.md{min-width:0}
  .msg.bot .welcome-card{padding:20px!important;max-width:calc(100% - 38px)!important;min-width:0!important}.welcome-card h3{font-size:19px!important}.welcome-card p{font-size:13px}.chips{margin-top:18px!important}.chip{padding:10px 12px!important;width:100%;font-size:12px!important}
  .input-bar{padding:12px 12px calc(10px + env(safe-area-inset-bottom))!important}.input-row{gap:8px!important}.input-row textarea{flex:1;min-height:48px!important;font-size:16px!important;padding:11px 12px!important}.input-row .send{height:48px;width:46px;flex-basis:46px}.stop-btn{height:48px;font-size:12px;padding:9px}.input-hint{font-size:10px!important;margin-top:7px!important}
  body.embed .menu-toggle{display:none}.hw-mask{padding:12px!important}.hw-panel{width:100%!important;padding:20px!important;max-height:90dvh!important}.hw-panel input,.hw-panel textarea{font-size:16px!important;min-width:0}
  .mobile-admin-head{display:flex;align-items:center;gap:12px;position:sticky;top:0;z-index:25;height:68px;padding:12px 16px;background:#fff;border-bottom:1px solid var(--border)}.mobile-admin-head b{font-size:16px;flex:1}.mobile-admin-head span{display:block;font-size:10px;color:var(--text2);font-weight:400;margin-top:1px}.mobile-admin-head a{font-size:12px;color:var(--primary);text-decoration:none}
  .main{margin-left:0!important;padding:22px 16px!important;width:100%;max-width:100%}.layout{min-height:calc(100dvh - 68px)}.page-head{align-items:flex-start;flex-wrap:wrap;gap:15px!important;margin-bottom:22px!important}.page-head h2{font-size:22px!important}.page-head>div{min-width:0;max-width:100%}.page-head p{font-size:12px!important;line-height:1.8}.card,.agent-card{padding:18px!important;max-width:100%}.card{overflow-x:auto}.card>div{min-width:0}.agent-grid{grid-template-columns:minmax(0,1fr)!important;gap:14px!important}.agent-ops{gap:7px}.form-grid{grid-template-columns:minmax(0,1fr)!important}.field.full{grid-column:auto}.field{min-width:0}.input,.select,.textarea{font-size:16px!important;min-width:0}.modal{width:calc(100vw - 24px)!important;max-width:calc(100vw - 24px)!important;padding:20px!important;max-height:90dvh!important}.mask{padding:12px;align-items:center}.modal-ops{flex-wrap:wrap}.modal-ops .btn{flex:1}.modal .card{overflow-x:visible}#kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}.kpi b{font-size:24px}.stat-cols{grid-template-columns:minmax(0,1fr)!important}.tab{display:flex;max-width:100%;gap:3px}.tab button{padding:8px 11px}.usage-breakdown{gap:8px}.usage-breakdown span{flex:1;white-space:nowrap}.user-bar{margin-top:auto}
  #plink-url{min-width:0!important;flex-basis:100%!important;width:100%}.var-row{grid-template-columns:minmax(0,1fr)!important}.login-card{padding:28px!important}.login-card h2{font-size:22px}#toast{max-width:calc(100vw - 28px);width:max-content;text-align:center;line-height:1.6}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}
