/* ============ 汤圆 · 基础样式 ============ */
:root{
  /* 主题色（可在设置里自定义，JS 会覆盖这四个值） */
  --accent:#E2603C;
  --accent-strong:#C74C2C;
  --accent-soft:#FDECE6;
  --accent-soft-2:#FFF6F2;
  --accent-rgb:226,96,60;

  --bg:#FFFFFF;
  --bg-2:#F4F4F6;
  --bg-3:#EFEFF2;
  --card:#FFFFFF;

  --text:#17171B;
  --text-2:#6A6A72;
  --text-3:#9A9AA2;
  --text-4:#B9B9C0;

  --line:#EDEDF0;
  --line-2:#E4E4E9;

  --danger:#E5484D;

  --fs:1;
  --sat:env(safe-area-inset-top, 0px);
  --sab:env(safe-area-inset-bottom, 0px);
  --radius-lg:22px;
  --radius-md:14px;

  --font:-apple-system,BlinkMacSystemFont,"PingFang SC","HarmonyOS Sans SC","MiSans","Noto Sans SC",Roboto,"Helvetica Neue",Arial,sans-serif;
  --mono:"SF Mono",ui-monospace,"JetBrains Mono",Menlo,Consolas,"Noto Sans Mono CJK SC",monospace;
}

*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
html,body{height:100%;margin:0;padding:0;}
html{font-size:calc(16px * var(--fs));-webkit-text-size-adjust:100%;}
body{
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  font-size:1rem;
  line-height:1.55;
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;font-size:inherit;color:inherit;background:none;border:none;padding:0;margin:0;cursor:pointer;}
input,textarea{font-family:inherit;font-size:inherit;color:inherit;background:none;border:none;outline:none;}
input::placeholder,textarea::placeholder{color:var(--text-3);}
img{display:block;max-width:100%;}
a{color:var(--accent);text-decoration:none;}

.sprite{position:absolute;width:0;height:0;overflow:hidden;}
.ico{width:1.5rem;height:1.5rem;display:block;flex:none;fill:none;}

.app{
  position:fixed;inset:0;
  overflow:hidden;
  background:var(--bg);
}

/* ---------- 通用按钮 ---------- */
.ibtn{
  width:2.75rem;height:2.75rem;flex:none;
  display:flex;align-items:center;justify-content:center;
  color:var(--text);border-radius:50%;
  transition:background .16s ease,opacity .16s ease;
}
.ibtn:active{background:rgba(0,0,0,.05);}
.ibtn.ghost{pointer-events:none;opacity:0;}
.ibtn .ico{width:1.55rem;height:1.55rem;}

/* ---------- 顶栏 ---------- */
.topbar{
  position:absolute;top:0;left:0;right:0;z-index:20;
  display:flex;align-items:center;justify-content:space-between;
  height:calc(3.5rem + var(--sat));
  padding:var(--sat) .5rem 0 .5rem;
  background:var(--bg);
  transition:border-color .2s ease;
  border-bottom:1px solid transparent;
}
.topbar.bordered{border-bottom-color:var(--line);}
/* 绝对定位 + 左右对称留白，保证相对屏幕正中 */
.topbar-title{
  position:absolute;
  left:5.5rem;right:5.5rem;
  top:var(--sat);
  height:3.5rem;line-height:3.5rem;
  padding:0 .5rem;
  text-align:center;
  font-size:1.0625rem;font-weight:600;letter-spacing:.01em;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  opacity:0;transition:opacity .18s ease;
  pointer-events:none;
}
.topbar-title.show{opacity:1;}
.topbar-actions{display:flex;align-items:center;gap:.125rem;}
.topbar-actions .ico{width:1.5rem;height:1.5rem;}

/* ---------- 滚动区 ---------- */
.scroll{
  position:absolute;left:0;right:0;
  top:calc(3.5rem + var(--sat));
  bottom:0;
  overflow-y:auto;overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  padding-bottom:calc(9.5rem + var(--sab));
}

