/* Hermes Mobile —— 双主题（Perplexity 风：深色默认 + 暖白亮色） */

/* ── 深色（默认）─────────────────────────────────── */
:root {
  color-scheme: dark;
  --bg: #191A1A;
  --bg-soft: #202222;
  --card: #2A2C2C;
  --card-2: #343737;
  --text: #E8E8E6;
  --dim: #9B9B99;
  --faint: #6E6E6C;
  --accent: #20808D;
  --accent-text: #7FD4DB;
  --danger: #E8463A;
  --border: rgba(255, 255, 255, 0.07);
  --input-bg: #2E3030;
  --input-border: transparent;
  --shadow: none;
  --r: 16px;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* iOS 键盘展开时由 JS（visualViewport）量出的键盘高度：输入框据此顶到键盘上沿 */
  --kb-lift: 0px;
  /* iOS 键盘收起后 webview 卡在变矮高度时，页面画不进去的那一截（仅主屏图标模式非 0） */
  --fix-gap: 0px;
  /* 悬浮 tab 栏：距屏幕底 = 安全区 + 间距；iOS 卡住时退到可绘制区边界（--fix-gap），看起来仍是悬浮 */
  --bar-bottom: max(0px, calc(var(--safe-b) + 8px - var(--fix-gap)));
  --bar-bg: rgba(32, 34, 34, 0.72);              /* 毛玻璃材质（深色默认） */
  --bar-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --veil: rgba(25, 26, 26, 0.62);                /* 输入框底衬：半透明＋模糊＝消息"透字" */
}

/* ── 亮色（Perplexity light：暖白底 + 深青字）───── */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #FCFCF9;
  --bg-soft: #F4F4EF;
  --card: #F0F0EA;
  --card-2: #E3E3DB;
  --text: #13343B;
  --dim: #5F6B6E;
  --faint: #8A9295;
  --accent: #20808D;
  --accent-text: #175F69;
  --danger: #C4372C;
  --border: rgba(19, 52, 59, 0.1);
  --input-bg: #FFFFFF;
  --input-border: rgba(19, 52, 59, 0.1);
  --shadow: 0 1px 2px rgba(19, 52, 59, 0.05);
  --bar-bg: rgba(244, 244, 239, 0.82);
  --bar-shadow: 0 10px 30px rgba(19, 52, 59, 0.16);
  --veil: rgba(252, 252, 249, 0.62);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* hidden 属性必须永远生效：否则像 #doc-view 这种带 display:flex 的元素会无视 hidden，
   从加载起就盖住整个界面（曾导致「一进去啥也干不了」） */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;   /* 禁用双击缩放 */
  font-family: -apple-system, "PingFang SC", "SF Pro Text", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  display: flex;
  flex-direction: column;
  /* 外壳高度：主屏模式下由 JS 实测（--app-h＝真实屏幕高），避免 iOS 键盘 bug 把可绘制区砍矮后
     正文再也没法延伸到屏幕底（表现为底部一条白条）；键盘展开时改用可视区高度（--kb-h） */
  height: var(--app-h, 100dvh);
  overflow: hidden;
}
body.kb-open { height: var(--kb-h, 100dvh); }

/* ── 顶栏 ─────────────────────────────────────────── */
#topbar {
  flex: 0 0 auto;
  height: calc(52px + var(--safe-t));
  padding: var(--safe-t) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.icon-btn {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 17px;
  padding: 8px;
  cursor: pointer;
}
.top-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn.open { color: var(--text); }
.tb-left { display: flex; align-items: center; gap: 2px; }
#menu-btn { font-size: 18px; }

