:root{
  --bg:#0a0f1c;
  --bg2:#0e1628;
  --panel:#111c33;
  --panel2:#162340;
  --line:rgba(148,180,255,.14);
  --text:#e9f0ff;
  --muted:#8ea3c7;
  --accent:#5eead4;
  --accent2:#7c9cff;
  --user1:#1d4ed8;
  --user2:#0891b2;
  --danger:#fb7185;
  --shadow:0 18px 50px rgba(0,0,0,.35);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
[hidden]{display:none!important}
html,body{height:100%}
body{
  margin:0;background:
    radial-gradient(900px 500px at 15% -10%,rgba(124,156,255,.18),transparent 60%),
    radial-gradient(700px 420px at 95% 0%,rgba(94,234,212,.12),transparent 55%),
    var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  font-size:16px;line-height:1.6;
  overflow:hidden;
}
button,input,textarea{font:inherit;color:inherit}
button{border:0;background:none;cursor:pointer}
a{color:var(--accent);text-decoration:none}
.app{height:100dvh;display:flex;flex-direction:column;max-width:560px;margin:0 auto;position:relative}
.topbar{
  flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:10px;
  padding:calc(12px + env(safe-area-inset-top)) 16px 12px;
  background:rgba(10,15,28,.72);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);
  border-bottom:1px solid var(--line);z-index:5;
}
.brand{display:flex;align-items:center;gap:10px;min-width:0}
.logo{
  width:38px;height:38px;border-radius:13px;display:grid;place-items:center;flex:0 0 auto;
  background:linear-gradient(145deg,rgba(94,234,212,.22),rgba(124,156,255,.25));
  border:1px solid rgba(94,234,212,.35);color:var(--accent);font-weight:800;font-size:19px;
  box-shadow:0 0 24px rgba(94,234,212,.12);
}
.brand h1{font-size:16px;line-height:1.2;margin:0;font-weight:700;letter-spacing:.3px}
.ctx{margin:2px 0 0;font-size:11.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.ctx b{color:var(--accent);font-weight:600}
.actions{display:flex;align-items:center;gap:8px;flex:0 0 auto}
.icon-btn{
  width:36px;height:36px;border-radius:12px;display:grid;place-items:center;
  background:rgba(255,255,255,.04);border:1px solid var(--line);color:var(--muted);
}
.icon-btn svg{width:18px;height:18px}
.icon-btn[hidden]{display:none!important}
.new-btn{
  height:36px;padding:0 13px;border-radius:12px;font-size:13px;font-weight:700;color:#04221f;
  background:linear-gradient(135deg,#5eead4,#7dd3fc);box-shadow:0 6px 18px rgba(94,234,212,.22);
}
.new-btn:active{transform:scale(.97)}
.chat{
  flex:1 1 auto;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:18px 14px 22px;scroll-behavior:smooth;
}
.welcome{
  margin:8vh auto 0;max-width:420px;text-align:center;padding:0 8px;
}
.welcome .big{
  width:68px;height:68px;margin:0 auto 16px;border-radius:22px;display:grid;place-items:center;
  background:linear-gradient(145deg,rgba(94,234,212,.16),rgba(124,156,255,.18));
  border:1px solid rgba(94,234,212,.28);font-size:30px;color:var(--accent);
}
.welcome h2{font-size:19px;margin:0 0 8px;letter-spacing:.2px}
.welcome p{color:var(--muted);font-size:13.5px;margin:0 auto 22px;max-width:320px}
.chips{display:flex;flex-wrap:wrap;gap:9px;justify-content:center}
.chip{
  padding:9px 13px;border-radius:999px;background:rgba(255,255,255,.045);
  border:1px solid var(--line);color:#cfe0ff;font-size:12.5px;
}
.chip:active{background:rgba(94,234,212,.12)}
.msg{display:flex;margin:0 0 16px;animation:in .18s ease-out}
@keyframes in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.msg.user{justify-content:flex-end}
.msg.assistant{justify-content:flex-start}
.bubble{
  max-width:86%;border-radius:18px;padding:11px 13px 9px;position:relative;
  border:1px solid var(--line);box-shadow:0 8px 24px rgba(0,0,0,.14);
  overflow-wrap:anywhere;
}
.msg.user .bubble{
  background:linear-gradient(155deg,var(--user1),var(--user2));border-color:rgba(125,211,252,.3);
  border-bottom-right-radius:6px;
}
.msg.assistant .bubble{
  background:linear-gradient(180deg,rgba(22,35,64,.96),rgba(17,28,51,.96));
  border-bottom-left-radius:6px;max-width:92%;
}
.bubble .text{font-size:15px;line-height:1.68;white-space:normal}
.bubble .text p{margin:0 0 8px}
.bubble .text p:last-child{margin-bottom:0}
.bubble .text code{
  background:rgba(0,0,0,.28);border-radius:5px;padding:1px 5px;font-size:13px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
.bubble .text pre{
  background:#08101f;border:1px solid rgba(148,180,255,.14);border-radius:10px;
  padding:10px 11px;overflow-x:auto;margin:8px 0;max-width:100%;
}
.bubble .text pre code{background:none;padding:0;font-size:12.5px;line-height:1.55}
.bubble .text strong{color:#fff}
.bubble .text em{font-style:italic;color:#f4f8ff}
.bubble .text h1,.bubble .text h2,.bubble .text h3,.bubble .text h4{
  margin:12px 0 6px;line-height:1.35;font-weight:700;color:#fff;
}
.bubble .text h1{font-size:19px}
.bubble .text h2{font-size:17px}
.bubble .text h3{font-size:15.5px}
.bubble .text h4{font-size:14.5px;color:#dbe7ff}
.bubble .text h1:first-child,.bubble .text h2:first-child,.bubble .text h3:first-child{margin-top:0}
.bubble .text ul,.bubble .text ol{margin:6px 0 8px;padding-left:1.45em}
.bubble .text li{margin:2px 0}
.bubble .text li>p{margin:0 0 4px}
.bubble .text blockquote{
  margin:8px 0;padding:5px 0 5px 10px;border-left:3px solid rgba(94,234,212,.45);
  color:#c6d6ef;background:rgba(94,234,212,.055);border-radius:0 8px 8px 0;
}
.bubble .text blockquote p:last-child{margin-bottom:0}
.bubble .text a{color:#7dd3fc;text-decoration:underline;text-underline-offset:2px}
.bubble .text hr{border:0;border-top:1px solid rgba(148,180,255,.18);margin:12px 0}
.bubble .text .table-wrap{overflow-x:auto;max-width:100%;margin:8px 0}
.bubble .text table{border-collapse:collapse;width:100%;font-size:13px;line-height:1.5}
.bubble .text th,.bubble .text td{border:1px solid rgba(148,180,255,.18);padding:5px 7px;text-align:left;vertical-align:top}
.bubble .text th{background:rgba(124,156,255,.12);color:#fff;font-weight:600}
.bubble .text tr:nth-child(even) td{background:rgba(255,255,255,.025)}
.bubble .text .katex{font-size:1.08em}
.bubble .text .katex-display{
  margin:10px 0;padding:2px 0;overflow-x:auto;overflow-y:hidden;
  max-width:100%;-webkit-overflow-scrolling:touch;
}
.bubble .text .katex-display>.katex{white-space:nowrap}
.bubble .text .katex-error{color:#fb7185;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12.5px}

.imgs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:2px 0 7px}
.imgs img{width:100%;aspect-ratio:1/1;object-fit:cover;border-radius:11px;border:1px solid rgba(255,255,255,.16)}
.meta{
  display:flex;align-items:center;gap:6px;flex-wrap:wrap;
  font-size:10.5px;color:rgba(233,240,255,.62);margin-top:6px;letter-spacing:.1px;
}
.msg.user .meta{color:rgba(255,255,255,.72)}
.meta .dot{width:3px;height:3px;border-radius:50%;background:currentColor;opacity:.55}
.meta .money{color:var(--accent)}
.msg.user .meta .money{color:#d9fffa}
details.think{margin-top:8px;border-top:1px dashed rgba(148,180,255,.18);padding-top:7px}
details.think summary{cursor:pointer;font-size:11.5px;color:var(--muted);list-style:none}
details.think summary::-webkit-details-marker{display:none}
details.think .reason{font-size:12.5px;color:#9fb2d4;line-height:1.6;margin-top:6px;white-space:pre-wrap}
.typing{display:flex;gap:4px;align-items:center;height:16px;padding:2px 2px 0}
.typing i{width:5px;height:5px;border-radius:50%;background:var(--accent);opacity:.35;animation:b 1.1s infinite}
.typing i:nth-child(2){animation-delay:.15s}.typing i:nth-child(3){animation-delay:.3s}
@keyframes b{0%,80%,100%{transform:translateY(0);opacity:.3}40%{transform:translateY(-4px);opacity:1}}
.composer{
  flex:0 0 auto;padding:8px 12px calc(10px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg,rgba(10,15,28,.2),rgba(10,15,28,.92) 28%);
  border-top:1px solid transparent;
}
.previews{display:flex;gap:8px;padding:0 2px 8px;overflow-x:auto}
.composer-tools{display:flex;align-items:center;gap:8px;padding:0 4px 7px}
.think-toggle{
  display:inline-flex;align-items:center;gap:5px;height:28px;padding:0 10px;border-radius:999px;
  border:1px solid var(--line);background:rgba(255,255,255,.04);color:var(--muted);
  font-size:11.5px;font-weight:600;white-space:nowrap;
}
.think-toggle .spark{font-size:12px;color:#8ea3c7;line-height:1}
.think-toggle.on{
  background:rgba(124,156,255,.16);border-color:rgba(124,156,255,.45);color:#dbe7ff;
  box-shadow:0 0 16px rgba(124,156,255,.12);
}
.think-toggle.on .spark{color:#a5b8ff}
.think-note{font-size:10.5px;color:#5f7394}
.preview{position:relative;flex:0 0 auto}
.preview img{width:58px;height:58px;object-fit:cover;border-radius:11px;border:1px solid var(--line)}
.preview button{
  position:absolute;top:-6px;right:-6px;width:20px;height:20px;border-radius:50%;
  background:#111b2f;border:1px solid var(--line);color:#fff;font-size:12px;display:grid;place-items:center;
}
.input-row{
  display:flex;align-items:flex-end;gap:8px;padding:6px;
  background:rgba(17,28,51,.92);border:1px solid var(--line);border-radius:20px;
  box-shadow:var(--shadow);
}
.attach{
  width:38px;height:38px;flex:0 0 auto;border-radius:13px;display:grid;place-items:center;
  color:var(--muted);font-size:24px;font-weight:300;
}
.attach:active{background:rgba(94,234,212,.1);color:var(--accent)}
#text{
  flex:1 1 auto;resize:none;border:0;outline:0;background:transparent;
  padding:8px 2px;max-height:132px;min-height:38px;font-size:15.5px;line-height:1.45;
}
#text::placeholder{color:#6e84a7}
.send{
  width:38px;height:38px;flex:0 0 auto;border-radius:13px;display:grid;place-items:center;
  background:linear-gradient(135deg,#5eead4,#7dd3fc);color:#04221f;font-size:19px;font-weight:800;
  box-shadow:0 6px 16px rgba(94,234,212,.2);transition:opacity .15s,transform .1s;
}
.send:disabled{opacity:.35;box-shadow:none}
.send:active:not(:disabled){transform:scale(.94)}
.hint{text-align:center;font-size:10.5px;color:#5f7394;margin:7px 0 0}
.toast{
  position:fixed;left:50%;bottom:calc(92px + env(safe-area-inset-bottom));transform:translate(-50%,10px);
  background:#111b2f;border:1px solid var(--line);color:#e9f0ff;padding:9px 14px;border-radius:12px;
  font-size:12.5px;opacity:0;pointer-events:none;transition:.2s;z-index:20;max-width:86vw;text-align:center;
  box-shadow:var(--shadow);
}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ---------- login ---------- */
.center-page{
  min-height:100dvh;display:flex;align-items:center;justify-content:center;padding:24px 20px;
}
.card{
  width:100%;max-width:400px;background:linear-gradient(180deg,rgba(22,35,64,.92),rgba(17,28,51,.96));
  border:1px solid var(--line);border-radius:24px;padding:26px 22px 22px;box-shadow:var(--shadow);
  backdrop-filter:blur(16px);
}
.login-logo{
  width:58px;height:58px;border-radius:18px;display:grid;place-items:center;margin:0 auto 14px;
  background:linear-gradient(145deg,rgba(94,234,212,.2),rgba(124,156,255,.22));
  border:1px solid rgba(94,234,212,.32);font-size:26px;color:var(--accent);
}
.card h1{font-size:21px;text-align:center;margin:0 0 6px;letter-spacing:.5px}
.card .sub{text-align:center;color:var(--muted);font-size:13px;margin:0 0 20px}
.account{
  display:flex;align-items:center;justify-content:space-between;gap:8px;padding:11px 13px;
  background:rgba(255,255,255,.04);border:1px solid var(--line);border-radius:13px;margin-bottom:14px;
}
.account span{font-size:11px;color:var(--muted)}
.account b{font-size:13.5px;font-weight:600;color:#dbe7ff;overflow:hidden;text-overflow:ellipsis}
.field{display:flex;gap:8px;margin-bottom:12px}
.field input{
  flex:1;min-width:0;background:rgba(0,0,0,.16);border:1px solid var(--line);border-radius:13px;
  padding:12px 13px;outline:0;font-size:15px;letter-spacing:2px;
}
.field input:focus{border-color:rgba(94,234,212,.45)}
.field input::placeholder{letter-spacing:0;color:#6e84a7}
.code-btn{
  flex:0 0 auto;padding:0 14px;border-radius:13px;background:rgba(94,234,212,.1);
  border:1px solid rgba(94,234,212,.3);color:var(--accent);font-size:12.5px;font-weight:600;white-space:nowrap;
}
.code-btn:disabled{color:#6e84a7;border-color:var(--line);background:rgba(255,255,255,.03)}
.primary{
  width:100%;padding:13px;border-radius:14px;background:linear-gradient(135deg,#5eead4,#7dd3fc);
  color:#04221f;font-weight:800;font-size:15px;letter-spacing:.5px;margin-top:4px;
}
.primary:disabled{opacity:.4}
.notice{font-size:11.5px;color:#6e84a7;text-align:center;margin:14px 0 0;line-height:1.6}
.error{font-size:12.5px;color:var(--danger);text-align:center;min-height:18px;margin:8px 0 0}

/* ---------- me ---------- */
.me-page{
  height:100dvh;overflow-y:auto;padding:calc(14px + env(safe-area-inset-top)) 16px calc(26px + env(safe-area-inset-bottom));
  max-width:560px;margin:0 auto;
}
.nav{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}
.nav a{color:var(--muted);font-size:13px;display:flex;align-items:center;gap:6px}
.nav h1{font-size:16px;margin:0;font-weight:700}
.hero{
  background:linear-gradient(150deg,rgba(94,234,212,.14),rgba(124,156,255,.16));
  border:1px solid rgba(94,234,212,.22);border-radius:24px;padding:22px 20px;margin-bottom:14px;
  position:relative;overflow:hidden;
}
.hero:after{content:"";position:absolute;width:180px;height:180px;border-radius:50%;
  background:rgba(94,234,212,.12);right:-70px;top:-90px;filter:blur(10px)}
.hero .label{font-size:12px;color:var(--muted);letter-spacing:.4px}
.hero .cost{font-size:34px;font-weight:800;letter-spacing:-.5px;margin:4px 0 2px;color:#fff}
.hero .cost small{font-size:15px;color:var(--accent);font-weight:600;margin-left:4px}
.hero .tokens{font-size:13px;color:#c8d7f4}
.hero .tokens b{color:#fff}
.grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:14px}
.stat{
  background:rgba(17,28,51,.85);border:1px solid var(--line);border-radius:18px;padding:14px 15px;
}
.stat .k{font-size:11.5px;color:var(--muted);margin-bottom:4px}
.stat .v{font-size:19px;font-weight:700;color:#eaf2ff}
.stat .v small{font-size:11px;color:var(--muted);font-weight:500;margin-left:2px}
.panel{background:rgba(17,28,51,.72);border:1px solid var(--line);border-radius:20px;padding:16px;margin-bottom:14px}
.panel h2{font-size:13px;margin:0 0 12px;color:#cddcf5;font-weight:600;letter-spacing:.3px}
.day{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:9px 0;border-bottom:1px solid rgba(148,180,255,.08);font-size:12.5px}
.day:last-child{border-bottom:0}
.day .d{color:var(--muted);flex:0 0 74px}
.day .bar{flex:1;height:5px;border-radius:99px;background:rgba(255,255,255,.06);overflow:hidden}
.day .bar i{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,#5eead4,#7c9cff)}
.day .m{flex:0 0 84px;text-align:right;color:#dbe7ff}
.day .m small{color:var(--muted)}
.logout{width:100%;padding:13px;border-radius:15px;background:rgba(251,113,133,.08);
  border:1px solid rgba(251,113,133,.22);color:#fda4af;font-size:13.5px;margin-top:6px}
.empty{text-align:center;color:var(--muted);font-size:12.5px;padding:14px 0}
@media (min-width:640px){
  body{background:radial-gradient(900px 500px at 50% -10%,rgba(124,156,255,.16),transparent 60%),#070b14}
  .app{border-left:1px solid rgba(148,180,255,.08);border-right:1px solid rgba(148,180,255,.08)}
}
