/* ---------------------------------------------------------
   DeepSeek Mobile (unlimited) — styles
   --------------------------------------------------------- */
:root{
  --blue:#4d6bfe;
  --blue-600:#3d59e8;
  --blue-soft:#eef2ff;
  --bg:#ffffff;
  --bg-2:#f7f8fa;
  --surface:#ffffff;
  --text:#1d1e22;
  --text-2:#5d6169;
  --text-3:#9aa0a6;
  --line:#ebecf0;
  --bubble:#eef2ff;
  --code-bg:#f5f6f9;
  --danger:#e5484d;
  --shadow:0 10px 34px rgba(18,28,70,.12);
  --fs:16px;
  --sb:288px;
  color-scheme: light;
}
:root[data-theme="dark"]{
  --blue:#6b85ff;
  --blue-600:#5a74f0;
  --blue-soft:#232a44;
  --bg:#0f1013;
  --bg-2:#16171b;
  --surface:#1a1b20;
  --text:#e9eaee;
  --text-2:#a9adb6;
  --text-3:#767b85;
  --line:#2a2c33;
  --bubble:#242b45;
  --code-bg:#1f2127;
  --danger:#ff6b6b;
  --shadow:0 12px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark){
  :root[data-theme="auto"]{
    --blue:#6b85ff; --blue-600:#5a74f0; --blue-soft:#232a44;
    --bg:#0f1013; --bg-2:#16171b; --surface:#1a1b20;
    --text:#e9eaee; --text-2:#a9adb6; --text-3:#767b85;
    --line:#2a2c33; --bubble:#242b45; --code-bg:#1f2127;
    --danger:#ff6b6b; --shadow:0 12px 40px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"PingFang TC","PingFang SC","Noto Sans TC","Microsoft JhengHei","Segoe UI",Roboto,sans-serif;
  background:var(--bg); color:var(--text);
  font-size:var(--fs);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
}
button{ font:inherit; color:inherit; background:none; border:0; padding:0; cursor:pointer; }
svg.i{ width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; display:block; }

.app{ display:flex; height:100dvh; }

/* ---------------- sidebar ---------------- */
.sidebar{
  position:fixed; top:0; bottom:0; left:0; width:var(--sb); z-index:41;
  background:var(--bg-2);
  border-right:1px solid var(--line);
  display:flex; flex-direction:column;
  transform:translateX(-102%);
  transition:transform .28s cubic-bezier(.4,0,.2,1);
  padding-top:env(safe-area-inset-top);
}
body.sb-open .sidebar{ transform:none; box-shadow:var(--shadow); }
.scrim{
  position:fixed; inset:0; z-index:40; background:rgba(10,12,20,.38);
  opacity:0; pointer-events:none; transition:opacity .25s;
  backdrop-filter:blur(1px);
}
body.sb-open .scrim{ opacity:1; pointer-events:auto; }

.sb-head{ display:flex; align-items:center; justify-content:space-between; padding:14px 12px 8px 16px; }
.brand{ display:flex; align-items:center; gap:8px; }
.brand-name{ font-weight:650; letter-spacing:.2px; }
.brand-tag{ font-size:13px; line-height:1; color:var(--blue); background:var(--blue-soft); border-radius:7px; padding:4px 7px; font-weight:700; }
.logo{
  width:30px; height:30px; border-radius:9px; display:grid; place-items:center;
  background:linear-gradient(140deg,#6d8bff,#3f59e0); color:#fff; font-weight:700; font-size:15px;
  box-shadow:0 3px 10px rgba(77,107,254,.35);
}
.logo.sm{ width:26px; height:26px; border-radius:8px; font-size:13px; }
.sb-close{ display:none; }

.new-chat{
  margin:8px 12px 10px; display:flex; align-items:center; justify-content:center; gap:8px;
  height:42px; border-radius:12px; background:var(--surface); border:1px solid var(--line);
  font-weight:600; font-size:14.5px; color:var(--text);
  transition:background .15s, border-color .15s;
}
.new-chat:active{ background:var(--blue-soft); border-color:var(--blue); }
.new-chat svg{ width:18px; height:18px; }

.sb-label{ font-size:11.5px; color:var(--text-3); padding:6px 18px 4px; letter-spacing:.06em; }
.sb-list{ flex:1; overflow-y:auto; padding:2px 8px 10px; overscroll-behavior:contain; }
.sb-item{
  display:block; width:100%; text-align:left; padding:9px 10px; border-radius:10px; margin-bottom:2px;
  transition:background .15s;
}
.sb-item:active{ background:rgba(125,135,160,.12); }
.sb-item.active{ background:var(--blue-soft); }
.sb-item .t{ font-size:14px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.sb-item .m{ font-size:12px; color:var(--text-3); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.sb-empty{ font-size:13px; color:var(--text-3); padding:10px 12px; }

.sb-foot{ border-top:1px solid var(--line); padding:8px 8px calc(10px + env(safe-area-inset-bottom)); }
.sb-row{ display:flex; align-items:center; gap:10px; width:100%; padding:9px 10px; border-radius:10px; font-size:14px; color:var(--text-2); }
.sb-row:active{ background:rgba(125,135,160,.12); }
.sb-user{ display:flex; align-items:center; gap:10px; padding:10px 10px 4px; }
.avatar{
  width:32px; height:32px; border-radius:50%; display:grid; place-items:center; flex:none;
  background:linear-gradient(140deg,#ff9a76,#ff5f6d); color:#fff; font-size:13px; font-weight:600;
}
.sb-user-txt .n{ font-size:13.5px; font-weight:600; }
.sb-user-txt .s{ font-size:11.5px; color:var(--text-3); }

/* ---------------- main ---------------- */
.main{ flex:1; display:flex; flex-direction:column; min-width:0; min-height:0; position:relative; height:100dvh; overflow:hidden; }

.topbar{
  display:flex; align-items:center; gap:6px; padding:calc(6px + env(safe-area-inset-top)) 8px 6px;
  min-height:52px; background:color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter:saturate(1.4) blur(14px);
  border-bottom:1px solid transparent; z-index:20;
}
.icon-btn{
  width:38px; height:38px; border-radius:11px; display:grid; place-items:center; color:var(--text-2);
  transition:background .15s, color .15s; flex:none;
}
.icon-btn:active{ background:rgba(125,135,160,.14); color:var(--text); }
.topbar-mid{ flex:1; min-width:0; text-align:center; }
.topbar-title{ font-size:15px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar-sub{ font-size:11.5px; color:var(--text-3); margin-top:1px; }

.chat{
  flex:1; min-height:0; overflow-y:auto; overflow-x:hidden;
  padding:14px 0 8px; overscroll-behavior:contain; scroll-behavior:smooth;
  -webkit-overflow-scrolling:touch;
}
.chat::-webkit-scrollbar{ width:6px; }
.chat::-webkit-scrollbar-thumb{ background:rgba(130,140,160,.28); border-radius:6px; }

/* ---------------- welcome ---------------- */
.welcome{ max-width:560px; margin:0 auto; padding:9vh 26px 20px; text-align:center; }
.welcome .logo{ width:54px; height:54px; border-radius:16px; font-size:25px; margin:0 auto 18px; }
.welcome h1{ font-size:23px; margin:0 0 8px; font-weight:650; letter-spacing:.2px; }
.welcome p{ margin:0 0 26px; color:var(--text-2); font-size:14.5px; line-height:1.7; }
.welcome .hint{ color:var(--text-3); font-size:12.5px; margin-bottom:18px; }
.chips{ display:flex; flex-direction:column; gap:10px; }
.chip-sug{
  text-align:left; padding:13px 16px; border-radius:14px; border:1px solid var(--line);
  background:var(--surface); font-size:14px; color:var(--text); line-height:1.5;
  display:flex; gap:11px; align-items:flex-start;
  transition:border-color .15s, transform .1s;
}
.chip-sug:active{ border-color:var(--blue); transform:scale(.985); }
.chip-sug svg{ width:17px; height:17px; color:var(--blue); flex:none; margin-top:2px; }
.chip-sug span small{ display:block; color:var(--text-3); font-size:12px; margin-top:2px; }

/* ---------------- messages ---------------- */
.msg{ max-width:820px; margin:0 auto 20px; padding:0 14px; display:flex; gap:10px; }
.msg.user{ justify-content:flex-end; }
.u-wrap{ display:flex; flex-direction:column; align-items:flex-end; max-width:82%; min-width:0; }
.bubble{
  max-width:100%; background:var(--bubble); color:var(--text);
  padding:10px 14px; border-radius:16px 16px 5px 16px;
  font-size:var(--fs); line-height:1.66;
  white-space:pre-wrap; word-break:break-word; overflow-wrap:anywhere;
}
.msg.user .files{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; margin-bottom:6px; }
.file-chip{
  font-size:12px; color:var(--text-2); background:rgba(255,255,255,.65); border:1px solid var(--line);
  padding:4px 9px; border-radius:9px; display:flex; align-items:center; gap:5px;
}
:root[data-theme="dark"] .file-chip{ background:rgba(255,255,255,.05); }
@media (prefers-color-scheme: dark){ :root[data-theme="auto"] .file-chip{ background:rgba(255,255,255,.05); } }
.file-chip svg{ width:13px; height:13px; }

.msg.ai{ align-items:flex-start; }
.ai-avatar{
  width:30px; height:30px; border-radius:50%; flex:none; margin-top:2px;
  background:linear-gradient(140deg,#6d8bff,#3f59e0); color:#fff;
  display:grid; place-items:center; font-weight:700; font-size:12.5px;
  box-shadow:0 2px 8px rgba(77,107,254,.28);
}
.ai-body{ flex:1; min-width:0; }
.ai-name{ display:none; }

.md{ font-size:var(--fs); line-height:1.74; word-break:break-word; overflow-wrap:anywhere; }
.md svg, .mact svg, .vernav svg, .sheet-item svg, .think-head svg, .cont-tag svg,
.set-btn svg, .file-chip svg, .chip-sug svg, .sb-row svg{
  fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round;
}
.md > :first-child{ margin-top:0; }
.md > :last-child{ margin-bottom:0; }
.md p{ margin:0 0 10px; }
.md h1,.md h2,.md h3,.md h4{ margin:18px 0 8px; font-size:calc(var(--fs) + 2px); font-weight:660; line-height:1.45; }
.md h1{ font-size:calc(var(--fs) + 4px); }
.md strong{ font-weight:680; }
.md em{ font-style:italic; }
.md a{ color:var(--blue); text-decoration:none; border-bottom:1px solid color-mix(in srgb, var(--blue) 35%, transparent); }
.md ul,.md ol{ margin:6px 0 11px; padding-left:21px; }
.md li{ margin:5px 0; }
.md li > ul,.md li > ol{ margin:4px 0 4px; }
.md hr{ border:0; border-top:1px solid var(--line); margin:16px 0; }
.md blockquote{
  margin:10px 0; padding:2px 0 2px 12px; border-left:3px solid color-mix(in srgb, var(--blue) 45%, var(--line));
  color:var(--text-2);
}
.md code{
  background:var(--code-bg); padding:1.5px 5px; border-radius:5px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:.88em;
}
.md pre{
  position:relative; background:var(--code-bg); border:1px solid var(--line);
  border-radius:12px; padding:12px 14px; overflow:auto; margin:10px 0;
  font-size:13px; line-height:1.6;
}
.md pre code{ background:none; padding:0; font-size:inherit; }
.md table{ border-collapse:collapse; width:100%; margin:10px 0; font-size:14px; display:block; overflow-x:auto; }
.md th,.md td{ border:1px solid var(--line); padding:7px 10px; text-align:left; }
.md th{ background:var(--bg-2); font-weight:600; }
.copy-code{
  position:absolute; top:8px; right:8px; font-size:11.5px; color:var(--text-3);
  background:var(--surface); border:1px solid var(--line); border-radius:7px; padding:3px 8px;
}

/* thinking block */
.think{
  border:1px solid var(--line); background:var(--bg-2); border-radius:12px;
  margin:0 0 11px; overflow:hidden;
}
.think-head{
  display:flex; align-items:center; gap:8px; padding:9px 12px;
  font-size:12.5px; color:var(--text-2); width:100%; text-align:left;
}
.think-head svg{ width:15px; height:15px; flex:none; color:var(--blue); }
.think-head .arrow{ margin-left:auto; transition:transform .2s; }
.think.open .think-head .arrow{ transform:rotate(180deg); }
.think-body{
  display:none; padding:0 13px 12px; font-size:13px; line-height:1.7; color:var(--text-2);
  border-top:1px dashed var(--line); padding-top:10px; margin:0 2px;
  max-height:44vh; overflow:auto;
}
.think.open .think-body{ display:block; }

/* message meta / actions */
.mact{ display:flex; align-items:center; gap:1px; margin-top:7px; color:var(--text-3); }
.msg.user .mact{ justify-content:flex-end; }
.mact button{
  width:30px; height:28px; border-radius:8px; display:grid; place-items:center; color:inherit;
  transition:background .15s, color .15s;
}
.mact button svg{ width:16px; height:16px; }
.mact button:active{ background:rgba(125,135,160,.16); color:var(--text); }
.vernav{ display:inline-flex; align-items:center; gap:2px; font-size:12px; color:var(--text-3); margin-left:4px; }
.vernav button{ width:24px; height:24px; border-radius:7px; display:grid; place-items:center; }
.vernav button svg{ width:14px; height:14px; }
.vernav b{ color:var(--text-2); font-weight:600; }

.cont-tag{
  display:inline-flex; align-items:center; gap:5px; font-size:11px; color:var(--blue);
  background:var(--blue-soft); border-radius:6px; padding:2px 7px; margin-bottom:8px; font-weight:600;
}
.stale-bar{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap;
  border:1px dashed color-mix(in srgb, var(--blue) 40%, var(--line));
  border-radius:11px; padding:8px 11px; margin-bottom:10px; font-size:12.5px; color:var(--text-2);
}
.stale-bar button{ color:var(--blue); font-weight:600; font-size:12.5px; }
.load-more{
  display:block; margin:0 auto 20px; font-size:13px; color:var(--text-2);
  border:1px solid var(--line); background:var(--surface); border-radius:20px; padding:8px 18px;
}
.load-more:active{ border-color:var(--blue); color:var(--blue); }

.cursor::after{
  content:""; display:inline-block; width:8px; height:1.05em; margin-left:2px;
  background:var(--blue); vertical-align:-2px; border-radius:1px;
  animation:blink 1s steps(2,start) infinite;
}
@keyframes blink{ 0%,49%{opacity:1} 50%,100%{opacity:0} }

.sys-note{
  max-width:820px; margin:0 auto 18px; padding:0 16px; font-size:12px; color:var(--text-3); text-align:center;
}

.cont-tag svg{ width:11px; height:11px; }

/* ---------------- composer ---------------- */
.attach-tray{ display:flex; flex-wrap:wrap; gap:6px; max-width:820px; margin:0 auto 6px; padding:0 4px; }
.tray-chip{
  display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--text-2);
  background:var(--surface); border:1px solid var(--line); border-radius:9px; padding:5px 8px;
}
.tray-chip button{ color:var(--text-3); font-size:12px; line-height:1; }
.composer-wrap{
  flex:none; padding:6px 10px calc(8px + env(safe-area-inset-bottom));
  background:linear-gradient(to top, var(--bg) 62%, transparent);
  z-index:15;
}
.quickbar{ display:flex; align-items:center; gap:7px; padding:0 4px 7px; max-width:820px; margin:0 auto; }
.chip{
  display:inline-flex; align-items:center; gap:5px; font-size:12.5px; color:var(--text-2);
  border:1px solid var(--line); background:var(--surface); border-radius:20px; padding:5px 11px;
  transition:all .16s;
}
.chip svg{ width:14px; height:14px; }
.chip.on{ color:var(--blue); border-color:color-mix(in srgb, var(--blue) 55%, var(--line)); background:var(--blue-soft); font-weight:600; }
.edit-note{
  margin-left:auto; display:inline-flex; align-items:center; gap:4px;
  font-size:11.5px; color:var(--text-3);
}
.edit-note svg{ width:13px; height:13px; }

.composer{
  display:flex; align-items:flex-end; gap:6px; max-width:820px; margin:0 auto;
  background:var(--surface); border:1px solid var(--line); border-radius:24px;
  padding:5px 5px 5px 6px; box-shadow:0 3px 16px rgba(20,30,60,.05);
  transition:border-color .18s, box-shadow .18s;
}
.composer:focus-within{ border-color:color-mix(in srgb, var(--blue) 45%, var(--line)); box-shadow:0 3px 18px rgba(77,107,254,.12); }
.composer textarea{
  flex:1; border:0; outline:0; background:transparent; resize:none;
  font:inherit; font-size:var(--fs); line-height:1.5; color:var(--text);
  padding:9px 2px; max-height:132px; min-height:20px;
}
.composer textarea::placeholder{ color:var(--text-3); }
.composer .plus{ width:36px; height:36px; border-radius:50%; color:var(--text-2); }
.composer .plus svg{ width:20px; height:20px; }
.send{
  width:36px; height:36px; border-radius:50%; flex:none; display:grid; place-items:center;
  background:var(--blue); color:#fff; transition:transform .12s, opacity .15s, background .15s;
  box-shadow:0 2px 8px rgba(77,107,254,.3);
}
.send:active{ transform:scale(.92); }
.send.off{ background:var(--line); color:var(--text-3); box-shadow:none; }
.send.stop{ background:var(--danger); }
.send.stop svg{ width:14px; height:14px; fill:currentColor; stroke:none; }
.composer-hint{ text-align:center; font-size:10.5px; color:var(--text-3); padding:6px 0 0; }

.to-bottom{
  position:absolute; right:14px; bottom:calc(112px + env(safe-area-inset-bottom));
  width:38px; height:38px; border-radius:50%; background:var(--surface);
  border:1px solid var(--line); box-shadow:0 4px 14px rgba(20,30,60,.12);
  display:grid; place-items:center; color:var(--text-2); z-index:18;
  opacity:0; pointer-events:none; transform:translateY(8px); transition:.2s;
}
.to-bottom.show{ opacity:1; pointer-events:auto; transform:none; }
.to-bottom svg{ width:18px; height:18px; }

/* ---------------- overlay / sheet / modal ---------------- */
.overlay{
  position:fixed; inset:0; background:rgba(10,12,20,.42); z-index:55;
  opacity:0; pointer-events:none; transition:opacity .22s; backdrop-filter:blur(2px);
}
.overlay.show{ opacity:1; pointer-events:auto; }

.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:56;
  background:var(--surface); border-radius:20px 20px 0 0;
  transform:translateY(102%); transition:transform .3s cubic-bezier(.32,.72,0,1);
  max-height:88dvh; display:flex; flex-direction:column;
  padding-bottom:env(safe-area-inset-bottom);
  box-shadow:0 -12px 40px rgba(10,15,40,.22);
}
.sheet.open{ transform:none; }
.sheet-grab{ width:38px; height:4px; border-radius:3px; background:var(--line); margin:9px auto 4px; flex:none; }
.sheet-title{ font-size:13.5px; color:var(--text-3); text-align:center; padding:6px 20px 10px; flex:none; }
.sheet-body{ padding:0 10px 14px; overflow-y:auto; }
.sheet-item{
  display:flex; align-items:center; gap:13px; width:100%; text-align:left;
  padding:13px 14px; border-radius:12px; font-size:15px;
}
.sheet-item:active{ background:rgba(125,135,160,.14); }
.sheet-item svg{ width:19px; height:19px; color:var(--text-2); flex:none; }
.sheet-item.danger{ color:var(--danger); }
.sheet-item.danger svg{ color:var(--danger); }
.sheet-item small{ margin-left:auto; font-size:12px; color:var(--text-3); }

.modal{
  position:fixed; inset:0; z-index:57; display:flex; align-items:flex-end; justify-content:center;
  background:rgba(10,12,20,.42); backdrop-filter:blur(2px);
  opacity:0; pointer-events:none; transition:opacity .2s;
}
.modal.open{ opacity:1; pointer-events:auto; }
.modal-card{
  width:100%; max-width:720px; background:var(--surface);
  border-radius:20px 20px 0 0; padding:14px 16px calc(16px + env(safe-area-inset-bottom));
  transform:translateY(20px); transition:transform .25s;
  display:flex; flex-direction:column; gap:10px;
}
.modal.open .modal-card{ transform:none; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; font-size:14px; font-weight:600; }
.modal-card textarea{
  width:100%; min-height:38vh; max-height:56dvh; resize:vertical;
  background:var(--bg-2); color:var(--text); border:1px solid var(--line); border-radius:12px;
  padding:12px 14px; font:inherit; font-size:15px; line-height:1.65; outline:0;
}
.modal-card textarea:focus{ border-color:var(--blue); }
.modal-foot{ display:flex; align-items:center; justify-content:space-between; }
.modal-count{ font-size:12px; color:var(--text-3); }
.modal-btns{ display:flex; gap:8px; }
.btn{ padding:9px 18px; border-radius:11px; font-size:14.5px; font-weight:600; }
.btn.ghost{ color:var(--text-2); background:var(--bg-2); }
.btn.primary{ color:#fff; background:var(--blue); }
.btn:active{ transform:scale(.97); }
.modal-note{ font-size:11.5px; color:var(--text-3); line-height:1.55; }

/* settings */
.set-group{ padding:4px 4px 14px; }
.set-group h4{ margin:10px 10px 8px; font-size:12px; color:var(--text-3); font-weight:600; letter-spacing:.05em; }
.set-row{ display:flex; align-items:center; gap:12px; padding:11px 12px; border-radius:12px; background:var(--bg-2); margin-bottom:8px; }
.set-row .lab{ flex:1; font-size:14.5px; }
.set-row .sub{ font-size:11.5px; color:var(--text-3); margin-top:2px; }
.set-row input[type="text"], .set-row input[type="password"], .set-row select{
  flex:1.4; min-width:0; background:var(--surface); border:1px solid var(--line); color:var(--text);
  border-radius:9px; padding:8px 10px; font:inherit; font-size:13px; outline:0;
}
.set-row input:focus, .set-row select:focus{ border-color:var(--blue); }
.seg{ display:flex; background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:2px; }
.seg button{ padding:6px 12px; border-radius:8px; font-size:13px; color:var(--text-2); }
.seg button.on{ background:var(--blue); color:#fff; font-weight:600; }
.range{ flex:1.4; accent-color:var(--blue); }
.set-btn{ width:100%; text-align:left; padding:12px; border-radius:12px; background:var(--bg-2); font-size:14.5px; margin-bottom:8px; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.set-btn svg{ width:18px; height:18px; flex:none; color:var(--text-3); }
.set-btn.danger{ color:var(--danger); }
.set-foot{ font-size:11.5px; color:var(--text-3); text-align:center; padding:6px 10px 10px; line-height:1.6; }

.toast{
  position:fixed; left:50%; bottom:96px; transform:translate(-50%,14px);
  background:rgba(28,30,38,.94); color:#fff; font-size:13.5px; padding:10px 18px; border-radius:12px;
  opacity:0; pointer-events:none; transition:.24s; z-index:70; max-width:80vw; text-align:center;
  box-shadow:0 8px 24px rgba(0,0,0,.25);
}
.toast.show{ opacity:1; transform:translate(-50%,0); }

/* ---------------- desktop ---------------- */
@media (min-width:1000px){
  .sidebar{ position:relative; transform:none; box-shadow:none; height:100dvh; }
  .scrim{ display:none; }
  .sb-close{ display:grid; }
  .topbar{ padding-left:14px; padding-right:14px; }
  .chat{ padding-top:20px; }
  .toast{ bottom:110px; }
}

/* ================= v2 additions ================= */
.model-pill{
  display:inline-flex; align-items:center; gap:3px; margin:2px auto 0;
  font-size:11.5px; color:var(--text-2); background:var(--bg-2);
  border:1px solid var(--line); border-radius:20px; padding:2px 8px 2px 10px;
}
.model-pill svg{ width:12px; height:12px; }
.model-pill:active{ border-color:var(--blue); color:var(--blue); }

.readonly-bar{
  display:flex; align-items:center; gap:10px; padding:8px 14px;
  background:var(--blue-soft); color:var(--text-2); font-size:12.5px;
  border-bottom:1px solid var(--line);
}
.readonly-bar span{ flex:1; }
.readonly-bar button{ color:var(--blue); font-weight:600; font-size:12.5px; }
body.readonly .composer-wrap{ display:none; }
body.dragging::after{
  content:"放開以附加檔案"; position:fixed; inset:16px; z-index:80;
  border:2px dashed var(--blue); border-radius:18px; background:rgba(77,107,254,.06);
  display:grid; place-items:center; color:var(--blue); font-size:15px; font-weight:600;
  pointer-events:none;
}

/* attachments */
.att-grid{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; margin-bottom:6px; }
.att-img{ margin:0; width:118px; height:118px; border-radius:12px; overflow:hidden; border:1px solid var(--line); background:var(--bg-2); }
.att-img img{ width:100%; height:100%; object-fit:cover; display:block; }

.attach-tray{ display:flex; flex-wrap:wrap; gap:8px; max-width:820px; margin:0 auto 6px; padding:0 4px; }
.tray-item{
  position:relative; width:64px; height:64px; border-radius:12px; overflow:hidden;
  border:1px solid var(--line); background:var(--bg-2); display:grid; place-items:center;
}
.tray-item img{ width:100%; height:100%; object-fit:cover; }
.tray-item .tray-ico{ font-size:22px; }
.tray-item .tray-st{ position:absolute; bottom:0; left:0; right:0; font-size:9.5px; text-align:center; background:rgba(0,0,0,.55); color:#fff; padding:1px 0; }
.tray-item button{
  position:absolute; top:2px; right:2px; width:18px; height:18px; border-radius:50%;
  background:rgba(0,0,0,.6); color:#fff; font-size:10px; display:grid; place-items:center;
}
.tray-item.bad{ border-color:var(--danger); }

/* tool / search cards */
.tool-card{
  border:1px solid var(--line); background:var(--bg-2); border-radius:12px;
  padding:9px 11px; margin:0 0 10px; font-size:12.5px;
}
.tool-head{ display:flex; align-items:center; gap:7px; color:var(--text-2); font-weight:600; }
.tool-head svg{ width:14px; height:14px; color:var(--blue); flex:none; }
.tool-results{ display:flex; flex-direction:column; gap:2px; margin-top:7px; }
.tool-res{
  display:flex; align-items:baseline; gap:8px; padding:4px 6px; border-radius:7px;
  color:var(--text); text-decoration:none; min-width:0;
}
.tool-res:active{ background:rgba(125,135,160,.14); }
.tool-res .site{ color:var(--text-3); font-size:11px; flex:none; max-width:34%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tool-res .t{ color:var(--blue); font-size:12.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* citations */
sup.cite{ line-height:0; }
sup.cite a{
  display:inline-grid; place-items:center; min-width:15px; height:15px; padding:0 3px;
  margin:0 1px; border-radius:5px; background:var(--blue-soft); color:var(--blue);
  font-size:10px; font-weight:600; text-decoration:none; vertical-align:super;
  border:0;
}

/* status rows */
.err-bar, .stop-bar{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:12.5px;
  border-radius:10px; padding:8px 11px; margin:8px 0 4px;
}
.err-bar{ background:rgba(229,72,77,.08); color:var(--danger); border:1px solid rgba(229,72,77,.25); }
.stop-bar{ background:var(--bg-2); color:var(--text-2); border:1px solid var(--line); }
.err-bar button, .stop-bar button{ color:var(--blue); font-weight:600; font-size:12.5px; }

.typing{ display:inline-flex; gap:3px; padding:6px 2px; }
.typing i{ width:5px; height:5px; border-radius:50%; background:var(--text-3); animation:bob 1.1s infinite ease-in-out; }
.typing i:nth-child(2){ animation-delay:.15s } .typing i:nth-child(3){ animation-delay:.3s }
@keyframes bob{ 0%,80%,100%{ transform:translateY(0); opacity:.4 } 40%{ transform:translateY(-4px); opacity:1 } }

/* sheets */
.sheet-item .sub{ display:block; font-size:11.5px; color:var(--text-3); margin-top:2px; font-weight:400; }
.sheet-item.on{ background:var(--blue-soft); color:var(--blue); font-weight:600; }
.sheet-item.on .sub{ color:var(--blue); opacity:.8; }
.share-preview{ padding:4px 8px 12px; }
.share-preview input{
  width:100%; font:inherit; font-size:12px; padding:9px 11px; border-radius:10px;
  border:1px solid var(--line); background:var(--bg-2); color:var(--text-2);
}
.share-meta{ font-size:11px; color:var(--text-3); margin-top:6px; padding:0 2px; }

.conn{ font-size:12.5px; }
.conn .ok{ color:#22a06b; font-weight:600; }
.conn .bad{ color:var(--danger); }
.conn .muted{ color:var(--text-3); }
.btn.small{ padding:6px 12px; font-size:12.5px; border-radius:9px; background:var(--blue); color:#fff; }
.toast button.toast-btn{ color:#8fb0ff; font-weight:600; margin-left:6px; }
.toast{ pointer-events:none; }
.toast.show{ pointer-events:auto; }

.readonly-bar[hidden], .attach-tray[hidden], #composerWrap[hidden]{ display:none !important; }

.storage-bar{ flex:0 0 120px; height:6px; border-radius:4px; background:var(--line); overflow:hidden; }
.storage-bar i{ display:block; height:100%; width:0; background:var(--blue); border-radius:4px; }

.err-bar .err-text{ flex:1 1 100%; min-width:0; line-height:1.55; white-space:pre-wrap; }