/* ── 侧边抽屉：最近会话（学 ChatGPT 的侧边栏）────────────── */
#drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
body.drawer-open #drawer-scrim { opacity: 1; pointer-events: auto; }
#drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 51;
  width: min(78vw, 320px);
  padding: calc(var(--safe-t) + 14px) 10px calc(var(--safe-b) + 14px);
  background: var(--bg);
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(-103%);
  visibility: hidden;
  transition: transform 0.22s ease, visibility 0.22s;
  /* 长按会话弹操作单：禁掉 iOS 的文本选择与系统菜单（否则一长按整页文字被选中） */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.drawer-open #drawer { transform: none; visibility: visible; }
/* 抽屉打开期间整页禁止选中/系统菜单（含遮罩与背后的页面），避免 iOS 长按把整页文字选中；
   重命名输入框例外（见下方 #dlg-input 覆盖） */
body.drawer-open {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
body.drawer-open input, body.drawer-open textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.drawer-head { padding: 0 8px; }
.drawer-head .brand { font-size: 20px; font-weight: 700; }   /* 抽屉标题：比区块标题（15px）明显大一档 */
.drawer-label { color: var(--text); font-size: 15px; font-weight: 600; margin: 20px 8px 8px; }
.drawer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  text-align: left;
  padding: 11px 10px;
  border-radius: 10px;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;   /* 长按弹我们自己的操作单，不弹系统菜单 */
  touch-action: pan-y;           /* 只保留上下滚动，压掉其它系统手势（不影响列表滚动） */
}
.drawer-item .t { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-item .d { flex: 0 0 auto; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.drawer-item:active { background: var(--card-2); }
.drawer-item.cur { background: var(--card); }
.drawer-item.cur .t { color: var(--accent-text); }
.drawer-empty { color: var(--dim); font-size: 13.5px; padding: 10px 8px; }
/* 定时任务：折叠标题 + 任务行 + 图钉 */
.drawer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 8px;
  margin-top: 8px;
  cursor: pointer;
}
.drawer-toggle .cnt { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; font-weight: 400; }
.drawer-toggle .chev { font-style: normal; font-size: 13px; transition: transform 0.18s; }
.drawer-toggle .chev.open { transform: rotate(180deg); }
.drawer-item .pin { flex: 0 0 auto; font-size: 12px; opacity: 0.3; padding-left: 6px; }
.drawer-item .pin.on { opacity: 1; }
.drawer-item.no-run { cursor: default; }

/* ── 会话长按操作单（学 ChatGPT 的底部菜单）───────────── */
#sheet-scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.45); }
#sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(var(--safe-b) + 10px);
  z-index: 61;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 16.5px;
  text-align: left;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
}
.sheet-item svg { flex: 0 0 auto; opacity: 0.85; }
.sheet-item:active { background: var(--card-2); }
.sheet-item.danger { color: #e5484d; }
.sheet-sep { height: 1px; background: var(--border); margin: 6px 12px; }

/* 通用小对话框（编辑名称 / 删除确认）*/
#dlg-scrim { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.45); }
#dlg {
  position: fixed;
  left: 14px;
  right: 14px;
  top: 46%;
  transform: translateY(-50%);
  z-index: 81;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.dlg-title { color: var(--text); font-size: 15px; margin: 2px 2px 12px; line-height: 1.5; }
.dlg-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  margin-bottom: 2px;
}
.dlg-input:focus { outline: none; border-color: var(--accent); }
.sp-btn.danger { background: #e5484d; color: #fff; }

/* 批量操作：选择模式 */
.sel-bar { display: flex; align-items: center; gap: 10px; margin: 12px 2px 8px; }
.sel-count { flex: 1; color: var(--text); font-size: 15px; font-weight: 600; }
.sel-act { background: none; border: 0; color: var(--accent-text); font: inherit; font-size: 14px; padding: 6px 4px; cursor: pointer; }
.sel-foot { display: flex; gap: 8px; margin: 0 0 12px; }
.sel-fbtn { flex: 1; background: var(--card-2); border: 0; color: var(--text); font: inherit; font-size: 14px; padding: 10px 0; border-radius: 10px; cursor: pointer; }
.sel-fbtn.danger { background: #e5484d; color: #fff; }
.drawer-item .ck {
  flex: 0 0 21px;
  height: 21px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
}
.drawer-item.sel.on .ck { background: var(--accent); border-color: var(--accent); }
.drawer-item.doc-add .t { color: var(--accent-text); font-size: 14px; }

/* ── 文档查看 / 编辑（抽屉「文档」）──────────────────── */
#doc-view { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: var(--bg); }
body.drawer-open #doc-view { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.doc-head { display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-t) + 6px) 10px 8px; border-bottom: 1px solid var(--border); }
.doc-title { flex: 1 1 auto; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-btn { background: var(--card-2); border: 0; color: var(--text); font: inherit; font-size: 13.5px; padding: 8px 13px; border-radius: 9px; cursor: pointer; }
.doc-btn.primary { background: var(--accent); color: #fff; }
.doc-btn:disabled { opacity: 0.6; }
.doc-body { flex: 1 1 auto; display: flex; overflow: hidden; }
#doc-text {
  flex: 1;
  width: 100%;
  border: 0;
  resize: none;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 12px;
}
#doc-text:focus { outline: none; }
.doc-preview { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px; }
.doc-preview iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.doc-pv-note { margin: 8px 0 0; font-size: 12px; color: #8b93a1; }
.doc-pre { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.7; margin: 0; }
.doc-foot { display: flex; align-items: center; padding: 8px 10px calc(var(--safe-b) + 8px); border-top: 1px solid var(--border); }
.doc-foot .spacer { flex: 1; }
.doc-remove { background: none; border: 0; color: #e5484d; font: inherit; font-size: 13.5px; padding: 8px 4px; cursor: pointer; }

/* ── 设置面板（⚙︎）：访问令牌 ───────────────────────── */
#settings-panel {
  position: fixed;
  top: calc(var(--safe-t) + 52px);
  right: 10px;
  z-index: 30;
  width: min(calc(100% - 20px), 320px);
  padding: 6px 12px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.sp-state { font-size: 13px; color: var(--dim); margin: 0 2px 8px; }
.sp-state.ok { color: var(--accent-text); }
#sp-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
}
#sp-input:focus { outline: none; border-color: var(--accent); }
.sp-actions { display: flex; gap: 8px; margin-top: 10px; }
.sp-btn {
  flex: 1 1 0;
  border: 0;
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 0;
  border-radius: 10px;
  cursor: pointer;
}
.sp-btn.primary { background: var(--accent); color: #fff; }
.sp-hint { font-size: 12px; color: var(--faint); margin: 10px 2px 0; line-height: 1.5; }
.sp-hint code { color: var(--dim); font-size: 11px; }

/* ── 视图容器 ─────────────────────────────────────── */
main.view {
  flex: 1 1 auto;
  overflow-y: auto;
  display: none;
  padding: 0 16px calc(var(--bar-bottom) + var(--tabbar-h) + 96px);
  -webkit-overflow-scrolling: touch;
}
main.view.active { display: block; }

/* ── 空态首页（Perplexity 式大标题）────────────────── */
.empty {
  text-align: center;
  padding-top: 26vh;
}
.empty h1 {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.3px;
  margin: 0 0 10px;
}
.empty p {
  color: var(--dim);
  font-size: 14px;
  margin: 0;
}

/* ── 对话流 ───────────────────────────────────────── */
.flow { padding-top: 18px; }
.msg { margin-bottom: 22px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--card);
  border-radius: 20px 20px 6px 20px;
  padding: 10px 15px;
  max-width: 84%;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant .body {
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .bubble img.msg-img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 14px;
  margin-bottom: 6px;
}
.msg.assistant .body a { color: var(--accent-text); }
/* agent 生成的图（聊天里的 MEDIA:<路径>）内联显示 */
.msg.assistant .body img.msg-img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  border-radius: 12px;
  margin-top: 8px;
}
.img-miss { color: var(--faint); font-size: 12.5px; margin-top: 6px; }
.msg .thinking {
  color: var(--faint);
  font-size: 13px;
  line-height: 1.55;
  border-left: 2px solid var(--border);
  padding: 2px 0 2px 10px;
  margin-bottom: 10px;
  max-height: 5.4em;
  overflow: hidden;
}
.msg .meta { color: var(--faint); font-size: 12px; margin-top: 6px; }
.cursor::after {
  content: "▍";
  color: var(--accent-text);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── 输入区（学 ChatGPT：药丸形 + 左侧＋ + 右侧圆形发送）─── */
#composer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* 坐在悬浮 tab 栏正上方 */
  bottom: calc(var(--bar-bottom) + var(--tabbar-h) + 10px);
  width: min(100%, 720px);
  padding: 10px 14px 12px;
  background: none;
}
/* 毛玻璃底衬：滚动到输入框后面的消息"透字"（模糊但仍可见），而不是被整块不透明底色遮住 */
#composer::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to top, var(--veil) 58%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-mask-image: linear-gradient(to top, #000 62%, transparent);
  mask-image: linear-gradient(to top, #000 62%, transparent);
  pointer-events: none;
}
.composer-inner {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 30px;
  padding: 7px 7px 7px 8px;
}
#plus-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#plus-btn:active { background: var(--card-2); }
#mic-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 按住说话：长按时禁掉滚动/选中/系统菜单，保证 pointerup 稳定触发 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#mic-btn.recording {
  color: #fff;
  background: var(--danger);
  animation: micpulse 1.2s ease-in-out infinite;
}
@keyframes micpulse { 50% { opacity: 0.6; } }
#input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  resize: none;
  color: var(--text);
  font: inherit;
  max-height: 116px;
  padding: 10px 2px;
}
#input::placeholder { color: var(--faint); }
#send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#send:disabled { background: var(--card-2); color: var(--faint); }
/* 生成中：发送键变「暂停」（学 ChatGPT：圆底 + 白方块） */
#send.stopping { background: var(--accent); color: #fff; font-size: 0; }
#send.stopping::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: currentColor;
}
#plus-btn { transition: transform 0.15s; }
#plus-btn.open { transform: rotate(45deg); }

/* ── ＋ 菜单（ChatGPT 风：浮层卡片 + 分区标题 + 图标圆底）───── */
#plus-menu {
  position: absolute;
  left: 14px;
  bottom: calc(100% + 8px);
  width: 268px;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 5;
}
.menu-head {
  color: var(--faint);
  font-size: 12.5px;
  margin: 8px 10px 4px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}
