
.tabs button {
  flex: 1;
  padding: 10px;
  border: none;
  background: #f5f5f5;
  cursor: default;
}

.tab-content {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: none;
}

.tab-content:not(.hidden) {
  display: block;
}

#chatlog {
  height: 280px;
  overflow-y: auto;
  background: #f9f9f9;
  padding: 5px;
  border: 1px solid #ddd;
  margin-bottom: 8px;
}


/* html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--fg);font:14px/1.6 system-ui,-apple-system,Segoe UI,Roboto,"Noto Sans SC","PingFang SC","Microsoft Yahei",sans-serif} */

/* 顶栏（示例页） */
main{padding:20px;max-width:1180px;margin:0 auto}
.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.card{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:16px;min-height:180px}
.muted{color:var(--muted)}
@media (max-width:1023px){ .grid{grid-template-columns:1fr}; main{padding:12px}}

/* 任务栏（示例） */
#taskbar{position:fixed;left:0;right:0;bottom:0;height:56px;z-index:var(--z-taskbar);
  background:rgba(255,255,255,.9);backdrop-filter:saturate(120%) blur(6px);
  border-top:1px solid var(--border);display:flex;align-items:center;padding:0 10px}
#tb-left,#tb-right{display:flex;gap:8px;align-items:center} #tb-center{flex:1;display:flex;justify-content:center;gap:8px}
.tb-btn{width:40px;height:40px;border-radius:10px;border:1px solid var(--border);background:var(--surface);display:grid;place-items:center;cursor:pointer;position:relative}
.badge{position:absolute;right:-4px;top:-4px;min-width:18px;height:18px;padding:0 5px;background:var(--bad);color:#fff;border-radius:999px;font-size:12px;/*display:grid;*/display:none;displace-items:center}
.tb-chip{display:inline-flex;align-items:center;gap:8px;height:32px;padding:0 10px;background:var(--surface);border:1px solid var(--border);border-radius:999px;cursor:pointer}
.tb-chip .mini{width:18px;height:18px;border-radius:50%}

/* HUD */
#hud{position:fixed;left:50%;top:calc(12px + var(--safe-top));transform:translateX(-50%) translateY(-6px);
  background:rgba(17,24,39,.94);color:#fff;border:1px solid rgba(255,255,255,.12);border-radius:999px;padding:10px 14px;display:inline-flex;align-items:center;gap:8px;
  box-shadow:0 12px 28px rgba(0,0,0,.22);white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .12s, transform .12s; z-index:var(--z-hud)}
#hud.show{opacity:1;transform:translateX(-50%) translateY(0);pointer-events:auto}
#hud .undo{color:#9AE6B4;background:transparent;border:0;cursor:pointer;font-weight:400}
#hud .close{color:#cbd5e1;background:transparent;border:0;margin-left:6px;border-left:1px solid rgba(255,255,255,.18);padding-left:8px;cursor:pointer}

/* 遮罩 */
#overlay-mask{position:fixed;inset:0;background:transparent;display:none;z-index:var(--z-mask)}

/* 侧面板（玻璃） */
#presence-sheet{
  position:fixed;top:180px;right:0;bottom:40px;width:min(86vw,var(--panel-w));
  background:var(--glass-surface);
  backdrop-filter:saturate(120%) blur(var(--glass-blur)); -webkit-backdrop-filter:saturate(120%) blur(var(--glass-blur));
  border-left:1px solid var(--glass-border); box-shadow:var(--glass-shadow);
  transform:translateX(100%);transition:transform .18s ease; z-index:var(--z-overlay);display:flex;flex-direction:column
}
#presence-sheet{ border-radius:16px;     backdrop-filter: saturate(120%) blur(var(--glass-blur));}
#presence-sheet.show{
    transform:translateX(0);
}
#presence-sheet header{
  display:grid; grid-template-columns: 1fr auto; align-items:center; gap:8px;
  padding:8px 12px; min-height:56px; height:auto;
  border-bottom:1px solid var(--glass-border);
}
#presence-sheet header .left{display:flex;align-items:center;gap:10px}
#presence-sheet header .right{ display:flex; align-items:center; gap:8px; white-space:nowrap; }
#presence-sheet .inner{padding:8px;overflow:auto;flex:1;overscroll-behavior:contain;background-color: #FFF;}