/* ---------- 空态 ---------- */
.empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  min-height:calc(100vh - 3.5rem - var(--sat) - 12rem - var(--sab));
  padding:2rem 1.5rem;
  transition:opacity .2s ease;
}
.empty.hide{display:none;}
.logo-wrap{margin-bottom:1.125rem;}
.brand-logo{width:4.25rem;height:4.25rem;display:block;border-radius:50%;box-shadow:0 8px 24px rgba(var(--accent-rgb),.22);}
.empty h1{
  margin:0;
  font-size:1.1875rem;font-weight:600;letter-spacing:.01em;
  color:var(--text);
  text-align:center;
}

/* ---------- 页面栈 ---------- */
.page{
  position:fixed;inset:0;z-index:60;
  background:var(--bg-2);
  transform:translate3d(100%,0,0);
  transition:transform .28s cubic-bezier(.32,.72,0,1);
  display:flex;flex-direction:column;
  will-change:transform;
}
.page.show{transform:translate3d(0,0,0);}
.page-bar{
  display:flex;align-items:center;
  height:calc(3.25rem + var(--sat));
  padding:var(--sat) .375rem 0 .375rem;
  background:var(--bg-2);
  flex:none;
}
.page-bar .ibtn .ico{width:1.5rem;height:1.5rem;}
.page-title{
  flex:1;text-align:center;
  font-size:1.0625rem;font-weight:600;
}
.page-scroll{
  flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:0 1rem calc(2rem + var(--sab));
  overscroll-behavior:contain;
}