.menu-item:active { background: var(--card-2); }
.mi-ic {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--card-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 15px;
}

/* 开关（思考）：关=灰底，开=主题色 + 滑块右移 */
.switch {
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: var(--card-2);
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
}
.switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s;
}
.switch.on { background: var(--accent); }
.switch.on i { transform: translateX(20px); }

/* 推理强度列表：选中档右侧显示 ✓（整块的显隐由 #effort-section[hidden] 控制） */
.effort-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.effort-item:active { background: var(--card-2); }
.effort-item .ck { visibility: hidden; }
.effort-item.sel .ck { visibility: visible; }

/* 待发送图片缩略图（输入框上方） */
#attach-strip { padding: 0 0 8px 6px; }
.attach-thumb { position: relative; display: inline-block; }
.attach-thumb img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.attach-thumb button {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: var(--card-2);
  color: var(--text);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

/* ── 底部 Tab（iOS 26 风悬浮胶囊：毛玻璃 + 大圆角，浮在底部留白之上）── */
#tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--bar-bottom);
  width: min(calc(100% - 24px), 420px);
  height: var(--tabbar-h);
  display: flex;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow: var(--bar-shadow);
  overflow: hidden;
}
.tab {
  flex: 1;
  background: none;
  border: 0;
  color: var(--faint);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}