/* “我”胶囊 */
.me-pill{display:flex;align-items:center;gap:8px;padding:4px 8px;border:1px solid var(--glass-border);border-radius:999px;background:var(--glass-head);cursor:pointer;flex:0 0 auto}
.me-pill .av{width:20px;height:20px;border-radius:50%}
.me-pill .name{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:400}

/* 内容区 Tabs（横向滚动 + sticky） */
.tabs-bar{
  position: sticky; top: 0; z-index: 3;
  display: flex; gap: 4px; align-items: center;
  overflow-x: auto; overscroll-behavior: contain;
  padding: 8px 2px; margin: -2px 0 8px;
  -webkit-backdrop-filter: saturate(120%) blur(calc(var(--glass-blur)*.75));
  border-bottom: 1px solid var(--glass-border);
}
.tabs-bar::-webkit-scrollbar{height:8px}
.tabs-bar .btn{flex:0 0 auto; white-space:nowrap}

/* 顶部工具栏（紧跟 tabs 之下） */
.toolbar{
  position: sticky; top: 52px; z-index: 2;      /* tabs 高 ~44 + 间距 */
  backdrop-filter: saturate(120%) blur(calc(var(--glass-blur)*.75));
  -webkit-backdrop-filter: saturate(120%) blur(calc(var(--glass-blur)*.75));
  border:1px solid var(--glass-border); border-radius:12px;
  display:flex; gap:8px; align-items:center;
  margin:8px 2px 12px; padding:8px;
}
.toolbar input[type="text"]{
  flex:1 1 auto; min-width:0; width:0; box-sizing:border-box;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  padding:8px 12px; border:1px solid var(--border); border-radius:10px;
  background:var(--surface); color:var(--fg);
  opacity: 0.5;
}
@supports not (gap: 8px) { .toolbar > * + * { margin-left: 8px; } }
#presence-sheet .inner::-webkit-scrollbar{width:8px}
#presence-sheet .inner::-webkit-scrollbar-thumb{background:rgba(0,0,0,.2);border-radius:8px}

/* 滑动开关（不打扰） */
.switch input{
  appearance:none; -webkit-appearance:none;
  width:38px; height:22px; border-radius:999px;
  background:#cbd5e1; border:1px solid var(--border);
  position:relative; outline:none; cursor:pointer;
  vertical-align:middle; transition:background .18s ease, border-color .18s ease;
}
.switch input::after{
  content:""; position:absolute; top:1px; left:1px;
  width:18px; height:18px; border-radius:50%;
  background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.2);
  transition:transform .18s ease;
}
.switch input:checked{ background:var(--primary); border-color:var(--primary-600); }
.switch input:checked::after{ transform:translateX(16px); }

#fab{position:fixed;right:16px;bottom:calc(16px + var(--safe-bot));width:56px;height:56px;border-radius:50%;
  background:var(--primary);color:#fff;display:none;align-items:center;justify-content:center;box-shadow:0 8px 24px rgba(0,0,0,.18);z-index:var(--z-overlay)}
