:root{
  --bg1:#f2f8ff; --bg2:#e3efff; --ink:#1b2b45; --muted:#7d90ad;
  --blue:#3f7fe8; --blue-soft:#d9e8ff; --card:#ffffff;
  --shadow:0 8px 24px rgba(38,86,168,.10);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;color:var(--ink);font:16px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #ffffff 0%, rgba(255,255,255,0) 60%),
    linear-gradient(180deg,var(--bg1),var(--bg2));
  overflow:hidden;
}
.hidden{display:none !important}

/* ---------- 登录 ---------- */
.login{position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:24px;text-align:center}
.login img{width:150px;height:150px;filter:drop-shadow(0 12px 20px rgba(60,120,220,.25))}
.login h1{margin:0;font-size:24px}
.login p{margin:0;color:var(--muted);font-size:14px}
.login input{width:min(320px,80vw);padding:14px 16px;border-radius:14px;border:1px solid #cfe0f8;background:#fff;font-size:16px;outline:none}
.login button{width:min(320px,80vw);padding:14px;border:0;border-radius:14px;background:var(--blue);color:#fff;font-size:16px;font-weight:600}
.login .hint{font-size:12px;color:#9db0c9}

/* ---------- 骨架 ---------- */
.app{height:100dvh;display:flex;flex-direction:column;max-width:720px;margin:0 auto}
.bar{
  display:flex;align-items:center;gap:10px;padding:calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background:rgba(255,255,255,.72);backdrop-filter:blur(14px);border-bottom:1px solid rgba(63,127,232,.10);
  position:sticky;top:0;z-index:5;
}
.avatar{width:44px;height:44px;border-radius:50%;background:#eaf3ff;display:grid;place-items:center;overflow:hidden;box-shadow:inset 0 0 0 2px #fff, 0 4px 10px rgba(63,127,232,.18)}
.avatar img{width:104%;height:104%;object-fit:cover;object-position:50% 12%;animation:bob 3.6s ease-in-out infinite}
@keyframes bob{0%,100%{transform:translateY(0) scale(1)}50%{transform:translateY(-1px) scale(1.02)}}
.avatar.happy{animation:hop .6s ease}
@keyframes hop{0%,100%{transform:translateY(0)}25%{transform:translateY(-7px)}55%{transform:translateY(0)}75%{transform:translateY(-3px)}}
.who{flex:1;min-width:0}
.name{font-weight:700;font-size:16px;letter-spacing:.3px}
.status{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--muted)}
.dot{width:6px;height:6px;border-radius:50%;background:#4ec98a;box-shadow:0 0 0 3px rgba(78,201,138,.18)}
.status.busy .dot{background:#f0a12e;box-shadow:0 0 0 3px rgba(240,161,46,.18)}
.icon-btn{border:0;background:transparent;color:#5a7398;padding:8px;border-radius:12px}
.icon-btn:active{background:#e7f1ff}

/* ---------- 聊天 ---------- */
.chat{flex:1;overflow-y:auto;padding:16px 14px 8px;display:flex;flex-direction:column;gap:10px;-webkit-overflow-scrolling:touch}

/* ---------- 顶部立绘 ---------- */
.hero{display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 0 14px}
.hero img{width:min(210px,52vw);height:auto;filter:drop-shadow(0 14px 22px rgba(40,80,160,.22));animation:heroFloat 5s ease-in-out infinite}
@keyframes heroFloat{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
.hero-name{font-size:15px;font-weight:700;margin-top:6px;letter-spacing:.5px}
.hero-sub{font-size:12px;color:#93a8c5}
.msg{display:flex;gap:8px;max-width:88%;animation:pop .22s ease-out}
@keyframes pop{from{opacity:0;transform:translateY(6px) scale(.98)}to{opacity:1;transform:none}}
.msg.fish{align-self:flex-start}
.msg.user{align-self:flex-end;flex-direction:row-reverse}
.bubble{padding:10px 14px;border-radius:18px;background:var(--card);box-shadow:var(--shadow);white-space:pre-wrap;word-break:break-word}
.msg.fish .bubble{border-bottom-left-radius:6px}
.msg.user .bubble{background:linear-gradient(180deg,#5f9bf0,#3f7fe8);color:#fff;border-bottom-right-radius:6px;box-shadow:0 8px 20px rgba(63,127,232,.28)}
.msg .face{width:30px;height:30px;flex:0 0 30px;border-radius:50%;background:#eaf3ff;overflow:hidden;display:grid;place-items:center;margin-top:2px}
.msg .face img{width:130%;height:130%;object-fit:contain;transform:translateY(8%)}
.time{align-self:center;font-size:11px;color:#a6b6cc;margin:6px 0}

.proactive-tag{font-size:11px;color:#93a8c5;margin-bottom:2px}

/* ---------- 正在输入 ---------- */
.typing{display:flex;align-items:center;gap:8px;padding:0 22px 4px;color:var(--muted);font-size:12px}
.typing img{width:22px;height:22px;border-radius:50%;background:#eaf3ff;padding:2px;animation:bob 1.2s ease-in-out infinite}
.dots{display:inline-flex;gap:3px}
.dots i{width:5px;height:5px;border-radius:50%;background:#a9c2e4;animation:blink 1.2s infinite}
.dots i:nth-child(2){animation-delay:.18s}
.dots i:nth-child(3){animation-delay:.36s}
@keyframes blink{0%,60%,100%{opacity:.3;transform:translateY(0)}30%{opacity:1;transform:translateY(-2px)}}

/* ---------- 输入区 ---------- */
.composer{
  display:flex;align-items:flex-end;gap:8px;padding:10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background:rgba(255,255,255,.8);backdrop-filter:blur(14px);border-top:1px solid rgba(63,127,232,.10);
}
.composer textarea{
  flex:1;resize:none;border:1px solid #d6e5fa;background:#f7fbff;border-radius:20px;
  padding:11px 16px;font:inherit;font-size:16px;max-height:120px;outline:none;color:var(--ink);
}
.composer textarea:focus{border-color:#a7c8f5;background:#fff}
.send{width:44px;height:44px;flex:0 0 44px;border:0;border-radius:50%;background:var(--blue);color:#fff;display:grid;place-items:center;box-shadow:0 8px 18px rgba(63,127,232,.32);transition:transform .12s}
.send:active{transform:scale(.92)}
.send[disabled]{opacity:.45;box-shadow:none}

/* ---------- 设置面板 ---------- */
.sheet{position:fixed;inset:0;background:rgba(20,40,70,.35);display:flex;align-items:flex-end;z-index:20;animation:fade .2s}
@keyframes fade{from{opacity:0}to{opacity:1}}
.sheet-card{
  width:100%;max-width:720px;margin:0 auto;background:#fff;border-radius:22px 22px 0 0;
  padding:20px 18px calc(env(safe-area-inset-bottom) + 18px);display:flex;flex-direction:column;gap:14px;
  max-height:86dvh;overflow-y:auto;animation:up .24s ease-out;
}
@keyframes up{from{transform:translateY(30px)}to{transform:none}}
.sheet-card h2{margin:0 0 4px;font-size:18px}
.sheet-card label{display:flex;flex-direction:column;gap:6px;font-size:13px;color:#546a8c}
.sheet-card label.row{flex-direction:row;align-items:center;justify-content:space-between;font-size:15px;color:var(--ink)}
.sheet-card input[type=text],.sheet-card textarea,.sheet-card select{
  border:1px solid #d6e5fa;border-radius:12px;padding:11px 13px;font:inherit;font-size:15px;background:#f8fbff;outline:none;color:var(--ink);
}
.sheet-card select{appearance:none;background-image:linear-gradient(45deg,transparent 50%,#7d90ad 50%),linear-gradient(135deg,#7d90ad 50%,transparent 50%);background-position:calc(100% - 18px) 50%,calc(100% - 13px) 50%;background-size:5px 5px,5px 5px;background-repeat:no-repeat}
.adv{margin-top:4px;border-top:1px dashed #e3ecf9;padding-top:10px}
.adv summary{cursor:pointer;font-size:13px;color:#7d90ad;padding:4px 0}
.adv textarea{margin-top:8px;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;line-height:1.6}
.adv .hint{margin:6px 0 0;font-size:11px;color:#9db0c9}
.sheet-card textarea{resize:vertical}
.switch{appearance:none;width:46px;height:28px;border-radius:14px;background:#d7e3f3;position:relative;transition:.2s}
.switch:checked{background:var(--blue)}
.switch::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;transition:.2s;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.switch:checked::after{left:21px}
.sheet-actions{display:flex;gap:10px;margin-top:4px}
.sheet-actions button{flex:1;padding:13px;border-radius:14px;border:0;background:var(--blue);color:#fff;font-size:16px;font-weight:600}
.sheet-actions .ghost,button.ghost{background:#eef4fd;color:#3f5f8c}
.sheet-card button.ghost{padding:10px 16px;border-radius:12px;border:0;font-size:14px}

.toast{
  position:fixed;left:50%;bottom:calc(env(safe-area-inset-bottom) + 88px);transform:translateX(-50%);
  background:rgba(27,43,69,.92);color:#fff;padding:10px 16px;border-radius:12px;font-size:13px;z-index:30;
  animation:pop .2s;max-width:86vw;text-align:center;
}