/* ---------- 设置分组 ---------- */
.group{margin-top:1.375rem;}
.group:first-child{margin-top:.5rem;}
.group-label{
  font-size:.8125rem;color:var(--text-3);
  padding:0 .875rem .4375rem;
  letter-spacing:.02em;
}
.group-card{
  background:var(--card);
  border-radius:var(--radius-md);
  overflow:hidden;
}
.row{
  display:flex;align-items:center;gap:.75rem;
  min-height:3.5rem;
  padding:.5rem .875rem;
  position:relative;
  transition:background .15s ease;
}
.row:active{background:#F2F2F5;}
.row + .row::before{
  content:"";position:absolute;left:2.875rem;right:0;top:0;height:1px;
  background:var(--line);
  transform:scaleY(.5);transform-origin:0 0;
}
.row .r-ico{width:1.375rem;height:1.375rem;flex:none;color:var(--text);}
.row .r-label{flex:1;min-width:0;font-size:1rem;color:var(--text);}
.row .r-value{font-size:.9375rem;color:var(--text-3);white-space:nowrap;}
.row .r-chev{width:1.125rem;height:1.125rem;flex:none;color:var(--text-4);}
.row.danger .r-label{color:var(--danger);}
.row.tall{min-height:3.75rem;}

/* ---------- 底部弹层 ---------- */
.sheet-scrim{
  position:fixed;inset:0;z-index:80;
  background:rgba(0,0,0,.34);
  opacity:0;pointer-events:none;
  transition:opacity .22s ease;
}
.sheet-scrim.show{opacity:1;pointer-events:auto;}
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:81;
  background:#fff;
  border-radius:1.125rem 1.125rem 0 0;
  padding:.75rem 1rem calc(1rem + var(--sab));
  transform:translate3d(0,105%,0);
  transition:transform .28s cubic-bezier(.32,.72,0,1);
  max-height:80vh;overflow-y:auto;
  box-shadow:0 -8px 32px rgba(0,0,0,.08);
}
.sheet.show{transform:translate3d(0,0,0);}
.sheet-title{
  font-size:.8125rem;color:var(--text-3);
  text-align:center;padding:.375rem 0 .625rem;
}
.sheet-item{
  display:flex;align-items:center;gap:.75rem;
  padding:.875rem .625rem;
  font-size:1rem;border-radius:.75rem;
  transition:background .15s ease;
}
.sheet-item:active{background:#F2F2F5;}
.sheet-item.danger{color:var(--danger);}
.sheet-item .ico{width:1.25rem;height:1.25rem;color:var(--text-2);}
.sheet-item.danger .ico{color:var(--danger);}
.sheet-cancel{
  margin-top:.5rem;width:100%;
  padding:.9375rem;
  background:#F4F4F6;border-radius:.75rem;
  font-size:1rem;font-weight:500;
}

/* ---------- Toast ---------- */
.toast{
  position:fixed;left:50%;bottom:calc(7rem + var(--sab));
  transform:translate(-50%,1rem);
  z-index:120;
  background:rgba(28,28,32,.92);
  color:#fff;font-size:.875rem;
  padding:.5625rem 1rem;border-radius:.625rem;
  opacity:0;pointer-events:none;
  transition:opacity .2s ease,transform .2s ease;
  max-width:80vw;text-align:center;
  backdrop-filter:blur(8px);
}
.toast.show{opacity:1;transform:translate(-50%,0);}

/* ---------- 语音浮层 ---------- */
.voice-mask{
  position:fixed;inset:0;z-index:110;
  background:rgba(0,0,0,.28);
  display:none;align-items:center;justify-content:center;
  backdrop-filter:blur(2px);
}
.voice-mask.show{display:flex;}
.voice-card{
  width:17rem;background:#fff;border-radius:1.25rem;
  padding:1.375rem 1.125rem 1rem;
  display:flex;flex-direction:column;align-items:center;
  box-shadow:0 12px 48px rgba(0,0,0,.16);
}
.wave{display:flex;align-items:center;gap:.25rem;height:2.5rem;margin-bottom:.875rem;}
.wave i{
  display:block;width:.25rem;border-radius:99px;background:var(--accent);
  height:.75rem;animation:wave 1s ease-in-out infinite;
}
.wave i:nth-child(2){animation-delay:.1s;}
.wave i:nth-child(3){animation-delay:.2s;}
.wave i:nth-child(4){animation-delay:.3s;}
.wave i:nth-child(5){animation-delay:.2s;}
.wave i:nth-child(6){animation-delay:.1s;}
.wave i:nth-child(7){animation-delay:0s;}
@keyframes wave{0%,100%{height:.75rem;opacity:.55}50%{height:2.25rem;opacity:1}}
.voice-hint{font-size:.875rem;color:var(--text-2);margin-bottom:.875rem;transition:color .15s ease;}
.voice-engine{
  font-size:.6875rem;color:var(--text-3);
  padding:.125rem .5rem;border-radius:99px;background:#F2F2F5;
  margin-bottom:.75rem;
}
.voice-partial{
  font-size:.875rem;color:var(--text);font-weight:500;
  min-height:1.2em;max-height:3.4em;overflow:hidden;
  text-align:center;line-height:1.55;
  margin:.5rem 0 0;padding:0 .25rem;
  word-break:break-all;
}
.voice-card.cancel{background:#FDECEC;}
.voice-card.cancel .wave i{background:#D33A3A;}
.voice-card.cancel .voice-hint{color:#D33A3A;}
.voice-card.cancel .voice-engine{background:#F8DADA;color:#B02A2A;}
.wave.live i{animation:none;transition:height .08s linear,opacity .12s linear;}
.voice-cancel{
  font-size:.9375rem;color:var(--text-3);
  padding:.375rem 1rem;border-radius:99px;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar{width:0;height:0;}

/* ---------- 深色主题 ---------- */
[data-theme="dark"]{
  --bg:#0E0E12;
  --bg-2:#14141A;
  --bg-3:#1C1C23;
  --card:#1A1A21;
  --text:#F0F0F5;
  --text-2:#A2A2B0;
  --text-3:#72727F;
  --text-4:#565662;
  --line:#26262F;
  --line-2:#30303A;
  --accent-soft:#3A2118;
  --accent-soft-2:#2A1812;
  --accent:#FF8A66;
  --accent-rgb:255,138,102;
}
[data-theme="dark"] .topbar{background:var(--bg);}
[data-theme="dark"] .drawer{background:#131318;box-shadow:2px 0 24px rgba(0,0,0,.4);}
[data-theme="dark"] .search-box{background:#1E1E26;}
[data-theme="dark"] .search-box:focus-within{background:#23232C;}
[data-theme="dark"] .d-item:active,[data-theme="dark"] .d-item.active{background:#1E1E26;}
[data-theme="dark"] .d-menu{background:#20202A;}
[data-theme="dark"] .d-menu button:active{background:#2A2A36;}
[data-theme="dark"] .sheet{background:#1A1A21;}
[data-theme="dark"] .sheet-item:active{background:#24242E;}
[data-theme="dark"] .sheet-cancel{background:#24242E;}
[data-theme="dark"] .composer{background:linear-gradient(to bottom,rgba(14,14,18,0) 0%,var(--bg) 1.25rem,var(--bg) 100%);}
[data-theme="dark"] .composer-box{background:#17171E;border-color:#26262F;box-shadow:none;}
[data-theme="dark"] .composer-box.focus{border-color:var(--accent);}
[data-theme="dark"] .chip{background:#1C1C24;border-color:#2A2A34;}
[data-theme="dark"] .chip:active{background:#24242E;}
[data-theme="dark"] .chip.on{background:var(--accent-soft);border-color:transparent;}
[data-theme="dark"] .rbtn:active{background:#24242E;}
[data-theme="dark"] .attach-panel{background:var(--bg);}
[data-theme="dark"] .attach-btn{background:#1E1E26;}
[data-theme="dark"] .attach-btn:active{background:#26262F;}
[data-theme="dark"] .recent-thumb{background:#1E1E26;}
[data-theme="dark"] .think-block{background:#17171E;border-color:#24242E;}
[data-theme="dark"] .think-body{border-top-color:#24242E;}
[data-theme="dark"] .search-status{background:var(--accent-soft-2);}
[data-theme="dark"] .ai-body code{background:#22222C;color:#FF8FAE;}
[data-theme="dark"] .ai-body th{background:#1C1C24;}
[data-theme="dark"] .ai-body th,[data-theme="dark"] .ai-body td{border-color:#2A2A34;}
[data-theme="dark"] .ai-body blockquote{border-left-color:#33333F;}
[data-theme="dark"] .msg-tools button:active{background:#24242E;}
[data-theme="dark"] .form-input{background:#1C1C24;}
[data-theme="dark"] .form-input:focus{background:#20202A;}
[data-theme="dark"] .seg{background:#1C1C24;}
[data-theme="dark"] .seg button.on{background:#2A2A36;}
[data-theme="dark"] .row:active,[data-theme="dark"] .opt-row:active{background:#1E1E26;}
[data-theme="dark"] .opt-row + .opt-row::before{background:#26262F;}
[data-theme="dark"] .btn.ghost{background:#1E1E26;}
[data-theme="dark"] .btn.ghost:active{background:#26262F;}
[data-theme="dark"] .fs-preview{background:#17171E;}
[data-theme="dark"] .about-block{background:#1A1A21;}
[data-theme="dark"] .switch{background:#33333F;}
[data-theme="dark"] .switch.on{background:var(--accent);}
[data-theme="dark"] .avatar{background:linear-gradient(135deg,#4D5FD6,#2E3F9E);}
[data-theme="dark"] .modal{background:#1C1C24;}
[data-theme="dark"] .modal-input{background:#24242E;}
[data-theme="dark"] .modal-btn{background:#24242E;}
[data-theme="dark"] .code-block{background:#101016;border-color:#22222C;}
[data-theme="dark"] .code-head{background:#17171F;}
[data-theme="dark"] .thumb-mini{background:#1E1E26;}
[data-theme="dark"] .chip-file{background:#1E1E26;}
[data-theme="dark"] .voice-card{background:#1C1C24;}

/* ---------- Modal ---------- */
.modal-mask{
  position:fixed;inset:0;z-index:100;
  background:rgba(0,0,0,.36);
  display:flex;align-items:center;justify-content:center;
  padding:2rem;
  opacity:0;transition:opacity .18s ease;
  backdrop-filter:blur(2px);
}
.modal-mask.show{opacity:1;}
.modal{
  width:100%;max-width:19rem;
  background:#fff;
  border-radius:1rem;
  padding:1.375rem 1.125rem 1rem;
  transform:scale(.94);
  transition:transform .22s cubic-bezier(.2,.8,.3,1);
  box-shadow:0 16px 56px rgba(0,0,0,.18);
}
.modal-mask.show .modal{transform:scale(1);}
.modal-title{
  font-size:1.0625rem;font-weight:600;
  text-align:center;line-height:1.5;
}
.modal-body{
  font-size:.875rem;color:var(--text-2);
  text-align:center;margin-top:.5rem;
  line-height:1.6;
  word-break:break-word;
}
.modal-input{
  width:100%;margin-top:.875rem;
  background:#F4F4F6;border-radius:.625rem;
  padding:.625rem .75rem;font-size:.9375rem;
  border:1px solid transparent;
}
.modal-input:focus{background:#fff;border-color:var(--accent);}
.modal-actions{display:flex;gap:.5rem;margin-top:1.125rem;}
.modal-btn{
  flex:1;height:2.5rem;border-radius:.625rem;
  background:#F4F4F6;font-size:.9375rem;font-weight:500;
  transition:background .15s;
}
.modal-btn:active{background:#E9E9EE;}
.modal-btn.primary{background:var(--accent);color:#fff;}
.modal-btn.primary:active{background:var(--accent-strong);}

/* ---------- 大图查看 ---------- */
.img-viewer{
  position:fixed;inset:0;z-index:130;
  background:rgba(0,0,0,.94);
  display:flex;align-items:center;justify-content:center;
  opacity:0;transition:opacity .2s ease;
  padding:1rem;
}
.img-viewer.show{opacity:1;}
.img-viewer img{max-width:100%;max-height:100%;object-fit:contain;border-radius:.5rem;}

[data-theme="dark"] .btn.ghost{background:#1E1E26;border-color:#2A2A34;}
[data-theme="dark"] .form-hint code{background:#26262F;color:#A2A2B0;}


/* ---------- 协议弹层 ---------- */
.legal-mask{
  position:fixed;inset:0;z-index:220;
  background:rgba(0,0,0,.35);
  display:none;align-items:center;justify-content:center;
  padding:1.5rem;
  backdrop-filter:blur(2px);
}
.legal-mask.show{display:flex;}
.legal-card{
  width:100%;max-width:21rem;max-height:78vh;
  background:#fff;border-radius:1.125rem;
  display:flex;flex-direction:column;overflow:hidden;
  box-shadow:0 16px 48px rgba(0,0,0,.2);
}
.legal-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:1rem 1.125rem .75rem;border-bottom:1px solid var(--line);
  font-size:1rem;font-weight:600;
}
.legal-head button{font-size:.8125rem;color:var(--accent);padding:.25rem .375rem;}
.legal-body{
  padding:1rem 1.125rem 1.375rem;overflow-y:auto;
  font-size:.8125rem;line-height:1.75;color:var(--text-2);
}
.legal-body h4{margin:.875rem 0 .25rem;font-size:.875rem;color:var(--text);}
.legal-body h4:first-child{margin-top:0;}
.legal-body p{margin:0 0 .25rem;}