.btn{height:32px;padding:0 12px;border:1px solid var(--border);background:#93c5fd; border-radius:10px;cursor:pointer;color:var(--fg)}

/* 列表项 */
.row{display:grid;grid-template-columns:48px 1fr auto;align-items:center;gap:10px;padding:8px;border-radius:12px;border:1px solid transparent;cursor:pointer;transition:background .15s ease;margin:6px 0}
.row .av{position:relative;width:36px;height:36px;border-radius:50%}
.row .dot{position:absolute;right:-2px;bottom:-2px;width:12px;height:12px;border:2px solid var(--surface);border-radius:50%}
.row .name{font-weight:400;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.row .last{font-size:12px;color:var(--muted)} .row .cta{grid-column:3}

/* 虚拟列表容器 */
#reco-list,#friends-list{position:relative;display:block;min-height:120px}
.vlist-viewport{position:absolute;left:0;right:0;top:0;will-change:transform}
.vlist-phantom{width:1px;opacity:0}

/* 悬停信息卡片 */
#profile-pop{position:fixed;min-width:220px;max-width:280px;background:#FFF;border:1px solid var(--border);box-shadow:0 18px 46px rgba(0,0,0,.22);border-radius: 16px;padding:10px;display:none;z-index:9999}
#profile-pop .title{font-weight:700}
#profile-pop .caps{margin-top:8px;display:flex;gap:8px;flex-wrap:wrap}
#profile-pop .cap{width:28px;height:28px;display:grid;place-items:center;border:1px solid var(--border);border-radius:999px;background:var(--surface);font-size:15px}
#profile-pop .cap.lock{opacity:.4}
#profile-pop .ops{margin-top:10px;display:flex;gap:8px}

/* 聊天面板 */
#chat{position:fixed;right:16px;bottom:96px;min-width:420px;max-width:calc(100vw - 24px);display:none;background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:0 12px 28px rgba(0,0,0,.18);overflow:hidden;z-index:var(--z-overlay)}
#chat.show{display:flex;flex-direction:column}
#chat::before{content:"";position:absolute;width:12px;height:12px;transform:rotate(45deg);background:var(--surface);border-left:1px solid var(--border);border-top:1px solid var(--border);right:18px;top:-6px}
#chat header{height:48px;display:flex;align-items:center;gap:10px;padding:0 10px;border-bottom:1px solid var(--border);background:var(--surface)}
#chat .av{width:30px;height:30px;border-radius:8px;position:relative;background:#93c5fd}
#chat .dot{position:absolute;right:-2px;bottom:-2px;width:10px;height:10px;border:2px solid var(--surface);border-radius:50%}
#chat .name{font-weight:500}
#chat .actions{margin-left:auto;display:flex;align-items:center;gap:8px}
.icon-btn{width:32px;height:32px;border-radius:999px;border:1px solid var(--border);background:var(--surface);display:grid;place-items:center;font-size:16px;cursor:pointer}
.icon-btn.lock{opacity:.45;cursor:not-allowed}
#chat .body{max-height:48vh;min-height:300px;overflow:auto;padding:10px;display:flex;flex-direction:column;gap:8px}
.msg{max-width:72%;padding:8px 10px;border-radius:12px;line-height:0}
.msg.peer{margin-right:auto;background:rgba(0,0,0,.06)} .msg.me{margin-left:auto;background:var(--primary);color:#fff}
#chat .input{border-top:1px solid var(--border);padding:8px;display:flex;gap:8px;align-items:center}
#chat textarea{flex:1;min-height:40px;max-height:120px;resize:vertical;border:1px solid var(--border);border-radius:10px;padding:8px 10px;background:var(--surface);color:var(--fg)}
#chat .send{height:40px;padding:0 12px;border-radius:10px}

@media (max-width:1023px){
  #fab{display:flex}
  #chat{left:0;right:0;width:auto;height:65vh;border-radius:18px 18px 0 0;bottom:56px;top:auto}
  #chat::before{display:none}
}
 /* 时间分割条 */
  #chat .time-sep{
    align-self: center;
    font-size: 12px;
    color: var(--muted);
    margin: 8px auto;
    padding: 2px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
  }
  /* 新消息闪烁 */
  @keyframes ww-blink { 0%,100% { filter:none; } 50% { filter:brightness(1.55) saturate(1.4); } }
  .row .av.blink { animation: ww-blink .9s linear infinite; }   /* 列表头像闪 */
  #btn-desktalk.blink-tray { animation: ww-blink .9s linear infinite; } /* 任务栏图标闪 */
  #ww-island{
  position: fixed;
  left:50%; top: calc(12px + var(--safe-top));
  transform: translateX(-50%);
  display: none; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 14px;
  background: var(--glass-head);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  z-index: var(--z-hud);
  max-width: min(78vw, 520px);
  color: var(--fg);
  backdrop-filter: saturate(120%) blur(calc(var(--glass-blur)*.75));
  -webkit-backdrop-filter: saturate(120%) blur(calc(var(--glass-blur)*.75));
}
#ww-island .mini{
  width: 18px; height: 18px; border-radius: 50%;
  background:#93c5fd; flex:0 0 auto;
  box-shadow: 0 0 0 2px var(--surface);
}
#ww-island.show{ display:flex; animation: islandIn .16s ease-out }
@keyframes islandIn { from{ transform:translateX(-50%) translateY(-6px); opacity:0 } to{ transform:translateX(-50%) translateY(0); opacity:1 } }
  /* Markdown 样式：代码块、引用、列表、链接 */
  #tab-ai .bubble pre { background: rgba(15,23,42,.06); padding: 10px; border-radius: 8px; overflow: auto; }
  #tab-ai .bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace; }
  #tab-ai .bubble a { color: #2563eb; text-decoration: underline; }
  #tab-ai .bubble ul, #tab-ai .bubble ol { padding-left: 1.2em; }
  #tab-ai .bubble blockquote { margin:.6em 0; padding:.4em .8em; border-left:3px solid var(--border); background: rgba(0,0,0,.03); border-radius:6px; }