.tab .ic { font-size: 17px; line-height: 1; }
.tab.active { color: var(--text); }

/* ── iOS 键盘展开时：dock 让位，输入框贴到键盘上沿 ─────────── */
body.kb-open #tabbar { display: none; }
body.kb-open #composer { bottom: calc(var(--kb-lift) + 8px); }

/* ── 区块标题 ─────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 12px;
}
.section-head h2 { font-size: 20px; font-weight: 500; margin: 0; }
.ghost-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--dim);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}

/* ── 任务列表 ─────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 10px; }
.tcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.tcard .t-title { font-size: 15px; margin-bottom: 8px; word-break: break-word; }
.trow { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: 0 0 auto; }
.dot.running { background: var(--accent); }
.dot.ready { background: var(--text); }
.dot.blocked, .dot.failed { background: var(--danger); }
.stat-group { margin-bottom: 18px; }
.stat-label { color: var(--dim); font-size: 13px; margin: 0 0 8px; }

/* ── 用量页 ───────────────────────────────────────── */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 15px;
  box-shadow: var(--shadow);
}
.metric .k { color: var(--dim); font-size: 12.5px; margin-bottom: 4px; }
.metric .v { font-size: 24px; font-weight: 600; letter-spacing: -0.4px; font-variant-numeric: tabular-nums; }
.metric .s { color: var(--faint); font-size: 12px; margin-top: 2px; }
.metric.wide { grid-column: 1 / -1; }
.metric .v.accent { color: var(--accent-text); }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar-row .name { flex: 0 0 76px; color: var(--dim); font-size: 13px; }
.bar-row .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--card-2); overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-row .val { flex: 0 0 64px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
/* 峰谷拆分条（近 7 天费用）：同色系深浅区分峰/谷 */
.bar-row .bar.split { display: flex; }
.bar-row .bar.split i { border-radius: 0; flex: 0 0 auto; }
.bar-row .bar.split i.pk { background: var(--accent); }
.bar-row .bar.split i.op { background: var(--accent); opacity: 0.35; }
.legend { display: flex; gap: 14px; color: var(--faint); font-size: 12px; margin: 8px 0 0; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .sw.pk { background: var(--accent); }
.legend .sw.op { background: var(--accent); opacity: 0.35; }

/* ── 通用 ─────────────────────────────────────────── */
.loading, .error-note { color: var(--dim); font-size: 14px; padding: 24px 0; text-align: center; }
.error-note { color: var(--danger); }

/* ── 最近会话（首页空态）──────────────────────────── */
.recent { margin-top: 34px; text-align: left; }
.recent-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 15px;
  margin-bottom: 9px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.recent-item:active { border-color: var(--accent); }
.recent-item .rt { font-size: 14.5px; margin-bottom: 5px; word-break: break-word; }
.recent-item .rm { color: var(--faint); font-size: 12px; display: flex; gap: 8px; }
.recent-item .src { color: var(--accent-text); }

/* ── 任务详情 ─────────────────────────────────────── */
.detail-title { font-size: 18px; font-weight: 500; margin: 4px 0 10px; word-break: break-word; line-height: 1.45; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill { border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; color: var(--dim); font-size: 12px; }
.detail-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 15px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.cmt { border-left: 2px solid var(--border); padding: 4px 0 4px 12px; margin: 12px 0; }
.cmt .ch { color: var(--faint); font-size: 12px; margin-bottom: 4px; display: flex; gap: 8px; }
.cmt .cb { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
.op-row { display: flex; gap: 10px; margin: 16px 0 8px; }
.op-btn {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.op-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cmt-input { display: flex; gap: 8px; margin-top: 14px; }
.cmt-input input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 15px;
  color: var(--text);
  font: inherit;
  outline: none;
}
.cmt-input button {
  background: var(--accent);
  border: 0;
  color: #fff;
  border-radius: 999px;
  padding: 0 18px;
  font-size: 14px;
  cursor: pointer;
}