:root{
  --bg:#f4f6fb;
  --bg2:#eaf0ff;
  --card:#ffffff;
  --ink:#16223a;
  --ink2:#5a6884;
  --muted:#8a97ae;
  --line:#e4e9f4;
  --brand:#2563eb;
  --brand2:#4f46e5;
  --brand-soft:#eef3ff;
  --ok:#16a34a;
  --danger:#dc2626;
  --shadow:0 10px 30px rgba(28,52,105,.08);
  --radius:16px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
html,body{height:100%;}
body{
  margin:0;color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  background:
    radial-gradient(1000px 500px at 10% -10%,#dfe9ff 0%,transparent 60%),
    radial-gradient(800px 400px at 100% 0%,#e7f0ff 0%,transparent 55%),
    var(--bg);
  font-size:15px;line-height:1.65;
}
.app{display:flex;flex-direction:column;height:100dvh;max-width:920px;margin:0 auto;}

/* ---------- 顶栏 ---------- */
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:14px 18px;background:rgba(255,255,255,.78);backdrop-filter:saturate(180%) blur(12px);
  border-bottom:1px solid var(--line);position:sticky;top:0;z-index:20;
}
.brand{display:flex;align-items:center;gap:11px;min-width:0;}
.logo{
  width:40px;height:40px;flex:0 0 auto;border-radius:12px;color:#fff;
  background:linear-gradient(135deg,var(--brand),var(--brand2));
  display:grid;place-items:center;box-shadow:0 6px 16px rgba(37,99,235,.28);
}
.logo svg{width:22px;height:22px;}
.brand-txt{min-width:0;}
.brand-txt h1{margin:0;font-size:16.5px;font-weight:700;letter-spacing:.2px;white-space:nowrap;}
.brand-txt h1 span{color:var(--muted);font-weight:400;margin:0 1px;}
.brand-txt p{margin:1px 0 0;font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.status{
  display:flex;align-items:center;gap:6px;font-size:12.5px;color:#15803d;
  background:#eafaf0;border:1px solid #c9f0d8;border-radius:999px;padding:5px 11px;flex:0 0 auto;
}
.status i{width:7px;height:7px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px rgba(22,163,74,.16);}
.status.off{color:#b45309;background:#fff7e6;border-color:#fde3b0;}
.status.off i{background:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.16);}
.topnav{margin-left:auto;}
.topnav a{font-size:13px;color:var(--ink2);padding:6px 12px;border-radius:999px;border:1px solid var(--line);background:#fff;}
.topnav a:hover{color:var(--brand);border-color:#cfdcfb;background:var(--brand-soft);}
@media (max-width:520px){.topnav a{font-size:12px;padding:5px 9px;}}

/* ---------- 聊天区 ---------- */
.chat{flex:1 1 auto;overflow-y:auto;overscroll-behavior:contain;padding:22px 18px 8px;scroll-behavior:smooth;}
.welcome{
  background:linear-gradient(180deg,#ffffff 0%,#fbfcff 100%);
  border:1px solid var(--line);border-radius:20px;padding:26px 22px;box-shadow:var(--shadow);
  text-align:center;margin:6px 0 22px;
}
.w-ico{
  width:52px;height:52px;margin:0 auto 12px;border-radius:16px;color:#fff;
  background:linear-gradient(135deg,#5b8def,var(--brand2));display:grid;place-items:center;
  box-shadow:0 10px 22px rgba(79,70,229,.26);
}
.w-ico svg{width:28px;height:28px;}
.welcome h2{margin:0 0 8px;font-size:19px;letter-spacing:.2px;}
.welcome p{margin:0;color:var(--ink2);font-size:13.8px;line-height:1.85;}
.welcome p b{color:var(--brand);font-weight:700;}
.chips{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;margin-top:16px;}
.chip{
  border:1px solid #d8e2f7;background:#fff;color:#28406b;border-radius:999px;
  padding:8px 13px;font-size:13px;cursor:pointer;transition:.16s;font-family:inherit;
}
.chip:hover{border-color:var(--brand);color:var(--brand);background:var(--brand-soft);transform:translateY(-1px);}
.chip:active{transform:translateY(0);}
.w-tip{margin:16px 0 0 !important;font-size:12px !important;color:var(--muted) !important;}

.msgs{display:flex;flex-direction:column;gap:16px;padding-bottom:12px;}
.msg{display:flex;gap:10px;align-items:flex-start;animation:fade .22s ease-out;}
@keyframes fade{from{opacity:0;transform:translateY(6px);}to{opacity:1;transform:none;}}
.msg.me{flex-direction:row-reverse;}
.avatar{
  width:34px;height:34px;flex:0 0 auto;border-radius:11px;display:grid;place-items:center;
  font-size:14px;font-weight:700;color:#fff;background:linear-gradient(135deg,var(--brand),var(--brand2));
  box-shadow:0 4px 10px rgba(37,99,235,.22);
}
.msg.me .avatar{background:linear-gradient(135deg,#7c8db3,#5a6884);box-shadow:none;}
.bubble{
  max-width:min(78%,660px);background:var(--card);border:1px solid var(--line);
  border-radius:14px;padding:12px 15px;box-shadow:0 4px 14px rgba(28,52,105,.05);
  font-size:14.4px;word-break:break-word;overflow-wrap:anywhere;
}
.msg.me .bubble{
  background:linear-gradient(135deg,var(--brand),#3b82f6);color:#fff;border-color:transparent;
  box-shadow:0 6px 18px rgba(37,99,235,.24);
}
.bubble p{margin:0 0 8px;}
.bubble p:last-child{margin-bottom:0;}
.bubble ul{margin:6px 0 6px;padding-left:20px;}
.bubble li{margin:2px 0;}
.bubble code{background:#f1f4fa;border-radius:5px;padding:1px 5px;font-size:13px;}
.bubble a{color:var(--brand);text-decoration:underline;text-underline-offset:2px;word-break:break-all;}
.msg.me .bubble a{color:#dbe8ff;}
.bubble .res-item,.bubble .dir-item{text-decoration:none;}
.bubble.err{background:#fff5f5;border-color:#fbd5d5;color:#991b1b;}

/* 打字指示 */
.typing{display:inline-flex;gap:4px;align-items:center;height:20px;}
.typing i{width:6px;height:6px;border-radius:50%;background:#b9c5da;animation:bounce 1.15s infinite;}
.typing i:nth-child(2){animation-delay:.16s;}
.typing i:nth-child(3){animation-delay:.32s;}
@keyframes bounce{0%,60%,100%{transform:translateY(0);opacity:.55;}30%{transform:translateY(-4px);opacity:1;}}

/* 资源卡片 */
.res{margin-top:10px;border-top:1px dashed var(--line);padding-top:9px;}
.res-h{font-size:12px;color:var(--muted);margin-bottom:7px;display:flex;align-items:center;gap:5px;}
.res-h svg{width:13px;height:13px;}
.res-item{
  display:flex;align-items:center;gap:9px;padding:7px 9px;border-radius:9px;
  border:1px solid #e8eefb;background:#fbfcff;margin-bottom:6px;text-decoration:none;color:inherit;
  transition:.15s;
}
.res-item:hover{border-color:#b9cdf5;background:#f4f8ff;}
.res-ext{
  flex:0 0 auto;font-size:10px;font-weight:700;color:#fff;background:#6b7c9b;border-radius:5px;
  padding:2px 5px;letter-spacing:.4px;text-transform:uppercase;
}
.res-ext.pdf{background:#dc2626;}
.res-ext.ppt,.res-ext.pptx,.res-ext.pps,.res-ext.ppsx{background:#d97706;}
.res-ext.doc,.res-ext.docx{background:#2563eb;}
.res-ext.zip,.res-ext.rar,.res-ext[data-ext="7z"]{background:#7c3aed;}
.res-ext.exe{background:#0f766e;}
.res-ext.mp4{background:#db2777;}
.res-main{min-width:0;flex:1 1 auto;}
.res-name{display:block;font-size:13.2px;font-weight:600;color:#1b2b4b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.res-meta{display:block;font-size:11.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.res-go{flex:0 0 auto;font-size:12px;color:var(--brand);font-weight:600;}
.dir-item{
  display:flex;align-items:center;gap:7px;font-size:12.6px;color:#33456b;
  padding:6px 9px;border-radius:8px;background:#f5f8ff;border:1px solid #e6eefc;margin-bottom:6px;
  text-decoration:none;
}
.dir-item:hover{border-color:#b9cdf5;}
.dir-item b{font-weight:600;color:#1b2b4b;}
.dir-item span{color:var(--muted);font-size:11.5px;}

/* ---------- 输入区 ---------- */
.composer{padding:10px 18px calc(12px + env(safe-area-inset-bottom));background:linear-gradient(180deg,rgba(244,246,251,0),var(--bg) 40%);}
.box{
  display:flex;align-items:flex-end;gap:9px;background:#fff;border:1px solid var(--line);
  border-radius:16px;padding:8px 8px 8px 14px;box-shadow:0 8px 24px rgba(28,52,105,.07);
  transition:.18s;
}
.box:focus-within{border-color:#b6cdf8;box-shadow:0 8px 26px rgba(37,99,235,.13);}
#input{
  flex:1 1 auto;border:none;outline:none;resize:none;font-family:inherit;font-size:14.6px;
  line-height:1.6;color:var(--ink);background:transparent;max-height:132px;padding:5px 0;
}
#input::placeholder{color:#a7b3c8;}
.send{
  flex:0 0 auto;width:40px;height:40px;border:none;border-radius:12px;color:#fff;cursor:pointer;
  background:linear-gradient(135deg,var(--brand),var(--brand2));display:grid;place-items:center;
  box-shadow:0 6px 14px rgba(37,99,235,.28);transition:.16s;
}
.send svg{width:19px;height:19px;transform:translateX(1px);}
.send:hover{filter:brightness(1.06);}
.send:active{transform:scale(.96);}
.send:disabled{opacity:.5;cursor:not-allowed;box-shadow:none;}
.tip{text-align:center;font-size:11.5px;color:var(--muted);margin-top:8px;}

/* ---------- 移动端 ---------- */
@media (max-width:640px){
  .topbar{padding:11px 13px;}
  .brand-txt h1{font-size:15px;}
  .brand-txt p{font-size:11.5px;}
  .chat{padding:16px 12px 6px;}
  .welcome{padding:22px 16px;border-radius:18px;}
  .welcome h2{font-size:17px;}
  .welcome p{font-size:13px;}
  .bubble{max-width:82%;font-size:14px;padding:11px 13px;}
  .composer{padding:8px 12px calc(10px + env(safe-area-inset-bottom));}
  .chips{gap:7px;}
  .chip{font-size:12.5px;padding:7px 11px;}
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0f1523;--bg2:#121a2c;--card:#18202f;--ink:#e8eefb;--ink2:#a8b6cd;--muted:#7d8ba3;
    --line:#26314a;--brand-soft:#1a2540;--shadow:0 10px 30px rgba(0,0,0,.32);
  }
  body{background:radial-gradient(900px 460px at 8% -10%,#17233d 0%,transparent 60%),var(--bg);}
  .topbar{background:rgba(19,26,41,.8);}
  .welcome{background:linear-gradient(180deg,#18212f,#151c29);}
  .bubble{background:#1a2333;}
  .msg.me .bubble{background:linear-gradient(135deg,#2b5bd7,#3b82f6);}
  .res-item{background:#151d2b;border-color:#243049;}
  .res-item:hover{background:#1a2436;border-color:#34507f;}
  .res-name{color:#dbe6f8;}
  .dir-item{background:#151d2b;border-color:#243049;color:#b8c7de;}
  .dir-item b{color:#dbe6f8;}
  .box{background:#18202f;}
  .status{background:#132a1e;border-color:#1f4632;}
}