/* 仅在面板与聊天浮窗作用域内定义 tokens，避免污染全局 */
#presence-sheet,
#chat{
  --bg:#f5f7fb; --fg:#111827; --muted:#6b7280; --border:#e5e7eb;
  --surface:#ffffff; --primary:#2563eb; --primary-600:#1d4ed8;
  --ok:#16a34a; --warn:#d97706; --bad:#ef4444;
  --panel-w: 320px;
  --glass-surface: rgba(255,255,255,.45);
  --glass-border: rgba(0,0,0,.10);
  --glass-shadow: 0 18px 46px rgba(0,0,0,.22);
  --glass-blur: 14px;
  --glass-head: rgba(255,255,255,.88);
}

/* 面板容器本身确保有背景与模糊（带兜底值） */
#presence-sheet{
  /* 主色系（和你当前蓝色体系相近） */
  --dt-accent-700: #1d4ed8;
  --dt-accent-600: #2563eb;
  --dt-accent-500: #3b82f6;
  --dt-accent-400: #60a5fa;

  /* 软按钮/标签使用的浅蓝底与边框 */
  --dt-soft-bg: rgba(37,99,235,.10);
  --dt-soft-bg-hover: rgba(37,99,235,.16);
  --dt-soft-border: rgba(37,99,235,.28);
  --dt-soft-text: #1d4ed8;

  /* 幽灵按钮（透明底）悬停色 */
  --dt-ghost-hover: rgba(0,0,0,.06);

  /* 主按钮文本与对比色 */
  --dt-on-primary: #ffffff;

  /* 焦点可视化 */
  --dt-focus: #93c5fd; /* 蓝 300 */
}

/* =============== 按钮基础 =============== */
#presence-sheet .btn{
  --_pad-y: 8px; --_pad-x: 12px;
  --_radius: 10px;
  padding: var(--_pad-y) var(--_pad-x);
  border-radius: var(--_radius);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  background: #fff;
  color: inherit;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .02s ease;
}
#presence-sheet .btn:focus-visible{
  outline: 2px solid var(--dt-focus);
  outline-offset: 2px;
}

#presence-sheet .btn.primary:hover{ background: var(--dt-accent-700); border-color: var(--dt-accent-700); }
#presence-sheet .btn.primary:active{ transform: translateY(1px); }

/* 选中页签高亮（你已有 .active 时用这个样式） */
#presence-sheet .tabs-bar .btn.active{
  background: var(--dt-accent-500);
  border-color: var(--dt-accent-500);
  color: var(--dt-on-primary);
}
/* =============== 幽灵按钮：关闭/最小化等工具 =============== */
#presence-sheet .btn.ghost{
  background: transparent;
  border-color: transparent;
  color: inherit;
}
#presence-sheet .btn.ghost:hover{ background: var(--dt-ghost-hover); }
/* 卡片、列表等如果用实底，补一个兜底，避免透明 */
#presence-sheet .card{
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
}

/* =============== 开关（不打扰）配色微调 =============== */
#presence-sheet .switch input:checked + span,
#presence-sheet .switch input:checked + i{
  /* 如果你用自定义开关，把勾选态主色调成与主按钮一致 */
  /*background: var(--dt-accent-600) !important;*/
  border-color: var(--dt-accent-600) !important;
}
/* =============== 软按钮：页签/筛选 =============== */
#presence-sheet .tabs-bar .btn,
#presence-sheet .toolbar .btn.soft{
  
  border-color: var(--dt-soft-border);
  color: #000;
  background: #fff;  
}
#presence-sheet .tabs-bar .btn:hover,
#presence-sheet .toolbar .btn.soft:hover{
  background: var(--dt-soft-bg-hover);
  border-color: var(--dt-soft-border);
}
.btn.primary {
    background: #2563eb !important;
    border-color: var(--primary-600);
    color: #fff !important;
}
#ai-body{
    background: #FFF !important;
    min-height: 150px;
}

