:root{
  --bg:#f2f3f5;
  --panel:#ffffff;
  --line:#e6e8eb;
  --text:#111827;
  --muted:#8a9199;
  --brand:#2f6fed;
  --brand-weak:#e8f0ff;
  --mine:#95ec69;
  --danger:#e5484d;
  --ok:#12a150;
  --radius:12px;
  --safe-b:env(safe-area-inset-bottom,0px);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;background:var(--bg);color:var(--text);
  font:15px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Helvetica Neue","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  overscroll-behavior-y:none;
}
button{font:inherit;color:inherit;border:0;background:none;cursor:pointer}
input,textarea{font:inherit;color:inherit}
a{color:var(--brand);text-decoration:none}
.hide{display:none!important}

/* ---------- 通用 ---------- */
.page{display:flex;flex-direction:column;height:100vh;height:100dvh}
.nav{
  flex:none;height:48px;display:flex;align-items:center;gap:8px;padding:0 12px;
  background:var(--panel);border-bottom:1px solid var(--line);position:relative;z-index:10;
}
.nav .title{flex:1;font-size:16px;font-weight:600;text-align:center;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.nav .side{min-width:56px;display:flex;align-items:center;gap:6px}
.nav .side.right{justify-content:flex-end}
.iconbtn{width:32px;height:32px;border-radius:8px;display:grid;place-items:center;font-size:17px;color:var(--text)}
.iconbtn:active{background:#f0f1f3}
.body{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}

.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  height:44px;padding:0 18px;border-radius:10px;background:var(--brand);color:#fff;
  font-weight:600;font-size:16px;width:100%;
}
.btn:active{opacity:.85}
.btn[disabled]{opacity:.45}
.btn.ghost{background:#eef0f3;color:var(--text)}
.btn.danger{background:#fff;color:var(--danger);border:1px solid #f3c9ca}
.btn.sm{height:34px;font-size:14px;padding:0 12px;width:auto;border-radius:8px}

.field{margin-bottom:14px}
.field label{display:block;font-size:13px;color:var(--muted);margin-bottom:6px}
.field input,.field textarea{
  width:100%;border:1px solid var(--line);background:var(--panel);border-radius:10px;
  padding:12px 14px;font-size:16px;outline:none;
}
.field input:focus,.field textarea:focus{border-color:var(--brand)}
.field textarea{min-height:84px;resize:none}
.hint{font-size:12px;color:var(--muted);margin-top:6px}
.err{color:var(--danger);font-size:13px;min-height:18px;margin:4px 0 10px}

/* ---------- 登录 ---------- */
#login{justify-content:center;padding:0 26px;background:var(--panel)}
#login .brand{text-align:center;margin-bottom:34px}
#login .logo{
  width:64px;height:64px;border-radius:18px;background:var(--brand-weak);color:var(--brand);
  display:grid;place-items:center;font-size:30px;margin:0 auto 14px;
}
#login h1{font-size:21px;margin:0 0 6px}
#login p{color:var(--muted);font-size:13px;margin:0}

/* ---------- 会话列表 ---------- */
#list .body{background:var(--panel)}
.conv{
  display:flex;gap:12px;padding:12px 14px;align-items:center;border-bottom:1px solid #f2f3f5;
}
.conv:active{background:#f7f8fa}
.avatar{
  flex:none;width:46px;height:46px;border-radius:10px;background:var(--brand-weak);color:var(--brand);
  display:grid;place-items:center;font-weight:600;font-size:17px;overflow:hidden;
}
.avatar img{width:100%;height:100%;object-fit:cover}
.conv .meta{flex:1;min-width:0}
.conv .name{font-size:16px;font-weight:500;margin-bottom:3px}
.conv .last{font-size:13px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.badge{
  flex:none;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--danger);color:#fff;
  font-size:11px;display:grid;place-items:center;font-weight:600;
}
.empty{padding:60px 20px;text-align:center;color:var(--muted);font-size:14px}

/* ---------- 聊天 ---------- */
#chat .body{background:var(--bg);padding:10px 12px 16px}
.sys{text-align:center;margin:10px 0}
.sys span{
  display:inline-block;background:#dadde0;color:#fff;font-size:12px;
  padding:3px 8px;border-radius:6px;max-width:80%;
}
.msg{display:flex;gap:8px;margin:14px 0;align-items:flex-start}
.msg.mine{flex-direction:row-reverse}
.msg .avatar{width:38px;height:38px;border-radius:8px;font-size:15px}
.msg .main{max-width:72%;display:flex;flex-direction:column;gap:3px}
.msg.mine .main{align-items:flex-end}
.msg .who{font-size:12px;color:var(--muted);padding:0 2px}
.bubble{
  background:var(--panel);padding:9px 12px;border-radius:10px;word-break:break-word;white-space:pre-wrap;
  font-size:15px;line-height:1.45;box-shadow:0 1px 1px rgba(0,0,0,.03);
}
.msg.mine .bubble{background:var(--mine)}
.bubble img{display:block;max-width:200px;border-radius:8px}

.chatbar{
  flex:none;display:flex;gap:8px;align-items:flex-end;padding:8px 10px calc(8px + var(--safe-b));
  background:var(--panel);border-top:1px solid var(--line);
}
.chatbar .plus{flex:none;width:36px;height:36px;border-radius:50%;background:#f0f1f3;display:grid;place-items:center;font-size:20px;color:#555}
.chatbar textarea{
  flex:1;border:1px solid var(--line);border-radius:10px;padding:9px 12px;max-height:110px;
  min-height:38px;outline:none;resize:none;font-size:15px;background:var(--panel);
}
.chatbar .send{flex:none;height:36px;padding:0 14px;border-radius:8px;background:var(--brand);color:#fff;font-size:14px;font-weight:600}
.chatbar .send[disabled]{opacity:.4}

/* 接龙卡片 */
.chaincard{
  background:var(--panel);border-radius:12px;padding:13px 14px;min-width:230px;max-width:270px;
  box-shadow:0 1px 3px rgba(0,0,0,.05);border:1px solid var(--line);
}
.chaincard .cc-top{display:flex;align-items:center;gap:6px;margin-bottom:8px}
.chaincard .cc-tag{background:var(--brand-weak);color:var(--brand);font-size:11px;font-weight:600;padding:2px 6px;border-radius:4px}
.chaincard .cc-title{font-size:15px;font-weight:600;line-height:1.35;margin-bottom:8px;word-break:break-word}
.chaincard .cc-row{font-size:13px;color:var(--muted);display:flex;justify-content:space-between;margin-top:4px}
.chaincard .cc-row b{color:var(--text);font-weight:600}
.chaincard .cc-go{
  margin-top:10px;width:100%;height:34px;border-radius:8px;background:var(--brand);color:#fff;
  font-size:14px;font-weight:600;
}
.chaincard .cc-go.done{background:var(--brand-weak);color:var(--brand)}

/* ---------- 接龙详情 ---------- */
#chain .body{padding:12px 12px 90px}
.card{background:var(--panel);border-radius:var(--radius);padding:16px;margin-bottom:12px}
.card h2{font-size:17px;margin:0 0 10px;line-height:1.4}
.card .note{color:#4b5563;font-size:14px;white-space:pre-wrap;margin-bottom:12px}
.stat{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.stat .item{background:#f7f8fa;border-radius:8px;padding:8px 10px;min-width:78px}
.stat .item i{display:block;font-size:11px;color:var(--muted);font-style:normal;margin-bottom:2px}
.stat .item b{font-size:15px}
.entries{margin-top:4px}
.entry{display:flex;gap:10px;padding:10px 0;border-bottom:1px solid #f2f3f5;align-items:flex-start}
.entry:last-child{border-bottom:0}
.entry .no{
  flex:none;width:24px;height:24px;border-radius:6px;background:var(--brand-weak);color:var(--brand);
  font-size:12px;font-weight:700;display:grid;place-items:center;margin-top:1px;
}
.entry .who{flex:1;min-width:0}
.entry .who .n{font-size:14px;font-weight:500}
.entry .who .c{font-size:13px;color:var(--muted);word-break:break-word;margin-top:2px}
.entry .paid{flex:none;white-space:nowrap;font-size:11px;line-height:18px;padding:1px 7px;border-radius:4px;background:#e8f7ee;color:var(--ok)}
.entry .paid.no{background:#fff1f1;color:var(--danger)}
.entry.cancelled{opacity:.45}
.entry.cancelled .n{text-decoration:line-through}
.footbar{
  position:fixed;left:0;right:0;bottom:0;padding:10px 12px calc(10px + var(--safe-b));
  background:var(--panel);border-top:1px solid var(--line);display:flex;gap:10px;z-index:20;
}
.footbar .btn{flex:1}

/* ---------- 我的 ---------- */
#me .body{padding:12px}
.profile{display:flex;gap:14px;align-items:center;background:var(--panel);border-radius:var(--radius);padding:18px 16px;margin-bottom:12px}
.profile .avatar{width:56px;height:56px;border-radius:12px;font-size:20px}
.profile .p-name{font-size:17px;font-weight:600}
.profile .p-sub{font-size:13px;color:var(--muted);margin-top:2px}
.list-item{display:flex;justify-content:space-between;align-items:center;background:var(--panel);padding:14px 16px;border-bottom:1px solid #f4f5f7;font-size:15px}
.list-item:first-child{border-radius:var(--radius) var(--radius) 0 0}
.list-item:last-child{border-bottom:0;border-radius:0 0 var(--radius) var(--radius)}
.list-item .v{color:var(--muted);font-size:14px}

/* ---------- 弹层 ---------- */
.sheet-mask{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:50;display:flex;align-items:flex-end}
.sheet{background:var(--panel);width:100%;border-radius:14px 14px 0 0;padding:18px 16px calc(18px + var(--safe-b));max-height:88vh;overflow-y:auto}
.sheet h3{margin:0 0 14px;font-size:16px;text-align:center}
.sheet .row2{display:flex;gap:10px}
.sheet .row2>*{flex:1}
.sheet .actions{display:flex;gap:10px;margin-top:8px}
.sheet .actions .btn{flex:1}
.qtybox{display:flex;align-items:center;gap:0;border:1px solid #e6e8eb;border-radius:10px;overflow:hidden;background:#fff}
.qtybox .qbtn{width:52px;height:48px;font-size:22px;line-height:1;color:#2f6fed;background:#f7f8fa;flex:0 0 52px}
.qtybox .qbtn:active{background:#eef0f3}
.qtybox input{flex:1;width:100%;height:48px;border:0;text-align:center;font-size:18px;font-weight:600;outline:none;-moz-appearance:textfield}
.qtybox input::-webkit-outer-spin-button,.qtybox input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}
.sheet .hint{margin:-6px 0 12px;font-size:13px;color:#8a9199}
.toast{
  position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);background:rgba(0,0,0,.78);color:#fff;
  padding:11px 18px;border-radius:10px;font-size:14px;z-index:99;max-width:76vw;text-align:center;
}
.spin{display:inline-block;width:15px;height:15px;border:2px solid rgba(255,255,255,.35);border-top-color:#fff;border-radius:50%;animation:sp .7s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
.newmsg{position:fixed;right:14px;bottom:70px;background:var(--brand);color:#fff;font-size:12px;padding:6px 12px;border-radius:16px;z-index:30;box-shadow:0 2px 8px rgba(0,0,0,.18)}

/* ---------- 电脑上打开：收成手机宽度，居中 ---------- */
@media (min-width:720px){
  body{background:#e9ebef}
  .page{
    max-width:480px;margin:0 auto;background:var(--bg);
    box-shadow:0 0 0 1px var(--line),0 8px 30px rgba(0,0,0,.06);
  }
  .footbar{left:50%;right:auto;width:100%;max-width:480px;transform:translateX(-50%)}
  .newmsg{right:calc(50% - 240px + 14px)}
  .sheet-mask{justify-content:center}
  .sheet{max-width:480px;border-radius:14px;margin-bottom:0}
  #login .body{display:flex;flex-direction:column;justify-content:center}
}