/* 聊天框样式补充 */
/* 悬浮聊天窗：固定 + 明确宽度 + 弹性高度 */
#chat{
  position: fixed;
  /* 仅兜底位置：实际以 JS 的 style.inset 为准 */
  right: 16px; bottom: calc(46px + var(--safe-bot, 0px));

  /* 关键：给出明确宽度，防止被拉伸 */
  width: clamp(360px, 42vw, 520px);
  max-width: min(560px, 96vw);
  min-width: 360px;

  /* 不要让它充满全高 */
  max-height: min(70vh, 640px);
  display: flex; flex-direction: column;
  box-sizing: border-box;
  display: none;
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  background: transparent;
  border: 1px solid var(--border);
  box-shadow: 0 18px 46px rgba(0,0,0,.22);
}
/* 初次打开：居中定位（拖动后会自动去掉这个类） */
#chat.center {
  left: 50%; top: 50%;
  right: auto; bottom: auto;
  transform: translate(-50%, -50%);
}

/* 拖动时禁用过渡，避免抖动 */
#chat.dragging { transition: none !important; }

/* 标题栏可拖动的光标与防选中 */
#chat > header {
  user-select: none;
  -webkit-user-select: none;
}

/* 玻璃底与内容分层 */
#chat::before{
  content:""; position:absolute; inset:0; border-radius:inherit;
  background: rgba(255,255,255,.88);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  z-index:0; pointer-events:none;
}
#chat > *{ position:relative; z-index:1; }

/* 中部占满；底部不透明 */
#chat header{ flex:0 0 auto; }
#chat .body{ flex:1 1 auto; min-height:240px; overflow:auto;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.96));
}
#chat .input{ flex:0 0 auto; background:rgba(255,255,255,.98); border-top:1px solid var(--border); }

/* 如果 JS 用 inline style 设置了 left 或 right，避免两侧同时生效而拉伸 */
#chat[style*="right"]{ left: auto !important; }
#chat[style*="left"] { right: auto !important; }
/* ========== Emoji 选择器 ========== */
#chat .input { position: relative; }

#chat-emoji-btn {
  font-family: var(--emoji-font, 'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',system-ui);
  font-size: 18px;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--glass-border, rgba(0,0,0,.10));
  background: var(--glass-head, rgba(255,255,255,.88));
  margin-right: 8px;
}

.emoji-panel {
  position: absolute;
  left: 8px; bottom: 48px; /* 运行时会动态调整 */
  width: 276px; max-height: 240px; overflow: auto;
  padding: 8px;
  display: none;
  border-radius: 12px;
  border: 1px solid var(--glass-border, rgba(0,0,0,.10));
  background: var(--surface, #fff);
  box-shadow: var(--glass-shadow, 0 18px 46px rgba(0,0,0,.22));
  -webkit-backdrop-filter: blur(var(--glass-blur, 14px));
  backdrop-filter: blur(var(--glass-blur, 14px));
  z-index: var(--z-pop, 2147483605);
}

.emoji-panel.show { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }

.emoji-item {
  font-family: var(--emoji-font, 'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',system-ui);
  font-size: 20px; line-height: 32px;
  width: 32px; height: 32px;
  border: none; border-radius: 6px;
  background: transparent; cursor: pointer;
}
.emoji-item:hover { background: rgba(0,0,0,.08); }
#desktalk-footer {
  position: absolute;   /* 绝对定位 */
  bottom: 0;            /* 紧贴容器底部 */
  left: 0;
  right: 0;
  height: 50px;
  border-top: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.tab-content {
  display: none;         /* 默认隐藏 */
  padding: 8px;          /* 内边距 */
  border: 1px solid #ccc; /* 边框 */
  background-color: #fff; /* 背景色 */
  min-height: 150px;      /* 最小高度 */
  box-sizing: border-box; /* 包含内边距在内 */
}
.tab-content.active {
  display: block;        /* 激活时显示 */
}
#settings-sheet{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  display: none;
  background:#fff;
  border-radius:16px 16px 0 0;
  box-shadow:0 -4px 20px rgba(0,0,0,0.2);
  padding:16px;
  z-index:2147483647;
  max-height:70vh;
  overflow:auto;
  transform:translateY(100%);
  transition:transform 0.3s ease;
}